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/Manage.php

    r866 r873  
    1010  {
    1111    $Output = '';
    12     if(!$this->System->User->CheckPermission('Finance', 'Manage'))
    13       return('Nemáte oprávnění');
    14 
    15     if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];
     12    if (!$this->System->User->CheckPermission('Finance', 'Manage'))
     13      return ('Nemáte oprávnění');
     14
     15    if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];
    1616      else $Operation = '';
    17     switch($Operation)
     17    switch ($Operation)
    1818    {
    1919      case 'Recalculate':
     
    4242        $Output .= '<a href="'.$this->System->Link('/finance/import/').'">Import plateb</a><br />';
    4343    }
    44     return($Output);
     44    return ($Output);
    4545  }
    4646
     
    5252
    5353    $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
    54     if($MonthCount <= 0) return(array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));
     54    if ($MonthCount <= 0) return (array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));
    5555    $MonthCurrent = date('n', $Time);
    5656
     
    6767    $PeriodTo = mktime(0, 0, 0, $MonthTo, date('t', mktime(0, 0, 0, $MonthTo, 1, $Year)), $Year);
    6868
    69     return(array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
     69    return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));
    7070  }
    7171
    7272  function ShowMonthlyPayment()
    7373  {
    74     if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     74    if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    7575    $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '.
    7676      '`MemberPayment`.`Cash` AS `Cash`, '.
     
    106106
    107107    $DbResult = $this->Database->query($Query);
    108     while($Row = $DbResult->fetch_assoc())
     108    while ($Row = $DbResult->fetch_assoc())
    109109    {
    110110      $Output .= '<tr>'.
     
    120120    $Output .= $PageList['Output'];
    121121    $Output .= '<a href="?Operation=ProcessMonthlyPayment">Generovat faktury</a>';
    122     return($Output);
     122    return ($Output);
    123123  }
    124124
     
    131131    $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    132132    $SumValue = 0;
    133     foreach($Items as $Item) {
     133    foreach ($Items as $Item) {
    134134      $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    135135    }
     
    143143      'Generate' => 1, 'Group' => $Group['Id']));
    144144    $InvoiceId = $this->Database->insert_id;
    145     foreach($Items as $Item)
     145    foreach ($Items as $Item)
    146146      $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId,
    147147        'Description' => $Item['Description'], 'Price' => $Item['Price'],
     
    149149    //$LastInsertTime = $Time;
    150150    //$this->CheckAdvancesAndLiabilities($Subject);
    151     return($InvoiceId);
     151    return ($InvoiceId);
    152152  }
    153153
     
    162162      'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` '.
    163163      'JOIN `Subject` ON `Subject`.`Id`=`Member`.`Subject`');
    164     while($Member = $DbResult->fetch_assoc())
     164    while ($Member = $DbResult->fetch_assoc())
    165165    {
    166166      $Output .= $Member['SubjectName'].': ';
     
    168168
    169169      /* Check if need to produce new invoice for customer */
    170       if(($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and
     170      if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and
    171171        ($Period['From'] > $Member['BillingPeriodLastUnixTime']))
    172172      {
     
    178178          'WHERE (`ServiceCustomerRel`.`Customer`='.
    179179          $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) ');
    180         while($Service = $DbResult2->fetch_assoc())
     180        while ($Service = $DbResult2->fetch_assoc())
    181181        {
    182182          $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'],
     
    188188        // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction
    189189        // Other subject should invoice only positive items. Negative items should be somehow removed.
    190         if($MonthlyTotal >= 0)
     190        if ($MonthlyTotal >= 0)
    191191        {
    192192          $InvoiceGroupId = INVOICE_GROUP_OUT;
     
    197197        // Load invoice group
    198198        $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
    199         foreach($InvoiceItems as $Index => $Item)
     199        foreach ($InvoiceItems as $Index => $Item)
    200200        {
    201201          $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign'];
    202202        }
    203203
    204         if($PayPerPeriod != 0)
     204        if ($PayPerPeriod != 0)
    205205        {
    206206          $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']);
     
    217217      $Output .= "\n";
    218218    }
    219     return($Output);
     219    return ($Output);
    220220  }
    221221
     
    225225    $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '.
    226226      '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC');
    227     while($Service = $DbResult->fetch_assoc())
    228     {
    229       if($Service['ChangeAction'] == 'add')
     227    while ($Service = $DbResult->fetch_assoc())
     228    {
     229      if ($Service['ChangeAction'] == 'add')
    230230      {
    231231        unset($Service['Id']);
     
    235235        $this->Database->insert($Table, $Service);
    236236      } else
    237       if($Service['ChangeAction'] == 'modify')
     237      if ($Service['ChangeAction'] == 'modify')
    238238      {
    239239        unset($Service['Id']);
     
    244244        $this->Database->update($Table, '`Id`='.$ReplaceId, $Service);
    245245      } else
    246       if($Service['ChangeAction'] == 'delete')
     246      if ($Service['ChangeAction'] == 'delete')
    247247      {
    248248        $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']);
     
    270270    $this->TableUpdateChanges('ServiceCustomerRel');
    271271
    272     return($Output);
     272    return ($Output);
    273273  }
    274274
    275275  function ProcessMonthlyPayment()
    276276  {
    277     if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     277    if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    278278    $Output = '';
    279279
     
    311311    // Zkontrolovat odečtení měsíčního poplatku
    312312    $Output .= 'Kontrola odečtení poplatků: Poslední měsíc-'.$MonthLast.' Aktuální měsíc-'.$MonthCurrent."\n";
    313     if($MonthCurrent != $MonthLast)
     313    if ($MonthCurrent != $MonthLast)
    314314    {
    315315      $Output .= 'Odečítám pravidelný poplatek...'."\n";
     
    335335    }
    336336    $Output = str_replace("\n", '<br/>', $Output);
    337     return($Output);
     337    return ($Output);
    338338  }
    339339
     
    366366    $MainSubjectAccount = $DbResult->fetch_assoc();
    367367
    368     if($User['Email'] != '')
     368    if ($User['Email'] != '')
    369369    {
    370370      $Title = 'Pravidelné vyúčtování služeb';
     
    392392        '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='.
    393393        $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")');
    394       while($DbRow = $DbResult->fetch_assoc())
     394      while ($DbRow = $DbResult->fetch_assoc())
    395395      {
    396396        $Text = $DbRow['Text'];
     
    417417    $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '.
    418418      'AND (`Value` != 0) AND (`Generate` = 1)'.$Where);
    419     while($Row = $DbResult->fetch_assoc())
     419    while ($Row = $DbResult->fetch_assoc())
    420420    {
    421421      if ($Row['File'] == null)
     
    447447    $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '.
    448448        'AND (`Value` != 0) AND (`Generate` = 1)'.$Where);
    449     while($Row = $DbResult->fetch_assoc())
     449    while ($Row = $DbResult->fetch_assoc())
    450450    {
    451451      if ($Row['File'] == null)
     
    462462      $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;
    463463      $Bill->SaveToFile($FullFileName);
    464       if(file_exists($FullFileName))
     464      if (file_exists($FullFileName))
    465465      {
    466466        $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName)));
     
    478478    $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)');
    479479    $Output .= $this->GenerateOperation(' AND (`File` IS NULL)');
    480     return($Output);
     480    return ($Output);
    481481  }
    482482}
Note: See TracChangeset for help on using the changeset viewer.