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

Legend:

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

    r866 r873  
    4444  {
    4545    $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
    46     while($BillingPeriod = $DbResult->fetch_assoc())
     46    while ($BillingPeriod = $DbResult->fetch_assoc())
    4747      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    4848
     
    8080  function W2Kc($Spotreba)
    8181  {
    82     return(round($Spotreba * 0.72 * $this->kWh));
     82    return (round($Spotreba * 0.72 * $this->kWh));
    8383  }
    8484
     
    9393    // Create DocumentLineSequence from previous
    9494    $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1');
    95     while($DbRow = $DbResult->fetch_assoc())
     95    while ($DbRow = $DbResult->fetch_assoc())
    9696    {
    9797          $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,
     
    102102  function GetFinanceYear($Year)
    103103  {
    104     if($Year == 0)
     104    if ($Year == 0)
    105105    {
    106106      // Get latest year
    107107      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108108    } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    109     if($DbResult->num_rows == 0) {
    110           if($Year == date('Y'))
     109    if ($DbResult->num_rows == 0) {
     110          if ($Year == date('Y'))
    111111          {
    112112                $this->CreateFinanceYear($Year);
     
    115115        }
    116116    $FinanceYear = $DbResult->fetch_assoc();
    117     if($FinanceYear['Closed'] == 1)
     117    if ($FinanceYear['Closed'] == 1)
    118118      throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.');
    119119    return $FinanceYear;
     
    131131    $Sequence = $DbResult->fetch_assoc();
    132132
    133     if($Sequence['YearPrefix'] == 1)
     133    if ($Sequence['YearPrefix'] == 1)
    134134    {
    135135      $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year'];
     
    138138    $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '.
    139139      'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')');
    140     return($Result);
     140    return ($Result);
    141141  }
    142142
     
    151151  {
    152152    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
    153     if($DbResult->num_rows == 1) {
     153    if ($DbResult->num_rows == 1) {
    154154      $Group = $DbResult->fetch_assoc();
    155       return($Group);
     155      return ($Group);
    156156    } else die('Finance group id '.$Id.' not found in table '.$Table);
    157157  }
     
    162162    $this->Database->query('TRUNCATE TABLE `MemberPayment`');
    163163    $DbResult = $this->Database->query('SELECT * FROM `Member`');
    164     while($Member = $DbResult->fetch_assoc())
     164    while ($Member = $DbResult->fetch_assoc())
    165165    {
    166166      $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '.
     
    182182      $DbRow = $DbResult2->fetch_assoc();
    183183      $Monthly = 0;
    184       if($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
     184      if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];
    185185      else $MonthlyInet = 0;
    186186
     
    189189      $Monthly = round($Monthly);
    190190
    191       if($Member['BillingPeriod'] == 1)
     191      if ($Member['BillingPeriod'] == 1)
    192192      {
    193193        // Inactive payer
     
    204204    }
    205205    $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
    206     return($Output);
     206    return ($Output);
    207207  }
    208208
     
    214214      TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1');
    215215    $Row = $DbResult->fetch_array();
    216     return($Row[0]);
     216    return ($Row[0]);
    217217  }
    218218}
     
    665665  function BeforeInsertFinanceOperation($Form)
    666666  {
    667     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     667    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    668668      else $Year = date("Y", $Form->Values['ValidFrom']);
    669669    $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
    670670    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    671     return($Form->Values);
     671    return ($Form->Values);
    672672  }
    673673
     
    677677    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    678678      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    679     return($Form->Values);
     679    return ($Form->Values);
    680680  }
    681681
     
    685685    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    686686      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    687     return($Form->Values);
     687    return ($Form->Values);
    688688  }
    689689
     
    691691  {
    692692    // Get new DocumentLineCode by selected invoice Group
    693     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     693    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    694694      else $Year = date("Y", $Form->Values['ValidFrom']);
    695695    $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
    696696    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    697     return($Form->Values);
     697    return ($Form->Values);
    698698  }
    699699
     
    707707    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    708708      ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    709     return($Form->Values);
     709    return ($Form->Values);
    710710  }
    711711
     
    718718    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    719719      ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
    720     return($Form->Values);
     720    return ($Form->Values);
    721721  }
    722722
     
    727727    $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
    728728    $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
    729     return($Form->Values);
     729    return ($Form->Values);
    730730  }
    731731
     
    736736    $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']);
    737737    $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']);
    738     return($Form->Values);
     738    return ($Form->Values);
    739739  }
    740740
    741741  function BeforeInsertContract($Form)
    742742  {
    743     if(array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
     743    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    744744      else $Year = date("Y", $Form->Values['ValidFrom']);
    745745    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year);
    746     return($Form->Values);
     746    return ($Form->Values);
    747747  }
    748748}
Note: See TracChangeset for help on using the changeset viewer.