Esempio n. 1
0
         					$image_transform->save($dir.'/'.$upload_result);
         */
         $file_data_arr = $upload->get_file();
         rename($dir . '/' . $upload_result, $dir . '/logo' . $file_data_arr['extension']);
         //$post_js = 'window.opener.document.getElementById(\'logo\').src = \''. Environment::getBaseURL().'/send_file.php?object_type=invoice_config&rand='.time().'\'; window.opener.showLogo();';
         $post_js = 'window.opener.setLogo()';
     }
     break;
 case 'license':
     Debug::Text('Post Upload Operation...', __FILE__, __LINE__, __METHOD__, 10);
     if (isset($success) and $success != '') {
         Debug::Text('Rename', __FILE__, __LINE__, __METHOD__, 10);
         $file_data_arr = $upload->get_file();
         $license_data = trim(file_get_contents($dir . '/' . $upload_result));
         //Validate License then save to system table.
         $license = new TTLicense();
         $parse_license_retval = $license->parseLicense($license_data);
         $validate_license_retval = $license->validateLicense($license_data);
         Debug::text('Parse License RetVal: ' . (int) $parse_license_retval . ' Validate License RetVal: ' . $validate_license_retval, __FILE__, __LINE__, __METHOD__, 9);
         if ($parse_license_retval === TRUE) {
             $sslf = new SystemSettingListFactory();
             $sslf->getByName('license');
             if ($sslf->getRecordCount() == 1) {
                 $obj = $sslf->getCurrent();
             } else {
                 $obj = new SystemSettingListFactory();
             }
             $obj->setName('license');
             $obj->setValue($license_data);
             if ($obj->isValid()) {
                 Debug::text('Setting License Data...', __FILE__, __LINE__, __METHOD__, 9);
 /**
  * Returns array of notifications message to be displayed to the user.
  * @param string $action Action that is being performed, possible values: 'login', 'preference', 'notification', 'pay_period'
  * @return array
  */
 function getNotifications($action = FALSE)
 {
     global $config_vars, $disable_database_connection;
     $retarr = FALSE;
     //Skip this step if disable_database_connection is enabled or the user is going through the installer still
     switch (strtolower($action)) {
         case 'login':
             if ((!isset($disable_database_connection) or isset($disable_database_connection) and $disable_database_connection != TRUE) and (!isset($config_vars['other']['installer_enabled']) or isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] != TRUE)) {
                 //Get all system settings, so they can be used even if the user isn't logged in, such as the login page.
                 $sslf = new SystemSettingListFactory();
                 $system_settings = $sslf->getAllArray();
             }
             unset($sslf);
             //Check license validity
             if ((DEPLOYMENT_ON_DEMAND == FALSE and $this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id']) and getTTProductEdition() > 10) {
                 if (!isset($system_settings['license'])) {
                     $system_settings['license'] = NULL;
                 }
                 $license = new TTLicense();
                 $license_validate = $license->validateLicense($system_settings['license']);
                 $license_message = $license->getFullErrorMessage($license_validate, TRUE);
                 if ($license_message != '') {
                     $destination_url = 'http://www.timetrex.com/r.php?id=899';
                     if ($license_validate === TRUE) {
                         //License likely expires soon.
                         $retarr[] = array('delay' => 0, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('WARNING: %1', $license_message), 'destination' => $destination_url);
                     } else {
                         //License error.
                         $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1', $license_message), 'destination' => $destination_url);
                     }
                 }
                 unset($license, $license_validate, $license_message, $destination);
             }
             //System Requirements not being met.
             if (isset($system_settings['valid_install_requirements']) and DEPLOYMENT_ON_DEMAND == FALSE and (int) $system_settings['valid_install_requirements'] == 0) {
                 $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 system requirement check has failed! Please contact your %1 administrator immediately to re-run the %1 installer to correct the issue.', APPLICATION_NAME), 'destination' => NULL);
             }
             //Check version mismatch
             if (isset($system_settings['system_version']) and DEPLOYMENT_ON_DEMAND == FALSE and APPLICATION_VERSION != $system_settings['system_version']) {
                 $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 application version does not match database version. Please re-run the %1 installer to complete the upgrade process.', APPLICATION_NAME), 'destination' => NULL);
             }
             //Only display message to the primary company.
             if (time() - (int) APPLICATION_VERSION_DATE > 86400 * 475 and ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) {
                 //~1yr and 3mths
                 $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: This %1 version (v%2) is severely out of date and may no longer be supported. Please upgrade to the latest version as soon as possible as invalid calculations may already be occurring.', array(APPLICATION_NAME, APPLICATION_VERSION)), 'destination' => NULL);
             }
             //New version available notification.
             if (DEMO_MODE == FALSE and (isset($system_settings['new_version']) and $system_settings['new_version'] == 1) and ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) {
                 //Only display this every two weeks.
                 $new_version_available_notification_arr = UserSettingFactory::getUserSetting($this->getCurrentUserObject()->getID(), 'new_version_available_notification');
                 if (!isset($new_version_available_notification_arr['value']) or isset($new_version_available_notification_arr['value']) and $new_version_available_notification_arr['value'] <= time() - 86400 * 14) {
                     UserSettingFactory::setUserSetting($this->getCurrentUserObject()->getID(), 'new_version_available_notification', time());
                     $retarr[] = array('delay' => -1, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: A new version of %1 available, it is highly recommended that you upgrade as soon as possible. Click here to download the latest version.', array(APPLICATION_NAME)), 'destination' => getTTProductEdition() == TT_PRODUCT_COMMUNITY ? 'http://www.timetrex.com/r.php?id=19' : 'http://www.timetrex.com/r.php?id=9');
                 }
                 unset($new_version_available_notification);
             }
             //Check for major new version.
             $new_version_notification_arr = UserSettingFactory::getUserSetting($this->getCurrentUserObject()->getID(), 'new_version_notification');
             if (DEMO_MODE == FALSE and (!isset($config_vars['branding']['application_name']) or ($this->getCurrentCompanyObject()->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $this->getCurrentCompanyObject()->getId() == $config_vars['other']['primary_company_id'])) and $this->getPermissionObject()->getLevel() >= 20 and $this->getCurrentUserObject()->getCreatedDate() <= APPLICATION_VERSION_DATE and (!isset($new_version_notification_arr['value']) or isset($new_version_notification_arr['value']) and Misc::MajorVersionCompare(APPLICATION_VERSION, $new_version_notification_arr['value'], '>'))) {
                 UserSettingFactory::setUserSetting($this->getCurrentUserObject()->getID(), 'new_version_notification', APPLICATION_VERSION);
                 $retarr[] = array('delay' => -1, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: Your instance of %1 has been upgraded to v%2, click here to see whats new.', array(APPLICATION_NAME, APPLICATION_VERSION)), 'destination' => 'http://www.timetrex.com/r.php?id=300');
             }
             unset($new_version_notification);
             //Check installer enabled.
             if (isset($config_vars['other']['installer_enabled']) and $config_vars['other']['installer_enabled'] == 1) {
                 $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 is currently in INSTALL MODE. Please go to your timetrex.ini.php file and set "installer_enabled" to "FALSE".', APPLICATION_NAME), 'destination' => NULL);
             }
             //Make sure CronJobs are running correctly.
             $cjlf = new CronJobListFactory();
             $cjlf->getMostRecentlyRun();
             if ($cjlf->getRecordCount() > 0) {
                 //Is last run job more then 48hrs old?
                 $cj_obj = $cjlf->getCurrent();
                 if (PRODUCTION == TRUE and DEMO_MODE == FALSE and $cj_obj->getLastRunDate() < time() - 172800 and $cj_obj->getCreatedDate() < time() - 172800) {
                     $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Critical maintenance jobs have not run in the last 48hours. Please contact your %1 administrator immediately.', APPLICATION_NAME), 'destination' => NULL);
                 }
             }
             unset($cjlf, $cj_obj);
             //Check if any pay periods are past their transaction date and not closed.
             if (DEMO_MODE == FALSE and $this->getPermissionObject()->Check('pay_period_schedule', 'enabled') and $this->getPermissionObject()->Check('pay_period_schedule', 'view')) {
                 $pplf = TTnew('PayPeriodListFactory');
                 $pplf->getByCompanyIdAndStatusAndTransactionDate($this->getCurrentCompanyObject()->getId(), array(10, 30), TTDate::getBeginDayEpoch(time()));
                 //Open or Post Adjustment pay periods.
                 if ($pplf->getRecordCount() > 0) {
                     foreach ($pplf as $pp_obj) {
                         if ($pp_obj->getCreatedDate() < time() - 86400 * 40) {
                             //Ignore pay period schedules newer than 40 days. They are automatically closed after 45 days.
                             $retarr[] = array('delay' => 0, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Pay periods past their transaction date have not been closed yet. It\'s critical that these pay periods are closed to prevent data loss, click here to close them now.'), 'destination' => array('menu_name' => 'Pay Periods'));
                             break;
                         }
                     }
                 }
                 unset($pplf, $pp_obj);
             }
             //CHeck for unread messages
             $mclf = new MessageControlListFactory();
             $unread_messages = $mclf->getNewMessagesByCompanyIdAndUserId($this->getCurrentCompanyObject()->getId(), $this->getCurrentUserObject()->getId());
             Debug::text('UnRead Messages: ' . $unread_messages, __FILE__, __LINE__, __METHOD__, 10);
             if ($unread_messages > 0) {
                 $retarr[] = array('delay' => 25, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: You have %1 new message(s) waiting, click here to read them now.', $unread_messages), 'destination' => array('menu_name' => 'Messages'));
             }
             unset($mclf, $unread_messages);
             if (DEMO_MODE == FALSE) {
                 $elf = new ExceptionListFactory();
                 $elf->getFlaggedExceptionsByUserIdAndPayPeriodStatus($this->getCurrentUserObject()->getId(), 10);
                 $display_exception_flag = FALSE;
                 if ($elf->getRecordCount() > 0) {
                     foreach ($elf as $e_obj) {
                         if ($e_obj->getColumn('severity_id') == 30) {
                             $display_exception_flag = 'red';
                         }
                         break;
                     }
                 }
                 if (isset($display_exception_flag) and $display_exception_flag !== FALSE) {
                     Debug::Text('Exception Flag to Display: ' . $display_exception_flag, __FILE__, __LINE__, __METHOD__, 10);
                     $retarr[] = array('delay' => 30, 'bg_color' => '#FFFF00', 'message' => TTi18n::getText('NOTICE: You have critical severity exceptions pending, click here to view them now.'), 'destination' => array('menu_name' => 'Exceptions'));
                 }
                 unset($elf, $e_obj, $display_exception_flag);
             }
             if (DEMO_MODE == FALSE and $this->getPermissionObject()->getLevel() >= 20 and ($this->getCurrentUserObject()->getWorkEmail() == '' and $this->getCurrentUserObject()->getHomeEmail() == '')) {
                 $retarr[] = array('delay' => 30, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: Please click here and enter an email address for your account, this is required to receive important notices and prevent your account from being locked out.'), 'destination' => array('menu_name' => 'Contact Information'));
             }
             break;
         default:
             break;
     }
     //Check timezone is proper.
     $current_user_prefs = $this->getCurrentUserObject()->getUserPreferenceObject();
     if ($current_user_prefs->setDateTimePreferences() == FALSE) {
         //Setting timezone failed, alert user to this fact.
         //WARNING: %1 was unable to set your time zone. Please contact your %1 administrator immediately.{/t} {if $permission->Check('company','enabled') AND $permission->Check('company','edit_own')}<a href="http://forums.timetrex.com/viewtopic.php?t=40">{t}For more information please click here.{/t}</a>{/if}
         if ($this->getPermissionObject()->Check('company', 'enabled') and $this->getPermissionObject()->Check('company', 'edit_own')) {
             $destination_url = 'http://www.timetrex.com/r.php?id=1010';
             $sub_message = TTi18n::getText('For more information please click here.');
         } else {
             $destination_url = NULL;
             $sub_message = NULL;
         }
         $retarr[] = array('delay' => -1, 'bg_color' => '#FF0000', 'message' => TTi18n::getText('WARNING: %1 was unable to set your time zone. Please contact your %1 administrator immediately.', APPLICATION_NAME) . ' ' . $sub_message, 'destination' => $destination_url);
         unset($destination_url, $sub_message);
     }
     return $retarr;
 }
Esempio n. 3
0
         if (isset($dir)) {
             @mkdir($dir, 0700, TRUE);
             $upload_result = $upload->upload("filedata", $dir);
             //var_dump($upload ); //file data
             if ($upload_result) {
                 $success = $upload_result . ' ' . TTi18n::gettext('Successfully Uploaded');
             } else {
                 $error = $upload->get_error();
             }
         }
         Debug::Text('Post Upload Operation...', __FILE__, __LINE__, __METHOD__, 10);
         if (isset($success) and $success != '') {
             Debug::Text('Rename', __FILE__, __LINE__, __METHOD__, 10);
             $file_data_arr = $upload->get_file();
             $license_data = trim(file_get_contents($dir . '/' . $upload_result));
             $license = new TTLicense();
             $retval = $license->getLicenseFile(TRUE, $license_data);
             //Download updated license file if one exists.
             if ($retval === FALSE) {
                 $error = TTi18n::gettext('Invalid License File');
             }
         }
     } else {
         Debug::Text('Permission denied for upload!', __FILE__, __LINE__, __METHOD__, 10);
     }
     break;
 case 'import':
     $import = TTnew('Import');
     $import->company_id = $current_company->getId();
     $import->user_id = $current_user->getId();
     //Debug::setVerbosity(11);
Esempio n. 4
0
 if ($ttsc->getLocalRegistrationKey() == FALSE or $ttsc->getLocalRegistrationKey() == '') {
     $ttsc->saveRegistrationKey();
 }
 //We must ensure that the data is up to date
 //Otherwise version check will fail.
 $ttsc->sendCompanyData($c_obj->getId());
 $ttsc->sendCompanyUserLocationData($c_obj->getId());
 $ttsc->sendCompanyUserCountData($c_obj->getId());
 $ttsc->sendCompanyVersionData($c_obj->getId());
 //Check for new license once it starts expiring.
 //Help -> About, checking for new versions also gets the updated license file.
 if ($c_obj->getID() == $config_vars['other']['primary_company_id'] and getTTProductEdition() > TT_PRODUCT_COMMUNITY) {
     if (!isset($system_settings['license'])) {
         $system_settings['license'] = NULL;
     }
     $license = new TTLicense();
     $license->checkLicenseFile($system_settings['license']);
 }
 //Only need to call this on the last company
 if ($i == $clf->getRecordCount() - 1) {
     $latest_version = $ttsc->isLatestVersion($c_obj->getId());
     $latest_tax_engine_version = $ttsc->isLatestTaxEngineVersion($c_obj->getId());
     $latest_tax_data_version = $ttsc->isLatestTaxDataVersion($c_obj->getId());
     $sslf = new SystemSettingListFactory();
     $sslf->getByName('new_version');
     if ($sslf->getRecordCount() == 1) {
         $obj = $sslf->getCurrent();
     } else {
         $obj = new SystemSettingListFactory();
     }
     $obj->setName('new_version');
Esempio n. 5
0
$authenticate = FALSE;
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
//Debug::setVerbosity(11);
$smarty->assign('title', TTi18n::gettext($title = '4. Upgrade Complete'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'data')));
$install_obj = new Install();
if ($install_obj->isInstallMode() == FALSE) {
    Redirect::Page(URLBuilder::getURL(NULL, 'install.php'));
    exit;
}
//Check for updated license file.
$license = new TTLicense();
$license->getLicenseFile(TRUE);
//Download updated license file if one exists.
$action = Misc::findSubmitButton();
switch ($action) {
    case 'back':
        Debug::Text('Back', __FILE__, __LINE__, __METHOD__, 10);
        Redirect::Page(URLBuilder::getURL(NULL, 'DatabaseConfig.php'));
        break;
    case 'next':
        Debug::Text('Next', __FILE__, __LINE__, __METHOD__, 10);
        Redirect::Page(URLBuilder::getURL(NULL, 'Done.php?upgrade=1'));
        break;
    default:
        break;
}
Esempio n. 6
0
            $begin_month_epoch = TTDate::getBeginMonthEpoch(TTDate::getBeginMonthEpoch(time()) - 86400);
        }
        $cuclf = new CompanyUserCountListFactory();
        $cuclf->getMonthlyMinAvgMaxByCompanyIdAndStartDateAndEndDate($current_company->getId(), $begin_month_epoch, TTDate::getEndMonthEpoch(time()), NULL, NULL, NULL, array('date_stamp' => 'desc'));
        if ($cuclf->getRecordCount() > 0) {
            foreach ($cuclf as $cuc_obj) {
                $data['user_counts'][] = array('label' => $month_of_year_arr[TTDate::getMonth(TTDate::strtotime($cuc_obj->getColumn('date_stamp')))] . ' ' . TTDate::getYear(TTDate::strtotime($cuc_obj->getColumn('date_stamp'))), 'max_active_users' => $cuc_obj->getColumn('max_active_users'), 'max_inactive_users' => $cuc_obj->getColumn('max_inactive_users'), 'max_deleted_users' => $cuc_obj->getColumn('max_deleted_users'));
            }
        }
        $cjlf = new CronJobListFactory();
        $cjlf->getMostRecentlyRun();
        if ($cjlf->getRecordCount() > 0) {
            $cj_obj = $cjlf->getCurrent();
            $data['cron'] = array('last_run_date' => $cj_obj->getLastRunDate());
        }
        if (($current_company->getId() == 1 or isset($config_vars['other']['primary_company_id']) and $current_company->getId() == $config_vars['other']['primary_company_id']) and getTTProductEdition() > 10) {
            if (!isset($system_settings['license'])) {
                $system_settings['license'] = NULL;
            }
            //Set this so the license upload area at least shows up regardles of edition.
            $data['license_data'] = array();
            $license = new TTLicense();
            $retval = $license->validateLicense($system_settings['license']);
            if ($retval == TRUE) {
                $data['license_data'] = array('organization_name' => $license->getOrganizationName(), 'major_version' => $license->getMajorVersion(), 'minor_version' => $license->getMinorVersion(), 'product_name' => $license->getProductName(), 'active_employee_licenses' => $license->getActiveEmployeeLicenses(), 'issue_date' => TTDate::getDate('DATE', $license->getIssueDate()), 'expire_date' => $license->getExpireDate(), 'expire_date_display' => TTDate::getDate('DATE', $license->getExpireDate()), 'registration_key' => $license->getRegistrationKey(), 'message' => $license->getFullErrorMessage($retval), 'retval' => $retval);
            }
        }
}
//var_dump($data);
$smarty->assign_by_ref('data', $data);
$smarty->display('help/About.tpl');
Esempio n. 7
0
 function isNewVersionAvailable($ytd = 0, $all_companies = FALSE)
 {
     Debug::Text('Check For Update!', __FILE__, __LINE__, __METHOD__, 10);
     $current_company = $this->getCurrentCompanyObject();
     $data = $this->getAboutData($ytd, $all_companies);
     $ttsc = new TimeTrexSoapClient();
     //We must ensure that the data is up to date
     //Otherwise version check will fail.
     $ttsc->sendCompanyData($current_company->getId(), TRUE);
     $ttsc->sendCompanyUserLocationData($current_company->getId());
     $ttsc->sendCompanyUserCountData($current_company->getId());
     $ttsc->sendCompanyVersionData($current_company->getId());
     $license = new TTLicense();
     $license->getLicenseFile(FALSE);
     //Download updated license file if one exists.
     $latest_version = $ttsc->isLatestVersion($current_company->getId());
     $latest_tax_engine_version = $ttsc->isLatestTaxEngineVersion($current_company->getId());
     $latest_tax_data_version = $ttsc->isLatestTaxDataVersion($current_company->getId());
     $sslf = TTnew('SystemSettingListFactory');
     $sslf->getByName('new_version');
     if ($sslf->getRecordCount() == 1) {
         $obj = $sslf->getCurrent();
     } else {
         $obj = TTnew('SystemSettingListFactory');
     }
     $obj->setName('new_version');
     if ($latest_version == FALSE or $latest_tax_engine_version == FALSE or $latest_tax_data_version == FALSE) {
         $obj->setValue(1);
         $data['new_version'] = TRUE;
     } else {
         $obj->setValue(0);
         $data['new_version'] = FALSE;
     }
     if ($obj->isValid()) {
         $obj->Save();
     }
     return $this->returnHandler($data);
 }