Ignore:
Timestamp:
Jan 12, 2015, 12:20:30 AM (10 years ago)
Author:
chronos
Message:
  • Added: Generic Scheduler module for running tasks on specified time and with specified period.
  • Added: System execution from command line using cmd.php entry point.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r639 r729  
    44include_once(dirname(__FILE__).'/ImportPS.php');
    55include_once(dirname(__FILE__).'/ImportFio.php');
     6include_once(dirname(__FILE__).'/../Scheduler/Scheduler.php');
    67
    78class ModuleFinanceBankAPI extends AppModule
     
    1516    $this->License = 'GNU/GPLv3';
    1617    $this->Description = 'Communication through API to various banks, manual file import';
    17     $this->Dependencies = array('Finance');
     18    $this->Dependencies = array('Finance', 'Scheduler');
    1819  }
    1920
     
    5859
    5960    $this->System->RegisterPage(array('finance', 'import-api'), 'PageImportAPI');
    60     $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile');
     61    $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile');   
    6162  }
    6263
     
    8182  }
    8283}
     84
     85class ScheduleBankImport extends SchedulerTask
     86{
     87        function Execute()
     88        {
     89                $Output = '';
     90                $DbResult = $this->Database->select('FinanceBankAccount', 'Id', '(AutoImport=1) AND ((TimeEnd IS NULL) OR (TimeEnd > NOW()))');
     91                while($DbRow = $DbResult->fetch_assoc())
     92                {                       
     93                        $Page = new PageImportAPI($this->System);
     94                        $Output .= $Page->Show();
     95                }
     96                return($Output);
     97        }
     98}
Note: See TracChangeset for help on using the changeset viewer.