static function getServiceSelect($selected = -1) { $services = CustomerManagementDao::findAllServices(); $output = '<select id="cm_plugin_service_id" name="cm_plugin_service_id"><option value=""></option>'; foreach ($services as $service) { $selected_attr = $selected == $service['id'] ? ' selected="selected" ' : ''; $output .= "<option value=\"{$service['id']}\" {$selected_attr}>{$service['name']}</option>"; } $output .= '</select>'; return $output; }
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) { $isBillable = CustomerManagementDao::getService($bugData['is_billable']); echo string_display_line($isBillable ? lang_get('yes') : lang_get('no')); } } plugin_pop_current(); }
function options() { plugin_push_current('CustomerManagement'); if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) { $options = array(); foreach (CustomerManagementDao::findAllGroups() as $group) { $options[$group['id']] = $group['name']; } } plugin_pop_current(); return $options; }
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) { $group = CustomerManagementDao::getGroupForCustomer($bugData['customer_id']); echo string_display_line($group['name']); } } plugin_pop_current(); }
function query($p_filter_input) { $is_billable = $p_filter_input[0]; if (!is_numeric($is_billable)) { return; } plugin_push_current('CustomerManagement'); if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) { $t_query = CustomerManagementDao::buildFilterArrayForIsBillable($is_billable == 1 ? 1 : 0); } plugin_pop_current(); return $t_query; }
function query($p_filter_input) { $invoice = $p_filter_input; if (is_blank($invoice)) { return; } plugin_push_current('CustomerManagement'); if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) { $t_query = CustomerManagementDao::buildFilterArrayForInvoice($invoice); } plugin_pop_current(); return $t_query; }
/** * 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; }
set_error_handler('json_error_handler'); access_ensure_global_level(plugin_config_get('manage_customers_threshold')); form_security_validate('manage_customers'); $contents = ''; switch ($_POST['action']) { case 'deleteGroup': CustomerManagementDao::deleteGroup(gpc_get_int('customerGroupId')); break; case 'deleteService': CustomerManagementDao::deleteService(gpc_get_int('serviceId')); break; case 'deleteCustomer': CustomerManagementDao::deleteCustomer(gpc_get_int('customerId')); break; case 'saveGroup': CustomerManagementDao::saveGroup(gpc_get_int('id', null), gpc_get_string('name')); break; case 'saveService': CustomerManagementDao::saveService(gpc_get_int('id', null), gpc_get_string('name')); break; case 'saveCustomer': CustomerManagementDao::saveCustomer(gpc_get_int('id', null), gpc_get_string('name'), gpc_get_int('customer_group_id'), gpc_get_string('email'), gpc_get_int_array('service_id', array())); break; case 'sendNotification': CustomerNotifier::notifyCustomers(gpc_get_int_array('customer_id'), gpc_get_string('from'), gpc_get_string('to')); break; case 'previewNotification': $contents = CustomerNotifier::buildNotificationEmails(gpc_get_int_array('customer_id'), gpc_get_string('from'), gpc_get_string('to')); break; } echo json_output_response($contents);
echo $group['id']; ?> "><?php echo $group['name']; ?> </option> <?php } ?> </select> <br /> <label for="service_id[]"><?php echo plugin_lang_get('services'); ?> </label> <select name="service_id[]" multiple="multiple"> <?php foreach (CustomerManagementDao::findAllServices() as $service) { ?> <option value="<?php echo $service['id']; ?> "><?php echo $service['name']; ?> </option> <?php } ?> </select> </form> <script>
public function delete_bug($p_event, $p_bug_id) { CustomerManagementDao::deleteBugData($p_bug_id); }