<commit_before><?php

class CRM_Timetrack_Case_Page_CaseView {
  /**
   * Implements hook_civicrm_caseSummary().
   */
  function caseSummary($case_id) {
    $summary = array();

    CRM_Core_Resources::singleton()->addStyleFile('ca.bidon.timetrack', 'css/crm-timetrack-case-page-caseview.css');

    $dao = CRM_Core_DAO::executeQuery('SELECT * FROM kcontract WHERE case_id = %1', array(
      1 => array($case_id, 'Positive'),
    ));

    if ($dao->fetch()) {
      $actions = array(
        array(
          'label' => ts('Add punch'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/punch', array('reset' => 1, 'cid' => $case_id, 'action' => 'create')),
          'classes' => 'icon add-icon',
        ),
        array(
          'label' => ts('Add task'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/task', array('reset' => 1, 'cid' => $case_id, 'action' => 'create')),
          'classes' => 'icon add-icon',
        ),
        array(
          'label' => ts('View/invoice punches'),
          'url' => CRM_Utils_System::url('civicrm/contact/search/custom', array('csid' => 16, 'case_id' => $case_id, 'force' => 1, 'crmSID' => '6_d')),
          'classes' => 'icon search-icon',
        ),
        array(
          'label' => ts('Invoice other items'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/invoice', array('case_id' => $case_id, 'reset' => 1)),
          'classes' => 'icon add-icon',
        ),
      );

      $actions_html = '';

      foreach ($actions as $key => $action) {
        $actions_html .= "<a href='{$action['url']}' class='button'><span><div class='{$action['classes']}'></div>{$action['label']}</span></a>";
      }

      $summary['timetrack_actions'] = array(
        'label' => ts('Time tracking:'),
        'value' => '<div>' . $actions_html . '</div>',
      );

      $summary['timetrack_billing_status'] = array(
        'label' => ts('Billing status'),
        'value' => ts('%1 unbilled hour(s)', array(1 => CRM_Timetrack_Utils::roundUpSeconds($this->getUnbilledHours($case_id)))),
      );

      $summary['timetrack_tasks'] = array(
        'label' => '',
        'value' => $this->getListOfTasks($case_id),
      );

      $summary['timetrack_invoices'] = array(
        'label' => '',
        'value' => $this->getListOfInvoice($case_id),
      );
    }
    else {
      $summary['timetrack_warning'] = array(
        'label' => ts('Timetrack:'),
        'value' => '<strong>None found. Either you need to add the node_id of the kcontract in the custom field of this case, or you need to create a <a href="/node/add/kcontract">new kcontract</a>.</strong>',
      );
    }

    return $summary;
  }
<commit_msg>CRM/Timetrack/Case/Page/CaseView.php: change the message if no kcontract was found for the case.<commit_after><?php

class CRM_Timetrack_Case_Page_CaseView {
  /**
   * Implements hook_civicrm_caseSummary().
   */
  function caseSummary($case_id) {
    $summary = array();

    CRM_Core_Resources::singleton()->addStyleFile('ca.bidon.timetrack', 'css/crm-timetrack-case-page-caseview.css');

    $dao = CRM_Core_DAO::executeQuery('SELECT * FROM kcontract WHERE case_id = %1', array(
      1 => array($case_id, 'Positive'),
    ));

    if ($dao->fetch()) {
      $actions = array(
        array(
          'label' => ts('Add punch'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/punch', array('reset' => 1, 'cid' => $case_id, 'action' => 'create')),
          'classes' => 'icon add-icon',
        ),
        array(
          'label' => ts('Add task'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/task', array('reset' => 1, 'cid' => $case_id, 'action' => 'create')),
          'classes' => 'icon add-icon',
        ),
        array(
          'label' => ts('View/invoice punches'),
          'url' => CRM_Utils_System::url('civicrm/contact/search/custom', array('csid' => 16, 'case_id' => $case_id, 'force' => 1, 'crmSID' => '6_d')),
          'classes' => 'icon search-icon',
        ),
        array(
          'label' => ts('Invoice other items'),
          'url' => CRM_Utils_System::url('civicrm/timetrack/invoice', array('case_id' => $case_id, 'reset' => 1)),
          'classes' => 'icon add-icon',
        ),
      );

      $actions_html = '';

      foreach ($actions as $key => $action) {
        $actions_html .= "<a href='{$action['url']}' class='button'><span><div class='{$action['classes']}'></div>{$action['label']}</span></a>";
      }

      $summary['timetrack_actions'] = array(
        'label' => ts('Time tracking:'),
        'value' => '<div>' . $actions_html . '</div>',
      );

      $summary['timetrack_billing_status'] = array(
        'label' => ts('Billing status'),
        'value' => ts('%1 unbilled hour(s)', array(1 => CRM_Timetrack_Utils::roundUpSeconds($this->getUnbilledHours($case_id)))),
      );

      $summary['timetrack_tasks'] = array(
        'label' => '',
        'value' => $this->getListOfTasks($case_id),
      );

      $summary['timetrack_invoices'] = array(
        'label' => '',
        'value' => $this->getListOfInvoice($case_id),
      );
    }
    else {
      // TODO: we should probably have a way to enable/disable timetracking per case type.
      // so that if we don't find any info, it's perfectly normal to have an option to edit.
      $summary['timetrack_warning'] = array(
        'label' => ts('Timetrack:'),
        'value' => 'No timetracking information was found for this case.',
      );
    }

    return $summary;
  }

{'fraction_non_alphanumeric': 0.1976112920738328, 'fraction_numerical': 0.003981179876945349, 'mean_word_length': 2.767552828902522, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997939', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1833, 'n_words': 349}