Changeset 500


Ignore:
Timestamp:
Mar 10, 2013, 10:08:23 AM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Bankovní účty se nyní odkazují do seznamu existujících bank. Z nich se pak přiřazuje kód banky.
  • Upraveno: Pro import plateb z banky bude nově použit samostatný modul FinanceBankAPI.
  • Upraveno: Zkušební podpora formulářového typu soubor (File).
  • Upraveno: Kód PrefixMultiplier přesunut do samostatného souboru.
Location:
trunk
Files:
4 added
11 edited
5 moved

Legend:

Unmodified
Added
Removed
  • trunk/Common/Forms.php

    r485 r500  
    5454  {
    5555    if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
    56     $Output = '<form class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().
     56    $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock().
    5757      '<div><input type="submit" value="'.$this->Definition['SubmitText'].'" /> '.
    5858      '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>';
  • trunk/Common/Global.php

    r498 r500  
    3939include_once(dirname(__FILE__).'/../Modules/WebCam/WebCam.php');
    4040include_once(dirname(__FILE__).'/../Modules/User/User.php');
    41 
    42 $PrefixMultipliers = array
    43 (
    44   'Binary' => array
    45   (
    46     'BaseIndex' => 0,
    47     'Definition' => array
    48     (
    49       array('', '', pow(2, 0)),
    50       array('Ki', 'kibi', pow(2, 10)),
    51       array('Mi', 'mebi', pow(2, 20)),
    52       array('Gi', 'gibi', pow(2, 30)),
    53       array('Ti', 'tebi', pow(2, 40)),
    54       array('Pi', 'pebi', pow(2, 50)),
    55       array('Ei', 'exbi', pow(2, 60)),
    56       array('Zi', 'zebi', pow(2, 70)),
    57       array('Yi', 'yobi', pow(2, 80)),
    58     ),
    59   ),
    60   'Decimal' => array
    61   (
    62     'BaseIndex' => 8,
    63     'Definition' => array
    64     (
    65       array('y', 'yocto', pow(10, -24)),
    66       array('z', 'zepto', pow(10, -21)),
    67       array('a', 'atto', pow(10, -18)),
    68       array('f', 'femto', pow(10, -15)),
    69       array('p', 'piko', pow(10, -12)),
    70       array('n', 'nano', pow(10, -9)),
    71       array('u', 'mikro', pow(10, -6)),
    72       array('m', 'mili', pow(10, -3)),
    73       array('', '', pow(10, 0)),
    74       array('k', 'kilo', pow(10, 3)),
    75       array('M', 'mega', pow(10, 6)),
    76       array('G', 'giga', pow(10, 9)),
    77       array('T', 'tera', pow(10, 12)),
    78       array('P', 'peta', pow(10, 15)),
    79       array('E', 'exa', pow(10, 18)),
    80       array('Z', 'zetta', pow(10, 21)),
    81       array('Y', 'yotta', pow(10, 24)),
    82     ),
    83   ),
    84   'Time' => array
    85   (
    86     'BaseIndex' => 8,
    87     'Definition' => array
    88     (
    89       array('ys', 'yoctosekunda', pow(10, -24)),
    90       array('zs', 'zeptosekunda', pow(10, -21)),
    91       array('as', 'attosekunda', pow(10, -18)),
    92       array('fs', 'femtosekunda', pow(10, -15)),
    93       array('ps', 'pikosekunda', pow(10, -12)),
    94       array('ns', 'nanosekunda', pow(10, -9)),
    95       array('us', 'mikrosekunda', pow(10, -6)),
    96       array('ms', 'milisekunda', pow(10, -3)),
    97       array('s', 'sekunda', 1),
    98       array('minut', 'minuta', 60),
    99       array('hodin', 'hodina', 60 * 60) ,
    100       array('dnů', 'den', 24 * 60 * 60),
    101       array('týdnů', 'týden', 7 * 24 * 60 * 60),
    102       array('měsíců', 'měsíc', 30 * 24 * 60 * 60),
    103       array('roků', 'rok', 364 * 24 * 60 * 60),
    104       array('desetiletí', 'desetiletí', 10 * 364 * 24 * 60 * 60),
    105       array('stalatí', 'staletí', 100 * 364 * 24 * 60 * 60),
    106       array('tisíciletí', 'tisiciletí', 10000 * 364 * 24 * 60 * 60),
    107     ),
    108   ),
    109 );
     41include_once(dirname(__FILE__).'/../Modules/Finance/Finance.php');
     42include_once(dirname(__FILE__).'/../Modules/FinanceBankAPI/FinanceBankAPI.php');
    11043
    11144class System extends Module
     
    14376      {
    14477        array_shift($PathItems);
    145         return(SearchPage($PathItems, $Path[$PathItem]));
    146       } else return($this->Pages[$PathItem]);
     78        return($this->SearchPage($PathItems, $Pages[$PathItem]));
     79      } else return($Pages[$PathItem]);
    14780    } else return('');
    14881  }
     
    215148    return(date('j.n.Y', $Time));
    216149  }
    217 
    218   function TruncateDigits($Value, $Digits = 4)
    219   {
    220     for($II = 2; $II > -6; $II--)
    221     {
    222       if($Value >= pow(10, $II))
    223       {
    224         if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits;
    225         $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
    226         break;
    227       }
    228     }
    229     return($Value);
    230   }
    231 
    232   function AddPrefixMultipliers($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal')
    233   {
    234     global $PrefixMultipliers;
    235 
    236     $Negative = ($Value < 0);
    237     $Value = abs($Value);
    238     if(($Unit == '') and ($PrefixType != 'Time'))
    239       return($this->TruncateDigits($Value, $Digits));
    240 
    241     $I = $PrefixMultipliers[$PrefixType]['BaseIndex'];
    242     if($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
    243      
    244     if($Value > 1)
    245     {
    246       while((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))
    247         $I = $I + 1;
    248     } else
    249     if($Value < 1)
    250     {
    251       while((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))
    252         $I = $I - 1;
    253     }
    254     $Value = $Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2];
    255    
    256     // Truncate digits count
    257     $Value = $this->TruncateDigits($Value, $Digits);
    258     if($Negative) $Value = -$Value;
    259     return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);
    260   }
    261150 
    262151  function Link($Target)
     
    323212  $System->ModuleManager->RegisterModule(new ModuleWebCam($System));
    324213  $System->ModuleManager->RegisterModule(new ModuleUser($System));
     214  $System->ModuleManager->RegisterModule(new ModuleFinance($System));
     215  $System->ModuleManager->RegisterModule(new ModuleFinanceBankAPI($System));
    325216  $System->ModuleManager->StartAll();
    326217}
     
    633524    else $PathString = '';
    634525  if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    635   //echo('"'.$QueryString.'"');
    636526  $PathItems = explode('/', $PathString);
    637527  if(strpos($_SERVER['REQUEST_URI'], '?') !== false)
  • trunk/Common/Types/File/File.php

    r428 r500  
    11<?php
    22
    3 class TypeFile
     3class TypeFile extends TypeBase
    44{
     5  var $UploadFileFolder;
     6  var $FileDownloadURL;
     7  var $DirectoryId;
     8 
     9  function __construct()
     10  {
     11    $this->FileDownloadURL = 'File.php';
     12    $this->DirectoryId = null;
     13  }
     14 
    515  function OnView($Item)
    616  {
     
    1121    {
    1222      $DbRow = $DbResult->fetch_assoc();
    13       return('<a href="types/File/FileDownload.php?Id='.$Item['Value'].'">'.$DbRow['Name'].'</a> ('.HumanSize($DbRow['Size']).')');
     23      return('<a href="'.$this->FileDownloadURL.'?Id='.$Item['Value'].'">'.$DbRow['Name'].'</a> ('.HumanSize($DbRow['Size']).')');
    1424    } else return('');
    1525  }
     
    2939
    3040    $Result = 0;
    31     //print_r($_FILES);
     41    print_r($_FILES);
     42    print_r($_POST);
    3243    if(array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
    3344    {
     
    3546      {
    3647        $FileName = substr($_FILES[$Item['Name']]['name'], strrpos($_FILES[$Item['Name']]['name'], '/'));
    37         $Database->query('INSERT INTO SystemFile (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Item['Name']]['tmp_name']).')');
     48        $Database->insert('File', array('Name' => $FileName, 'Size' => filesize($_FILES[$Item['Name']]['tmp_name']),
     49           'Directory' => $this->DirectoryId));
    3850        $Result = $Database->insert_id;
    39         if(!move_uploaded_file($_FILES[$Item['Name']]['tmp_name'], $Config['UploadFileFolder'].'/'.$Result)) SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
     51        if(!move_uploaded_file($_FILES[$Item['Name']]['tmp_name'], $this->UploadFileFolder.'/'.$Result))
     52          SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
    4053      }
    4154    }
  • trunk/Common/Types/Type.php

    r484 r500  
    9898}
    9999
    100 
    101100?>
  • trunk/Common/Version.php

    r499 r500  
    11<?php
    22
    3 $Revision = 499; // Subversion revision
    4 $DatabaseRevision = 499;
     3$Revision = 500; // Subversion revision
     4$DatabaseRevision = 500;
    55$ReleaseTime = '2013-03-03';
    66
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r499 r500  
    11<?php
    22
    3 include_once('../Common/Global.php');
     3include_once(dirname(__FILE__).'/../Common/Global.php');
    44
    5 class FinanceImportPayment extends Page
     5class PageFileImport extends Page
    66{
    77  var $FullTitle = 'Import plateb';
     
    1010  function Show()
    1111  {
     12    $Output = '';
    1213    if(!$this->System->Modules['User']->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');
    1314    if(array_key_exists('Operation', $_GET))
    1415    {
    15       if($_GET['Operation'] == 'prepare') return($this->Prepare());
    16       else if($_GET['Operation'] == 'insert') return($this->Insert());
    17       else echo('Neplatná akce');
    18     } else
    19     {
    20       $Output = 'Vložte CSV data z SYLK exportu Poštovní spořitelny';
    21       $Output .= '<form action="?Operation=prepare" method="post">';
    22       $Output .= '<textarea name="Source" cols="80" rows="20"></textarea><br/>';
    23       $Output .= '<input type="submit" value="Analyzovat"/>';
    24       $Output .= '</form>';
    25       return($Output);
    26     }
     16      if($_GET['Operation'] == 'prepare') $Output .= $this->Prepare();
     17      else if($_GET['Operation'] == 'insert') $Output .= $this->Insert();
     18      else $Output .= 'Neplatná akce';
     19    } else $Output .= $this->ShowForm();
     20    return($Output);
     21  }
     22 
     23  function ShowForm()
     24  {
     25    $FormImport = new Form('ImportBankFile');
     26    $FormImport->OnSubmit = '?Operation=prepare';
     27    $Output = $FormImport->ShowEditForm();
     28    return($Output);
    2729  }
    2830 
    2931  function Prepare()
    3032  {   
     33    $FormImport = new Form('ImportBankFile');
     34    $FormImport->LoadValuesFromForm();
     35    $Output = $FormImport->ShowEditForm();
     36   
    3137    $Finance = $this->System->Modules['Finance'];
    32     $Data = explode("\n", $_POST['Source']);
     38    $Output = $FormImport->Values['File'];
     39    return($Output);
     40   
     41    $Data =  $FormImport->Values['File'];
    3342    foreach($Data as $Key => $Value)
    3443    {
     
    146155}
    147156
    148 $System->AddModule(new FinanceImportPayment());
    149 $System->Modules['FinanceImportPayment']->GetOutput();
    150 
    151157?>
  • trunk/admin/Updates.php

    r499 r500  
    3737    "VALUES (NULL , 'Parametry účtování', '2', 'FinanceCharge', '');");
    3838  $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
    39     "VALUES (NULL , 'Úseky sítě', '2', 'NetworkSegment', ''");
     39    "VALUES (NULL , 'Úseky sítě', '2', 'NetworkSegment', '');");
    4040  $Manager->Execute("ALTER TABLE `ServiceCustomerRel` ADD `Action` ENUM( 'add', 'modify', 'remove' ) NULL , ".
    4141    "ADD `ReplaceId` INT NULL");
     
    121121}
    122122
     123function UpdateTo500($Manager)
     124{
     125  $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` (
     126  `Id` int(11) NOT NULL AUTO_INCREMENT,
     127  `Name` varchar(255) NOT NULL,
     128  `Code` varchar(4) NOT NULL,
     129  `BIC` varchar(255) NOT NULL,
     130  `Country` int(11) NOT NULL,
     131  PRIMARY KEY (`Id`),
     132  KEY `Country` (`Country`)
     133) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     134  $Manager->Execute("ALTER TABLE `FinanceBank`
     135  ADD CONSTRAINT `FinanceBank_ibfk_1` FOREIGN KEY (`Country`) REFERENCES `Country` (`Id`);");
     136  $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `Bank` INT NOT NULL AFTER `Number` ,".
     137     " ADD INDEX ( `Bank` )");
     138  $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD FOREIGN KEY ( `Bank` ) REFERENCES `FinanceBank` (".
     139    "`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
     140  $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
     141    "VALUES (NULL , 'Banky', '2', 'FinanceBank', '');");
     142}
     143
    123144$Updates = array(
    124145        491 => array('Revision' => 493, 'Function' => 'UpdateTo493'),
     
    128149  497 => array('Revision' => 498, 'Function' => 'UpdateTo498'),
    129150  498 => array('Revision' => 499, 'Function' => 'UpdateTo499'),
     151  499 => array('Revision' => 500, 'Function' => 'UpdateTo500'),
    130152);
    131153
  • trunk/aktuality/index.php

    r438 r500  
    9090        if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $Category))
    9191        {
    92           //print_r($_FILES);
    9392          // Process uploaded file
    9493          $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
     
    122121        {
    123122          $Row['Content'] = str_replace('<br />', '', $Row['Content']);
    124           $Output .= '<strong>Editace aktuality v kategorii '.$CategoryName.':</strong><br />';
     123          $Output .= '<strong>Úprava aktuality v kategorii '.$CategoryName.':</strong><br />';
    125124          $Output .= '<form action="index.php?action=update" method="post">'.
    126125          '<input type="hidden" value="'.$_GET['id'].'" name="id">'.
  • trunk/aktuality/news.php

    r452 r500  
    5656    $Output .= '</div></div><div class="Content">';
    5757    $DbResult = $Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
    58     //echo($Database->error.'<br />');
    59     //echo($Database->LastQuery.'<br />');
    6058    //echo('<table cellpadding="0" cellspacing="0" width="100%"><tr><td>');
    6159    $Index = 0;
     
    192190    foreach($Setting as $Index => $Item)
    193191      $Setting[$Index]['Index'] = $Index + 1;
    194     // print_r($Setting);
    195192
    196193    // Store new cookie value
  • trunk/finance/bills.php

    r498 r500  
    4343    $MainSubject = $DbResult->fetch_assoc();
    4444   
    45     $DbResult = $this->Database->select('FinanceBankAccount', '*', '(`Subject`='.
    46         $Config['Finance']['MainSubjectId'].') AND (`Use`=1)');
     45    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, FinanceBank.Code AS NumberFull FROM FinanceBankAccount '.
     46      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
     47      'WHERE (FinanceBankAccount.`Subject`='.$Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
    4748    $MainSubjectAccount = $DbResult->fetch_assoc();
    4849   
     
    6667      'IČ: '.$MainSubject['IC'].'<br>'.
    6768      'DIČ: '.$MainSubject['DIC'].'<br>'.
    68       'Účet: '.$MainSubjectAccount['Number'].'<br>'.
     69      'Účet: '.$MainSubjectAccount['NumberFull'].'<br>'.
    6970      'Plátce DPH: '.$BooleanText[$MainSubject['PayVAT']].'<br>'.
    7071      '</td><td valign="top">'.
     
    134135    $MainSubject = $DbResult->fetch_assoc();
    135136   
    136     $DbResult = $this->Database->select('FinanceBankAccount', '*', '(`Subject`='.
    137         $Config['Finance']['MainSubjectId'].') AND (`Use`=1)');
     137    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, FinanceBank.Code AS NumberFull FROM FinanceBankAccount '.
     138      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
     139      'WHERE (FinanceBankAccount.`Subject`='.$Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
    138140    $MainSubjectAccount = $DbResult->fetch_assoc();
    139141   
  • trunk/finance/manage.php

    r498 r500  
    553553    $MainSubject = $DbResult->fetch_assoc(); 
    554554   
    555     $DbResult = $this->Database->select('FinanceBankAccount', '*', '(`Subject`='.
    556       $Config['Finance']['MainSubjectId'].') AND (`Use`=1)');
     555    $DbResult = $this->Database->query('SELECT FinanceBankAccount.*, FinanceBank.Code AS NumberFull FROM FinanceBankAccount '.
     556      'JOIN FinanceBank ON FinanceBank.Id=FinanceBankAccount.Bank '.
     557      'WHERE (FinanceBankAccount.`Subject`='.$Config['Finance']['MainSubjectId'].') AND (FinanceBankAccount.`Use`=1)');
    557558    $MainSubjectAccount = $DbResult->fetch_assoc();
    558559       
     
    569570        'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".
    570571        'Pravidelná platba za období: <strong>'.$MemberPayment['MonthlyTotal'].' Kč</strong><br />'."\n".
    571         'Bankovní účet: <strong>'.$MainSubjectAccount['Number'].'<br/>'."\n".
     572        'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'<br/>'."\n".
    572573        'Variabilní symbol: <strong>'.$Member['Subject'].'</strong><br/>'."\n".
    573574        'Stav vašeho účtu: <strong>'.($MemberPayment['Cash'] - $MemberPayment['MonthlyTotal']).' Kč</strong><br /><br />'."\n";
  • trunk/form_classes.php

    r499 r500  
    1616*/
    1717
    18 $FormClasses = array(   
     18$FormClasses = array(
     19  'ImportBankFile' => array(
     20    'Title' => 'Import souborů s platbami',
     21    'Table' => 'FinanceBank',
     22    'SubmitText' => 'Načíst',
     23    'Items' => array(
     24      'BankAccount' => array('Type' => 'TBankAccount', 'Caption' => 'Bankovní účet', 'Default' => ''),
     25      'File' => array('Type' => 'File', 'Caption' => 'Soubor', 'Default' => ''),
     26    )
     27   ),       
     28  'FinanceBank' => array(
     29    'Title' => 'Banky',
     30    'Table' => 'FinanceBank',
     31    'Items' => array(
     32      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
     33      'Code' => array('Type' => 'String', 'Caption' => 'Český kód', 'Default' => ''),
     34      'BIC' => array('Type' => 'String', 'Caption' => 'Kód BIC', 'Default' => ''),
     35      'Country' => array('Type' => 'TCountry', 'Caption' => 'Země', 'Default' => ''),
     36    ),
     37  ),
    1938  'FinanceBankImport' => array(
    2039    'Title' => 'Import plateb z účtu',
    2140    'Table' => 'FinanceBankImport',
    2241    'Items' => array(
    23       'BankAccount' => array('Type' => 'TBankAccount', 'Caption' => 'Účet'),
     42      'BankAccount' => array('Type' => 'TBankAccount', 'Caption' => 'Účet', 'Default' => ''),
    2443      'Time' => array('Type' => 'Date', 'Caption' => 'Čas', 'Default' => ''),
    2544      'Identification' => array('Type' => 'String', 'Caption' => 'Kód operace', 'Default' => ''),
     
    469488      'Comment' => array('Type' => 'String', 'Caption' => 'Komentář', 'Default' => ''),
    470489      'Number' => array('Type' => 'String', 'Caption' => 'Číslo', 'Default' => ''),
     490      'Bank' => array('Type' => 'TFinanceBank', 'Caption' => 'Banka', 'Default' => ''),
    471491      'TimeCreate' => array('Type' => 'Date', 'Caption' => 'Čas vytvoření', 'Default' => ''),
    472492      'TimeEnd' => array('Type' => 'Date', 'Caption' => 'Čas zrušení', 'Default' => ''),
     
    909929    'Table' => 'FinanceBankAccount',
    910930    'Id' => 'Id',
    911     'Name' => 'Comment',
     931    'Name' => 'CONCAT(Comment, " (", Number, ")")',
    912932    'Filter' => '1',
    913933  ),
     
    10381058    'Id' => 'Id',
    10391059    'Name' => 'Name',
     1060    'Filter' => '1',
     1061  ),
     1062  'TFinanceBank' => array(
     1063    'Type' => 'Reference',
     1064    'Table' => 'FinanceBank',
     1065    'Id' => 'Id',
     1066    'Name' => 'CONCAT(Name, " (", Code, ")")',
    10401067    'Filter' => '1',
    10411068  ),
Note: See TracChangeset for help on using the changeset viewer.