コード例 #1
0
 function postSave()
 {
     $this->removeCache($this->getId());
     $this->remoteSave();
     if ($this->getDeleted() == FALSE) {
         //Add base currency for this new company.
         if ($this->getEnableAddCurrency() == TRUE) {
             $clf = new CurrencyListFactory();
             $clf->getByCompanyId($this->getId());
             if ($clf->getRecordCount() == 0) {
                 Debug::text('Adding Default Currency', __FILE__, __LINE__, __METHOD__, 9);
                 $cf = new CurrencyFactory();
                 $country_to_currency_map_arr = $cf->getOptions('country_currency');
                 if (isset($country_to_currency_map_arr[$this->getCountry()])) {
                     $base_currency = $country_to_currency_map_arr[$this->getCountry()];
                     Debug::text('Found Base Currency For Country: ' . $this->getCountry() . ' Currency: ' . $base_currency, __FILE__, __LINE__, __METHOD__, 9);
                 } else {
                     Debug::text('DID NOT Find Base Currency For Country: ' . $this->getCountry() . ' Using default USD.', __FILE__, __LINE__, __METHOD__, 9);
                     $base_currency = 'USD';
                 }
                 $cf->setCompany($this->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()) {
                     $cf->Save();
                 }
             }
         }
         if ($this->getEnableAddPermissionGroupPreset() == TRUE) {
             Debug::text('Adding Preset Permission Groups', __FILE__, __LINE__, __METHOD__, 9);
             $pf = new PermissionFactory();
             $pf->StartTransaction();
             if ($this->getProductEdition() == 20) {
                 $preset_flags = array('job' => 1, 'invoice' => 1, 'document' => 1);
             } else {
                 $preset_flags = array();
             }
             $preset_options = $pf->getOptions('preset');
             foreach ($preset_options as $preset_id => $preset_name) {
                 $pcf = new PermissionControlFactory();
                 $pcf->setCompany($this->getId());
                 $pcf->setName($preset_name);
                 $pcf->setDescription('');
                 if ($pcf->isValid()) {
                     $pcf_id = $pcf->Save(FALSE);
                     $pf->applyPreset($pcf_id, $preset_id, $preset_flags);
                 }
             }
             //$pf->FailTransaction();
             $pf->CommitTransaction();
         }
         if ($this->getEnableAddStation() == TRUE) {
             Debug::text('Adding Default Station', __FILE__, __LINE__, __METHOD__, 9);
             //Enable punching in from all stations
             $sf = new StationFactory();
             $sf->setCompany($this->getId());
             $sf->setStatus(20);
             $sf->setType(10);
             $sf->setSource('ANY');
             $sf->setStation('ANY');
             $sf->setDescription('All stations');
             $sf->setGroupSelectionType(10);
             $sf->setBranchSelectionType(10);
             $sf->setDepartmentSelectionType(10);
             if ($sf->isValid()) {
                 $sf->Save();
             }
         }
         if ($this->getEnableAddPayStubEntryAccountPreset() == TRUE) {
             Debug::text('Adding Pay Stub Entry Account Presets', __FILE__, __LINE__, __METHOD__, 9);
             PayStubEntryAccountFactory::addPresets($this->getId());
         }
         if ($this->getEnableAddCompanyDeductionPreset() == TRUE) {
             Debug::text('Adding Company Deduction Presets', __FILE__, __LINE__, __METHOD__, 9);
             CompanyDeductionFactory::addPresets($this->getId());
         }
         if ($this->getEnableAddRecurringHolidayPreset() == TRUE) {
             Debug::text('Adding Recurring Holiday Presets', __FILE__, __LINE__, __METHOD__, 9);
             RecurringHolidayFactory::addPresets($this->getId(), $this->getCountry());
         }
     }
     if ($this->getDeleted() == TRUE) {
         $ulf = new UserListFactory();
         $ulf->getByCompanyId($this->getID());
         if ($ulf->getRecordCount() > 0) {
             $ulf->StartTransaction();
             foreach ($ulf as $u_obj) {
                 Debug::text('Deleting User ID: ' . $u_obj->getId(), __FILE__, __LINE__, __METHOD__, 9);
                 $u_obj->setDeleted(TRUE);
                 if ($u_obj->isValid()) {
                     $u_obj->Save();
                 }
             }
             $ulf->CommitTransaction();
         }
     }
     return TRUE;
 }
