コード例 #1
0
ファイル: Tag.php プロジェクト: nickschuch/tl
 /**
  * Tag all entries.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function tagAll(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $last = FALSE;
     try {
         $entries = $this->repository->review(Review::ALL, TRUE);
         $categories = $this->connector->fetchCategories();
     } catch (ConnectException $e) {
         $output->writeln('<error>You are offline, please try again later.</error>');
         return;
     }
     foreach ($entries as $entry) {
         if ($entry->category && !$input->getOption('retag')) {
             continue;
         }
         $title = $this->connector->ticketDetails($entry->tid);
         $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(), $entry->duration, $last ?: static::DEFAULT_TAG), $categories, $last ?: static::DEFAULT_TAG);
         $tag_id = $helper->ask($input, $output, $question);
         $tag = $categories[$tag_id];
         list(, $tag) = explode(':', $tag);
         $this->repository->tag($tag, $entry->id);
         $last = $tag_id;
     }
     if (!$last) {
         $output->writeln('<error>All items already tagged, use --retag to retag</error>');
     }
 }
コード例 #2
0
ファイル: Reviewer.php プロジェクト: nickschuch/tl
 public function getSummary($date = 19780101, $check = FALSE, $exact = FALSE)
 {
     $data = $this->repository->review($date, $check);
     if (count($data) == 0 && !$check) {
         throw new \Exception('All entries stored in remote system');
     }
     $total = 0;
     $offline = FALSE;
     try {
         $categories = $this->connector->fetchCategories();
     } catch (ConnectException $e) {
         $offline = TRUE;
     }
     $exact_total = 0;
     foreach ($data as $record) {
         $total += $record->duration;
         $details = $this->connector->ticketDetails($record->tid);
         $category_id = str_pad($record->category, 3, 0, STR_PAD_LEFT);
         $category = '';
         if ($record->category) {
             if ($offline) {
                 $category = 'Offline';
             } elseif (isset($categories[$category_id])) {
                 $category = $categories[$category_id];
             } else {
                 $category = 'Unknown';
             }
         }
         $row = [$record->id, $record->tid, $record->duration];
         if ($exact) {
             $row[] = Formatter::formatDuration($record->end - $record->start);
             $exact_total += $record->end - $record->start;
         }
         $row = array_merge($row, [substr($details->getTitle(), 0, 25) . '...', $category, $record->comment]);
         $rows[] = $row;
     }
     $rows[] = new TableSeparator();
     if ($exact) {
         $rows[] = ['', '<comment>Total</comment>', '<info>' . $total . ' h</info>', '<info>' . Formatter::formatDuration($exact_total) . '</info>', '', '', ''];
     } else {
         $rows[] = ['', '<comment>Total</comment>', '<info>' . $total . ' h</info>', '', '', ''];
     }
     return $rows;
 }
コード例 #3
0
ファイル: Comment.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $entries = $this->repository->review(Review::ALL, TRUE);
     $helper = $this->getHelper('question');
     $last = FALSE;
     foreach ($entries as $entry) {
         if ($entry->comment && !$input->getOption('recomment')) {
             continue;
         }
         $title = $this->connector->ticketDetails($entry->tid);
         $question = new Question(sprintf('Enter comment for slot <comment>%d</comment> [<info>%d</info>]: %s [<info>%s h</info>] [%s]', $entry->id, $entry->tid, $title->getTitle(), $entry->duration, $last ?: static::DEFAULT_COMMENT), $last ?: static::DEFAULT_COMMENT);
         $comment = $helper->ask($input, $output, $question);
         $this->repository->comment($entry->id, $comment);
         $last = $comment;
     }
     if (!$last) {
         $output->writeln('<error>All items already commented, use --recomment to recomment</error>');
     }
 }
コード例 #4
0
ファイル: TagAll.php プロジェクト: nickschuch/tl
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $entries = $this->repository->review(Review::ALL, TRUE);
     $helper = $this->getHelper('question');
     $last = FALSE;
     $categories = $this->connector->fetchCategories();
     $question = new ChoiceQuestion(sprintf('Select tag to use:[%s]', $last ?: Tag::DEFAULT_TAG), $categories, $last ?: Tag::DEFAULT_TAG);
     $tag_id = $helper->ask($input, $output, $question);
     $tag = $categories[$tag_id];
     list(, $tag) = explode(':', $tag);
     foreach ($entries as $entry) {
         if ($entry->category) {
             continue;
         }
         $this->repository->tag($tag, $entry->id);
         $last = $tag;
     }
     if (!$last) {
         $output->writeln('<error>All items already tagged, use --retag to retag</error>');
     }
 }