public function __construct()
 {
     global $db, $cache;
     $this->tax_table_file = dirname(__FILE__) . '/CAPayrollDeductionTest2009.csv';
     require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
     TTDate::setTimeZone('PST');
 }
 public function __construct()
 {
     global $db, $cache;
     require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
     $this->company_id = PRIMARY_COMPANY_ID;
     TTDate::setTimeZone('PST');
 }
Ejemplo n.º 3
0
 function __construct()
 {
     $this->src_pdf_t4 = Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'ca' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 't4flat-06b.pdf';
     $this->src_pdf_t4summary = Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'ca' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 't4-sum-08b.pdf';
     $this->src_pdf_t4a = Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'ca' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 't4a-flat-08b.pdf';
     $this->src_pdf_t4asummary = Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'ca' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 't4a-sum-08b.pdf';
     return TRUE;
 }
Ejemplo n.º 4
0
 function getPayrollDeductionObject()
 {
     if (!isset($this->payroll_deduction_obj)) {
         require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'payroll_deduction' . DIRECTORY_SEPARATOR . 'PayrollDeduction.class.php';
         $this->payroll_deduction_obj = new PayrollDeduction('CA', NULL);
         $this->payroll_deduction_obj->setDate(TTDate::getTimeStamp($this->year, 12, 31));
     }
     return $this->payroll_deduction_obj;
 }
Ejemplo n.º 5
0
 function __construct()
 {
     require_once Environment::getBasePath() . 'classes/pdflib/phppdflib.class.php';
     //2.835 pdf units = 1mm  ---- (0,0) = 0,792.0990 (MAX,0) = 611.5095,0
     $this->pdf = new pdffile();
     $this->pdf->debug = 10;
     $this->pdf->set_default('margin', $this->margin);
     //$this->page = $this->pdf->new_page("letter");
     $this->page = $this->pdf->new_page("611.5095x792.0990");
     return TRUE;
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     global $db, $cache, $profiler;
     require_once '../includes/global.inc.php';
     require_once Environment::getBasePath() . '/classes/modules/core/DependencyTree.class.php';
     $profiler = new Profiler(true);
     Debug::setBufferOutput(FALSE);
     Debug::setEnable(TRUE);
     if (PRODUCTION != FALSE) {
         echo "DO NOT RUN ON A PRODUCTION SERVER<br>\n";
         exit;
     }
 }
 public function __construct()
 {
     global $db, $cache;
     require_once '../includes/global.inc.php';
     require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
     $profiler = new Profiler(true);
     Debug::setBufferOutput(FALSE);
     Debug::setEnable(TRUE);
     TTDate::setTimeZone('PST');
     if (PRODUCTION != FALSE) {
         echo "DO NOT RUN ON A PRODUCTION SERVER<br>\n";
         exit;
     }
 }
