Merge remote-tracking branch 'gerrit/pu/2013.03/modelconfig-hr'
authorCornelius Weiß <mail@corneliusweiss.de>
Thu, 28 Mar 2013 16:49:28 +0000 (17:49 +0100)
committerCornelius Weiß <mail@corneliusweiss.de>
Thu, 28 Mar 2013 16:49:28 +0000 (17:49 +0100)
Conflicts:
tine20/HumanResources/Setup/Update/Release7.php
tine20/HumanResources/Setup/setup.xml

1  2 
tine20/HumanResources/Setup/Update/Release7.php
tine20/HumanResources/Setup/setup.xml
tine20/Tinebase/js/widgets/grid/GridPanel.js

@@@ -158,24 -158,232 +158,251 @@@ class HumanResources_Setup_Update_Relea
          $this->setTableVersion('humanresources_contract', '2');
          $this->setApplicationVersion('HumanResources', '7.7');
      }
 -    
 +
      /**
       * update 7.7 -> 7.8
-         $this->setApplicationVersion('HumanResources', '7.8');
 +     * 
 +     * - change description field varchar 255 -> clob
 +     * 
 +     * @see https://forge.tine20.org/mantisbt/view.php?id=7994
 +     */
 +    public function update_7()
 +    {
 +        $field = '<field>
 +                    <name>description</name>
 +                    <type>clob</type>
 +                </field>';
 +
 +        $declaration = new Setup_Backend_Schema_Field_Xml($field);
 +        $this->_backend->alterCol('humanresources_employee', $declaration);
 +        $this->setTableVersion('humanresources_employee', '12');
 -    public function update_7()
++    }
++    
++    /**
++     * update 7.8 -> 7.9
+      *
+      * - add account module with the corresponding tables
+      */
 -        $this->setApplicationVersion('HumanResources', '7.8');
