protected function createComponentItemsTable()
 {
     $comp = $this->itemsTableControlFactory->create($this->listingResult);
     $comp->showActions(__DIR__ . '/templates/actions.latte', ['listingID' => $this->listing->getId()]);
     $comp->showTableCaption();
     return $comp;
 }
 protected function createComponentItemsTable()
 {
     $comp = $this->itemsTableControlFactory->create($this->listingResult);
     $comp->showTableCaption('Front:Listing:detail', ['id' => $this->listing->getId()]);
     $comp->showCheckBoxes();
     return $comp;
 }
 public function actionEdit($id, $day)
 {
     $this->listingResult = $this->getListingByID($id);
     $this->listing = $this->listingResult->getListing();
     $date = TimeUtils::getDateTimeFromParameters($this->listing->year, $this->listing->month, $day);
     if ($date === false) {
         $this->redirect('Listing:detail', ['id' => $this->listing->getId()]);
     }
 }
 public function showTableCaption($destination = null, array $params = [])
 {
     if ($destination !== null) {
         $this['description']->setAsClickable($destination, $params);
     }
     $listingData = $this->listingsFacade->getWorkedDaysAndTime($this->listing->getId());
     $this->workedDays = $listingData['worked_days'];
     $this->totalWorkedHours = new \InvoiceTime((int) $listingData['total_worked_hours_in_sec']);
     $this->isTableCaptionVisible = true;
 }
 private function handleInvalidation(Listing $listing)
 {
     $cache = $this->cacheFactory->getCache($listing->user->id, $listing->year);
     // removal of all generated pdf files of given Listing
     $generatedFiles = $cache->load('generatedPdfFilesByListing/' . $listing->getId());
     if ($generatedFiles !== null) {
         foreach ($generatedFiles as $key => $filePath) {
             if (!is_dir($filePath) and file_exists($filePath)) {
                 FileSystem::delete($filePath);
             }
         }
     }
     $cache->clean([Cache::TAGS => 'listing/' . $listing->id]);
 }
 protected function createComponentListingDescription()
 {
     $comp = $this->listingDescriptionControlFactory->create($this->listing);
     $comp->setAsClickable('Front:Listing:detail', ['id' => $this->listing->getId()]);
     return $comp;
 }
 public function getNotificationMessage(Listing $newListing, User $sender)
 {
     $period = TimeUtils::getMonthName($newListing->month) . ' ' . $newListing->year;
     $m = new SentMessage($this->constructSubject($sender->username, $period), $this->constructMessage($sender->username, $newListing->getUser()->username, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $newListing->getId()])), $sender);
     return $m;
 }
 /**
  * @return int
  */
 public function getListingId()
 {
     return $this->listing->getId();
 }
 /**
  * @param Listing $listing
  * @param User $recipient
  * @param $description
  * @param array $ignoredListingDays
  * @return Listing
  * @throws \Exception
  */
 public function shareListing(Listing $listing, User $recipient, $description, array $ignoredListingDays = [])
 {
     Validators::assert($description, 'unicode');
     try {
         $this->em->beginTransaction();
         /** @var ListingItem[] $listingItems */
         $listingItems = $this->listingItemsReader->findListingItems($listing->getId(), $ignoredListingDays, true);
         $newListing = clone $listing;
         $newListing->setUser($recipient);
         $newListing->setDescription($description);
         $newListing->setHourlyWage(null);
         $this->em->persist($newListing);
         foreach ($listingItems as $item) {
             $newItem = clone $item;
             $newItem->setListing($newListing);
             $newItem->setDescription(null);
             $newItem->removeDescOtherHours();
             $this->em->persist($newItem);
         }
         $this->em->flush();
         $this->em->commit();
         return $newListing;
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         $this->onError('shareListing', $e, self::class);
         throw $e;
     }
 }