Changeset 873 for trunk/Modules/Finance


Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
Location:
trunk/Modules/Finance
Files:
6 edited

Legend:

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

    r748 r873  
    88  function GenerateHTML()
    99  {
    10     return('');
     10    return ('');
    1111  }
    1212
     
    2222  {
    2323    $Encoding = new Encoding();
    24     if($this->Checked == false) {
    25       if(CommandExist('htmldoc')) {
     24    if ($this->Checked == false) {
     25      if (CommandExist('htmldoc')) {
    2626        $this->Checked = true;
    2727      } else throw new Exception('htmldoc is not installed.');
     
    2929    $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)).
    3030      '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -');
    31     return($Output);
     31    return ($Output);
    3232  }
    3333}
     
    4343      $Subject['AddressStreet'].'<br>'.
    4444      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    45     if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    46     if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    47     if($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
    48     if($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';
    49     return($Output);
     45    if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     46    if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     47    if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';
     48    if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';
     49    return ($Output);
    5050  }
    5151
     
    7878    $InvoiceItems = array();
    7979    $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId);
    80     while($Item = $DbResult->fetch_assoc())
     80    while ($Item = $DbResult->fetch_assoc())
    8181    {
    8282      $InvoiceItems[$Item['Id']] = $Item;
     
    8484
    8585    // If direction is in => switch sides
    86     if($Invoice['Direction'] == FINANCE_DIRECTION_OUT)
    87     {
    88     }
    89     else if($Invoice['Direction'] == FINANCE_DIRECTION_IN)
     86    if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT)
     87    {
     88    }
     89    else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN)
    9090    {
    9191      $Subject = $SubjectTo;
     
    121121      'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'.
    122122      'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>';
    123     if(($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))
     123    if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))
    124124      $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '.
    125125        HumanDate($Invoice['PeriodTo']).'<br>';
     
    133133
    134134    $Total = 0;
    135     foreach($InvoiceItems as $Item)
     135    foreach ($InvoiceItems as $Item)
    136136    {
    137137      $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'.
     
    146146      '</table>';
    147147
    148     return($Output);
     148    return ($Output);
    149149  }
    150150}
     
    174174
    175175    $BooleanText = array('Ne', 'Ano');
    176     if($Operation['Direction'] == FINANCE_DIRECTION_OUT)
     176    if ($Operation['Direction'] == FINANCE_DIRECTION_OUT)
    177177    $Desc = array(
    178178      'Type' => 'VÝDAJOVÝ',
     
    180180      'Target' => 'Vydáno komu',
    181181    );
    182     else if($Operation['Direction'] == FINANCE_DIRECTION_IN)
     182    else if ($Operation['Direction'] == FINANCE_DIRECTION_IN)
    183183    $Desc = array(
    184184      'Type' => 'PŘÍJMOVÝ',
     
    206206      $Subject['AddressStreet'].'<br>'.
    207207      $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>';
    208     if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
    209     if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
     208    if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';
     209    if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';
    210210    $Description = $Operation['Text'];
    211211    $Output .= '</td></tr>'.
     
    215215      '<tr><td>&nbsp;</td><td><br><br>'.$Desc['Signature'].':</td></tr>';
    216216    $Output .= '</table>';
    217     return($Output);
     217    return ($Output);
    218218  }
    219219}
  • 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}
  • 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}
  • 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}
  • trunk/Modules/Finance/Trade.php

    r847 r873  
    6565    $Row = $DbResult->fetch_array();
    6666    $Balance['SmallAssets']['End'] = $Row[0] + 0;
    67     return($Balance);
     67    return ($Balance);
    6868  }
    6969
     
    7777    $StartYear = date('Y', $this->StartEvidence);
    7878    $EndYear = date('Y', time());
    79     for($Year = $StartYear; $Year <= $EndYear; $Year++)
     79    for ($Year = $StartYear; $Year <= $EndYear; $Year++)
    8080    {
    8181      $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    8282      //$Year = date('Y', $EndTime);
    8383      $StartTime = mktime(0, 0, 0, 1, 1, $Year);
    84       if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     84      if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
    8585
    8686      $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
     
    113113    $StartYear = date('Y', $this->StartEvidence);
    114114    $EndYear = date('Y', time());
    115     for($Year = $StartYear; $Year <= $EndYear; $Year++)
    116     {
    117       for($Month = 1; $Month <= 12; $Month++)
     115    for ($Year = $StartYear; $Year <= $EndYear; $Year++)
     116    {
     117      for ($Month = 1; $Month <= 12; $Month++)
    118118      {
    119119        $EndTime = mktime(0, 0, 0, $Month, 31, $Year);
    120120        //$Year = date('Y', $EndTime);
    121121        $StartTime = mktime(0, 0, 0, $Month, 1, $Year);
    122         if(($StartTime < time()) and ($EndTime > $this->StartEvidence))
     122        if (($StartTime < time()) and ($EndTime > $this->StartEvidence))
    123123        {
    124           if($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
     124          if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;
    125125
    126126          $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime);
     
    164164      'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
    165165      'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    166     while($Row = $DbResult->fetch_array())
     166    while ($Row = $DbResult->fetch_array())
    167167    {
    168168      $Row['Time'] = explode(' ', $Row['Time']);
     
    204204      'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '.
    205205      'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    206     while($Row = $DbResult->fetch_array())
     206    while ($Row = $DbResult->fetch_array())
    207207    {
    208208      $Row['Time'] = explode(' ', $Row['Time']);
     
    245245      'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart'].
    246246      '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`');
    247     while($Row = $DbResult->fetch_array())
    248     {
    249       if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
     247    while ($Row = $DbResult->fetch_array())
     248    {
     249      if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    250250      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
    251251      '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';
     
    276276      'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart'].
    277277      '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    278     while($Row = $DbResult->fetch_array())
    279     {
    280       if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
     278    while ($Row = $DbResult->fetch_array())
     279    {
     280      if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    281281      $Row['Value'] = $Row['Value'] * $Row['ValueSign'];
    282282      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName'].
     
    314314      'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '.
    315315      'FROM Subject ORDER BY Name');
    316     while($Row = $DbResult->fetch_assoc())
     316    while ($Row = $DbResult->fetch_assoc())
    317317    {
    318318      $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>';
     
    330330      'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '.
    331331      'WHERE (TimeElimination IS NOT NULL)');
    332     while($Row = $DbResult->fetch_array())
     332    while ($Row = $DbResult->fetch_array())
    333333    {
    334334      $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>';
     
    349349      'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '.
    350350      'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`');
    351     while($Row = $DbResult->fetch_array())
     351    while ($Row = $DbResult->fetch_array())
    352352    {
    353353      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text'].
     
    364364      'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '.
    365365      'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`');
    366     while($Row = $DbResult->fetch_array())
     366    while ($Row = $DbResult->fetch_array())
    367367    {
    368368      $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']).
     
    375375     $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>';
    376376     $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']);
    377      while($Row = $DbResult->fetch_array())
     377     while ($Row = $DbResult->fetch_array())
    378378     {
    379379     $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';
     
    411411    $Output .= '<strong>Roční přehledy</strong><br/>';
    412412    $Output .= $this->ShowFinanceYears();
    413     if(array_key_exists('year', $_GET))
     413    if (array_key_exists('year', $_GET))
    414414    {
    415415      $Year = $_GET['year'] * 1;
     
    426426  function Show()
    427427  {
    428     if(!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
    429       return('Nemáte oprávnění');
     428    if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
     429      return ('Nemáte oprávnění');
    430430
    431431    $Finance = &$this->System->Modules['Finance'];
    432432
    433433    $Output = '';
    434     if(!array_key_exists('table', $_GET)) $_GET['table'] = '';
    435     switch($_GET['table'])
     434    if (!array_key_exists('table', $_GET)) $_GET['table'] = '';
     435    switch ($_GET['table'])
    436436    {
    437437      case 'AnnualBalance':
     
    478478        $Output = $this->ShowDefault();
    479479    }
    480     return($Output);
     480    return ($Output);
    481481  }
    482482
     
    485485    $Output = 'Roky: ';
    486486    $DbRows = $this->Database->select('FinanceYear', '*');
    487     while($DbRow = $DbRows->fetch_assoc())
     487    while ($DbRow = $DbRows->fetch_assoc())
    488488      $Output .= '<a href="?year='.$DbRow['Id'].'">'.$DbRow['Year'].'</a> ';
    489489    $Output .= '<br/>';
    490     return($Output);
     490    return ($Output);
    491491  }
    492492
  • trunk/Modules/Finance/UserState.php

    r825 r873  
    4444    $DbResult = $this->Database->query($Query);
    4545    $SumValue = 0;
    46     while($Row = $DbResult->fetch_assoc())
     46    while ($Row = $DbResult->fetch_assoc())
    4747    {
    4848      $Row['State'] = round($Row['State'], 2);
    49       if($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';
    50       if($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';
    51       if($Row['Value'] == -0) $Row['Value'] = 0;
    52       if($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    53       if($Row['BillName'] == '') $Row['BillName'] = 'PDF';
    54       if($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';
     49      if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';
     50      if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';
     51      if ($Row['Value'] == -0) $Row['Value'] = 0;
     52      if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
     53      if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';
     54      if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';
    5555        else $Invoice = NotBlank($Row['BillName']);
    56       if($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
     56      if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
    5757        else $Period = '&nbsp;';
    5858      $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'.
     
    6666    $Output .= '</table>';
    6767    $Output .= $PageList['Output'];
    68     return($Output);
     68    return ($Output);
    6969  }
    7070
     
    7575
    7676    // Determine which customer should be displayed
    77     if(array_key_exists('i', $_GET))
     77    if (array_key_exists('i', $_GET))
    7878    {
    79       if(!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');
     79      if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění');
    8080      $CustomerId = $_GET['i'];
    8181    } else
    8282    {
    83       if(!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');
     83      if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return ('Nemáte oprávnění');
    8484      $UserId = $this->System->User->User['Id'];
    8585      $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
    86       if($DbResult->num_rows > 0)
     86      if ($DbResult->num_rows > 0)
    8787      {
    8888        $CustomerUserRel = $DbResult->fetch_assoc();
    8989        $CustomerId = $CustomerUserRel['Customer'];
    90       } else return($this->SystemMessage('Chyba', 'Nejste zákazníkem'));
     90      } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem'));
    9191    }
    9292
    9393    // Load customer info
    9494    $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId);
    95     if($DbResult->num_rows == 1)
     95    if ($DbResult->num_rows == 1)
    9696    {
    9797      $Customer = $DbResult->fetch_assoc();
    98     } else return($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));
     98    } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));
    9999
    100100
    101101    // Load subject info
    102102    $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']);
    103     if($DbResult->num_rows == 1)
     103    if ($DbResult->num_rows == 1)
    104104    {
    105105      $Subject = $DbResult->fetch_assoc();
    106     } else return($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));
     106    } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));
    107107
    108108
     
    141141      'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '.
    142142      'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)');
    143     while($DbRow = $DbResult->fetch_assoc())
     143    while ($DbRow = $DbResult->fetch_assoc())
    144144    {
    145145      $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>';
     
    152152
    153153    $Output .= '</td></tr></table>';
    154     return($Output);
     154    return ($Output);
    155155  }
    156156}
Note: See TracChangeset for help on using the changeset viewer.