Ejemplo n.º 8
0
 function __construct($country, $province, $district = NULL)
 {
     $this->setCountry($country);
     $this->setProvince($province);
     $this->setDistrict($district);
     $base_file_name = Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction_Base.class.php';
     $province_file_name = Environment::getBasePath() . '/classes/payroll_deduction/' . $this->getCountry() . '/' . $this->getProvince() . '.class.php';
     $district_file_name = Environment::getBasePath() . '/classes/payroll_deduction/' . $this->getCountry() . '/' . $this->getProvince() . '_' . $this->getDistrict() . '.class.php';
     $country_file_name = Environment::getBasePath() . '/classes/payroll_deduction/' . $this->getCountry() . '.class.php';
     $data_file_name = Environment::getBasePath() . '/classes/payroll_deduction/' . $this->getCountry() . '/Data.class.php';
     if ($this->getDistrict() != '' and $this->getDistrict() != '00') {
         $class_name = 'PayrollDeduction_' . $this->getCountry() . '_' . $this->getProvince() . '_' . $this->getDistrict();
     } elseif ($this->getProvince() != '') {
         $class_name = 'PayrollDeduction_' . $this->getCountry() . '_' . $this->getProvince();
     } else {
         $class_name = 'PayrollDeduction_' . $this->getCountry();
     }
     //Debug::text('Country: '. $country_file_name .' Province: '. $province_file_name .' District: '. $district_file_name .' Class: '. $class_name, __FILE__, __LINE__, __METHOD__, 10);
     if ((file_exists($country_file_name) or $this->getProvince() != '' and file_exists($province_file_name) or $this->getDistrict() != '' and file_exists($district_file_name)) and file_exists($data_file_name)) {
         //Debug::text('Country File Exists: '. $country_file_name .' Province File Name: '. $province_file_name .' Data File: '. $data_file_name, __FILE__, __LINE__, __METHOD__, 10);
         include_once $base_file_name;
         include_once $data_file_name;
         if (file_exists($country_file_name)) {
             include_once $country_file_name;
         }
         if ($this->getProvince() != '' and file_exists($province_file_name)) {
             include_once $province_file_name;
         }
         if ($this->getDistrict() != '' and file_exists($district_file_name)) {
             include_once $district_file_name;
         }
         if (class_exists($class_name)) {
             $this->obj = new $class_name();
             $this->obj->setCountry($this->getCountry());
             $this->obj->setProvince($this->getProvince());
             $this->obj->setDistrict($this->getDistrict());
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         Debug::text('File DOES NOT Exists Country File Name: ' . $country_file_name . ' Province File: ' . $province_file_name, __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Add Calendar Based Accruals to Cron.
     $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR;
     if (PHP_OS == 'WINNT') {
         $cron_job_base_command = 'php-win.exe ' . $maint_base_path;
     } else {
         $cron_job_base_command = 'php ' . $maint_base_path;
     }
     Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9);
     $cjf = new CronJobFactory();
     $cjf->setName('AddAccrualPolicyTime');
     $cjf->setMinute(30);
     $cjf->setHour(1);
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand($cron_job_base_command . 'AddAccrualPolicyTime.php');
     $cjf->Save();
     return TRUE;
 }
Ejemplo n.º 10
0
 /**
  * Draws a image barcode
  *
  * @param  string $text     A text that should be in the image barcode
  * @param  string $type     The barcode type. Supported types:
  *                          Code39 - Code 3 of 9
  *                          int25  - 2 Interleaved 5
  *                          ean13  - EAN 13
  *                          upca   - UPC-A
  * @param  string $imgtype  The image type that will be generated
  *
  * @return image            The corresponding image barcode
  *
  * @access public
  *
  * @author Marcelo Subtil Marcal <*****@*****.**>
  * @since  Image_Barcode 0.3
  */
 function draw($text, $type = 'int25', $imgtype = 'png', $send_headers = TRUE, $print_text = TRUE, $height = NULL)
 {
     // Check if include file exists
     //echo "PEAR_INSTALL_DIR: ". PEAR_INSTALL_DIR ."<br>\n";
     //$barcodepath = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . "Image" . DIRECTORY_SEPARATOR . "Barcode";
     $supportedtypes = array('Code39.php', 'code128.php');
     /*
             if ( $incdir = opendir($barcodepath) ) {
                 while ( false != ( $avaiabletype = readdir($incdir) ) ) {
                     if ( strstr($avaiabletype, ".php") ) {
                         $supportedtypes[] = $avaiabletype;
                     }
                 }
                 closedir($incdir);
             }
     */
     if (in_array($type . ".php", $supportedtypes)) {
         include_once Environment::getBasePath() . "/classes/Image_Barcode/Barcode/{$type}.php";
     } else {
         return PEAR::raiseError("{$type} barcode is not supported");
     }
     $classname = "Image_Barcode_{$type}";
     if (!class_exists($classname)) {
         return PEAR::raiseError("Unable to include the Image/Barcode/{$type}.php file");
     }
     if (!in_array('draw', get_class_methods($classname))) {
         return PEAR::raiseError("Unable to find create method in '{$classname}' class");
     }
     @($obj =& new $classname());
     $obj->send_headers = $send_headers;
     $obj->_print_text = $print_text;
     if ($height != NULL and $height > 0) {
         $obj->_barcodeheight = $height;
     }
     $obj->draw($text, $imgtype);
 }
Ejemplo n.º 11
0
function getTTProductEdition()
{
    if (file_exists(Environment::getBasePath() . 'classes' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'job' . DIRECTORY_SEPARATOR . 'JobFactory.class.php')) {
        return TT_PRODUCT_PROFESSIONAL;
    } elseif (file_exists(Environment::getBasePath() . 'classes' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'time_clock' . DIRECTORY_SEPARATOR . 'TimeClock.class.php')) {
        return TT_PRODUCT_BUSINESS;
    }
    return TT_PRODUCT_STANDARD;
}
Ejemplo n.º 12
0
 function setLang($locale)
 {
     // Beware: this is changing the locale process-wide.
     // But *only* for LC_MESSAGES, not other LC_*.
     // This is not thread-safe.  For threaded web servers,
     // the slower Translation2 classes should be used.
     //Setting the locale again here overrides what i18Nv2 just set
     //breaking Windows. However not setting it breaks some Linux distro's.
     //Because apparently LC_ALL doesn't matter on some Unix, it still doesn't set LC_MESSAGES.
     //So if we didn't explicity set LC_MESSAGES above, do it here.
     if (OPERATING_SYSTEM == 'LINUX') {
         $rc = setlocale(LC_MESSAGES, $locale);
         if ($rc == 0) {
             Debug::text('setLocale failed!: ' . (int) $rc . ' Locale: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
         }
     }
     // Normally, setting env var(s) would not be necessary, but I18Nv2
     // is explicitly setting LANG* env variables, which seem to be
     // overriding setlocale(). Setting the env var here, fixes it.
     // Yes, I know it seems backwards.  YMMV.
     @putEnv('LANGUAGE=' . $locale);
     $domain = 'messages';
     //This fixes the mysterious issue of the "sticky locale". Where PHP
     //wouldn't change locales half way through a script.
     textdomain($domain);
     // Tell gettext where to find the locale translation files.
     bindtextdomain("{$domain}", Environment::getBasePath() . DIRECTORY_SEPARATOR . 'interface' . DIRECTORY_SEPARATOR . 'locale');
     // Tell gettext which codeset to use for output.
     bind_textdomain_codeset($domain, 'UTF-8');
     return TRUE;
 }
Ejemplo n.º 13
0
         //var_dump($user_ps_entries);
     }
     unset($pay_period_ids, $ps_entries);
 }
 //Calc Part 1, Line 3 here.
 if (isset($lines_arr)) {
     $lines_arr['total'] = Misc::ArrayAssocSum($lines_arr, NULL, 6);
     Debug::Arr($lines_arr, 'Lines Array: ', __FILE__, __LINE__, __METHOD__, 10);
     //Line 8
     $p1_line8 = $lines_arr['total']['p1_6'] - 0;
 }
 $border = 0;
 $pdf = new fpdi();
 //Import original Gov't supplied PDF.
 if ($show_background == TRUE) {
     $pagecount = $pdf->setSourceFile(Environment::getBasePath() . 'interface' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR . 'us' . DIRECTORY_SEPARATOR . 'tax' . DIRECTORY_SEPARATOR . 'f940ez.pdf');
     $tplidx = $pdf->ImportPage(1);
 }
 $pdf->setMargins(0, 0, 0, 0);
 $pdf->SetAutoPageBreak(FALSE);
 $pdf->SetFont('freeserif', '', 10);
 $pdf->AddPage();
 if (isset($tplidx)) {
     $pdf->useTemplate($tplidx, 0, 0);
 }
 $pdf->setXY(40, 39);
 $pdf->Cell(75, 6, $current_company->getName(), $border, 0, 'L');
 $pdf->setXY(157, 39);
 $pdf->Cell(10, 6, $filter_data['year'], $border, 0, 'R');
 $pdf->setXY(122, 47);
 $pdf->Cell(45, 6, $current_company->getBusinessNumber(), $border, 0, 'R');
Ejemplo n.º 14
0
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 3021 $
 * $Id: Upload.php 3021 2009-11-11 23:33:03Z ipso $
 * $Date: 2009-11-11 15:33:03 -0800 (Wed, 11 Nov 2009) $
 */
require_once '../../includes/global.inc.php';
//Debug::setVerbosity(11);
$skip_message_check = TRUE;
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
require_once Environment::getBasePath() . 'classes/upload/fileupload.class.php';
/*
if ( !$permission->Check('user','enabled')
		OR !( $permission->Check('user','view') ) ) {

	$permission->Redirect( FALSE ); //Redirect

}
*/
$smarty->assign('title', TTi18n::gettext($title = 'File Upload'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'object_type', 'object_id', 'data', 'userfile')));
$ulf = new UserListFactory();
Ejemplo n.º 15
0
 function postInstall()
 {
     global $cache;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Configure currencies for Standard Edition.
     if ($this->getIsUpgrade() == TRUE) {
         $clf = TTnew('CompanyListFactory');
         $clf->StartTransaction();
         $clf->getAll();
         if ($clf->getRecordCount() > 0) {
             foreach ($clf as $c_obj) {
                 if ($c_obj->getStatus() == 10) {
                     //Converting to new Accrual Policy table.
                     Debug::text('Converting to new Accrual Policy Table: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
                     $pglf = TTnew('PolicyGroupListFactory');
                     $pglf->getByCompanyId($c_obj->getId());
                     if ($pglf->getRecordCount() > 0) {
                         foreach ($pglf as $pg_obj) {
                             Debug::text('Accrual Policy ID: ' . $pg_obj->getColumn('accrual_policy_id'), __FILE__, __LINE__, __METHOD__, 9);
                             if ($pg_obj->getColumn('accrual_policy_id') != '' and $pg_obj->getColumn('accrual_policy_id') != 0) {
                                 $pg_obj->setAccrualPolicy(array($pg_obj->getColumn('accrual_policy_id')));
                                 if ($pg_obj->isValid()) {
                                     $pg_obj->Save();
                                 }
                             }
                         }
                     }
                     Debug::text('Adding Currency Information to Company: ' . $c_obj->getName() . ' ID: ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
                     $crlf = TTnew('CurrencyListFactory');
                     $crlf->getByCompanyId($c_obj->getId());
                     if ($crlf->getRecordCount() == 0) {
                         $cf = TTnew('CurrencyFactory');
                         $country_to_currency_map_arr = $cf->getOptions('country_currency');
                         if (isset($country_to_currency_map_arr[$c_obj->getCountry()])) {
                             $base_currency = $country_to_currency_map_arr[$c_obj->getCountry()];
                             Debug::text('Found Base Currency For Country: ' . $c_obj->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9);
                         } else {
                             Debug::text('DID NOT Find Base Currency For Country: ' . $c_obj->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9);
                             $base_currency = 'USD';
                         }
                         $cf->setCompany($c_obj->getId());
                         $cf->setStatus(10);
                         $cf->setName($base_currency);
                         $cf->setISOCode($base_currency);
                         $cf->setConversionRate('1.000000000');
                         $cf->setAutoUpdate(FALSE);
                         $cf->setBase(TRUE);
                         $cf->setDefault(TRUE);
                         if ($cf->isValid()) {
                             $base_currency_id = $cf->Save();
                             Debug::text('Base Currency ID: ' . $base_currency_id, __FILE__, __LINE__, __METHOD__, 10);
                             //Set Employee Hire Defaults.
                             $udlf = TTnew('UserDefaultListFactory');
                             $udlf->getByCompanyId($c_obj->getId());
                             if ($udlf->getRecordCount() > 0) {
                                 $ud_obj = $udlf->getCurrent();
                                 $ud_obj->setCurrency($base_currency_id);
                                 $ud_obj->setLanguage('en');
                                 if ($ud_obj->isValid()) {
                                     $ud_obj->Save();
                                 }
                             }
                             unset($udlf, $ud_obj);
                             if (is_numeric($base_currency_id)) {
                                 $ulf = TTnew('UserListFactory');
                                 $ulf->getByCompanyId($c_obj->getId());
                                 if ($ulf->getRecordCount() > 0) {
                                     foreach ($ulf as $u_obj) {
                                         $user_id = $u_obj->getID();
                                         Debug::text('Setting Base Currency For User: '******' ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                                         $u_obj->setCurrency($base_currency_id);
                                         if ($u_obj->isValid()) {
                                             if ($u_obj->Save() == TRUE) {
                                                 //Set User Default Language
                                                 $uplf = TTnew('UserPreferenceListFactory');
                                                 $uplf->getByUserIDAndCompanyID($user_id, $c_obj->getId());
                                                 if ($uplf->getRecordCount() > 0) {
                                                     $up_obj = $uplf->getCurrent();
                                                     $up_obj->setLanguage('en');
                                                     //Englist
                                                     if ($up_obj->isValid()) {
                                                         $up_obj->Save();
                                                     }
                                                 }
                                                 unset($uplf, $up_obj);
                                                 Debug::text('  Setting Base Currency for Pay Stubs, User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                                                 //Change all pay stubs for this user to the base currency.
                                                 //Do this in a single query for speed purposes.
                                                 $ph = array('currency_id' => $base_currency_id, 'currency_rate' => '1.000000000', 'user_id' => $user_id);
                                                 $query = 'update pay_stub set currency_id = ?, currency_rate = ? where user_id = ?';
                                                 $u_obj->db->Execute($query, $ph);
                                                 /*
                                                 $pslf = TTnew( 'PayStubListFactory' );
                                                 $pslf->getByUserIdAndCompanyId( $user_id, $c_obj->getId() );
                                                 if ( $pslf->getRecordCount() > 0 ) {
                                                 	foreach( $pslf as $ps_obj ) {
                                                 		//Debug::text('    Setting Base Currency for Pay Stub ID: '. $ps_obj->getId(), __FILE__, __LINE__, __METHOD__,10);
                                                 
                                                 		$ps_obj->setCurrency( $base_currency_id );
                                                 		if ( $ps_obj->isValid() ) {
                                                 
                                                 			$ps_obj->setEnableLinkedAccruals( FALSE );
                                                 			$ps_obj->setEnableCalcYTD( FALSE );
                                                 			$ps_obj->setEnableProcessEntries( FALSE );
                                                 
                                                 			$ps_obj->Save();
                                                 		}
                                                 
                                                 		unset($ps_obj);
                                                 	}
                                                 }
                                                 unset($pslf);
                                                 */
                                             } else {
                                                 Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                                             }
                                         } else {
                                             Debug::text('Failed saving user ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                                         }
                                         unset($u_obj, $user_id);
                                     }
                                 }
                                 unset($ulf);
                             }
                         }
                         unset($cf);
                     }
                 } else {
                     Debug::text('Company is not active! ' . $c_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 }
                 unset($c_obj, $base_currency, $base_currency_id, $crlf);
             }
         }
         //$clf->FailTransaction();
         $clf->CommitTransaction();
     }
     //Add currency updating to cron.
     $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR;
     if (PHP_OS == 'WINNT') {
         $cron_job_base_command = 'php-win.exe ' . $maint_base_path;
     } else {
         $cron_job_base_command = 'php ' . $maint_base_path;
     }
     Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9);
     $cjf = TTnew('CronJobFactory');
     $cjf->setName('UpdateCurrencyRates');
     $cjf->setMinute(45);
     $cjf->setHour(1);
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand($cron_job_base_command . 'UpdateCurrencyRates.php');
     $cjf->Save();
     return TRUE;
 }
Ejemplo n.º 16
0
 * You should have received a copy of the GNU Affero 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 TimeTrex headquarters at Unit 22 - 2475 Dobbin Rd. Suite
 * #292 Westbank, BC V4T 2E9, Canada or at email address info@timetrex.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 Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 1246 $
 * $Id: barcode_img.php 1246 2007-09-14 23:47:42Z ipso $
 * $Date: 2007-09-14 16:47:42 -0700 (Fri, 14 Sep 2007) $
 */
//require_once("Image/Barcode.php");
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Image_Barcode' . DIRECTORY_SEPARATOR . 'Barcode.php';
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '1010101';
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'code128';
//$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'Code39';
$imgtype = isset($_REQUEST['imgtype']) ? $_REQUEST['imgtype'] : 'png';
Image_Barcode::draw($num, $type, $imgtype);
 function postInstall()
 {
     global $cache;
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     if (is_array($this->station_users) and count($this->station_users) > 0) {
         foreach ($this->station_users as $station_id => $user_ids) {
             //Get station object.
             $slf = new StationListFactory();
             $slf->getById($station_id);
             if ($slf->getRecordCount() > 0) {
                 $s_obj = $slf->getCurrent();
                 if (in_array('-1', $user_ids)) {
                     //All users allowed
                     $s_obj->setGroupSelectionType(10);
                     $s_obj->setBranchSelectionType(10);
                     $s_obj->setDepartmentSelectionType(10);
                 } else {
                     //Only specific users allowed
                     $s_obj->setIncludeUser($user_ids);
                 }
                 if ($s_obj->isValid()) {
                     $s_obj->Save();
                 }
             }
         }
     }
     unset($this->station_users);
     //Add currency updating to cron.
     $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR;
     if (PHP_OS == 'WINNT') {
         $cron_job_base_command = 'php-win.exe ' . $maint_base_path;
     } else {
         $cron_job_base_command = 'php ' . $maint_base_path;
     }
     Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9);
     $cjf = new CronJobFactory();
     $cjf->setName('TimeClockSync');
     $cjf->setMinute('*');
     $cjf->setHour('*');
     $cjf->setDayOfMonth('*');
     $cjf->setMonth('*');
     $cjf->setDayOfWeek('*');
     $cjf->setCommand($cron_job_base_command . 'TimeClockSync.php');
     $cjf->Save();
     return TRUE;
 }
Ejemplo n.º 18
0
 static function Tidy()
 {
     if (self::$enable_tidy == TRUE) {
         $tidy_config = Environment::getBasePath() . '/includes/tidy.conf';
         self::$tidy_obj = tidy_parse_string(ob_get_contents(), $tidy_config);
         //erase the output buffer
         ob_clean();
         //tidy_clean_repair();
         self::$tidy_obj->cleanRepair();
         echo self::$tidy_obj;
     }
     return TRUE;
 }
Ejemplo n.º 19
0
        } elseif (isset($enable_iphone) and $enable_iphone == TRUE) {
            Redirect::Page(URLBuilder::getURL(NULL, Environment::GetBaseURL() . 'iphone/login/login.php'));
        } else {
            Redirect::Page(URLBuilder::getURL(NULL, Environment::GetBaseURL() . 'Login.php'));
        }
        //exit;
    }
}
require_once Environment::getBasePath() . 'classes' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = TRUE;
$smarty->template_dir = Environment::getTemplateDir();
$smarty->compile_dir = Environment::getTemplateCompileDir();
$smarty->assign('css_file', 'global.css.php');
$smarty->assign('IMAGES_URL', Environment::getImagesURL());
$smarty->assign('BASE_PATH', Environment::getBasePath());
$smarty->assign('APPLICATION_NAME', APPLICATION_NAME);
$smarty->assign('APPLICATION_VERSION', APPLICATION_VERSION);
$smarty->assign('DEPLOYMENT_ON_DEMAND', DEPLOYMENT_ON_DEMAND);
if (isset($cron_out_of_date)) {
    $smarty->assign('CRON_OUT_OF_DATE', $cron_out_of_date);
}
if (isset($db_time_zone_error)) {
    $smarty->assign('DB_TIME_ZONE_ERROR', $db_time_zone_error);
}
if (isset($config_vars['other']['installer_enabled'])) {
    $smarty->assign('INSTALLER_ENABLED', $config_vars['other']['installer_enabled']);
}
if (isset($system_settings['system_version']) and DEPLOYMENT_ON_DEMAND == FALSE and APPLICATION_VERSION != $system_settings['system_version']) {
    $smarty->assign('VERSION_MISMATCH', TRUE);
}
 static function addPresets($company_id)
 {
     if ($company_id == '') {
         Debug::text('Company ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $clf = new CompanyListFactory();
     $clf->getById($company_id);
     if ($clf->getRecordCount() > 0) {
         $company_obj = $clf->getCurrent();
         $country = $company_obj->getCountry();
         $province = $company_obj->getProvince();
     } else {
         Debug::text('bCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     //Get PayStub Link accounts
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($company_id);
     if ($pseallf->getRecordCount() > 0) {
         $psea_obj = $pseallf->getCurrent();
     } else {
         Debug::text('cCompany ID: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     require_once Environment::getBasePath() . '/classes/payroll_deduction/PayrollDeduction.class.php';
     $cdf = new CompanyDeductionFactory();
     $cdf->StartTransaction();
     /*
     								10 => 'Percent',
     								15 => 'Advanced Percent',
     								20 => 'Fixed Amount',
     
     								//Federal
     								100 => 'Federal Income Tax Formula',
     
     								//Province/State
     								200 => 'Province/State Income Tax Formula',
     								210 => 'Province/State UI Formula',
     */
     Debug::text('Country: ' . $country, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($country)) {
         case 'ca':
             $pd_obj = new PayrollDeduction($country, 'BC');
             //Pick default province for now.
             $pd_obj->setDate(time());
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Income Tax');
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('CA');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1($pd_obj->getBasicFederalClaimCodeAmount());
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union'));
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 //var_dump($exclude_ids);
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Additional Income Tax');
             $cdf->setCalculation(20);
             $cdf->setCalculationOrder(105);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Additional Income Tax%'));
             $cdf->setUserValue1(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('CPP - Employee');
             $cdf->setCalculation(90);
             // CPP Formula
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP'));
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('CPP - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(85);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%CPP - Employer%'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'CPP')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('EI - Employee');
             $cdf->setCalculation(91);
             //EI Formula
             $cdf->setCalculationOrder(90);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI'));
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('EI - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%EI - Employer%'));
             $cdf->setUserValue1(140);
             //2006
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'EI')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('WCB - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, '%WCB%'));
             $cdf->setUserValue1(0.0);
             //Default
             $cdf->setUserValue2(0);
             //Annual Wage Base: WCB has this, but can differ between rates/classifications.
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(20);
             //Deduction
             $cdf->setName('Vacation Accrual');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(50);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 50, 'Vacation Accrual'));
             $cdf->setUserValue1(4);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time'));
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(20);
             //Deduction
             $cdf->setName('Vacation Release');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(51);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'));
             $cdf->setUserValue1(4);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Accrual Release'), self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 10, 'Vacation Time'));
                 $cdf->setExcludePayStubEntryAccount($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'us':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Income Tax');
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('US');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1(10);
             //Single
             $cdf->setUserValue2(1);
             //0 Allowances
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Advance Earned Income Credit (EIC)');
             $cdf->setCalculation(80);
             $cdf->setCalculationOrder(105);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Advance EIC%'));
             $cdf->setUserValue1(10);
             //Single
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Federal Unemployment Insurance - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Fed. Unemployment Ins.'));
             $cdf->setUserValue1(0.8);
             //2009
             $cdf->setUserValue2(7000);
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Social Security - Employee');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(80);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)'));
             $cdf->setUserValue1(6.2);
             //2009
             $cdf->setUserValue2(106800);
             $cdf->setUserValue3(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Social Security - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(85);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Social Security%'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Social Security (FICA)')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Medicare - Employee');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(90);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare'));
             $cdf->setUserValue1(1.45);
             //2009
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName('Medicare - Employer');
             $cdf->setCalculation(10);
             $cdf->setCalculationOrder(95);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'Medicare'));
             $cdf->setUserValue1(100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 //$cdf->setIncludePayStubEntryAccount( array( $psea_obj->getTotalGross() ));
                 $cdf->setIncludePayStubEntryAccount(array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Medicare')));
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'cr':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(TTi18n::gettext('Income Tax'));
             $cdf->setCalculation(100);
             $cdf->setCalculationOrder(100);
             $cdf->setCountry('CR');
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Federal Income%'));
             $cdf->setUserValue1(10);
             //Single
             $cdf->setUserValue2(0);
             //0 Allowances
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
     }
     $pd_obj = new PayrollDeduction($country, $province);
     $pd_obj->setDate(time());
     Debug::text('Province/State: ' . $province, __FILE__, __LINE__, __METHOD__, 10);
     switch (strtolower($province)) {
         //Canada
         case 'ab':
         case 'bc':
         case 'sk':
         case 'mb':
         case 'qc':
         case 'on':
         case 'nl':
         case 'nb':
         case 'ns':
         case 'pe':
         case 'nt':
         case 'yt':
         case 'nu':
             $provincial_claim_amount = $pd_obj->getBasicProvinceClaimCodeAmount();
             break;
             //US
         //US
         case 'al':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ak':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employer');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(32700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance - Employee');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(32700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ar':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'az':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Job Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.1);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ca':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Disability Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(180);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.'));
             $cdf->setUserValue1(1.1);
             //2009
             $cdf->setUserValue2(90669);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employee Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.1);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'co':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ct':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(15000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'dc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'de':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(10500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'fl':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ga':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'hi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(13000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ia':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(23700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'id':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(33200);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'il':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins. - Employer'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'in':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ks':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ky':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'la':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ma':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(14000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'md':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'me':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mn':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(26000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mo':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ms':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'mt':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(25100);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(19300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nd':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(23700);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nh':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ne':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nj':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(28900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(28900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nm':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(20900);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'nv':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(26600);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ny':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Reemployment Service Fund');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Reemployment'));
             $cdf->setUserValue1(0.075);
             //2009
             $cdf->setUserValue2(8500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Disability Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(180);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'State Disability Ins.'));
             $cdf->setUserValue1(0.5);
             //2009
             $cdf->setUserValue2(0);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'oh':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ok':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(14200);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'or':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Insurance'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(31300);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'pa':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ri':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employment Security');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(18000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'sc':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'sd':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(9500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'tn':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(7000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'tx':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0);
             //2009
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Employee Training');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Employee Training'));
             $cdf->setUserValue1(0.0);
             //2006
             $cdf->setUserValue2(9000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'ut':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(27800);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'va':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'vt':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wa':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(37500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wi':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(12000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wv':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(8000);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
         case 'wy':
             $cdf = new CompanyDeductionFactory();
             $cdf->setCompany($company_id);
             $cdf->setStatus(10);
             //Enabled
             $cdf->setType(10);
             //Tax
             $cdf->setName(strtoupper($province) . ' - Unemployment Insurance');
             $cdf->setCalculation(15);
             $cdf->setCalculationOrder(185);
             $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 30, 'State Unemployment Ins.'));
             $cdf->setUserValue1(0.0);
             //2009
             $cdf->setUserValue2(21500);
             if ($cdf->isValid()) {
                 $cdf->Save(FALSE);
                 $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
                 unset($exclude_ids);
                 if ($cdf->isValid()) {
                     $cdf->Save();
                 }
             }
             break;
     }
     if ($country == 'CA') {
         $cdf = new CompanyDeductionFactory();
         $cdf->setCompany($company_id);
         $cdf->setStatus(10);
         //Enabled
         $cdf->setType(10);
         //Tax
         $cdf->setName(strtoupper($province) . ' - Provincial Income Tax');
         $cdf->setCalculation(200);
         $cdf->setCalculationOrder(110);
         $cdf->setCountry('CA');
         $cdf->setProvince(strtoupper($province));
         $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%Provincial Income%'));
         $cdf->setUserValue1($provincial_claim_amount);
         if ($cdf->isValid()) {
             $cdf->Save(FALSE);
             $exclude_ids = array(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, 'Union'));
             $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
             $cdf->setExcludePayStubEntryAccount($exclude_ids);
             unset($exclude_ids);
             if ($cdf->isValid()) {
                 $cdf->Save();
             }
         }
     } elseif ($country = 'US') {
         $cdf = new CompanyDeductionFactory();
         $cdf->setCompany($company_id);
         $cdf->setStatus(10);
         //Enabled
         $cdf->setType(10);
         //Tax
         $cdf->setName('State Income Tax');
         $cdf->setCalculation(200);
         $cdf->setCalculationOrder(200);
         $cdf->setCountry('US');
         $cdf->setProvince(strtoupper($province));
         $cdf->setPayStubEntryAccount(self::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, 20, '%State Income%'));
         $cdf->setUserValue1(10);
         //Single
         $cdf->setUserValue2(1);
         //0 Allowances
         if ($cdf->isValid()) {
             $cdf->Save(FALSE);
             $cdf->setIncludePayStubEntryAccount(array($psea_obj->getTotalGross()));
             unset($exclude_ids);
             if ($cdf->isValid()) {
                 $cdf->Save();
             }
         }
     }
     $cdf->CommitTransaction();
     //$cdf->FailTransaction();
     return TRUE;
 }