++    public function update_8()
+     {
+         $tableDeclaration = new Setup_Backend_Schema_Table_Xml('
+             <table>
+             <name>humanresources_account</name>
+             <version>1</version>
+             <declaration>
+                 <field>
+                     <name>id</name>
+                     <type>text</type>
+                     <length>40</length>
+                     <notnull>true</notnull>
+                 </field>
+                 <field>
+                     <name>employee_id</name>
+                     <type>text</type>
+                     <length>40</length>
+                     <notnull>true</notnull>
+                 </field>
+                 <field>
+                     <name>year</name>
+                     <type>integer</type>
+                     <notnull>true</notnull>
+                     <length>4</length>
+                 </field>
+                 <field>
+                     <name>created_by</name>
+                     <type>text</type>
+                     <length>40</length>
+                 </field>
+                 <field>
+                     <name>creation_time</name>
+                     <type>datetime</type>
+                 </field> 
+                 <field>
+                     <name>last_modified_by</name>
+                     <type>text</type>
+                     <length>40</length>
+                 </field>
+                 <field>
+                     <name>last_modified_time</name>
+                     <type>datetime</type>
+                 </field>
+                 <field>
+                     <name>is_deleted</name>
+                     <type>boolean</type>
+                     <default>false</default>
+                 </field>
+                 <field>
+                     <name>deleted_by</name>
+                     <type>text</type>
+                     <length>40</length>
+                 </field>
+                 <field>
+                     <name>deleted_time</name>
+                     <type>datetime</type>
+                 </field>
+                 <field>
+                     <name>seq</name>
+                     <type>integer</type>
+                     <notnull>true</notnull>
+                     <default>0</default>
+                 </field>
+                 <index>
+                     <name>id</name>
+                     <primary>true</primary>
+                     <field>
+                         <name>id</name>
+                     </field>
+                 </index>
+                 <index>
+                     <name>account::employee_id--employee::id</name>
+                     <field>
+                         <name>employee_id</name>
+                     </field>
+                     <foreign>true</foreign>
+                     <reference>
+                         <table>humanresources_employee</table>
+                         <field>id</field>
+                     </reference>
+                 </index>
+             </declaration>
+         </table>
+         ');
+         $this->_backend->createTable($tableDeclaration, 'HumanResources');
+         $tableDeclaration = new Setup_Backend_Schema_Table_Xml('
+             <table>
+                 <name>humanresources_extra_freetime</name>
+                 <version>1</version>
+                 <declaration>
+                     <field>
+                         <name>id</name>
+                         <type>text</type>
+                         <length>40</length>
+                         <notnull>true</notnull>
+                     </field>
+                     <field>
+                         <name>account_id</name>
+                         <type>text</type>
+                         <length>40</length>
+                         <notnull>true</notnull>
+                     </field>
+                     <field>
+                         <name>days</name>
+                         <type>integer</type>
+                         <notnull>true</notnull>
+                         <length>4</length>
+                     </field>
+                     <field>
+                         <name>type</name>
+                         <type>text</type>
+                         <length>64</length>
+                         <default>vacation</default>
+                     </field>
+                     <field>
+                         <name>description</name>
+                         <type>text</type>
+                         <length>255</length>
+                         <notnull>false</notnull>
+                     </field>
+                     <field>
+                         <name>created_by</name>
+                         <type>text</type>
+                         <length>40</length>
+                     </field>
+                     <field>
+                         <name>creation_time</name>
+                         <type>datetime</type>
+                     </field> 
+                     <field>
+                         <name>last_modified_by</name>
+                         <type>text</type>
+                         <length>40</length>
+                     </field>
+                     <field>
+                         <name>last_modified_time</name>
+                         <type>datetime</type>
+                     </field>
+                     <field>
+                         <name>is_deleted</name>
+                         <type>boolean</type>
+                         <default>false</default>
+                     </field>
+                     <field>
+                         <name>deleted_by</name>
+                         <type>text</type>
+                         <length>40</length>
+                     </field>
+                     <field>
+                         <name>deleted_time</name>
+                         <type>datetime</type>
+                     </field>
+                     <field>
+                         <name>seq</name>
+                         <type>integer</type>
+                         <notnull>true</notnull>
+                         <default>0</default>
+                     </field>
+                     <index>
+                         <name>id</name>
+                         <primary>true</primary>
+                         <field>
+                             <name>id</name>
+                         </field>
+                     </index>
+                     <index>
+                         <name>exfreetime::account_id--account::id</name>
+                         <field>
+                             <name>account_id</name>
+                         </field>
+                         <foreign>true</foreign>
+                         <reference>
+                             <table>humanresources_account</table>
+                             <field>id</field>
+                         </reference>
+                     </index>
+                 </declaration>
+             </table>
+         ');
+         
+         $this->_backend->createTable($tableDeclaration, 'HumanResources');
+         
+         // extra free time type
+         $freeTimeTypeConfig = array(
+             'name'    => HumanResources_Config::EXTRA_FREETIME_TYPE,
+             'records' => array(
+                 array('id' => 'PAYED',     'value' => 'Payed',     'icon' => NULL, 'system' => TRUE),  //_('Payed')
+                 array('id' => 'NOT_PAYED', 'value' => 'Not payed', 'icon' => NULL, 'system' => TRUE),  //_('Not payed')
+             ),
+         );
+         
+         // create type config
+         $cb = new Tinebase_Backend_Sql(array(
+             'modelName' => 'Tinebase_Model_Config',
+             'tableName' => 'config',
+         ));
+         $appId = Tinebase_Application::getInstance()->getApplicationByName('HumanResources')->getId();
+         
+         $cb->create(new Tinebase_Model_Config(array(
+             'application_id'    => $appId,
+             'name'              => HumanResources_Config::EXTRA_FREETIME_TYPE,
+             'value'             => json_encode($freeTimeTypeConfig),
+         )));
+         
+         // remove unused stati
+         $filter = new Tinebase_Model_ConfigFilter(array(
+             array('field' => 'name', 'operator' => 'equals', 'value' => HumanResources_Config::FREETIME_TYPE)
+         ));
+         $record = $cb->search($filter)->getFirstRecord();
+         $result = json_decode($record->value);
+         $newResult = array('name' => HumanResources_Config::FREETIME_TYPE);
+         foreach($result->records as $field) {
+             if ($field->id == 'VACATION_EXTRA' || $field->id == 'VACATION_REMAINING') {
+                 continue;
+             }
+             $newResult['records'][] = $field;
+         }
+         $record->value = json_encode($newResult);
+         $cb->update($record);
+         
++        $this->setApplicationVersion('HumanResources', '7.9');
      }
  }
Simple merge