function display($p_filter_value)
 {
     plugin_push_current('CustomerManagement');
     if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) {
         if (is_numeric($p_filter_value)) {
             $customer = CustomerManagementDao::getCustomer((int) $p_filter_value);
             return string_display_line($customer['name']);
         }
     }
     plugin_pop_current();
 }
 public function display($p_bug, $p_columns_target)
 {
     plugin_push_current('CustomerManagement');
     if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) {
         $bugData = CustomerManagementDao::getBugData($p_bug->id);
         if (count($bugData) > 0) {
             $customer = CustomerManagementDao::getCustomer($bugData['customer_id']);
             echo string_display_line($customer['name']);
         }
     }
     plugin_pop_current();
 }
 /**
  * Builds notification emails for the selected customers about changes made in bugs reports they are linked to
  *
  * @param array $customer_ids the ids of the customer to notify
  * @param string $from the start of the interval
  * @param string $to the end of the interval
  *
  * @return array notified customers
  */
 static function buildNotificationEmails($customer_ids, $from, $to)
 {
     $emails = array();
     lang_push(plugin_config_get('email_notification_language'));
     $fromDate = self::startOfDay(strtotime($from));
     $toDate = self::endOfDay(strtotime($to));
     $changedBugIds = CustomerManagementDao::findAllChangedBugIds($customer_ids, $fromDate, $toDate);
     $dateFormat = config_get('short_date_format');
     foreach ($customer_ids as $customer_id) {
         $changesForCustomer = array();
         foreach ($changedBugIds as $changedBugId) {
             if ($changedBugId['customer_id'] == $customer_id) {
                 $changesForCustomer[] = array('bug' => bug_get($changedBugId['bug_id']));
             }
         }
         if (count($changesForCustomer) > 0) {
             $counter = 0;
             $text = '';
             foreach ($changesForCustomer as $changeForCustomer) {
                 $counter++;
                 $bugId = $changeForCustomer['bug']->id;
                 $text .= $counter . '. ';
                 $text .= sprintf(plugin_lang_get('email_notification_bug_header'), $changeForCustomer['bug']->id, $changeForCustomer['bug']->summary, date($dateFormat, $changeForCustomer['bug']->date_submitted), get_enum_element('status', $changeForCustomer['bug']->status));
                 $text .= "\n";
                 $reporterName = user_get_name($changeForCustomer['bug']->reporter_id);
                 $reporterEmail = user_get_email($changeForCustomer['bug']->reporter_id);
                 $text .= sprintf(plugin_lang_get('email_notification_bug_reported_by'), $reporterName, $reporterEmail);
                 $text .= "\n";
                 $text .= sprintf(plugin_lang_get('email_notification_bug_description'), $changeForCustomer['bug']->description);
                 $text .= "\n\n";
             }
             $customer = CustomerManagementDao::getCustomer($customer_id);
             $email = new EmailData();
             $email->email = $customer['email'];
             $email->subject = sprintf(plugin_lang_get('email_notification_title'), $customer['name'], $from, $to);
             $email->body = $text;
             $email->metadata['priority'] = config_get('mail_priority');
             $email->metadata['charset'] = 'utf-8';
             array_push($emails, $email);
         }
     }
     lang_pop();
     return $emails;
 }
    public function view_bug_details($p_event, $p_bug_id)
    {
        if (!access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) {
            return;
        }
        $bug_data = CustomerManagementDao::getBugData($p_bug_id);
        if (!$bug_data) {
            return;
        }
        $class = helper_alternate_class();
        $class2 = helper_alternate_class();
        $customer_label = plugin_lang_get('customer');
        $service_label = plugin_lang_get('service');
        $is_billable_label = plugin_lang_get('is_billable');
        $invoice_label = plugin_lang_get('invoice');
        $show_invoice = bug_get_field($p_bug_id, 'status') >= plugin_config_get('display_invoice_field_status_threshold');
        $customer = CustomerManagementDao::getCustomer($bug_data['customer_id']);
        $service = CustomerManagementDao::getService($bug_data['service_id']);
        $is_billable = $bug_data['is_billable'] ? lang_get('yes') : lang_get('no');
        if ($bug_data) {
            $row = <<<EOD
<tr {$class}>
\t<td class="category">{$customer_label}</td>
\t<td>{$customer['name']}</td>
\t<td class="category">{$service_label}</td>
\t<td>{$service['name']}</td>
\t<td class="category">{$is_billable_label}</td>
\t<td>{$is_billable}</td>
</tr>
EOD;
            if ($show_invoice) {
                $row .= <<<EOD
<tr {$class}>
\t<td class="category">{$invoice_label}</td>
\t<td>{$bug_data['invoice']}</td>
\t<td class="category">&nbsp;</td>
\t<td>&nbsp;</td>
\t<td class="category">&nbsp;</td>
\t<td>&nbsp;</td>
</tr>\t\t\t\t
EOD;
            }
            echo $row;
        }
    }