Merge branch 'pu/2013.10-longrun'
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 29 Aug 2014 17:01:18 +0000 (19:01 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 29 Aug 2014 17:01:18 +0000 (19:01 +0200)
Conflicts:
tests/tine20/HumanResources/JsonTests.php
tests/tine20/HumanResources/TestCase.php
tests/tine20/Sales/JsonTest.php
tine20/HumanResources/js/DatePicker.js
tine20/Sales/Controller/NumberableAbstract.php
tine20/Sales/Setup/Update/Release8.php
tine20/Sales/Setup/setup.xml
tine20/Tinebase/Controller/Record/Abstract.php
tine20/Tinebase/Convert/Json.php
tine20/Tinebase/Frontend/Json/Abstract.php
tine20/Tinebase/js/widgets/grid/GridPanel.js
tine20/Tinebase/translations/de.po

Change-Id: Iaecffe4312b8a58584e95fbda49d4d9ab254da6d

14 files changed:
1  2 
tests/tine20/ActiveSync/Controller/CalendarTests.php
tests/tine20/Calendar/Controller/EventGrantsTests.php
tests/tine20/Calendar/Controller/MSEventFacadeTest.php
tests/tine20/Calendar/JsonTests.php
tests/tine20/HumanResources/JsonTests.php
tine20/Admin/Frontend/Json.php
tine20/HumanResources/js/DatePicker.js
tine20/Sales/Controller/NumberableAbstract.php
tine20/Tinebase/Backend/Sql/Command/Mysql.php
tine20/Tinebase/Controller/Record/Abstract.php
tine20/Tinebase/Model/Filter/Date.php
tine20/Tinebase/js/widgets/grid/GridPanel.js
tine20/Tinebase/translations/de.po
tine20/Tinebase/translations/template.pot

Simple merge
@@@ -889,187 -895,51 +900,236 @@@ class HumanResources_JsonTests extends 
      }
      
      /**
 +     * @see: https://forge.tine20.org/mantisbt/view.php?id=10122
 +     */
 +    public function testAlternatingContracts()
 +    {
 +        $date = Tinebase_DateTime::now()->setDate(2014, 1, 1)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $employee = $this->_getEmployee('unittest');
 +        
 +        $employee->employment_begin = clone $date;
 +        
 +        $contract1 = $this->_getContract();
 +        $contract1->start_date = clone $date; // 1.1.2014
 +        $date->addMonth(7)->subDay(1); 
 +        $contract1->end_date = clone $date; // 31.7.2014 
 +        $contract1->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
 +        $contract1->vacation_days = 27;
 +        $date->addDay(1); // 1.8.2014
 +        $contract2 = $this->_getContract();
 +        $contract2->start_date = clone $date;
 +        $contract2->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
 +        $contract2->vacation_days = 30;
 +        
 +        $recordData = $employee->toArray();
 +        $recordData['contracts'] = array($contract1->toArray(), $contract2->toArray());
 +        $recordData = $this->_json->saveEmployee($recordData);
 +        
 +        $recordData['vacation'] = array(
 +            array()
 +        );
 +        
 +        $res = $this->_json->searchAccounts(array(
 +            array('field' => 'year', 'operator' => 'equals', 'value' => '2014')
 +        ), array());
 +        
 +        $account = $res['results'][0];
 +        $date->subDay(1); // 31.7.2014
 +        
 +        $extraFreeTime = HumanResources_Controller_ExtraFreeTime::getInstance()->create(new HumanResources_Model_ExtraFreeTime(array(
 +            'account_id' => $account['id'],
 +            'days' => 4,
 +            'expires' => clone $date,
 +            'type' => 'payed'
 +        )));
 +        
 +        $res = $this->_json->getFeastAndFreeDays($recordData['id'], 2014);
 +        
 +        // at this point, vacation days are not created, so the extra freetime is expired
 +        $this->assertEquals(28, $res['results']['remainingVacation']);
 +        
 +        // create vacation days
 +        $day = Tinebase_DateTime::now()->setDate(2014, 1, 2)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $newFreeTime = array(
 +            'account_id' => $account['id'],
 +            'employee_id' => $recordData['id'],
 +            'type' => 'vacation',
 +            'status' => 'ACCEPTED',
 +            'firstday_date' => $day->toString()
 +        );
 +        
 +        $newFreeTime['freedays'] = array(
 +            array('duration' => '1', 'date' => $day->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +        );
 +        
 +        $newFreeTime['days_count']   = 2;
 +        $newFreeTime['lastday_date'] = $day->toString();
 +        
 +        $this->_json->saveFreeTime($newFreeTime);
 +        
 +        // create vacation days
 +        $day = Tinebase_DateTime::now()->setDate(2014, 6, 10)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $newFreeTime = array(
 +            'account_id' => $account['id'],
 +            'employee_id' => $recordData['id'],
 +            'type' => 'vacation',
 +            'status' => 'ACCEPTED',
 +            'firstday_date' => $day->toString()
 +        );
 +        
 +        $newFreeTime['freedays'] = array(
 +            array('duration' => '1', 'date' => $day->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +        );
 +        
 +        $newFreeTime['days_count']   = 4;
 +        $newFreeTime['lastday_date'] = $day->toString();
 +        
 +        $this->_json->saveFreeTime($newFreeTime);
 +        
 +        
 +        // create vacation days
 +        $day = Tinebase_DateTime::now()->setDate(2014, 7, 28)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $newFreeTime = array(
 +            'account_id' => $account['id'],
 +            'employee_id' => $recordData['id'],
 +            'type' => 'vacation',
 +            'status' => 'ACCEPTED',
 +            'firstday_date' => $day->toString()
 +        );
 +        
 +        $newFreeTime['freedays'] = array(
 +            array('duration' => '1', 'date' => $day->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +            array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +        );
 +        
 +        $newFreeTime['days_count']   = 5;
 +        $newFreeTime['lastday_date'] = $day->toString();
 +        
 +        $this->_json->saveFreeTime($newFreeTime);
 +        
 +        // create sickness days
 +        $day = Tinebase_DateTime::now()->setDate(2014, 1, 21)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $newFreeTime = array(
 +            'account_id' => $account['id'],
 +            'employee_id' => $recordData['id'],
 +            'type' => 'sickness',
 +            'status' => "EXCUSED",
 +            'firstday_date' => $day->toString()
 +        );
 +        
 +        $newFreeTime['freedays'] = array(
 +                array('duration' => '1', 'date' => $day->toString()),
 +                array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +                array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +                array('duration' => '1', 'date' => $day->addDay(1)->toString()),
 +        );
 +        
 +        $day->addDay(2);
 +        
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        
 +        $day->addDay(2);
 +        
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        $newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
 +        
 +        $newFreeTime['days_count']   = 14;
 +        $newFreeTime['lastday_date'] = $day->toString();
 +        
 +        $this->_json->saveFreeTime($newFreeTime);
 +        
 +        // create sickness days
 +        $day = Tinebase_DateTime::now()->setDate(2014, 1, 6)->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
 +        $newFreeTime = array(
 +                'account_id' => $account['id'],
 +                'employee_id' => $recordData['id'],
 +                'type' => 'sickness',
 +                'status' => "UNEXCUSED",
 +                'firstday_date' => $day->toString()
 +        );
 +        
 +        $newFreeTime['freedays'] = array(
 +                array('duration' => '1', 'date' => $day->toString()),
 +        );
 +        
 +        $this->_json->saveFreeTime($newFreeTime);
 +        
 +        $res = $this->_json->getFeastAndFreeDays($recordData['id'], 2014);
 +        
 +        // at this point the extra freetime has been taken and is not expired
 +        // 28 + 4 - 11 = 21
 +        $this->assertEquals(21, $res['results']['remainingVacation']);
 +        
 +        $account = $this->_json->getAccount($account['id']);
 +        
 +        $this->assertEquals(32, $account['possible_vacation_days']);
 +        $this->assertEquals(0, $account['expired_vacation_days']);
 +        $this->assertEquals(21, $account['remaining_vacation_days']);
 +        $this->assertEquals(11, $account['taken_vacation_days']);
 +        $this->assertEquals(14, $account['excused_sickness']);
 +        $this->assertEquals(1, $account['unexcused_sickness']);
 +    }
++    
++    /**
+      * @see: https://forge.tine20.org/mantisbt/view.php?id=10176
+      */
+     public function testSavingRelatedRecord()
+     {
+         $date = new Tinebase_DateTime();
+         $e = $this->_getEmployee();
+         $c = $this->_getContract($date);
+         // in fe the record gets an id, to allow stores crud and sort actions. this must be set to a 40 length ssha key
+         $c->id = '1234567890';
+         
+         $employeeJson = $e->toArray();
+         $employeeJson['contracts'] = array($c->toArray());
+         
+         $employeeJson = $this->_json->saveEmployee($employeeJson);
+         
+         $id = $employeeJson['contracts'][0]['id'];
+         // the id should be set to a 40 length ssha key
+         $this->assertEquals(40, strlen($id));
+         
+         $employeeJson = $this->_json->saveEmployee($employeeJson);
+         $this->assertEquals($id, $employeeJson['contracts'][0]['id']);
+     }
+     
+     /**
+      * @see: https://forge.tine20.org/mantisbt/view.php?id=10176
+      */
+     public function testSavingRelatedRecordWithCorruptId()
+     {
+         $date = new Tinebase_DateTime();
+         $e = $this->_getEmployee();
+         $c = $this->_getContract($date);
+         $c->id = '1234567890';
+     
+         $employeeJson = $e->toArray();
+         $employeeJson = $this->_json->saveEmployee($employeeJson);
+     
+         $c->employee_id = $employeeJson['id'];
+         
+         $c = HumanResources_Controller_Contract::getInstance()->create($c);
+         $this->assertEquals('1234567890', $c->getId());
+         $employeeJson['contracts'] = array($c->toArray());
+         $employeeJson = $this->_json->saveEmployee($employeeJson);
+         
+         // if it has been corrupted before this change was committed, the corrupted id should stay
+         $this->assertEquals('1234567890', $employeeJson['contracts'][0]['id']);
+     }
  }
Simple merge
@@@ -249,8 -248,13 +249,9 @@@ Tine.HumanResources.DatePicker = Ext.ex
          
          if (this.accountPickerActive) {
              var substractDays = this.editDialog.getDaysToSubstract();
-             this.editDialog.getForm().findField('remaining_vacation_days').setValue(rr.allVacation - substractDays);
+             
 -            if (! freetime && onInit) {
 -                substractDays = substractDays + freetime.get('days_count');
 -            }
 -
+             this.editDialog.getForm().findField('remaining_vacation_days').setValue(rr.remainingVacation - substractDays);
+             this.editDialog.accountPicker.setValue(this.currentYear);
          }
          
          this.updateCellClasses();
   *
   */
  
--abstract class Sales_Controller_NumberableAbstract extends Tinebase_Controller_Record_Abstract {
++abstract class Sales_Controller_NumberableAbstract extends Tinebase_Controller_Record_Abstract
++{
+     /**
+      * the number gets prefixed zeros until this amount of chars is reached
+      *
+      * @var integer
+      */
+     protected $_numberZerofill = NULL;
+     
+     /**
+      * the prefix for the invoice
+      *
+      * @var string
+      */
+     protected $_numberPrefix = NULL;
+     
+     /**
+      * the property which holds the number of the record
+      * 
+      * @var string
+      */
+     protected $_numberProperty = 'number';
      
      /**
       * Checks if number is unique if manual generated
@@@ -40,32 -41,32 +40,56 @@@ class Tinebase_Backend_Sql_Command_Mysq
          
          return new Zend_Db_Expr("GROUP_CONCAT( DISTINCT $quotedField)");
      }
 -
 +    
 +    /**
 +     * returns concatenation expression
 +     *
 +     * @param array $values
 +     */
 +    public function getConcat($values)
 +    {
 +        $str = 'CONCAT(';
 +        $i   = 1;
 +        $vc  = count($values);
 +        
 +        foreach($values as $value) {
 +            $str .= $value;
 +            if ($i < $vc) {
 +                $str .= ', ';
 +            }
 +            $i++;
 +        }
 +        
 +        $str .= ')';
 +        
 +        return new Zend_Db_Expr($str);
 +    }
 +    
      /**
+      * returns concatenation expression
+      * 
+      * @param array $values
+      */
+     public function getConcat($values)
+     {
+         $str = 'CONCAT(';
+         $i   = 1;
+         $vc  = count($values);
+         
+         foreach($values as $value) {
+             $str .= $value;
+             if ($i < $vc) {
+                 $str .= ', ';
+             }
+             $i++;
+         }
+         
+         $str .= ')';
+         
+         return new Zend_Db_Expr($str);
+     }
+     
+     /**
       * @param string $field
       * @param mixed $returnIfTrue
       * @param mixed $returnIfFalse
Simple merge
@@@ -2951,3 -2951,6 +2951,6 @@@ msgstr "Sie haben versucht, eine VerknÃ
  
  msgid "Invalid Relations"
  msgstr "Fehlerhafte Verknüpfung"
 -msgstr "Datensätze"
+ msgid "Records"
++msgstr "Datensätze"
@@@ -2935,3 -2935,6 +2935,6 @@@ msgid "
  "You are not allowed to delete this Container. Please define another "
  "container as the default addressbook for internal contacts!"
  msgstr ""
 -msgstr ""
+ msgid "Records"
++msgstr ""