function handle_hook($hook, $calling_module = false, $owner_table = false, $key_name = false, $key_value = false, $rel_data = false) { switch ($hook) { case "home_alerts": $alerts = array(); if (module_config::c('allow_note_reminders', 1)) { // find any jobs that are past the due date and dont have a finished date. $key = _l('Note Reminder'); if (class_exists('module_dashboard', false)) { module_dashboard::register_group($key, array('columns' => array('name' => _l('Reminder'), 'type' => _l('Type'), 'full_link' => _l('Link'), 'date' => _l('Date'), 'days' => _l('Date')))); } $sql = "SELECT * FROM `" . _DB_PREFIX . "note` n "; $sql .= " WHERE n.`reminder` = 1 AND n.note_time < " . (int) strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days') . ""; $sql .= " AND ( n.`user_id` = 0 OR n.`user_id` = " . module_security::get_loggedin_id() . ")"; $sql .= " ORDER BY n.note_time ASC"; $tasks = qa($sql); foreach ($tasks as $task) { $alert_res = process_alert(date('Y-m-d', $task['note_time']), $key); if ($alert_res) { $alert_res['link'] = $task['rel_data']; // fix for linking when changing folder. $alert_res['type'] = _l(ucwords($task['owner_table'])); switch ($task['owner_table']) { case 'user': $user = module_user::get_user($task['owner_id']); if ($user['customer_id'] || $user['vendor_id']) { $alert_res['link'] = module_user::link_open_contact($task['owner_id'], false, $user); $alert_res['full_link'] = module_user::link_open_contact($task['owner_id'], true, $user); $alert_res['type'] = _l('Contact'); } else { $alert_res['link'] = module_user::link_open($task['owner_id'], false, $user); $alert_res['full_link'] = module_user::link_open($task['owner_id'], true, $user); } break; case 'invoice': $invoice_data = module_invoice::get_invoice($task['owner_id'], true); if (!$invoice_data || !isset($invoice_data['invoice_id']) || $invoice_data['invoice_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_invoice::link_open($task['owner_id'], false, $invoice_data); $alert_res['full_link'] = module_invoice::link_open($task['owner_id'], true, $invoice_data); break; case 'quote': $quote_data = module_quote::get_quote($task['owner_id'], true); if (!$quote_data || !isset($quote_data['quote_id']) || $quote_data['quote_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_quote::link_open($task['owner_id'], false, $quote_data); $alert_res['full_link'] = module_quote::link_open($task['owner_id'], true, $quote_data); break; case 'website': $website_data = module_website::get_website($task['owner_id']); if (!$website_data || !isset($website_data['website_id']) || $website_data['website_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_website::link_open($task['owner_id'], false); $alert_res['full_link'] = module_website::link_open($task['owner_id'], true); break; case 'customer': $customer_data = module_customer::get_customer($task['owner_id']); if (!$customer_data || !isset($customer_data['customer_id']) || $customer_data['customer_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_customer::link_open($task['owner_id'], false, $customer_data); $alert_res['full_link'] = module_customer::link_open($task['owner_id'], true, $customer_data); break; case 'vendor': $vendor_data = module_vendor::get_vendor($task['owner_id']); if (!$vendor_data || !isset($vendor_data['vendor_id']) || $vendor_data['vendor_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_vendor::link_open($task['owner_id'], false, $vendor_data); $alert_res['full_link'] = module_vendor::link_open($task['owner_id'], true, $vendor_data); break; case 'job': $job_data = module_job::get_job($task['owner_id']); if (!$job_data || !isset($job_data['job_id']) || $job_data['job_id'] != $task['owner_id']) { continue 2; } $alert_res['link'] = module_job::link_open($task['owner_id'], false, $job_data); $alert_res['full_link'] = module_job::link_open($task['owner_id'], true, $job_data); break; // todo - add others. } $alert_res['name'] = $task['note']; $alert_res['date'] = print_date($alert_res['date']); $alert_res['time'] = $task['note_time']; $alerts[] = $alert_res; } } } return $alerts; break; /*case "note_list": if($owner_id && $owner_id != 'new'){ $note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id)); foreach($note_items as &$note_item){ // do it in loop here because of $this issues in static method below. // instead of include file below. $note_item['html'] = $this->print_note($note_item['note_id']); } include("pages/note_list.php"); }else{ echo 'Please save first before creating notes.'; } break;*/ /*case "note_list": if($owner_id && $owner_id != 'new'){ $note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id)); foreach($note_items as &$note_item){ // do it in loop here because of $this issues in static method below. // instead of include file below. $note_item['html'] = $this->print_note($note_item['note_id']); } include("pages/note_list.php"); }else{ echo 'Please save first before creating notes.'; } break;*/ case "note_delete": // find the key we are saving this address against. $owner_id = (int) $key_value; if (!$owner_id || $owner_id == 'new') { // find one in the post data. if (isset($_REQUEST[$key_name])) { $owner_id = $_REQUEST[$key_name]; } } $note_hash = md5($owner_id . '|' . $owner_table); // just for posting unique arrays. if ($owner_table && $owner_id) { $this->note_delete($owner_table, $owner_id); } break; } }
} //todo: display a warning if the same email address is used within the same customer as a different contact //todo: display a warning if this email address is used as a main system "user" (similar to what we do in users anyway). } if ((int) $user_id > 0) { //handle_hook("note_list",$module,"user","user_id",$user_id); if (class_exists('module_note', false) && module_note::is_plugin_enabled()) { module_note::display_notes(array('title' => 'Contact Notes', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => $module->link_open($user_id))); } if (class_exists('module_group', false) && module_group::is_plugin_enabled()) { module_group::display_groups(array('title' => 'Contact Groups', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => module_user::link_open($user_id))); } } hook_handle_callback('layout_column_half', 2); if (is_file('includes/plugin_user/pages/user_admin_edit_login.php')) { include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_login.php'); } if (is_file('includes/plugin_user/pages/user_admin_edit_staff.php')) { include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_staff.php'); } if ($use_master_key == 'vendor_id' && is_file('includes/plugin_user/pages/user_admin_edit_company.php')) { include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_company.php'); } hook_handle_callback('layout_column_half', 'end'); $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save Contact')), array('ignore' => !((int) $user_id > 1 && module_user::can_i('delete', 'Contacts', $contact_type)), 'type' => 'delete_button', 'name' => 'butt_del_contact', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => $use_master_key == 'customer_id' ? "window.location.href='" . module_customer::link_open($user['customer_id']) . "';" : "window.location.href='" . module_vendor::link_open($user['vendor_id']) . "';"))); echo module_form::generate_form_actions($form_actions); ?> </form>
} }, 'cell_class' => 'row_action'); $columns['phone'] = array('title' => 'Phone Number', 'callback' => function ($user) { module_user::print_contact_summary($user['user_id'], 'html', array('phone|mobile')); }); $columns['email'] = array('title' => 'Email Address', 'callback' => function ($user) { module_user::print_contact_summary($user['user_id'], 'html', array('email')); }); if ($show_customer_details) { $columns['customer'] = array('title' => $contact_type_permission, 'callback' => function ($user) use($contact_module_name) { switch ($contact_module_name) { case 'customer': echo module_customer::link_open($user['customer_id'], true, $user); break; case 'vendor': echo module_vendor::link_open($user['vendor_id'], true, $user); break; } }); } if (class_exists('module_group', false) && module_user::can_i('view', 'Contact Groups')) { $columns['group'] = array('title' => 'Group', 'callback' => function ($user) { $groups = module_group::get_groups_search(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } echo implode(', ', $g); }); } $table_manager->set_columns($columns);
<a href="<?php echo module_vendor::link_open($vendor['vendor_id'], false); ?> "><?php echo htmlspecialchars($company_name); ?> </a> <?php } } else { _e('N/A'); } }); } $columns['vendor_name'] = array('title' => $page_type_single . ' Name', 'callback' => function ($vendor) { echo module_vendor::link_open($vendor['vendor_id'], true, $vendor); }, 'cell_class' => 'row_action'); $columns['primary_contact_name'] = array('title' => 'Primary Contact', 'callback' => function ($vendor) { if ($vendor['primary_user_id']) { echo module_user::link_open_contact($vendor['primary_user_id'], true); } else { echo ''; } }); $columns['phone_number'] = array('title' => 'Phone Number', 'callback' => function ($vendor) { if ($vendor['primary_user_id']) { module_user::print_contact_summary($vendor['primary_user_id'], 'html', array('phone|mobile')); } else { echo ''; } });