static function getCustomerSelect($selected = -1) { $customers = CustomerManagementDao::findAllCustomers(); $output = '<select id="cm_plugin_customer_id" name="cm_plugin_customer_id"><option value=""></option>'; foreach ($customers as $customer) { $selected_attr = $selected == $customer['id'] ? ' selected="selected" ' : ''; $output .= "<option value=\"{$customer['id']}\" {$selected_attr}>{$customer['name']}</option>"; } $output .= '</select>'; return $output; }
function options() { plugin_push_current('CustomerManagement'); if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) { $options = array(); foreach (CustomerManagementDao::findAllCustomers() as $customer) { $options[$customer['id']] = $customer['name']; } } plugin_pop_current(); return $options; }
<?php require_once 'core.php'; access_ensure_global_level(plugin_config_get('manage_customers_threshold')); html_page_top(plugin_lang_get('manage_customers')); print_manage_menu(plugin_page('manage_customers')); $groups = CustomerManagementDao::findAllGroups(); $customers = CustomerManagementDao::findAllCustomers(); ?> <style type="text/css"> .ui-dialog-content label { display: inline-block; width: 60px; margin-left: 10px; vertical-align: top; } .ui-dialog-content input, .ui-dialog-content select { width: 180px; } </style> <h1><?php echo plugin_lang_get('manage_customers'); ?> </h1> <div id="tabs"> <ul> <li><a href="#customers"><?php echo plugin_lang_get('customers'); ?>
private function prepage_bug_report_internal($verticalLayout, $bug_id = 0) { if (!access_has_global_level(plugin_config_get('edit_customer_fields_threshold'))) { return; } $customer_id = 0; $service_id = 0; $is_billable = 0; $invoice = ''; $show_invoice = false; if ($bug_id) { $bug = bug_get($bug_id); $show_invoice = $bug->status >= plugin_config_get('display_invoice_field_status_threshold'); $bug_data = CustomerManagementDao::getBugData($bug_id); if ($bug_data) { $customer_id = $bug_data['customer_id']; $service_id = $bug_data['service_id']; $is_billable = $bug_data['is_billable'] == 1; $invoice = $bug_data['invoice']; } } $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'); $class = helper_alternate_class(); $class2 = helper_alternate_class(); $class3 = helper_alternate_class(); $class4 = helper_alternate_class(); $customer_select = CustomerManagementViewHelper::getCustomerSelect($customer_id); $service_select = CustomerManagementViewHelper::getServiceSelect($service_id); $is_billable_checkbox = CustomerManagementViewHelper::getBillableCheckbox($is_billable); $invoice_input = CustomerManagementViewHelper::getInvoiceInput($invoice); $customers = CustomerManagementDao::findAllCustomers(); $customersToServices = array(); foreach ($customers as $customer) { $serviceIds = array(); foreach ($customer['services'] as $service) { $serviceIds[] = $service['id']; } $customersToServices[$customer['id']] = $serviceIds; } $customersToServicesJson = json_encode($customersToServices); $prependCustomerName = $bug_id === 0 && plugin_config_get('auto_prepend_customer_name_to_summary'); if ($verticalLayout) { $row = <<<EOD <tr {$class}> \t<td class="category" width="30%"> \t\t{$customer_label} \t</td> \t<td width="70%"> \t\t{$customer_select} \t</td> </tr> <tr {$class2}> \t<td class="category" width="30%"> \t\t{$service_label} \t</td> \t<td width="70%"> \t\t{$service_select} \t</td> </tr> <tr {$class3}> \t<td class="category" width="30%"> \t\t{$is_billable_label} \t</td> \t<td width="70%"> \t\t{$is_billable_checkbox} \t</td> </tr> EOD; if ($show_invoice) { $row .= <<<EOD <tr {$class4}> \t<td class="category" width="30%"> \t\t{$invoice_label} \t</td> \t<td width="70%"> \t\t{$invoice_input} \t</td> </tr> EOD; } } else { $row = <<<EOD <tr {$class}> \t<td class="category"> \t\t{$customer_label} \t</td> \t<td> \t\t{$customer_select} \t</td> \t<td class="category"> \t\t{$service_label} \t</td> \t<td> \t\t{$service_select} \t</td> \t<td class="category"> \t\t{$is_billable_label} \t</td> \t<td> \t\t{$is_billable_checkbox} \t</td> </tr> EOD; if ($show_invoice) { $row .= <<<EOD <tr {$class2}> \t<td class="category"> \t\t{$invoice_label} \t</td> \t<td> \t\t{$invoice_input} \t</td> \t<td class="category"> \t\t \t</td> \t<td> \t\t \t</td> \t<td class="category"> \t\t \t</td> \t<td> \t\t \t</td> </tr> EOD; } } $row .= <<<EOD <script type="text/javascript"> var customerManagementBugUi = new CustomerManagementBugUi({$customersToServicesJson}); customerManagementBugUi.init({'prependCustomerName' : '{$prependCustomerName}'}); </script>\t\t EOD; echo $row; }