Ejemplo n.º 21
0
//    Copyright 2004-2009 Setasign - Jan Slabon
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
define('FPDI_VERSION', '1.3.1');
require_once Environment::getBasePath() . '/classes/tcpdf/tcpdf.php';
// Check for TCPDF and remap TCPDF to FPDF
if (class_exists('TCPDF')) {
    require_once 'fpdi2tcpdf_bridge.php';
}
require_once 'fpdf_tpl.php';
require_once 'fpdi_pdf_parser.php';
class FPDI extends FPDF_TPL
{
    /**
     * Actual filename
     * @var string
     */
    var $current_filename;
    /**
     * Parser-Objects
Ejemplo n.º 22
0
 function writeBarCodeFile($file_name, $num, $print_text = TRUE, $height = 60)
 {
     if (!class_exists('Image_Barcode')) {
         require_once Environment::getBasePath() . '/classes/Image_Barcode/Barcode.php';
     }
     ob_start();
     Image_Barcode::draw($num, 'code128', 'png', FALSE, $print_text, $height);
     $ob_contents = ob_get_contents();
     ob_end_clean();
     if (file_put_contents($file_name, $ob_contents) > 0) {
         //echo "Writing file successfull<Br>\n";
         return TRUE;
     } else {
         //echo "Error writing file<Br>\n";
         return FALSE;
     }
 }
 function getDeductionAmount($user_id, $pay_stub_obj, $pay_period_obj)
 {
     if ($user_id == '') {
         Debug::Text('Missing User ID: ', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     if (!is_object($pay_stub_obj)) {
         Debug::Text('Missing Pay Stub Object: ', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     if (!is_object($pay_period_obj)) {
         Debug::Text('Missing Pay Period Object: ', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     //Calculates the deduction.
     $cd_obj = $this->getCompanyDeductionObject();
     $annual_pay_periods = $pay_period_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods();
     if (!is_object($cd_obj)) {
         return FALSE;
     }
     require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'payroll_deduction' . DIRECTORY_SEPARATOR . 'PayrollDeduction.class.php';
     $retval = 0;
     Debug::Text('Company Deduction: ID: ' . $cd_obj->getID() . ' Name: ' . $cd_obj->getName() . ' Calculation ID: ' . $cd_obj->getCalculation(), __FILE__, __LINE__, __METHOD__, 10);
     switch ($cd_obj->getCalculation()) {
         case 10:
             //Basic Percent
             if ($this->getUserValue1() == '') {
                 $percent = $cd_obj->getUserValue1();
             } else {
                 $percent = $this->getUserValue1();
             }
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             $retval = bcmul($amount, bcdiv($percent, 100));
             break;
         case 15:
             //Advanced Percent
             if ($this->getUserValue1() == '') {
                 $percent = $cd_obj->getUserValue1();
             } else {
                 $percent = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $wage_base = $cd_obj->getUserValue2();
             } else {
                 $wage_base = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $exempt_amount = $cd_obj->getUserValue3();
             } else {
                 $exempt_amount = $this->getUserValue3();
             }
             //Annual Wage Base is the maximum earnings that an employee can earn before they are no longer eligible for this deduction
             //Annual Deduction Amount
             Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10);
             if ($percent != 0) {
                 if ($exempt_amount > 0) {
                     $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), bcdiv($exempt_amount, $annual_pay_periods));
                     Debug::Text('Amount After Exemption: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 } else {
                     $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
                     Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 }
                 if ($wage_base > 0) {
                     //*NOTE: If the first pay stub in TimeTrex is near the end of the year, and the employee has already exceeded the wage base amount
                     //the payroll admin needs to make sure they add a YTD Adjustment for each Include PS Accounts that this calculation is based on,
                     //NOT the total amount they have paid for the resulting calculation, as that has no effect whatsoever.
                     //getCalculationYTDAmount is the previous pay stub YTD amount, but it includes any YTD Adjustments in the current pay stub too.
                     $ytd_amount = $cd_obj->getCalculationYTDAmount($pay_stub_obj);
                     Debug::Text('Wage Base is set: ' . $wage_base . ' Amount: ' . $amount . ' Current YTD: ' . $ytd_amount, __FILE__, __LINE__, __METHOD__, 10);
                     //Possible calcations:
                     //
                     //Wage Base: 3000
                     //Amount: 500 YTD: 0		= 500
                     //Amount: 500 YTD: 2900		= 100
                     //Amount: 500 YTD: 3100		= 0
                     //Amount: 3500 YTD: 0		= 3000
                     //AMount: 3500 YTD: 2900	= 100
                     //Amount: 3500 YTD: 3100	= 0
                     //Check to see if YTD is less than wage base.
                     $remaining_wage_base = bcsub($wage_base, $ytd_amount);
                     Debug::Text('Remaining Wage Base to be calculated: ' . $remaining_wage_base, __FILE__, __LINE__, __METHOD__, 10);
                     if ($remaining_wage_base > 0) {
                         if ($amount > $remaining_wage_base) {
                             $amount = $remaining_wage_base;
                         }
                     } else {
                         $amount = 0;
                         //Exceeded wage base, nothing to calculate.
                     }
                     unset($remaining_wage_base);
                 } else {
                     Debug::Text('Wage Base is NOT set: ' . $wage_base, __FILE__, __LINE__, __METHOD__, 10);
                 }
                 $retval = bcmul($amount, bcdiv($percent, 100));
             } else {
                 $retval = 0;
             }
             if ($percent >= 0 and $retval < 0) {
                 $retval = 0;
             }
             unset($amount, $ytd_amount, $percent, $wage_base);
             break;
         case 17:
             //Advanced Percent (Range Bracket)
             if ($this->getUserValue1() == '') {
                 $percent = $cd_obj->getUserValue1();
             } else {
                 $percent = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $min_wage = $cd_obj->getUserValue2();
             } else {
                 $min_wage = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $max_wage = $cd_obj->getUserValue3();
             } else {
                 $max_wage = $this->getUserValue3();
             }
             if ($this->getUserValue4() == '') {
                 $annual_deduction_amount = $cd_obj->getUserValue4();
             } else {
                 $annual_deduction_amount = $this->getUserValue4();
             }
             if ($this->getUserValue5() == '') {
                 $annual_fixed_amount = $cd_obj->getUserValue5();
             } else {
                 $annual_fixed_amount = $this->getUserValue5();
             }
             $min_wage = bcdiv($min_wage, $annual_pay_periods);
             $max_wage = bcdiv($max_wage, $annual_pay_periods);
             $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods);
             $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods);
             Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10);
             if ($percent != 0) {
                 $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount);
                 Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 if ($amount >= $min_wage and $amount <= $max_wage) {
                     $retval = bcadd(bcmul($amount, bcdiv($percent, 100)), $annual_fixed_amount);
                 }
             } else {
                 $retval = 0;
             }
             if ($percent >= 0 and $retval < 0) {
                 $retval = 0;
             }
             unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount);
             break;
         case 18:
             //Advanced Percent (Tax Bracket)
             if ($this->getUserValue1() == '') {
                 $percent = $cd_obj->getUserValue1();
             } else {
                 $percent = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $wage_base = $cd_obj->getUserValue2();
             } else {
                 $wage_base = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $exempt_amount = $cd_obj->getUserValue3();
             } else {
                 $exempt_amount = $this->getUserValue3();
             }
             if ($this->getUserValue4() == '') {
                 $annual_deduction_amount = $cd_obj->getUserValue4();
             } else {
                 $annual_deduction_amount = $this->getUserValue4();
             }
             Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10);
             if ($percent != 0) {
                 if ($exempt_amount > 0) {
                     $pp_exempt_amount = bcdiv($exempt_amount, $annual_pay_periods);
                 } else {
                     $pp_exempt_amount = 0;
                 }
                 //Debug::Text('PP Exempt Amount: '. $pp_exempt_amount, __FILE__, __LINE__, __METHOD__,10);
                 if ($wage_base > 0) {
                     $pp_wage_base_amount = bcdiv($wage_base, $annual_pay_periods);
                 } else {
                     $pp_wage_base_amount = 0;
                 }
                 if ($annual_deduction_amount > 0) {
                     $pp_annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods);
                 } else {
                     $pp_annual_deduction_amount = 0;
                 }
                 //Debug::Text('PP Wage Base Base Amount: '. $pp_wage_base_amount, __FILE__, __LINE__, __METHOD__,10);
                 $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $pp_annual_deduction_amount);
                 //Debug::Text('Calculation Pay Stub Amount: '. $cd_obj->getCalculationPayStubAmount( $pay_stub_obj ), __FILE__, __LINE__, __METHOD__,10);
                 if ($pp_wage_base_amount > 0 and $amount > $pp_wage_base_amount) {
                     //Debug::Text('Exceeds Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10);
                     $amount = bcsub($pp_wage_base_amount, $pp_exempt_amount);
                 } else {
                     //Debug::Text('Under Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10);
                     $amount = bcsub($amount, $pp_exempt_amount);
                 }
                 Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 $retval = bcmul($amount, bcdiv($percent, 100));
             } else {
                 $retval = 0;
             }
             if ($percent >= 0 and $retval < 0) {
                 $retval = 0;
             }
             unset($amount, $percent, $wage_base, $pp_wage_base_amount, $pp_exempt_amount, $annual_deduction_amount, $pp_annual_deduction_amount);
             break;
         case 19:
             //Advanced Percent (Tax Bracket Alternate)
             /*
             	This is designed to be used for single line item tax calculations, in that the formula looks like this,
             	where only ONE bracket would be applied to the employee, NOT all:
             	Wage between 0 - 10,000 calculate 10%
             	Wage between 10,001 - 20,000 calculate 15% + $1000 (10% of 10,000 as per above)
             	Wage between 20,001 - 30,000 calculate 20% + $2500 (10% of 10,000 as first bracket, and 15% of 10,000 as per 2nd bracket)
             */
             if ($this->getUserValue1() == '') {
                 $percent = $cd_obj->getUserValue1();
             } else {
                 $percent = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $min_wage = $cd_obj->getUserValue2();
             } else {
                 $min_wage = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $max_wage = $cd_obj->getUserValue3();
             } else {
                 $max_wage = $this->getUserValue3();
             }
             if ($this->getUserValue4() == '') {
                 $annual_deduction_amount = $cd_obj->getUserValue4();
             } else {
                 $annual_deduction_amount = $this->getUserValue4();
             }
             if ($this->getUserValue5() == '') {
                 $annual_fixed_amount = $cd_obj->getUserValue5();
             } else {
                 $annual_fixed_amount = $this->getUserValue5();
             }
             $min_wage = bcdiv($min_wage, $annual_pay_periods);
             $max_wage = bcdiv($max_wage, $annual_pay_periods);
             $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods);
             $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods);
             Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10);
             if ($percent != 0) {
                 $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount);
                 Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 if ($amount >= $min_wage and $amount <= $max_wage) {
                     $retval = bcadd(bcmul(bcsub($amount, $min_wage), bcdiv($percent, 100)), $annual_fixed_amount);
                 }
             } else {
                 $retval = 0;
             }
             if ($percent >= 0 and $retval < 0) {
                 $retval = 0;
             }
             unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount);
             break;
         case 20:
             //Fixed amount
             if ($this->getUserValue1() == FALSE) {
                 $amount = $cd_obj->getUserValue1();
             } else {
                 $amount = $this->getUserValue1();
             }
             $retval = $amount;
             unset($amount);
             break;
         case 30:
             //Fixed Amount (Range Bracket)
             if ($this->getUserValue1() == '') {
                 $fixed_amount = $cd_obj->getUserValue1();
             } else {
                 $fixed_amount = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $min_wage = $cd_obj->getUserValue2();
             } else {
                 $min_wage = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $max_wage = $cd_obj->getUserValue3();
             } else {
                 $max_wage = $this->getUserValue3();
             }
             if ($this->getUserValue4() == '') {
                 $annual_deduction_amount = $cd_obj->getUserValue4();
             } else {
                 $annual_deduction_amount = $this->getUserValue4();
             }
             $min_wage = bcdiv($min_wage, $annual_pay_periods);
             $max_wage = bcdiv($max_wage, $annual_pay_periods);
             $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods);
             Debug::Text('Amount: ' . $fixed_amount . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10);
             if ($fixed_amount != 0) {
                 $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount);
                 Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 if ($amount >= $min_wage and $amount <= $max_wage) {
                     $retval = $fixed_amount;
                 }
             } else {
                 $retval = 0;
             }
             unset($fixed_amount, $amount, $percent, $min_wage, $max_wage, $annual_deduction_amount);
             break;
         case 52:
             //Fixed Amount (w/Limit)
             if ($this->getUserValue1() == '') {
                 $fixed_amount = $cd_obj->getUserValue1();
             } else {
                 $fixed_amount = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $target_amount = $cd_obj->getUserValue2();
             } else {
                 $target_amount = $this->getUserValue2();
             }
             Debug::Text('Amount: ' . $fixed_amount . ' Target Amount: ' . $target_amount, __FILE__, __LINE__, __METHOD__, 10);
             $retval = 0;
             if ($fixed_amount != 0) {
                 $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
                 Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
                 if ($amount !== $target_amount) {
                     if (abs($fixed_amount) < abs(bcsub($amount, $target_amount))) {
                         //Use full fixed amount
                         Debug::Text('Not within reach of target, use full fixed amount...', __FILE__, __LINE__, __METHOD__, 10);
                         $retval = $fixed_amount;
                     } else {
                         Debug::Text('Within reach of target, use partial fixed amount...', __FILE__, __LINE__, __METHOD__, 10);
                         //Use partial fixed_amount
                         $retval = bcadd(abs($amount), $target_amount);
                     }
                 }
             }
             $retval = abs($retval);
             unset($fixed_amount, $tmp_amount, $amount, $min_limit, $max_limit);
             break;
         case 69:
             // Custom Formulas
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $user_value2 = $cd_obj->getUserValue2();
             } else {
                 $user_value2 = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $user_value3 = $cd_obj->getUserValue3();
             } else {
                 $user_value3 = $this->getUserValue3();
             }
             if ($this->getUserValue4() == '') {
                 $user_value4 = $cd_obj->getUserValue4();
             } else {
                 $user_value4 = $this->getUserValue4();
             }
             if ($this->getUserValue5() == '') {
                 $user_value5 = $cd_obj->getUserValue5();
             } else {
                 $user_value5 = $this->getUserValue5();
             }
             if ($this->getUserValue6() == '') {
                 $user_value6 = $cd_obj->getUserValue6();
             } else {
                 $user_value6 = $this->getUserValue6();
             }
             if ($this->getUserValue7() == '') {
                 $user_value7 = $cd_obj->getUserValue7();
             } else {
                 $user_value7 = $this->getUserValue7();
             }
             if ($this->getUserValue8() == '') {
                 $user_value8 = $cd_obj->getUserValue8();
             } else {
                 $user_value8 = $this->getUserValue8();
             }
             if ($this->getUserValue9() == '') {
                 $user_value9 = $cd_obj->getUserValue9();
             } else {
                 $user_value9 = $this->getUserValue9();
             }
             if ($this->getUserValue10() == '') {
                 $user_value10 = $cd_obj->getUserValue10();
             } else {
                 $user_value10 = $this->getUserValue10();
             }
             // evaluate math expressions as the company_value1 and user_value1-10 defined by user.
             $company_value1 = $cd_obj->getCompanyValue1();
             // Custom Formula
             $variables = array();
             $formula_variables = array_keys((array) TTMath::parseColumnsFromFormula($company_value1));
             Debug::Arr($formula_variables, 'Formula Variables: ', __FILE__, __LINE__, __METHOD__, 10);
             if (is_array($formula_variables)) {
                 if (in_array('currency_conversion_rate', $formula_variables) and is_object($this->getUserObject()) and is_object($this->getUserObject()->getCurrencyObject())) {
                     $currency_iso_code = $this->getUserObject()->getCurrencyObject()->getISOCode();
                     $currency_conversion_rate = $this->getUserObject()->getCurrencyObject()->getConversionRate();
                     Debug::Text('Currency Variables: Rate: ' . $currency_conversion_rate . ' ISO: ' . $currency_iso_code, __FILE__, __LINE__, __METHOD__, 10);
                 }
                 //First pass to gather any necessary data based on variables
                 if (in_array('employee_hourly_rate', $formula_variables) or in_array('employee_annual_wage', $formula_variables) or in_array('employee_wage_average_weekly_hours', $formula_variables)) {
                     $uwlf = TTnew('UserWageListFactory');
                     $uwlf->getWageByUserIdAndPayPeriodEndDate($this->getUser(), $pay_period_obj->getEndDate());
                     if ($uwlf->getRecordCount() > 0) {
                         $uwf = $uwlf->getCurrent();
                         $employee_hourly_rate = $uwf->getHourlyRate();
                         $employee_annual_wage = $uwf->getAnnualWage();
                         $employee_wage_average_weekly_hours = TTDate::getHours($uwf->getWeeklyTime());
                     } else {
                         $employee_hourly_rate = 0;
                         $employee_annual_wage = 0;
                         $employee_wage_average_weekly_hours = 0;
                     }
                     Debug::Text('Employee Hourly Rate: ' . $employee_hourly_rate, __FILE__, __LINE__, __METHOD__, 10);
                 }
                 if ($cd_obj->getCompanyValue2() != '' and $cd_obj->getCompanyValue2() > 0 and $cd_obj->getCompanyValue3() != '' and $cd_obj->getCompanyValue3() > 0) {
                     Debug::Text('Formula Lookback enable: ' . $cd_obj->getCompanyValue2(), __FILE__, __LINE__, __METHOD__, 10);
                     foreach ($formula_variables as $formula_variable) {
                         if (strpos($formula_variable, 'lookback_') !== FALSE) {
                             Debug::Text('Lookback variables exist...', __FILE__, __LINE__, __METHOD__, 10);
                             $lookback_dates = $cd_obj->getLookbackStartAndEndDates($pay_period_obj);
                             $lookback_pay_stub_dates = $cd_obj->getLookbackPayStubs($this->getUser(), $pay_period_obj);
                             break;
                         }
                     }
                 }
                 //Second pass to define variables.
                 foreach ($formula_variables as $formula_variable) {
                     if (!isset($variables[$formula_variable])) {
                         switch ($formula_variable) {
                             case 'custom_value1':
                                 $variables[$formula_variable] = $user_value1;
                                 break;
                             case 'custom_value2':
                                 $variables[$formula_variable] = $user_value2;
                                 break;
                             case 'custom_value3':
                                 $variables[$formula_variable] = $user_value3;
                                 break;
                             case 'custom_value4':
                                 $variables[$formula_variable] = $user_value4;
                                 break;
                             case 'custom_value5':
                                 $variables[$formula_variable] = $user_value5;
                                 break;
                             case 'custom_value6':
                                 $variables[$formula_variable] = $user_value6;
                                 break;
                             case 'custom_value7':
                                 $variables[$formula_variable] = $user_value7;
                                 break;
                             case 'custom_value8':
                                 $variables[$formula_variable] = $user_value8;
                                 break;
                             case 'custom_value9':
                                 $variables[$formula_variable] = $user_value9;
                                 break;
                             case 'custom_value10':
                                 $variables[$formula_variable] = $user_value10;
                                 break;
                             case 'employee_hourly_rate':
                                 $variables[$formula_variable] = $employee_hourly_rate;
                                 break;
                             case 'employee_annual_wage':
                                 $variables[$formula_variable] = $employee_annual_wage;
                                 break;
                             case 'employee_wage_average_weekly_hours':
                                 $variables[$formula_variable] = $employee_wage_average_weekly_hours;
                                 break;
                             case 'annual_pay_periods':
                                 $variables[$formula_variable] = $annual_pay_periods;
                                 break;
                             case 'pay_period_start_date':
                                 $variables[$formula_variable] = $pay_period_obj->getStartDate();
                                 break;
                             case 'pay_period_end_date':
                                 $variables[$formula_variable] = $pay_period_obj->getEndDate();
                                 break;
                             case 'pay_period_transaction_date':
                                 $variables[$formula_variable] = $pay_period_obj->getTransactionDate();
                                 break;
                             case 'employee_hire_date':
                                 $variables[$formula_variable] = $this->getUserObject()->getHireDate();
                                 break;
                             case 'employee_termination_date':
                                 $variables[$formula_variable] = $this->getUserObject()->getTerminationDate();
                                 break;
                             case 'employee_birth_date':
                                 $variables[$formula_variable] = $this->getUserObject()->getBirthDate();
                                 break;
                             case 'currency_iso_code':
                                 $variables[$formula_variable] = $currency_iso_code;
                                 break;
                             case 'currency_conversion_rate':
                                 $variables[$formula_variable] = $currency_conversion_rate;
                                 break;
                             case 'include_pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10);
                                 break;
                             case 'include_pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30);
                                 break;
                             case 'include_pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20);
                                 break;
                             case 'include_pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40);
                                 break;
                             case 'exclude_pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 10);
                                 break;
                             case 'exclude_pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 30);
                                 break;
                             case 'exclude_pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 20);
                                 break;
                             case 'exclude_pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 40);
                                 break;
                             case 'pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10, 10);
                                 break;
                             case 'pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30, 30);
                                 break;
                             case 'pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20, 20);
                                 break;
                             case 'pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40, 40);
                                 break;
                                 //Lookback variables.
                             //Lookback variables.
                             case 'lookback_total_pay_stubs':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['total_pay_stubs']) ? $lookback_pay_stub_dates['total_pay_stubs'] : 0;
                                 break;
                             case 'lookback_start_date':
                                 $variables[$formula_variable] = isset($lookback_dates['start_date']) ? $lookback_dates['start_date'] : 0;
                                 break;
                             case 'lookback_end_date':
                                 $variables[$formula_variable] = isset($lookback_dates['end_date']) ? $lookback_dates['end_date'] : 0;
                                 break;
                             case 'lookback_first_pay_stub_start_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_start_date']) ? $lookback_pay_stub_dates['first_pay_stub_start_date'] : 0;
                                 break;
                             case 'lookback_first_pay_stub_end_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_end_date']) ? $lookback_pay_stub_dates['first_pay_stub_end_date'] : 0;
                                 break;
                             case 'lookback_first_pay_stub_transaction_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['first_pay_stub_transaction_date'] : 0;
                                 break;
                             case 'lookback_last_pay_stub_start_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_start_date']) ? $lookback_pay_stub_dates['last_pay_stub_start_date'] : 0;
                                 break;
                             case 'lookback_last_pay_stub_end_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_end_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0;
                                 break;
                             case 'lookback_last_pay_stub_transaction_date':
                                 $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0;
                                 break;
                             case 'lookback_include_pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10);
                                 break;
                             case 'lookback_include_pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30);
                                 break;
                             case 'lookback_include_pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20);
                                 break;
                             case 'lookback_include_pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40);
                                 break;
                             case 'lookback_exclude_pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 10);
                                 break;
                             case 'lookback_exclude_pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 30);
                                 break;
                             case 'lookback_exclude_pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 20);
                                 break;
                             case 'lookback_exclude_pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 40);
                                 break;
                             case 'lookback_pay_stub_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10, 10);
                                 break;
                             case 'lookback_pay_stub_ytd_amount':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30, 30);
                                 break;
                             case 'lookback_pay_stub_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20, 20);
                                 break;
                             case 'lookback_pay_stub_ytd_units':
                                 $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40, 40);
                                 break;
                         }
                     }
                 }
                 unset($uwlf, $uwf, $employee_hourly_rate, $employee_annual_wage, $employee_wage_average_weekly_hours, $annual_pay_periods, $lookback_dates, $lookback_pay_stub_dates, $currency_iso_code, $currency_conversion_rate);
             }
             //Debug::Arr( $variables,  'Formula Variable values: ', __FILE__, __LINE__, __METHOD__, 10 );
             Debug::Arr(array(str_replace("\r", '; ', $company_value1), str_replace("\r", '; ', TTMath::translateVariables($company_value1, $variables))), 'Original/Translated Formula: ', __FILE__, __LINE__, __METHOD__, 10);
             $retval = TTMath::evaluate(TTMath::translateVariables($company_value1, $variables));
             Debug::Text('Formula Retval: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
             break;
         case 80:
             //US Earning Income Credit (EIC). Repealed as of 31-Dec-2010.
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10);
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction('US', NULL);
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             if (is_object($this->getUserObject())) {
                 $currency_id = $this->getUserObject()->getCurrency();
                 $pd_obj->setUserCurrency($currency_id);
                 Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10);
             }
             $pd_obj->setEICFilingStatus($user_value1);
             $pd_obj->setGrossPayPeriodIncome($amount);
             //Allow negative value, infact it always should be.
             $retval = $pd_obj->getEIC();
             break;
         case 82:
             //US - Medicare - Employee
         //US - Medicare - Employee
         case 83:
             //US - Medicare - Employer
         //US - Medicare - Employer
         case 84:
             //US - Social Security - Employee
         //US - Social Security - Employee
         case 85:
             //US - Social Security - Employer
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10);
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction('US', NULL);
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             if (is_object($this->getUserObject())) {
                 $currency_id = $this->getUserObject()->getCurrency();
                 $pd_obj->setUserCurrency($currency_id);
                 Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10);
             }
             $pd_obj->setGrossPayPeriodIncome($amount);
             switch ($cd_obj->getCalculation()) {
                 case 82:
                     //US - Medicare - Employee
                     $pd_obj->setMedicareFilingStatus($user_value1);
                     $pd_obj->setYearToDateGrossIncome($cd_obj->getCalculationYTDAmount($pay_stub_obj));
                     $retval = $pd_obj->getEmployeeMedicare();
                     break;
                 case 83:
                     //US - Medicare - Employer
                     $retval = $pd_obj->getEmployerMedicare();
                     break;
                 case 84:
                     //US - Social Security - Employee
                     $retval = $pd_obj->getEmployeeSocialSecurity();
                     break;
                 case 85:
                     //US - Social Security - Employer
                     $retval = $pd_obj->getEmployerSocialSecurity();
                     break;
             }
             break;
         case 90:
             //Canada - CPP
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction('CA', NULL);
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             $pd_obj->setEnableCPPAndEIDeduction(TRUE);
             if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') {
                 Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                 $previous_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                 $current_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                 Debug::text('YTD CPP Contribution: Previous Amount: ' . $previous_ytd_cpp_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_cpp_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
                 $pd_obj->setYearToDateCPPContribution(bcadd($previous_ytd_cpp_arr['ytd_amount'], $current_ytd_cpp_arr['ytd_amount']));
                 unset($previous_ytd_cpp_arr, $current_ytd_cpp_arr);
             }
             $pd_obj->setGrossPayPeriodIncome($amount);
             $retval = $pd_obj->getEmployeeCPP();
             if ($retval < 0) {
                 $retval = 0;
             }
             break;
         case 91:
             //Canada - EI
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction('CA', NULL);
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             $pd_obj->setEnableCPPAndEIDeduction(TRUE);
             if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') {
                 Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                 $previous_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                 $current_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                 Debug::text('YTD EI Contribution: Previous Amount: ' . $previous_ytd_ei_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_ei_arr['amount'], __FILE__, __LINE__, __METHOD__, 10);
                 $pd_obj->setYearToDateEIContribution(bcadd($previous_ytd_ei_arr['ytd_amount'], $current_ytd_ei_arr['ytd_amount']));
                 unset($previous_ytd_ei_arr, $current_ytd_ei_arr);
             }
             $pd_obj->setGrossPayPeriodIncome($amount);
             $retval = $pd_obj->getEmployeeEI();
             if ($retval < 0) {
                 $retval = 0;
             }
             break;
         case 100:
             //Federal Income Tax
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $user_value2 = $cd_obj->getUserValue2();
             } else {
                 $user_value2 = $this->getUserValue2();
             }
             Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10);
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), NULL);
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             if (is_object($this->getUserObject())) {
                 $currency_id = $this->getUserObject()->getCurrency();
                 $pd_obj->setUserCurrency($currency_id);
                 Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10);
             }
             if ($this->getCompanyDeductionObject()->getCountry() == 'CA') {
                 //CA
                 $pd_obj->setFederalTotalClaimAmount($user_value1);
                 $pd_obj->setEnableCPPAndEIDeduction(TRUE);
                 //$pself = TTnew( 'PayStubEntryListFactory' );
                 if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') {
                     Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                     //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt.
                     //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by
                     //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt.
                     //Make sure we handle the maximum CPP contribution cases properly as well.
                     $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                     if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) {
                         Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10);
                         $pd_obj->setCPPExempt(TRUE);
                     }
                     $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                     Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10);
                     $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']);
                     unset($ytd_cpp_arr, $current_cpp);
                 }
                 if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') {
                     Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                     //See comment above regarding CPP exempt.
                     $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                     if (isset($current_ei['amount']) and $current_ei['amount'] == 0) {
                         Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10);
                         $pd_obj->setEIExempt(TRUE);
                     }
                     $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                     Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10);
                     $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']);
                     unset($ytd_ei_arr, $current_ei);
                 }
             } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') {
                 //US
                 $pd_obj->setFederalFilingStatus($user_value1);
                 $pd_obj->setFederalAllowance($user_value2);
             } elseif ($this->getCompanyDeductionObject()->getCountry() == 'CR') {
                 //CR
                 $pd_obj->setFederalFilingStatus($user_value1);
                 //Single/Married
                 $pd_obj->setFederalAllowance($user_value2);
                 //Allownces/Children
             }
             $pd_obj->setGrossPayPeriodIncome($amount);
             $retval = $pd_obj->getFederalPayPeriodDeductions();
             if ($retval < 0) {
                 $retval = 0;
             }
             break;
         case 200:
             //Province Income Tax
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $user_value2 = $cd_obj->getUserValue2();
             } else {
                 $user_value2 = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $user_value3 = $cd_obj->getUserValue3();
             } else {
                 $user_value3 = $this->getUserValue3();
             }
             Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10);
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince());
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             $pd_obj->setGrossPayPeriodIncome($amount);
             if ($this->getCompanyDeductionObject()->getCountry() == 'CA') {
                 Debug::Text('Canada Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10);
                 $pd_obj->setProvincialTotalClaimAmount($user_value1);
                 $pd_obj->setEnableCPPAndEIDeduction(TRUE);
                 //$pself = TTnew( 'PayStubEntryListFactory' );
                 if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') {
                     Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                     //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt.
                     //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by
                     //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt.
                     //Make sure we handle the maximum CPP contribution cases properly as well.
                     $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                     if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) {
                         Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10);
                         $pd_obj->setCPPExempt(TRUE);
                     }
                     $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP());
                     Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10);
                     $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']);
                     unset($ytd_cpp_arr, $current_cpp);
                 }
                 if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') {
                     Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10);
                     //See comment above regarding CPP exempt.
                     $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                     if (isset($current_ei['amount']) and $current_ei['amount'] == 0) {
                         Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10);
                         $pd_obj->setEIExempt(TRUE);
                     }
                     $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI());
                     Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10);
                     $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']);
                     unset($ytd_ei_arr, $current_ei);
                 }
                 $retval = $pd_obj->getProvincialPayPeriodDeductions();
             } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') {
                 Debug::Text('US Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10);
                 //Need to set Federal settings here.
                 $udlf = TTnew('UserDeductionListFactory');
                 $udlf->getByUserIdAndCountryID($user_id, $this->getCompanyDeductionObject()->getCountry());
                 if ($udlf->getRecordCount() > 0) {
                     Debug::Text('Found Federal User Deduction...', __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_ud_obj = $udlf->getCurrent();
                     if ($tmp_ud_obj->getUserValue1() == '') {
                         $tmp_user_value1 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue1();
                     } else {
                         $tmp_user_value1 = $tmp_ud_obj->getUserValue1();
                     }
                     if ($tmp_ud_obj->getUserValue2() == '') {
                         $tmp_user_value2 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue2();
                     } else {
                         $tmp_user_value2 = $tmp_ud_obj->getUserValue2();
                     }
                     Debug::Text('TmpUserValue1: ' . $tmp_user_value1, __FILE__, __LINE__, __METHOD__, 10);
                     Debug::Text('TmpUserValue2: ' . $tmp_user_value2, __FILE__, __LINE__, __METHOD__, 10);
                     $pd_obj->setFederalFilingStatus($tmp_user_value1);
                     $pd_obj->setFederalAllowance($tmp_user_value2);
                     unset($tmp_ud_obj, $tmp_user_value1, $tmp_user_value1);
                 }
                 unset($udlf);
                 $pd_obj->setStateFilingStatus($user_value1);
                 $pd_obj->setStateAllowance($user_value2);
                 $pd_obj->setUserValue1($user_value1);
                 $pd_obj->setUserValue2($user_value2);
                 $pd_obj->setUserValue3($user_value3);
                 $retval = $pd_obj->getStatePayPeriodDeductions();
             }
             if ($retval < 0) {
                 $retval = 0;
             }
             break;
         case 300:
             //District Income Tax
             if ($this->getUserValue1() == '') {
                 $user_value1 = $cd_obj->getUserValue1();
             } else {
                 $user_value1 = $this->getUserValue1();
             }
             if ($this->getUserValue2() == '') {
                 $user_value2 = $cd_obj->getUserValue2();
             } else {
                 $user_value2 = $this->getUserValue2();
             }
             if ($this->getUserValue3() == '') {
                 $user_value3 = $cd_obj->getUserValue3();
             } else {
                 $user_value3 = $this->getUserValue3();
             }
             Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10);
             $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj);
             Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10);
             Debug::Text('District: ' . $this->getCompanyDeductionObject()->getDistrict(), __FILE__, __LINE__, __METHOD__, 10);
             $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince(), $this->getCompanyDeductionObject()->getDistrict());
             $pd_obj->setCompany($this->getUserObject()->getCompany());
             $pd_obj->setUser($this->getUser());
             $pd_obj->setDate($pay_period_obj->getTransactionDate());
             $pd_obj->setAnnualPayPeriods($annual_pay_periods);
             $pd_obj->setDistrictFilingStatus($user_value1);
             $pd_obj->setDistrictAllowance($user_value2);
             $pd_obj->setUserValue1($user_value1);
             $pd_obj->setUserValue2($user_value2);
             $pd_obj->setUserValue3($user_value3);
             $pd_obj->setGrossPayPeriodIncome($amount);
             $retval = $pd_obj->getDistrictPayPeriodDeductions();
             if ($retval < 0) {
                 $retval = 0;
             }
             break;
     }
     Debug::Text('Deduction Amount: ' . $retval, __FILE__, __LINE__, __METHOD__, 10);
     //Allow negative values, as some advanced tax bracket setups require this.
     if ($retval < 0) {
         //Debug::Text('Deduction was negative, setting to 0...', __FILE__, __LINE__, __METHOD__,10);
         Debug::Text('Deduction was negative...', __FILE__, __LINE__, __METHOD__, 10);
         //$retval = 0;
     }
     return $retval;
 }
