Changeset 719 for trunk/Common


Ignore:
Timestamp:
Jan 2, 2015, 11:16:56 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for Hidden items in form types values.
  • Added: Support for Filtered items in form types values.
  • Modified: FinanceOperation Value splitted to (Direction * Value). Direction can be +1 or -1 depends on if money goes out or in company.
  • Added: Menu "Incomes and spends" is now splitted to incomes/spends of bank account or treasury. Direction and document line is filled automatically.
Location:
trunk/Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Form/Form.php

    r706 r719  
    33include_once(dirname(__FILE__).'/../Database.php');
    44include_once(dirname(__FILE__).'/Types/Type.php');
     5
     6/*
     7Form item type definition:
     8Type - identifikace typu z podporovaných
     9Caption - popisek, titulek položky
     10Default - výchozí hodnota
     11Null - hodnota nemusí být zadána
     12NotInList - sloupec neviditelný v seznamu položek
     13Hidden - neviditelný, při přidání nové položky se použije výchozí hodnota.
     14Filter - column is used as filer according default value
     15Suffix - text za hodnotou
     16Description - popis významu položky
     17ReadOnly - je položky pouze pro čtení
     18Required - položka je vyžadována
     19SQL - SQL dotaz pro zjištění hodnoty, #Id bude nahrazeno Id aktuální položky
     20*/
     21
    522
    623class Form
     
    3249    ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))
    3350    {
    34       if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default'];
     51      if(!array_key_exists($Index, $this->Values) and isset($Item['Default']))
     52        $this->Values[$Index] = $Item['Default'];
    3553    }
    3654  }
     
    6785    );
    6886    foreach($this->Definition['Items'] as $Index => $Item)
     87    if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    6988    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    7089    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     
    115134      if(!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;
    116135    if($Item['ReadOnly'] == false)
     136    if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
    117137    if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    118138    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     
    255275    $Values = array();
    256276    foreach($this->Definition['Items'] as $Index => $Item)
     277    if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))
     278    {
    257279    if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or
    258280    (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and
     
    279301        $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad',
    280302          $Parameters);
     303    }
     304    } else
     305    {
     306      if(isset($Item['Default'])) {
     307        if(isset($Item['Null']) and ($Item['Null'] == true))
     308                $Values[$Index] = null;
     309        else $Values[$Index] = $Item['Default'];
     310      }
    281311    }
    282312    return($Values);
  • trunk/Common/Setup/Updates.php

    r718 r719  
    10301030    $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
    10311031      "VALUES (NULL , 'Firmy', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1032  }
     1033}
     1034
     1035/*
     1036function UpdateTo719($Manager)
     1037{       
     1038  $Manager->Execute('ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_1`;');
     1039  $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Subject` `SubjectFrom` INT(11) NULL DEFAULT "";');
     1040  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `SubjectTo` INT NULL AFTER `SubjectFrom`, ADD INDEX (`SubjectTo`) ;');
     1041  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`SubjectFrom`) REFERENCES `Subject`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1042  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`SubjectTo`) REFERENCES `Subject`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;');
     1043  // Set target subject to 1 = company subject id
     1044  $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectTo` = 1;');
     1045  $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectTo` = `SubjectFrom` WHERE `Value` < 0');
     1046  $Manager->Execute('UPDATE `FinanceOperation` SET `SubjectFrom` = 1,`Value`= -`Value`  WHERE `Value` < 0');
     1047   
     1048}
     1049*/
     1050
     1051function UpdateTo719($Manager)
     1052{       
     1053  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;');
     1054  $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = 1 WHERE `Value` >= 0 ;');
     1055  $Manager->Execute('UPDATE `FinanceOperation` SET `Direction` = -1 WHERE `Value` < 0 ;');
     1056  $Manager->Execute('UPDATE `FinanceOperation` SET `Value` = -`Value` WHERE `Value` < 0 ;');
     1057
     1058  // IS menu item
     1059  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"');
     1060  if($DbResult->num_rows > 0)
     1061  {
     1062        $DbRow = $DbResult->fetch_assoc();
     1063    $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1064    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1065    NULL , "", "Příjem do pokladny", "1", "/is/?t=FinanceTreasuryIn&a=list", NULL , NULL , NULL , "1");');
     1066    $ActionId = $Manager->Database->insert_id;
     1067        $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1068      "VALUES (NULL , 'Příjem do pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1069    $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1070    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1071    NULL , "", "Výdej z pokladny", "1", "/is/?t=FinanceTreasuryOut&a=list", NULL , NULL , NULL , "1");');
     1072    $ActionId = $Manager->Database->insert_id;
     1073        $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1074      "VALUES (NULL , 'Výdej z pokladny', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1075    $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1076    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1077    NULL , "", "Příjem na účet", "1", "/is/?t=FinanceAccountIn&a=list", NULL , NULL , NULL , "1");');
     1078    $ActionId = $Manager->Database->insert_id;
     1079        $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1080      "VALUES (NULL , 'Příjem na účet', ".$DbRow['Id'].", '".$ActionId."', '1');");
     1081    $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     1082    `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     1083    NULL , "", "Výdej z účtu", "1", "/is/?t=FinanceAccountOut&a=list", NULL , NULL , NULL , "1");');
     1084    $ActionId = $Manager->Database->insert_id;
     1085        $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     1086      "VALUES (NULL , 'Výdej z účtu', ".$DbRow['Id'].", '".$ActionId."', '1');");
    10321087  }
    10331088}
     
    10861141      696 => array('Revision' => 697, 'Function' => 'UpdateTo697'),
    10871142      697 => array('Revision' => 707, 'Function' => 'UpdateTo707'),
    1088       710 => array('Revision' => 715, 'Function' => 'UpdateTo715'),
     1143      707 => array('Revision' => 710, 'Function' => 'UpdateTo710'),
     1144        710 => array('Revision' => 715, 'Function' => 'UpdateTo715'),
    10891145      715 => array('Revision' => 718, 'Function' => 'UpdateTo718'),
     1146      718 => array('Revision' => 719, 'Function' => 'UpdateTo719'),
    10901147    ));
    10911148  }
Note: See TracChangeset for help on using the changeset viewer.