コード例 #2
0
BreadCrumb::setCrumb($title);
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'page', 'sort_column', 'sort_order', 'ids')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('sort_column' => $sort_column, 'sort_order' => $sort_order, 'page' => $page));
$sort_array = NULL;
if ($sort_column != '') {
    $sort_array = array($sort_column => $sort_order);
}
Debug::Arr($ids, 'Selected Objects', __FILE__, __LINE__, __METHOD__, 10);
$action = Misc::findSubmitButton();
switch ($action) {
    case 'add_presets':
        //Debug::setVerbosity(11);
        RecurringHolidayFactory::addPresets($current_company->getId(), $current_company->getCountry());
        Redirect::Page(URLBuilder::getURL(NULL, 'RecurringHolidayList.php'));
    case 'add':
        Redirect::Page(URLBuilder::getURL(NULL, 'EditRecurringHoliday.php', FALSE));
        break;
    case 'delete' or 'undelete':
        if (strtolower($action) == 'delete') {
            $delete = TRUE;
        } else {
            $delete = FALSE;
        }
        $rhlf = new RecurringHolidayListFactory();
        foreach ($ids as $id) {
            $rhlf->getByIdAndCompanyId($id, $current_company->getId());
            foreach ($rhlf as $rh_obj) {
                $rh_obj->setDeleted($delete);
コード例 #3
0
 static function addPresets($company_id, $country)
 {
     if ($company_id == '') {
         return FALSE;
     }
     switch (strtolower($country)) {
         case 'ca':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('New Years Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Good Friday');
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Canada Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Canada Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(7);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Labour Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(1);
             $rhf->setDayOfWeek(1);
             //$rhf->setDayOfMonth( 1 );
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Xmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Christmas');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             //BC Holidays
             Debug::text('Saving.... British Columbia Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('BC - British Columbia Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(1);
             $rhf->setDayOfWeek(1);
             //$rhf->setDayOfMonth( 1 );
             $rhf->setMonth(8);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             //AB Holidays
             Debug::text('Saving.... Family Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('AB - Family Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(3);
             $rhf->setDayOfWeek(1);
             //$rhf->setDayOfMonth( 1 );
             $rhf->setMonth(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             //Holidays across different provinces
             Debug::text('Saving.... Victoria Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Victoria Day');
             $rhf->setType(30);
             $rhf->setSpecialDay(0);
             $rhf->setPivotDayDirection(10);
             $rhf->setDayOfWeek(1);
             $rhf->setDayOfMonth(24);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Thanksgiving', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Thanksgiving Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(2);
             $rhf->setDayOfWeek(1);
             //$rhf->setDayOfMonth( 1 );
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Rememberance Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Rememberance Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(11);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'us':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('New Years Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Independence Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(4);
             $rhf->setMonth(7);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Veterans Day');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(11);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Christmas');
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             //$rhf->setWeekInterval( $data['week_interval'] );
             //$rhf->setDayOfWeek( $data['day_of_week'] );
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Martin Luther King Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(3);
             $rhf->setDayOfWeek(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Presidents Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(3);
             $rhf->setDayOfWeek(1);
             $rhf->setMonth(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             //Pivot Day
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Memorial Day');
             $rhf->setType(30);
             $rhf->setSpecialDay(0);
             $rhf->setPivotDayDirection(20);
             $rhf->setDayOfWeek(1);
             $rhf->setDayOfMonth(24);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Labor Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(1);
             $rhf->setDayOfWeek(1);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Columbus Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(2);
             $rhf->setDayOfWeek(1);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Thanksgiving Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(4);
             $rhf->setDayOfWeek(4);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Day After Thanksgiving Day');
             $rhf->setType(20);
             $rhf->setSpecialDay(0);
             $rhf->setWeekInterval(4);
             $rhf->setDayOfWeek(5);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName('Good Friday');
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'cr':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Thursday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Thursday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Juan Santamaria Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Juan Santamaria Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(11);
             $rhf->setMonth(4);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Anexion de Guanacaste Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Anexion de Guanacaste Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(7);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Virgen de los Angeles Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Virgen de los Angeles Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(2);
             $rhf->setMonth(8);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Mothers  Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Mothers Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(8);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day CR'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Culture Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Culture Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(12);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'gt':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Wednesday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Wednesday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(3);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Thursday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Thursday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Army Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Army Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(30);
             $rhf->setMonth(6);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Virgin Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Virgin Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(8);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day CR'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... 1944 Revolution Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('1944 Revolution Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(20);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... All Saint Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('All Saint Day'));
             $rhf->setType(30);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas Eve', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas Eve'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(24);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'hn':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Thursday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Thursday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Saturday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Saturday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Morazan Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Morazan Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(3);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Culture Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Culture Day'));
             $rhf->setType(30);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(12);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Armed Forces Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Armed Forces Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(21);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'sv':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Thursday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Thursday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Bank Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Bank Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(30);
             $rhf->setMonth(6);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... San Salvador Party', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('San Salvador Party'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(4);
             $rhf->setMonth(8);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Columbus Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Columbus Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(12);
             $rhf->setMonth(10);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... All Saints Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('All Saints Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(2);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... First Cry of Independence', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('First Cry of Independence'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(5);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'ni':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Thursday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Thursday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(2);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Revolution Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Revolution Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(19);
             $rhf->setMonth(7);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... San Jacinto Battle', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('San Jacinto Battle'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(14);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(15);
             $rhf->setMonth(9);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
         case 'pa':
             Debug::text('Saving.... New Years', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('New Years Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Martyr`s Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Martyr`s Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(9);
             $rhf->setMonth(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Good Friday/Easter', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Good Friday'));
             $rhf->setType(20);
             $rhf->setSpecialDay(1);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Labour Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Labour Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(1);
             $rhf->setMonth(5);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Separation Day (from Colombia)', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Separation Day from Colombia'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(3);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Flag Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Flag Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(4);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Primer Grito de Independencia de la Villa de los Santos', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Primer Grito de Independencia de la Villa de los Santos'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(10);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Independence Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Independence Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(28);
             $rhf->setMonth(11);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Mothers Day', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Mothers Day'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(8);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             Debug::text('Saving.... Christmas', __FILE__, __LINE__, __METHOD__, 10);
             $rhf = new RecurringHolidayFactory();
             $rhf->setCompany($company_id);
             $rhf->setName(TTi18n::gettext('Christmas'));
             $rhf->setType(10);
             $rhf->setSpecialDay(0);
             $rhf->setDayOfMonth(25);
             $rhf->setMonth(12);
             if ($rhf->isValid()) {
                 $rhf->Save();
             }
             break;
     }
     return TRUE;
 }
コード例 #4
0
 * $Id: EditRecurringHoliday.php 2875 2009-10-07 20:27:06Z ipso $
 * $Date: 2009-10-07 13:27:06 -0700 (Wed, 07 Oct 2009) $
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
if (!$permission->Check('holiday_policy', 'enabled') or !($permission->Check('holiday_policy', 'edit') or $permission->Check('holiday_policy', 'edit_own'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Edit Recurring Holiday'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'data')));
$rhf = new RecurringHolidayFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        //Debug::setVerbosity(11);
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $rhf->setId($data['id']);
        $rhf->setCompany($current_company->getId());
        $rhf->setName($data['name']);
        $rhf->setType($data['type_id']);
        /*
        if ( isset($data['easter']) ) {
        	$rhf->setEaster( TRUE );
        } else {
        	$rhf->setEaster( FALSE );