/**
  * @param $time
  * @param bool $isZeroVisible
  * @return int|string
  */
 public function toTimeWithComma($time, $isZeroVisible = false)
 {
     if (!$time instanceof \InvoiceTime) {
         $time = new \InvoiceTime($time);
     }
     if ($time->getTime() == '00:00:00') {
         if ($isZeroVisible === false) {
             return '';
         } else {
             return 0;
         }
     }
     return $time->toTimeWithComma();
 }
Example #2
0
 /**
  * @param InvoiceTime $workStart
  * @param InvoiceTime $workEnd
  * @param InvoiceTime $lunch
  * @param InvoiceTime|null $otherHours
  * @return \App\Model\Entities\WorkedHours
  */
 protected function setupWorkedHours(InvoiceTime $workStart, InvoiceTime $workEnd, InvoiceTime $lunch, InvoiceTime $otherHours = null)
 {
     $otherHours = $otherHours === null ? new \InvoiceTime(null) : $otherHours;
     $arr = ['workStart' => $workStart->getTime(), 'workEnd' => $workEnd->getTime(), 'lunch' => $lunch->getTime(), 'otherHours' => $otherHours->getTime()];
     try {
         $this->connection->query('INSERT INTO [worked_hours]', $arr);
         $id = $this->connection->getInsertId();
     } catch (\DibiException $e) {
         if ($e->getCode() == 1062) {
             $id = $this->connection->query('SELECT workedHoursID as id FROM worked_hours
                  WHERE %and', $arr)->fetchSingle();
         }
     }
     $workedHours = new \App\Model\Entities\WorkedHours($workStart, $workEnd, $lunch, $otherHours);
     $this->makeEntityAlive($workedHours, $id);
     return $workedHours;
 }
 public function fromInvoiceTime(\InvoiceTime $time)
 {
     return $time->getTime();
 }