Changeset 627


Ignore:
Timestamp:
Jan 2, 2014, 12:42:49 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Přejmenováno v Invoice sloupec TimeCreation na Time.
  • Přidáno: Umožnění přidávat faktury a finanční operace i pro starší neuzavřené účetní období. Rok pro dokladovou řadu se určí podle data vytvoření.
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r620 r627  
    7676      'DateStart' => array('Type' => 'Date', 'Caption' => 'První den', 'Default' => ''),       
    7777      'DateEnd' => array('Type' => 'Date', 'Caption' => 'Poslední den', 'Default' => ''),       
     78      'Closed' => array('Type' => 'Boolean', 'Caption' => 'Uzavřen', 'Default' => 0),       
    7879      'Sequence' => array('Type' => 'TDocumentLineSequenceListYear', 'Caption' => 'Čísleníky', 'Default' => ''),       
    7980    ),
  • trunk/Application/Version.php

    r623 r627  
    11<?php
    22
    3 $Revision = 623; // Subversion revision
    4 $DatabaseRevision = 620; // SQL structure revision
    5 $ReleaseTime = '2013-12-29';
     3$Revision = 627; // Subversion revision
     4$DatabaseRevision = 627; // SQL structure revision
     5$ReleaseTime = mktime(0, 0, 0, 1, 2, 2014);
  • trunk/Common/Global.php

    r599 r627  
    5353function HumanDate($Time)
    5454{
    55   $Date = explode(' ', $Time);
    56   $Parts = explode('-', $Date[0]);
    57   if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
    58   else return('&nbsp;');
     55        if($Time != '') {               
     56    $Date = explode(' ', $Time);
     57    $Parts = explode('-', $Date[0]);
     58    if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
     59    else return('&nbsp;');
     60        } else return('&nbsp;'); 
    5961}
    6062
  • trunk/Common/Page.php

    r607 r627  
    112112      $Output .= '<div id="Footer">'.
    113113      '<i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | '.
    114       ' Verze: '.$Revision.' ('.HumanDate($ReleaseTime).') |';
     114      ' Verze: '.$Revision.' ('.$this->System->HumanDate($ReleaseTime).') |';
    115115      if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').
    116116        ' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
  • trunk/Common/Setup/Updates.php

    r623 r627  
    536536}
    537537
     538function UpdateTo627($Manager)
     539{
     540        $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `TimeCreation` `Time` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00";');
     541        $Manager->Execute('ALTER TABLE `FinanceYear` ADD `Closed` INT NOT NULL ;');
     542}
     543
    538544class Updates
    539545{
     
    569575      615 => array('Revision' => 619, 'Function' => 'UpdateTo619'),
    570576      619 => array('Revision' => 620, 'Function' => 'UpdateTo620'),
     577      620 => array('Revision' => 627, 'Function' => 'UpdateTo627'),
    571578    ));
    572579  }
  • trunk/Modules/Finance/Bill.php

    r565 r627  
    8686      '</td><td valign="top">'.
    8787      '<br>'.
    88       'Datum vystavení: '.HumanDate($Invoice['TimeCreation']).'<br>'.
    89       'Datum zdanitel. plnění: '.HumanDate($Invoice['TimeCreation']).'<br>'.
     88      'Datum vystavení: '.HumanDate($Invoice['Time']).'<br>'.
     89      'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'.
    9090      'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>';
    9191    if(($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))
  • trunk/Modules/Finance/Finance.php

    r605 r627  
    164164      // Get latest year
    165165      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    166     } else $DbResult = $this->Database->select('FinanceYear', '*', 'Id='.$FinanceYear);
     166    } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$FinanceYear);
     167        echo('rok:'.$FinanceYear.' '.$DbResult->num_rows);
     168    if($DbResult->num_rows == 0) throw new Exception('Rok '.$FinanceYear.' nenalezen');
    167169    $FinanceYear = $DbResult->fetch_assoc();
     170    if($FinanceYear['Closed'] == 1) throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.');
    168171
    169172    $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);
     
    349352      'Title' => 'Faktury',
    350353      'Table' => 'FinanceInvoice',
    351       'DefaultSortColumn' => 'TimeCreation',
     354      'DefaultSortColumn' => 'Time',
    352355      'Items' => array(
    353356        'DocumentLine' => array('Type' => 'TDocumentLine', 'Caption' => 'Dokladová řada', 'Default' => ''),
    354357        'BillCode' => array('Type' => 'String', 'Caption' => 'Označení', 'Default' => ''),
    355358        'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subjekt', 'Default' => ''),
    356         'TimeCreation' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
     359        'Time' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
    357360        'TimeDue' => array('Type' => 'Date', 'Caption' => 'Čas splatnosti', 'Default' => ''),
    358361        'TimePayment' => array('Type' => 'Date', 'Caption' => 'Čas zaplacení', 'Default' => '', 'Null' => true),
     
    462465  function BeforeInsertFinanceOperation($Form)
    463466  {
     467        $Year = date("Y", $Form->Values['Time']);
    464468    $DocumentLine = $Form->Values['DocumentLine'];
    465     $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine);
     469    $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumber($DocumentLine, $Year);
    466470    return($Form->Values);
    467471  } 
  • trunk/Modules/Finance/Manage.php

    r609 r627  
    111111        $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    112112    $this->Database->insert('FinanceInvoice', array(
    113           'Subject' => $Subject, 'TimeCreation' => TimeToMysqlDateTime($TimeCreation),
     113          'Subject' => $Subject, 'Time' => TimeToMysqlDateTime($TimeCreation),
    114114          'TimeDue' => TimeToMysqlDateTime($TimeDue), 'Value' => $SumValue, 'BillCode' => $BillCode,
    115115          'PeriodFrom' => TimeToMysqlDate($PeriodFrom), 'PeriodTo' => TimeToMysqlDate($PeriodTo),
     
    352352        '<th style="border-style: solid; border-width: 1px; padding: 1px 5px 1px 5px; text-align: center; font-weight: bold;">Částka [Kč]</th></tr>'."\n";
    353353      $DbResult = $this->Database->query('SELECT T1.* FROM ((SELECT Text, Time, Value AS Value, File FROM FinanceOperation WHERE (Subject='.$Member['Subject'].')) UNION ALL '.
    354         '(SELECT CONCAT(`Text`, (SELECT GROUP_CONCAT(`Description` SEPARATOR "<br/>") FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`)) AS `Text`, TimeCreation as Time, -Value as Value, File FROM FinanceInvoice WHERE (Subject='.
     354        '(SELECT CONCAT(`Text`, (SELECT GROUP_CONCAT(`Description` SEPARATOR "<br/>") FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice` = `FinanceInvoice`.`Id`)) AS `Text`, Time, -Value as Value, File FROM FinanceInvoice WHERE (Subject='.
    355355        $Member['Subject'].')) ORDER BY Time DESC) AS T1 WHERE (T1.Time > "'.$Member['BillingPeriodLastDate'].'")');
    356356      while($DbRow = $DbResult->fetch_assoc())
  • trunk/Modules/Finance/UserState.php

    r554 r627  
    6969      'FROM FinanceOperation WHERE (Subject='.$Subject['Id'].')) UNION ALL '.
    7070      '(SELECT (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoice=FinanceInvoice.Id) AS Text, '.
    71       'TimeCreation as Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
     71      'Time, -Value as Value, File, BillCode, PeriodFrom, PeriodTo FROM FinanceInvoice WHERE (Subject='.$Subject['Id'].')) ORDER BY Time DESC) AS T1';
    7272    $DbResult = $this->Database->query('SELECT SUM(T1.Value) AS Total FROM '.$UserOperationTableQuery);
    7373    $DbRow = $DbResult->fetch_array();
  • trunk/Modules/Finance/Zivnost.php

    r548 r627  
    2828    $Balance['Spend']['End'] = $Row[0] + 0;
    2929
    30     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
     30    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
    3131    $Row = $DbResult->fetch_array();
    3232    $Balance['Claims']['Start'] = $Row[0] + 0;
    33     $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
     33    $DbResult = $this->Database->query('SELECT SUM(Value) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value > 0)');
    3434    $Row = $DbResult->fetch_array();
    3535    $Balance['Claims']['End'] = $Row[0] + 0;
    3636
    37     $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation < "'.TimeToMysqlDateTime($StartTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
     37    $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (Time < "'.TimeToMysqlDateTime($StartTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
    3838    $Row = $DbResult->fetch_array();
    3939    $Balance['Liabilities']['Start'] = $Row[0] + 0;
    40     $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (TimeCreation <= "'.TimeToMysqlDateTime($EndTime).'") AND (TimeCreation >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
     40    $DbResult = $this->Database->query('SELECT SUM(-Value) FROM FinanceInvoice WHERE (Time <= "'.TimeToMysqlDateTime($EndTime).'") AND (Time >= "'.TimeToMysqlDateTime($this->StartEvidence).'") AND (Value < 0)');
    4141    $Row = $DbResult->fetch_array();
    4242    $Balance['Liabilities']['End'] = $Row[0] + 0;
     
    207207        $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '.
    208208          'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '.
    209           'WHERE (Value > 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart'].
    210           '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation');
     209          'WHERE (Value > 0) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].
     210          '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    211211        while($Row = $DbResult->fetch_array())
    212212        {
    213213          if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    214           $Output .= '<tr><td>'.HumanDate($Row['TimeCreation']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';
     214          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';
    215215          $Total += $Row['Value'];
    216216        }
     
    229229        $DbResult = $this->Database->query('SELECT *, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text '.
    230230          'FROM FinanceInvoice JOIN Subject ON Subject.Id = FinanceInvoice.Subject '.
    231           'WHERE (Value < 0) AND (FinanceInvoice.TimeCreation >= "'.$Year['DateStart'].
    232           '") AND (FinanceInvoice.TimeCreation <= "'.$Year['DateEnd'].'") ORDER BY TimeCreation');
     231          'WHERE (Value < 0) AND (FinanceInvoice.Time >= "'.$Year['DateStart'].
     232          '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time');
    233233        while($Row = $DbResult->fetch_array())
    234234        {
    235235          if($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = '&nbsp;';
    236236          $Row['Value'] = $Row['Value'] * -1;
    237           $Output .= '<tr><td>'.HumanDate($Row['TimeCreation']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';         
     237          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillCode'].'</td><td>'.$Row['Name'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>';         
    238238          $Total += $Row['Value'];
    239239        }
     
    288288        $Output .= '<table style="font-size: smaller;" border="1" cellspacing="0" cellpadding="3">';
    289289        $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th><th>Doklad</th></tr>';
    290         $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 'Subject='.$_GET['Id'].' ORDER BY TimeCreation');
    291         while($Row = $DbResult->fetch_array())
    292         {
    293           $Output .= '<tr><td>'.HumanDate($Row['TimeCreation']).'</td><td>'.HumanDate($Row['TimePayment']).
     290        $DbResult = $this->Database->select('FinanceInvoice', '*, (SELECT GROUP_CONCAT(Description SEPARATOR ",") FROM FinanceInvoiceItem WHERE FinanceInvoiceItem.FinanceInvoice = FinanceInvoice.Id) AS Text', 'Subject='.$_GET['Id'].' ORDER BY Time');
     291        while($Row = $DbResult->fetch_array())
     292        {
     293          $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']).
    294294            '</td><td>'.$Row['Text'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['BillCode'].'</td></tr>';
    295295        }
     
    302302        while($Row = $DbResult->fetch_array())
    303303        {
    304           $Output .= '<tr><td>'.$Row['TimeCreation'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';
     304          $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['Direction'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>';
    305305        }
    306306        $Output .= '</table>';*/
  • trunk/Modules/IS/IS.php

    r608 r627  
    9292        } catch (Exception $E)
    9393        {
    94                 $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.');
     94                $Output .= $this->SystemMessage('Úprava položky', 'Položku se nepodařilo uložit. Opravte problém a opakujte akci.<br/>'.$E->getMessage());
    9595          $Form->OnSubmit = '?a=edit&amp;t='.$Table.'&amp;i='.$_GET['i'].'&amp;o=save';
    9696          $Output .= $Form->ShowEditForm();
     
    178178        } catch (Exception $E)
    179179        {
    180                 $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.');
     180                $Output .= $this->SystemMessage('Přidání položky', 'Položku se nepodařilo přidat. Opravte problém a opakujte akci.<br/>'.$E->getMessage());
    181181                $Form->OnSubmit = '?a=add&amp;t='.$Table.'&amp;o=save';
    182182          $Output .= $Form->ShowEditForm();
  • trunk/temp/Bills.php

    r548 r627  
    1515  if(strpos($Invoice['Text'], 'Poplatek za měsíc') !== false)
    1616  {
    17         $Time = MysqlDateTimeToTime($Invoice['TimeCreation']);
     17        $Time = MysqlDateTimeToTime($Invoice['Time']);
    1818        $TimeParts = ExtractTime($Time);
    1919        $PeriodFrom = mktime($TimeParts['Hour'], $TimeParts['Minute'], $TimeParts['Second'],
Note: See TracChangeset for help on using the changeset viewer.