/**
  * @param Phprojekt $phprojekt
  */
 protected function doStopWorkingtime($phprojekt)
 {
     try {
         $this->info('[Action] Stop working time');
         $phprojekt->getTimecardApi()->workEnd();
         $this->info('[Action] Done');
     } catch (InvalidArgumentException $e) {
         $this->error('[Response] No active workingtime found');
     }
     $this->call('t:list');
 }
 /**
  * @param Phprojekt $phprojekt
  */
 protected function doStartWorkingtime($phprojekt)
 {
     try {
         $this->info('[Action] Start working time');
         $phprojekt->getTimecardApi()->workStart();
         $this->info('[Action] Done');
     } catch (InvalidArgumentException $e) {
         $this->error('[Response] Working time already started');
     }
     $this->call('t:list');
 }
Example #3
0
 /**
  * @param Phprojekt $phprojekt
  */
 protected function doBookTime($phprojekt)
 {
     $start = trim($this->argument('start'));
     $end = trim($this->argument('end'));
     if (strlen($start) != 4 || strlen($end) != 4) {
         exit($this->error('[Response] Wrong format... Please use 0100 as example.'));
     }
     try {
         $this->info('[Action] Book working time');
         $timeCardApi = $phprojekt->getTimecardApi();
         $timeCardApi->logWorkingHours(new \DateTime(), $start, $end);
         $this->info('[Action] Done');
     } catch (InvalidArgumentException $e) {
         $this->error('[Response] Something failed here...');
     }
     $this->call('t:list');
 }
Example #4
0
 /**
  * @param Phprojekt $phprojekt
  */
 protected function doListWorkingtime($phprojekt)
 {
     try {
         $timeCardApi = $phprojekt->getTimecardApi();
         $workLog = $timeCardApi->getWorkingHours(new \DateTime());
         $table = new Table(new ConsoleOutput());
         $table->setHeaders(['Start', 'End', 'Sum']);
         foreach ($workLog as $row) {
             $start = $row->getStart();
             $end = $row->getEnd();
             $diff = $end->diff($start);
             $table->addRow([$start->format('H:i'), $end->format('H:i'), $diff->format('%h h %i m')]);
         }
         $table->addRow(new TableSeparator());
         $table->addRow(['', 'Overall', $workLog->getOverallTime()]);
         exit($table->render());
     } catch (InvalidArgumentException $e) {
         $this->error('[Response] No bookings today...');
     }
 }
Example #5
0
 /**
  * @param Phprojekt $phprojekt
  */
 protected function doAddProjectTime($phprojekt)
 {
     $project = trim($this->argument('project'));
     $time = trim($this->argument('time'));
     $description = trim($this->argument('description'));
     if (strlen($time) != 4) {
         exit($this->error('[Response] Wrong format... Please use 0100 as example.'));
     }
     $hours = $time[0] . $time[1];
     $minutes = $time[2] . $time[3];
     try {
         $this->info('[Action] Book project time');
         $timeCardApi = $phprojekt->getTimecardApi();
         $timeCardApi->logProjectHours(new \DateTime(), $project, $hours + $minutes / 60, $description);
         $this->call('p:list');
         $this->info('[Action] Done');
     } catch (InvalidArgumentException $e) {
         $this->error('[Response] Something failed here...');
         $this->comment($e->getMessage());
     }
 }