Beispiel #1
0
 function init()
 {
     parent::init();
     $this->addExpression('color')->set(function ($m) {
         return $m->dsql()->expr("IF([0]>=90,'danger',\n\t\t\t\t\t\tif([0]>=75,'warning',\n\t\t\t\t\t\tif([0]>=50,'primary',\n\t\t\t\t\t\tif([0]>=25,'success','danger'\t\n\t\t\t\t\t\t))))", [$m->getElement('priority')]);
     });
     $this->addExpression('is_started')->set(function ($m, $q) {
         return $m->refSQL('xepan\\projects\\Timesheet')->count();
     });
     $this->addExpression('is_running')->set(function ($m, $q) {
         return $m->refSQL('xepan\\projects\\Timesheet')->addCondition('endtime', null)->count();
     });
     // $this->debug();
     $this->addExpression('total_duration')->set(function ($m, $q) {
         $time_sheet = $this->add('xepan\\projects\\Model_Timesheet', ['table_alias' => 'total_duration']);
         $time_sheet->addCondition('task_id', $q->getField('id'));
         return $time_sheet->dsql()->del('fields')->field($q->expr('sec_to_time(SUM([0]))', [$time_sheet->getElement('duration')]));
     });
     $this->addExpression('comment_count')->set(function ($m, $q) {
         return $m->refSQL('xepan\\projects\\Comment')->count();
     });
     $this->addExpression('attachment_count')->set(function ($m, $q) {
         return $m->refSQL('xepan\\projects\\Task_Attachment')->count();
     });
 }
Beispiel #2
0
 function init()
 {
     parent::init();
     $this->addExpression('average_receiving_time')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('starting_date', '>', $this->start_date)->addCondition('starting_date', '<', $this->end_date)->addCondition('type', 'Task');
         if (!empty($this->employee)) {
             $task->addCondition('created_by_id', '<>', $this->employee)->addCondition('assign_to_id', $this->employee);
         }
         $task->addExpression('diff_time')->set(function ($m, $q) {
             return $q->expr('TIMESTAMPDIFF([0],[1],[2])', ['MINUTE', $q->getField('created_at'), $q->getField('received_at')]);
         });
         return $task->_dsql()->del('fields')->field($q->expr('avg([0])', [$task->getElement('diff_time')]));
     });
     $this->addExpression('average_submission_time')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('starting_date', '>', $this->start_date)->addCondition('starting_date', '<', $this->end_date)->addCondition('type', 'Task');
         if (!empty($this->employee)) {
             $task->addCondition('created_by_id', '<>', $this->employee)->addCondition('assign_to_id', $this->employee);
         }
         $task->addExpression('diff_time')->set(function ($m, $q) {
             return $q->expr('TIMESTAMPDIFF([0],[1],[2])', ['MINUTE', $q->getField('created_at'), $q->getField('submitted_at')]);
         });
         return $task->_dsql()->del('fields')->field($q->expr('avg([0])', [$task->getElement('diff_time')]));
     });
     $this->addExpression('average_reacting_time')->set(function ($m, $q) {
         $task = $this->add('xepan\\projects\\Model_Task');
         $task->addCondition('starting_date', '>', $this->start_date)->addCondition('starting_date', '<', $this->end_date)->addCondition('type', 'Task');
         if (!empty($this->employee)) {
             $task->addCondition('created_by_id', $this->employee)->addCondition('assign_to_id', '<>', $this->employee);
         }
         $task->addExpression('diff_time')->set(function ($m, $q) {
             return $q->expr('TIMESTAMPDIFF([0],[1],[2])', ['MINUTE', $q->getField('submitted_at'), $q->getField('completed_at')]);
         });
         return $task->_dsql()->del('fields')->field($q->expr('avg([0])', [$task->getElement('diff_time')]));
     });
 }