Ignore:
Timestamp:
Apr 14, 2015, 10:20:16 PM (10 years ago)
Author:
chronos
Message:
  • Removed: Spaces on end of line.
  • Modified: Tabs converted to spaces.
File:
1 edited

Legend:

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

    r719 r738  
    88  var $Database;
    99  var $BankAccount;
    10  
     10
    1111  function __construct($System)
    1212  {
     
    1414    $this->System = &$System;
    1515  }
    16      
     16
    1717  function Import()
    1818  {
    1919  }
    20  
     20
    2121  function ImportFile($Content, $Ext)
    22   {   
     22  {
    2323  }
    24  
     24
    2525  function PairOperations()
    2626  {
     
    3232        $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']);
    3333        if($DbResult2->num_rows == 1)
    34         { 
     34        {
    3535          $DbRow2 = $DbResult2->fetch_assoc();
    36           // TODO: Replace constants by links to real database numbers 
     36          // TODO: Replace constants by links to real database numbers
    3737          if($DbRow['Value'] >= 0) {
    38                 $DocumentLine = 3; // Receive money
    39                 $Direction = 1;                 
     38            $DocumentLine = 3; // Receive money
     39            $Direction = 1;
    4040          } else {
    41                 $DocumentLine = 4; // Send money
    42                 $Direction = -1;
     41            $DocumentLine = 4; // Send money
     42            $Direction = -1;
    4343          }
    4444          $Year = date('Y', MysqlDateToTime($DbRow['Time']));
    4545          $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
    46           $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 
     46          $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
    4747            'Value' => Abs($DbRow['Value']), 'Direction' => $Direction, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4848            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'DocumentLine' => $DocumentLine));
     
    6161
    6262  function Show()
    63   {   
     63  {
    6464    $Output = '';
    6565    if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    66      
     66
    6767    $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$_GET['i']);
    6868    $BankAccount = $DbResult->fetch_assoc();
    69    
     69
    7070    $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']);
    7171    $Bank = $DbResult->fetch_assoc();
    7272    $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')';
    73    
     73
    7474    if($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
    7575      else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
     
    8080      $Output .= $Import->Import();
    8181      $Import->PairOperations();
    82     } 
     82    }
    8383    return($Output);
    8484  }
    8585}
    86  
     86
    8787class PageImportFile extends Page
    8888{
     
    9090  var $ShortTitle = 'Import plateb ze souboru';
    9191  var $ParentClass = 'PageFinance';
    92  
     92
    9393  function Show()
    9494  {
     
    103103    return($Output);
    104104  }
    105  
     105
    106106  function ShowForm()
    107107  {
     
    113113    return($Output);
    114114  }
    115  
     115
    116116  function Prepare()
    117   {   
     117  {
    118118    $Form = new Form($this->System->FormManager);
    119119    $Form->SetClass('ImportBankFile');
     
    125125    $DbResult = $this->Database->select('FinanceBankAccount', '*', 'Id='.$Form->Values['BankAccount']);
    126126    $BankAccount = $DbResult->fetch_assoc();
    127    
     127
    128128    $DbResult = $this->Database->select('FinanceBank', '*', 'Id='.$BankAccount['Bank']);
    129129    $Bank = $DbResult->fetch_assoc();
    130130    $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')';
    131    
     131
    132132    if($Bank['Code'] == '2010') $Import = new ImportFio($this->System);
    133133      else if($Bank['Code'] == '0300') $Import = new ImportPS($this->System);
     
    135135    $Import->BankAccount = $BankAccount;
    136136    $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt());
    137    
     137
    138138    return($Output);
    139139  }
    140  
     140
    141141  function InsertMoney($Subject, $Value, $Direction, $Cash, $Taxable, $Time, $Text, $DocumentLine)
    142142  {
    143     $Year = date('Y', $Time);     
     143    $Year = date('Y', $Time);
    144144    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
    145     $this->Database->insert('FinanceOperation', array('Text' => $Text, 
    146         'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction,
    147         'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode));
     145    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     146      'Subject' => $Subject, 'Cash' => $Cash, 'Value' => $Value, 'Direction' => $Direction,
     147      'Time' => TimeToMysqlDateTime($Time), 'Taxable' => $Taxable, 'BillCode' => $BillCode));
    148148  }
    149149
     
    152152    $Finance = $this->System->Modules['Finance'];
    153153    $Output = '';
    154    
     154
    155155    for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    156156    {
    157157      // TODO: Use links to database records instead of contants
    158158      if($_POST['Money'.$I] < 0) {
    159         $DocumentLine = 4;
    160         $Direction = -1;
     159        $DocumentLine = 4;
     160        $Direction = -1;
    161161      } else {
    162         $DocumentLine = 3;
    163         $Direction = 1;
     162        $DocumentLine = 3;
     163        $Direction = 1;
    164164      }
    165         $Date = explode('-', $_POST['Date'.$I]);
     165      $Date = explode('-', $_POST['Date'.$I]);
    166166      $Date = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]);
    167167      $this->InsertMoney($_POST['Subject'.$I], Abs($_POST['Money'.$I]), $Direction, 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $DocumentLine);
Note: See TracChangeset for help on using the changeset viewer.