Ejemplo n.º 24
0
 function exportPayStub($pslf = NULL, $export_type = NULL)
 {
     global $current_company;
     if (!is_object($pslf) and $this->getId() != '') {
         $pslf = new PayStubListFactory();
         $pslf->getById($this->getId());
     }
     if (get_class($pslf) !== 'PayStubListFactory') {
         return FALSE;
     }
     if ($export_type == '') {
         return FALSE;
     }
     if ($pslf->getRecordCount() > 0) {
         Debug::Text('aExporting...', __FILE__, __LINE__, __METHOD__, 10);
         switch (strtolower($export_type)) {
             case 'hsbc':
             case '1464':
             case '105':
             case 'ach':
                 //Get file creation number
                 $ugdlf = new UserGenericDataListFactory();
                 $ugdlf->getByCompanyIdAndScriptAndDefault($current_company->getId(), 'PayStubFactory', TRUE);
                 if ($ugdlf->getRecordCount() > 0) {
                     Debug::Text('Found Script Setup Data!', __FILE__, __LINE__, __METHOD__, 10);
                     $ugd_obj = $ugdlf->getCurrent();
                     $setup_data = $ugd_obj->getData();
                 } else {
                     $ugd_obj = new UserGenericDataFactory();
                 }
                 Debug::Text('bExporting...', __FILE__, __LINE__, __METHOD__, 10);
                 //get User Bank account info
                 $balf = new BankAccountListFactory();
                 $balf->getCompanyAccountByCompanyId($current_company->getID());
                 if ($balf->getRecordCount() > 0) {
                     $company_bank_obj = $balf->getCurrent();
                     //Debug::Arr($company_bank_obj,'Company Bank Object', __FILE__, __LINE__, __METHOD__,10);
                 }
                 if (isset($setup_data['file_creation_number'])) {
                     $setup_data['file_creation_number']++;
                 } else {
                     //Start at a high number, in attempt to eliminate conflicts.
                     $setup_data['file_creation_number'] = 500;
                 }
                 Debug::Text('bFile Creation Number: ' . $setup_data['file_creation_number'], __FILE__, __LINE__, __METHOD__, 10);
                 //Increment file creation number in DB
                 if ($ugd_obj->getId() == '') {
                     $ugd_obj->setID($ugd_obj->getId());
                 }
                 $ugd_obj->setCompany($current_company->getId());
                 $ugd_obj->setName('PayStubFactory');
                 $ugd_obj->setScript('PayStubFactory');
                 $ugd_obj->setData($setup_data);
                 $ugd_obj->setDefault(TRUE);
                 if ($ugd_obj->isValid()) {
                     $ugd_obj->Save();
                 }
                 $eft = new EFT();
                 $eft->setFileFormat($export_type);
                 $eft->setOriginatorID($current_company->getOriginatorID());
                 $eft->setFileCreationNumber($setup_data['file_creation_number']);
                 $eft->setDataCenter($current_company->getDataCenterID());
                 $eft->setOriginatorShortName($current_company->getShortName());
                 $psealf = new PayStubEntryAccountListFactory();
                 foreach ($pslf as $pay_stub_obj) {
                     Debug::Text('Looping over Pay Stub... ID: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                     //Get pay stub entries.
                     $pself = new PayStubEntryListFactory();
                     $pself->getByPayStubId($pay_stub_obj->getId());
                     $prev_type = NULL;
                     $description_subscript_counter = 1;
                     foreach ($pself as $pay_stub_entry) {
                         $description_subscript = NULL;
                         //$pay_stub_entry_name_obj = $psenlf->getById( $pay_stub_entry->getPayStubEntryNameId() ) ->getCurrent();
                         $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                         if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                             $type = $pay_stub_entry_name_obj->getType();
                         }
                         //var_dump( $pay_stub_entry->getDescription() );
                         if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) {
                             $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
                             $description_subscript = $description_subscript_counter;
                             $description_subscript_counter++;
                         }
                         if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) {
                             $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy());
                         }
                         $prev_type = $pay_stub_entry_name_obj->getType();
                     }
                     if (isset($pay_stub_entries)) {
                         $pay_stub = array('id' => $pay_stub_obj->getId(), 'display_id' => str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'start_date' => $pay_stub_obj->getStartDate(), 'end_date' => $pay_stub_obj->getEndDate(), 'transaction_date' => $pay_stub_obj->getTransactionDate(), 'status' => $pay_stub_obj->getStatus(), 'entries' => $pay_stub_entries, 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy());
                         unset($pay_stub_entries);
                         //Get User information
                         $ulf = new UserListFactory();
                         $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
                         //Get company information
                         $clf = new CompanyListFactory();
                         $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
                         //get User Bank account info
                         $balf = new BankAccountListFactory();
                         $user_bank_obj = $balf->getUserAccountByCompanyIdAndUserId($user_obj->getCompany(), $user_obj->getId());
                         if ($user_bank_obj->getRecordCount() > 0) {
                             $user_bank_obj = $user_bank_obj->getCurrent();
                         } else {
                             continue;
                         }
                         $record = new EFT_Record();
                         $record->setType('C');
                         $amount = $pay_stub['entries'][40][0]['amount'];
                         $record->setCPACode(200);
                         $record->setAmount($amount);
                         unset($amount);
                         $record->setDueDate(TTDate::getBeginDayEpoch($pay_stub_obj->getTransactionDate()));
                         //$record->setDueDate( strtotime("24-Sep-99") );
                         $record->setInstitution($user_bank_obj->getInstitution());
                         $record->setTransit($user_bank_obj->getTransit());
                         $record->setAccount($user_bank_obj->getAccount());
                         $record->setName($user_obj->getFullName());
                         $record->setOriginatorShortName($company_obj->getShortName());
                         $record->setOriginatorLongName(substr($company_obj->getName(), 0, 30));
                         $record->setOriginatorReferenceNumber('TT' . $pay_stub_obj->getId());
                         if (isset($company_bank_obj) and is_object($company_bank_obj)) {
                             $record->setReturnInstitution($company_bank_obj->getInstitution());
                             $record->setReturnTransit($company_bank_obj->getTransit());
                             $record->setReturnAccount($company_bank_obj->getAccount());
                         }
                         $eft->setRecord($record);
                     }
                 }
                 $eft->compile();
                 $output = $eft->getCompiledData();
                 break;
             case 'cheque_9085':
             case 'cheque_9209p':
             case 'cheque_dlt103':
             case 'cheque_dlt104':
             case 'cheque_cr_standard_form_1':
             case 'cheque_cr_standard_form_2':
                 $border = 0;
                 $show_background = 0;
                 $pdf = new TTPDF();
                 $pdf->setMargins(0, 0, 0, 0);
                 $pdf->SetAutoPageBreak(FALSE);
                 $pdf->SetFont('freeserif', '', 10);
                 $psealf = new PayStubEntryAccountListFactory();
                 $i = 0;
                 foreach ($pslf as $pay_stub_obj) {
                     //Get pay stub entries.
                     $pself = new PayStubEntryListFactory();
                     $pself->getByPayStubId($pay_stub_obj->getId());
                     $pay_stub_entries = NULL;
                     $prev_type = NULL;
                     $description_subscript_counter = 1;
                     foreach ($pself as $pay_stub_entry) {
                         $description_subscript = NULL;
                         //$pay_stub_entry_name_obj = $psenlf->getById( $pay_stub_entry->getPayStubEntryNameId() ) ->getCurrent();
                         $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                         //Use this to put the total for each type at the end of the array.
                         if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                             $type = $pay_stub_entry_name_obj->getType();
                         }
                         //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10);
                         //var_dump( $pay_stub_entry->getDescription() );
                         if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) {
                             $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
                             $description_subscript = $description_subscript_counter;
                             $description_subscript_counter++;
                         }
                         $amount_words = str_pad(ucwords(Numbers_Words::toWords(floor($pay_stub_entry->getAmount()), "en_US")) . ' ', 65, "-", STR_PAD_RIGHT);
                         //echo "Amount: ". floor($pay_stub_entry->getAmount()) ." - Words: ". $amount_words ."<br>\n";
                         //var_dump($amount_words);
                         if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) {
                             $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'amount_padded' => str_pad($pay_stub_entry->getAmount(), 12, '*', STR_PAD_LEFT), 'amount_words' => $amount_words, 'amount_cents' => Misc::getAfterDecimal($pay_stub_entry->getAmount()), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy());
                         }
                         unset($amount_words);
                         //Only for net pay, make a total YTD of Advance plus Net.
                         /*
                         if ( $type == 40 ) {
                         	$pay_stub_entries[$type][0]['ytd_net_plus_advance'] =
                         }
                         */
                         $prev_type = $pay_stub_entry_name_obj->getType();
                     }
                     //Get User information
                     $ulf = new UserListFactory();
                     $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
                     //Get company information
                     $clf = new CompanyListFactory();
                     $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
                     if ($user_obj->getCountry() == 'CA') {
                         $date_format = 'd/m/Y';
                     } else {
                         $date_format = 'm/d/Y';
                     }
                     $pay_stub = array('id' => $pay_stub_obj->getId(), 'display_id' => str_pad($pay_stub_obj->getId(), 15, 0, STR_PAD_LEFT), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'start_date' => $pay_stub_obj->getStartDate(), 'end_date' => $pay_stub_obj->getEndDate(), 'transaction_date' => $pay_stub_obj->getTransactionDate(), 'transaction_date_display' => date($date_format, $pay_stub_obj->getTransactionDate()), 'status' => $pay_stub_obj->getStatus(), 'entries' => $pay_stub_entries, 'tainted' => $pay_stub_obj->getTainted(), 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy());
                     unset($pay_stub_entries);
                     Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10);
                     //Get Pay Period information
                     $pplf = new PayPeriodListFactory();
                     $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent();
                     $pp_start_date = $pay_period_obj->getStartDate();
                     $pp_end_date = $pay_period_obj->getEndDate();
                     $pp_transaction_date = $pay_period_obj->getTransactionDate();
                     //Get pay period numbers
                     $ppslf = new PayPeriodScheduleListFactory();
                     $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent();
                     $pay_period_data = array('start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date), 'annual_pay_periods' => $pay_period_schedule_obj->getAnnualPayPeriods());
                     $pdf->AddPage();
                     switch ($export_type) {
                         case 'cheque_9085':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 5, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY(50, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY(50, $adjust_y));
                             $pdf->Cell(23, 5, ' ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(55, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(60, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(65, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 95;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_9209p':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9209P.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(25, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(25, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(57, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(62, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(67, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_dlt103':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_dlt103.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(54, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(46, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(46, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_dlt104':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_dlt104.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(52, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(43, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(48, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_cr_standard_form_1':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(41, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'] . TTi18n::gettext(' and ') . $pay_stub['entries'][40][0]['amount_cents'] . '/100 *****', $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(100, $adjust_x), Misc::AdjustXY(23, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(136, $adjust_x), Misc::AdjustXY(32, $adjust_y));
                             $pdf->Cell(24, 5, '  $' . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 95;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: $') . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: $') . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             //Signature lines
                             $pdf->setXY(Misc::AdjustXY(7, $adjust_x), Misc::AdjustXY(250, $adjust_y));
                             $border = 0;
                             $pdf->Cell(40, 5, TTi18n::gettext('Employee Signature:'), $border, 0, 'L');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'L');
                             $pdf->Cell(40, 5, TTi18n::gettext('Supervisor Signature:'), $border, 0, 'R');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'L');
                             $pdf->Ln();
                             $pdf->Cell(40, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C');
                             $pdf->Ln();
                             $pdf->Cell(147, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'C');
                             $pdf->Ln();
                             $pdf->Cell(140, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, TTi18n::gettext('(print name)'), $border, 0, 'C');
                             break;
                         case 'cheque_cr_standard_form_2':
                             $pdf_created_date = time();
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(41, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'] . TTi18n::gettext(' and ') . $pay_stub['entries'][40][0]['amount_cents'] . '/100 *****', $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(100, $adjust_x), Misc::AdjustXY(23, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(136, $adjust_x), Misc::AdjustXY(32, $adjust_y));
                             $pdf->Cell(24, 5, '$  ' . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 110;
                             $pdf->SetFont('', 'U', 14);
                             $pdf->setXY(Misc::AdjustXY(65, $adjust_x), Misc::AdjustXY(100, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Recipient Copy:'), $border, 0, 'C');
                             $pdf->SetFont('', '', 10);
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Date of Issue:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, TTDate::getDate('DATE+TIME', $pdf_created_date), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Date of Issue:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, TTDate::getDate('DATE+TIME', $pdf_created_date), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Recipient:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(110, 5, $user_obj->getFullName(), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Recipient:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, $user_obj->getFullName(), $border, 0, 'J');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(130, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Amount:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, ' $' . $pay_stub['entries'][40][0]['amount'], $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(130 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Amount:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, ' $' . $pay_stub['entries'][40][0]['amount'], $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(140, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Regarding:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, TTi18n::gettext('Payment from') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']) . ' ' . TTi18n::gettext('to') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(140 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Regarding:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, TTi18n::gettext('Payment from') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']) . ' ' . TTi18n::gettext('to') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'J');
                             $pdf->SetFont('', 'U', 14);
                             $pdf->setXY(Misc::AdjustXY(65, $adjust_x), Misc::AdjustXY(210, $adjust_y));
                             $pdf->Cell(75, 5, $company_obj->getName() . ' ' . TTi18n::gettext('Copy:'), $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(30, $adjust_x), Misc::AdjustXY(260, $adjust_y));
                             $column_widths = array('generated_by' => 25, 'signed_by' => 25, 'received_by' => 35, 'date' => 35, 'sin_ssn' => 35);
                             $line_h = 4;
                             $cell_h_min = $cell_h_max = $line_h * 4;
                             $pdf->SetFont('', '', 8);
                             $pdf->setFillColor(255, 255, 255);
                             $pdf->MultiCell($column_widths['generated_by'], $line_h, TTi18n::gettext('Generated By') . "\n\n\n ", 1, 'C', 1, 0);
                             $pdf->MultiCell($column_widths['signed_by'], $line_h, TTi18n::gettext('Signed By') . "\n\n\n ", 1, 'C', 1, 0);
                             $pdf->MultiCell($column_widths['received_by'], $line_h, TTi18n::gettext('Received By') . "\n\n\n ", 'T,L,B', 'C', 1, 0);
                             $pdf->MultiCell($column_widths['date'], $line_h, TTi18n::gettext('Date') . "\n\n\n ", 'T,B', 'C', 1, 0);
                             $pdf->MultiCell($column_widths['sin_ssn'], $line_h, TTi18n::gettext('SIN / SSN') . "\n\n\n ", 'T,R,B', 'C', 1, 0);
                             $pdf->Ln();
                             $pdf->SetFont('', '', 10);
                             break;
                     }
                     $i++;
                 }
                 $output = $pdf->Output('', 'S');
                 break;
         }
     }
     if (isset($output)) {
         return $output;
     }
     return FALSE;
 }
Ejemplo n.º 25
0
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 7487 $
 * $Id: ViewScheduleWeek.php 7487 2012-08-15 22:35:09Z ipso $
 * $Date: 2012-08-15 15:35:09 -0700 (Wed, 15 Aug 2012) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
require_once Environment::getBasePath() . 'classes/misc/arr_multisort.class.php';
//Debug::setVerbosity(11);
if (!$permission->Check('schedule', 'enabled') or !($permission->Check('schedule', 'view') or $permission->Check('schedule', 'view_own') or $permission->Check('schedule', 'view_child'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'My Schedule'));
// See index.php
//BreadCrumb::setCrumb($title);
BreadCrumb::setCrumb($title, str_replace('ViewScheduleWeek.php', 'ViewSchedule.php', $_SERVER['REQUEST_URI']));
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('do', 'page', 'sort_column', 'sort_order', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
if (isset($filter_data['start_date']) and $filter_data['start_date'] != '') {
Ejemplo n.º 26
0
 static function isEmail($email, $check_dns = TRUE, $error_level = TRUE)
 {
     if (!function_exists('is_email')) {
         require_once Environment::getBasePath() . '/classes/misc/is_email.php';
     }
     $result = is_email($email, $check_dns, $error_level);
     if ($result === ISEMAIL_VALID) {
         return TRUE;
     } else {
         Debug::Text('Result Code: ' . $result, __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
Ejemplo n.º 27
0
 function getFormObject()
 {
     if (!isset($this->form_obj['gf']) or !is_object($this->form_obj['gf'])) {
         //
         //Get all data for the form.
         //
         require_once Environment::getBasePath() . '/classes/GovernmentForms/GovernmentForms.class.php';
         $gf = new GovernmentForms();
         $this->form_obj['gf'] = $gf;
         return $this->form_obj['gf'];
     }
     return $this->form_obj['gf'];
 }
Ejemplo n.º 28
0
 }
 $ulf = TTnew('UserListFactory');
 $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
 if ($ulf->getRecordCount() > 0) {
     foreach ($ulf as $u_obj) {
         $filter_data['user_ids'][] = $u_obj->getId();
     }
     if (isset($filter_data['user_ids']) and isset($filter_data['year'])) {
         $pseallf = TTnew('PayStubEntryAccountLinkListFactory');
         $pseallf->getByCompanyId($current_company->getId());
         if ($pseallf->getRecordCount() > 0) {
             $pseal_obj = $pseallf->getCurrent();
         }
         require_once Environment::getBasePath() . '/classes/fpdi/fpdi.php';
         require_once Environment::getBasePath() . '/classes/tcpdf/tcpdf.php';
         require_once Environment::getBasePath() . '/classes/GovernmentForms/GovernmentForms.class.php';
         $gf = new GovernmentForms();
         $f940 = $gf->getFormObject('940', 'US');
         //$f940->setDebug(FALSE);
         $f940->setShowBackground($show_background);
         //
         //Get all data for the form.
         //
         foreach ($quarter_dates as $quarter_id => $quarter_dates_arr) {
             //Get Pay Periods in date range.
             Debug::Text('Start Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['start']) . ' End Date: ' . TTDate::getDate('DATE+TIME', $quarter_dates_arr['end']), __FILE__, __LINE__, __METHOD__, 10);
             $pplf = TTnew('PayPeriodListFactory');
             $pplf->getByCompanyIdAndTransactionStartDateAndTransactionEndDate($current_company->getId(), $quarter_dates_arr['start'], $quarter_dates_arr['end']);
             if ($pplf->getRecordCount() > 0) {
                 foreach ($pplf as $pp_obj) {
                     $pay_period_ids[] = $pp_obj->getID();
Ejemplo n.º 29
0
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 2723 $
 * $Id: EditRequest.php 2723 2009-08-13 22:05:43Z ipso $
 * $Date: 2009-08-13 15:05:43 -0700 (Thu, 13 Aug 2009) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
//Debug::setVerbosity(11);
if (!$permission->Check('request', 'enabled') or !($permission->Check('request', 'edit') or $permission->Check('request', 'edit_own'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Edit Request'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'data')));
if (isset($data)) {
    $data['date_stamp'] = TTDate::parseDateTime($data['date_stamp']);
}
$rf = new RequestFactory();
Ejemplo n.º 30
0
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by TimeTrex" logo. If the display of the logo is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by TimeTrex".
 ********************************************************************************/
/*
 * $Revision: 2906 $
 * $Id: T4Summary.php 2906 2009-10-16 21:41:04Z ipso $
 * $Date: 2009-10-16 14:41:04 -0700 (Fri, 16 Oct 2009) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
require Environment::getBasePath() . '/classes/fpdi/fpdi.php';
if (!$permission->Check('report', 'enabled') or !$permission->Check('report', 'view_t4_summary')) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'T4 Summary Report'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'setup_data', 'generic_data', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('filter_data' => $filter_data));
$static_columns = array('-1000-full_name' => TTi18n::gettext('Full Name'), '-1010-title' => TTi18n::gettext('Title'), '-1020-province' => TTi18n::gettext('Province'), '-1030-country' => TTi18n::gettext('Country'), '-1039-group' => TTi18n::gettext('Group'), '-1040-default_branch' => TTi18n::gettext('Default Branch'), '-1050-default_department' => TTi18n::gettext('Default Department'), '-1060-sin' => TTi18n::gettext('SIN'));
$non_static_columns = array('-1100-income' => TTi18n::gettext('Income (14)'), '-1110-income_tax' => TTi18n::gettext('Income Tax (22)'), '-1120-employee_cpp' => TTi18n::gettext('Employee CPP (16)'), '-1125-ei_earnings' => TTi18n::gettext('EI Insurable Earnings (24)'), '-1126-cpp_earnings' => TTi18n::gettext('CPP Pensionable Earnings (26)'), '-1130-employee_ei' => TTi18n::gettext('Employee EI (18)'), '-1140-union_dues' => TTi18n::gettext('Union Dues (44)'), '-1150-employer_cpp' => TTi18n::gettext('Employer CPP'), '-1160-employer_ei' => TTi18n::gettext('Employer EI'), '-1170-rpp' => TTi18n::gettext('RPP Contributions (20)'), '-1180-charity' => TTi18n::gettext('Charity Donations (46)'), '-1190-pension_adjustment' => TTi18n::gettext('Pension Adjustment (52)'), '-1200-other_box_0' => TTi18n::gettext('Other Box 1'), '-1210-other_box_1' => TTi18n::gettext('Other Box 2'), '-1220-other_box_2' => TTi18n::gettext('Other Box 3'), '-1220-other_box_3' => TTi18n::gettext('Other Box 4'), '-1220-other_box_4' => TTi18n::gettext('Other Box 5'), '-1220-other_box_5' => TTi18n::gettext('Other Box 6'));
$pseallf = new PayStubEntryAccountLinkListFactory();
$pseallf->getByCompanyId($current_company->getId());