Ignore:
Timestamp:
Feb 17, 2021, 9:27:32 PM (4 years ago)
Author:
chronos
Message:
  • Added: Documents section accessible from users panel.
  • Added: Contract model moved to separate module Contract.
  • Added: New action to generate PDF from Contract.
  • Fixed: Allow users to download files only by hash instead of direct id.
  • Added: Support for SHA1 as allowed mysql function.
File:
1 edited

Legend:

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

    r888 r901  
    1111  }
    1212
    13   function ShowFinanceOperation(int $Subject): string
     13  function ShowFinanceOperation(int $SubjectId): string
    1414  {
    15     $UserOperationTableQuery = '((SELECT `Text`, `Time`, `Value`, `File`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '.
     15    $UserOperationTableQuery = '((SELECT `Text`, `FinanceOperation`.`Time`, `Value`, `File`.`Hash` AS `FileHash`, `BillCode`, NULL AS `PeriodFrom`, NULL AS `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '.
    1616      'FROM `FinanceOperation` '.
    1717      'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceOperation`.`BillCode` '.
    18       'WHERE (`Subject`='.$Subject['Id'].') '.
     18      'LEFT JOIN `File` ON `File`.`Id`=`FinanceOperation`.`File` '.
     19      'WHERE (`Subject`='.$SubjectId.') '.
    1920      ') UNION ALL '.
    2021      '(SELECT (SELECT GROUP_CONCAT(`Description` SEPARATOR ",") FROM `FinanceInvoiceItem` WHERE `FinanceInvoice`=`FinanceInvoice`.`Id`) AS `Text`, '.
    21       '`Time`, -`Value`, `File`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceInvoice` '.
     22      '`FinanceInvoice`.`Time`, -`Value`, `File`.`Hash` AS `FileHash`, `BillCode`, `PeriodFrom`, `PeriodTo`, `DocumentLineCode`.`Name` AS `BillName` '.
     23      'FROM `FinanceInvoice` '.
    2224      'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id`=`FinanceInvoice`.`BillCode` '.
    23       'WHERE (`Subject`='.$Subject['Id'].') AND (`VisibleToUser` = 1)))';
     25      'LEFT JOIN `File` ON `File`.`Id`=`FinanceInvoice`.`File` '.
     26      'WHERE (`Subject`='.$SubjectId.') AND (`VisibleToUser` = 1)))';
    2427
    2528    $Output = '<div style="text-align:center">Výpis finančních operací</div>';
     
    5659      if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];
    5760      if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';
    58       if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';
     61      if ($Row['FileHash'] != '') $Invoice = '<a href="'.$this->System->Link('/file?h='.$Row['FileHash']).'">'.$Row['BillName'].'</a>';
    5962        else $Invoice = NotBlank($Row['BillName']);
    6063      if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);
     
    102105    } else return $this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen');
    103106
    104 
    105107    // Load subject info
    106108    $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']);
     
    109111      $Subject = $DbResult->fetch_assoc();
    110112    } else return $this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen');
    111 
    112113
    113114    $Output = '<table width="100%" border="0" cellspacing="0" cellpadding="3"><tr><td valign="top">';
     
    124125
    125126    // Tabulka operaci
    126     $Output .= $this->ShowFinanceOperation($Subject);
     127    $Output .= $this->ShowFinanceOperation($Subject['Id']);
    127128
    128129    $Output .= '</td><td valign="top">';
Note: See TracChangeset for help on using the changeset viewer.