コード例 #1
0
ファイル: Combine.php プロジェクト: nickschuch/tl
 protected function stopTicket($slot_id, OutputInterface $output)
 {
     if ($stop = $this->repository->stop($slot_id)) {
         $stopped = $this->connector->ticketDetails($stop->tid);
         $output->writeln(sprintf('Closed slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', $stop->id, $stop->tid, $stopped->getTitle(), Formatter::formatDuration($stop->duration)));
     }
 }
コード例 #2
0
ファイル: Stop.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($stop = $this->repository->stop()) {
         $stopped = $this->connector->ticketDetails($stop->tid);
         $output->writeln(sprintf('<bg=blue;fg=white;options=bold>[%s]</> Closed slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', (new \DateTime())->format('h:i'), $stop->id, $stop->tid, $stopped->getTitle(), Formatter::formatDuration($stop->duration)));
         if (($comment = $input->getOption('comment')) || $input->getOption('pause')) {
             if ($this->connector->pause($stop->tid, $comment)) {
                 $output->writeln(sprintf('Ticket <comment>%s</comment> set to paused.', $stop->tid));
             } else {
                 $output->writeln('<error>Could not update ticket status</error>');
             }
         }
         return;
     }
     $output->writeln('<error>No active slot</error>');
 }
コード例 #3
0
ファイル: Start.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $ticket_id = $input->getArgument('issue_number');
     if ($alias = $this->repository->loadAlias($ticket_id)) {
         $ticket_id = $alias;
     }
     if ($title = $this->connector->ticketDetails($ticket_id)) {
         if ($stop = $this->repository->stop()) {
             $stopped = $this->connector->ticketDetails($stop->tid);
             $output->writeln(sprintf('Closed slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', $stop->id, $stop->tid, $stopped->getTitle(), Formatter::formatDuration($stop->duration)));
         }
         try {
             list($slot_id, $continued) = $this->repository->start($ticket_id, $input->getArgument('comment'));
             $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', $ticket_id, $title->getTitle(), $slot_id));
             if ($input->getOption('status')) {
                 if ($this->connector->setInProgress($ticket_id, $assign = $input->getOption('assign'))) {
                     $output->writeln(sprintf('Ticket <comment>%s</comment> set to in-progress.', $ticket_id));
                     if ($assign) {
                         $output->writeln(sprintf('Ticket <comment>%s</comment> assigned to you.', $ticket_id));
                     }
                 } else {
                     $output->writeln('<error>Could not update ticket status</error>');
                     if ($assign) {
                         $output->writeln('<error>Could not assign ticket</error>');
                     }
                 }
             } elseif ($input->getOption('assign')) {
                 if ($this->connector->assign($ticket_id)) {
                     $output->writeln(sprintf('Ticket <comment>%s</comment> assigned to you.', $ticket_id));
                 } else {
                     $output->writeln('<error>Could not assign ticket</error>');
                 }
             }
         } catch (\Exception $e) {
             $output->writeln(sprintf('<error>Error creating slot: %s</error>', $e->getMessage()));
         }
     } else {
         $output->writeln('<error>Error: no such ticket id or access denied</error>');
     }
 }