コード例 #1
0
ファイル: Combine.php プロジェクト: nickschuch/tl
 protected function validateSlots($slot1, $slot2, OutputInterface $output)
 {
     if ($slot1 === $slot2) {
         throw new \InvalidArgumentException('You cannot combine a slot with itself.');
     }
     // Stop any open tickets to ensure they get an end time.
     $this->stopTicket($slot1, $output);
     // Ensure we can load both slots.
     if (!($entry1 = $this->repository->slot($slot1))) {
         throw new \InvalidArgumentException(sprintf('Invalid slot id %s', $slot1));
     }
     // Stop any open tickets to ensure they get an end time.
     $this->stopTicket($slot2, $output);
     if (!($entry2 = $this->repository->slot($slot2))) {
         throw new \InvalidArgumentException(sprintf('Invalid slot id %s', $slot2));
     }
     // Ensure we've not already sent the slots.
     if (!empty($entry1->teid) || !empty($entry1->teid)) {
         throw new \InvalidArgumentException('You cannot combine entries that have already been sent.');
     }
     // Ensure the slots are both against the same job.
     if ($entry1->tid != $entry2->tid) {
         throw new \InvalidArgumentException('You cannot combine entries from separate issues.');
     }
     return [$entry1, $entry2];
 }
コード例 #2
0
ファイル: Continues.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($slot_id = $input->getArgument('slot_id')) {
         $slot = $this->repository->slot($slot_id);
     } else {
         $slot = $this->repository->latest();
     }
     if ($slot) {
         $details = $this->connector->ticketDetails($slot->tid);
         list($slot_id, $continued) = $this->repository->start($slot->tid, $slot->comment, $slot->id);
         $output->writeln(sprintf('<bg=blue;fg=white;options=bold>[%s]</> <comment>%s</comment> entry for <info>%d</info>: %s [slot:<comment>%d</comment>]', (new \DateTime())->format('h:i'), $continued ? 'Continued' : 'Started new', $slot->tid, $details->getTitle(), $slot_id));
         return;
     }
     $output->writeln('<error>Could not find the slot to continue</error>');
 }
コード例 #3
0
ファイル: Delete.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $slot_id = $input->getArgument('slot_id');
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('Are you sure?', false);
     $confirm = NULL;
     if (($slot = $this->repository->slot($slot_id)) && ($confirm = $helper->ask($input, $output, $question)) && $this->repository->delete($slot_id)) {
         $deleted = $this->connector->ticketDetails($slot->tid);
         $output->writeln(sprintf('Deleted slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', $slot->id, $slot->tid, $deleted->getTitle(), Formatter::formatDuration($slot->end - $slot->start)));
         return;
     }
     if ($confirm !== FALSE) {
         $output->writeln('<error>Cannot delete slot, either does not exist or has been sent to back end.</error>');
     }
 }
コード例 #4
0
ファイル: Tag.php プロジェクト: nickschuch/tl
 /**
  * Tag single entry.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param $slot_id
  */
 protected function tagOne(InputInterface $input, OutputInterface $output, $slot_id)
 {
     if ($entry = $this->repository->slot($slot_id)) {
         $helper = $this->getHelper('question');
         try {
             $title = $this->connector->ticketDetails($entry->tid);
             $categories = $this->connector->fetchCategories();
         } catch (ConnectException $e) {
             $output->writeln('<error>You are offline, please try again later.</error>');
             return;
         }
         $question = new ChoiceQuestion(sprintf('Enter tag for slot <comment>%d</comment> [<info>%d</info>]: %s [<info>%s h</info>] [%s]', $entry->id, $entry->tid, $title->getTitle(), Formatter::formatDuration($entry->end - $entry->start), static::DEFAULT_TAG), $categories, static::DEFAULT_TAG);
         $tag_id = $helper->ask($input, $output, $question);
         $tag = $categories[$tag_id];
         list(, $tag) = explode(':', $tag);
         $this->repository->tag($tag, $entry->id);
     } else {
         $output->writeln('<error>No such slot - please check your slot ID</error>');
     }
 }