Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/Import.php

    r812 r873  
    99  function Show()
    1010  {
    11     if(!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    12     if(array_key_exists('Operation', $_GET))
     11    if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění');
     12    if (array_key_exists('Operation', $_GET))
    1313    {
    14       if($_GET['Operation'] == 'prepare') return($this->Prepare());
    15       else if($_GET['Operation'] == 'insert') return($this->Insert());
     14      if ($_GET['Operation'] == 'prepare') return ($this->Prepare());
     15      else if ($_GET['Operation'] == 'insert') return ($this->Insert());
    1616      else echo('Neplatná akce');
    1717    } else
     
    2222      $Output .= '<input type="submit" value="Analyzovat"/>';
    2323      $Output .= '</form>';
    24       return($Output);
     24      return ($Output);
    2525    }
    2626  }
     
    3131    $Finance->LoadMonthParameters(0);
    3232    $Data = explode("\n", $_POST['Source']);
    33     foreach($Data as $Key => $Value)
     33    foreach ($Data as $Key => $Value)
    3434    {
    3535      $Value = str_replace('\"', '"', $Value);
    3636      $Data[$Key] = str_getcsv($Value, ',', '"', "\\");
    3737      //print_r($Data[$Key]);
    38       foreach($Data[$Key] as $Key2 => $Value2)
     38      foreach ($Data[$Key] as $Key2 => $Value2)
    3939      {
    40         if(substr($Data[$Key][$Key2], 0, 2) == '\"')
     40        if (substr($Data[$Key][$Key2], 0, 2) == '\"')
    4141          $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2);
    4242      }
     
    6161    //print_r($Data);
    6262
    63     if($Header != $Data[0]) {
     63    if ($Header != $Data[0]) {
    6464      $Output = 'Nekompatibilní struktura CSV';
    6565      print_r($Header);
     
    7373      $Output = '<form action="?Operation=insert" method="post">';
    7474      $I = 0;
    75       foreach($Data as $Key => $Value)
     75      foreach ($Data as $Key => $Value)
    7676      {
    77         if(count($Value) <= 1) continue;
    78         if($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
     77        if (count($Value) <= 1) continue;
     78        if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna
    7979        $Time = explode('.', $Value[0]);
    8080        $Time = $Time[2].'-'.$Time[1].'-'.$Time[0];
    8181        $Money = $Value[1];
    82         if(is_numeric($Value[5]))
     82        if (is_numeric($Value[5]))
    8383        {
    8484          $Subject = $Value[5] * 1;
    8585          $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject));
    86           if($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
     86          if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';
    8787        } else
    8888        {
    8989          $Subject = '? ('.$Value[5].')';
    9090        }
    91         if(!is_numeric($Subject))
     91        if (!is_numeric($Subject))
    9292        {
    9393          $Mode = 'Ručně';
     
    9999        }
    100100
    101         if($Money < 0) $Text = 'Platba převodem';
     101        if ($Money < 0) $Text = 'Platba převodem';
    102102          else $Text = 'Přijatá platba';
    103103        $Automatic .= '<tr>'.
     
    121121      $Output .= '<input type="submit" value="Zpracovat"/></form>';
    122122    }
    123     return($Output);
     123    return ($Output);
    124124  }
    125125
     
    142142    $Output = '';
    143143
    144     for($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
     144    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    145145    {
    146       if($_POST['Money'.$I] < 0) {
     146      if ($_POST['Money'.$I] < 0) {
    147147        $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    148148      } else {
     
    156156      $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
    157157    }
    158     return($Output);
     158    return ($Output);
    159159  }
    160160}
Note: See TracChangeset for help on using the changeset viewer.