public function ajax_search($search_key) { // return results based on an ajax search. $ajax_results = array(); $search_key = trim($search_key); if (strlen($search_key) > module_config::c('search_ajax_min_length', 2)) { //$sql = "SELECT * FROM `"._DB_PREFIX."vendor` c WHERE "; //$sql .= " c.`vendor_name` LIKE %$search_key%"; //$results = qa($sql); $results = $this->get_vendors(array('generic' => $search_key)); if (count($results)) { foreach ($results as $result) { // what part of this matched? if (preg_match('#' . preg_quote($search_key, '#') . '#i', $result['name']) || preg_match('#' . preg_quote($search_key, '#') . '#i', $result['last_name']) || preg_match('#' . preg_quote($search_key, '#') . '#i', $result['phone'])) { // we matched the vendor contact details. $match_string = _l('Vendor Contact: '); $match_string .= _shl($result['vendor_name'], $search_key); $match_string .= ' - '; $match_string .= _shl($result['name'], $search_key); // hack $_REQUEST['vendor_id'] = $result['vendor_id']; $ajax_results[] = '<a href="' . module_user::link_open_contact($result['user_id']) . '">' . $match_string . '</a>'; } else { $match_string = _l('Vendor: '); $match_string .= _shl($result['vendor_name'], $search_key); $ajax_results[] = '<a href="' . $this->link_open($result['vendor_id']) . '">' . $match_string . '</a>'; //$ajax_results [] = $this->link_open($result['vendor_id'],true); } } } } return $ajax_results; }
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; } }
?> "> <?php } ?> <?php $search_bar = array('elements' => array('name' => array('title' => _l('Contact Name, Email or Phone Number:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '', 'size' => 30)))); echo module_form::search_bar($search_bar); /** START TABLE LAYOUT **/ $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['name'] = array('title' => 'Name', 'callback' => function ($user) { echo module_user::link_open_contact($user['user_id'], true, $user); if ($user['is_primary'] == $user['user_id']) { echo ' *'; } }, '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);
$c[$row['user_id']] = $row['name'] . ' ' . $row['last_name']; } if ($ticket['user_id'] && !isset($c[$ticket['user_id']])) { // this option isn't in the listing. add it in. $user_temp = module_user::get_user($ticket['user_id'], false); $c[$ticket['user_id']] = $user_temp['name'] . ' ' . $user_temp['last_name']; if ($user_temp['customer_id'] >= 0) { $c[$ticket['user_id']] .= ' ' . _l('(under different customer)'); } else { // user not assigned to a customer. } } echo '<a name="#change_contact"></a>'; echo print_select_box($c, 'change_user_id', $ticket['user_id']); } else { echo module_user::link_open_contact($ticket['user_id'], true); if (module_ticket::can_edit_tickets()) { echo ' '; echo '<a href="' . module_ticket::link_open($ticket_id) . '&show_change_contact#change_contact">' . _l('Change') . '</a>'; } } /* $c = array(); $res = module_user::get_users(array('customer_id'=>$ticket['customer_id'])); while($row = array_shift($res)){ $c[$row['user_id']] = $row['name']; } if(false && module_ticket::can_i('edit','Related to')){ echo print_select_box($c,'user_id',$ticket['user_id']); }else if($ticket['user_id']){ echo isset($c[$ticket['user_id']]) ? $c[$ticket['user_id']] : 'N/A';
if (isset($user['customer_id']) && $user['customer_id'] || isset($user['vendor_id']) && $user['vendor_id']) { // we have a contact! die('Wrong file'); } else { $use_master_key = false; // we have a normal site user.. } // find a contact with matching email address. if (isset($user['email']) && strlen($user['email']) > 3) { $contacts = module_user::get_contacts(array('email' => $user['email'])); if (count($contacts) > 0) { foreach ($contacts as $c) { ?> <div class="warning"><?php _e('Warning: a contact from the Customer %s exists with this same email address: %s <br/>This may create problems when trying to login. <br/>We suggest you remove/change THIS user account and use the existing CONTACT account instead.', module_customer::link_open($c['customer_id'], true), module_user::link_open_contact($c['user_id'], true)); ?> </div> <?php } } } ?> <form action="" method="post" autocomplete="off"> <input type="hidden" name="_process" value="save_user" /> <!-- <input type="hidden" name="_redirect" value="<?php echo $module->link("", array("saved" => true, "user_id" => (int) $user_id ? $user_id : ''));
} } else { if ($use_master_key == 'vendor_id') { $vendor_data = module_vendor::get_vendor($user[$use_master_key]); if ($vendor_data['primary_user_id'] == $user_id) { $primary = true; } } } if ($primary && !isset($hide_more_button)) { $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($user_id, false)); } $fieldset_data['elements']['primary'] = array('title' => 'Primary', 'fields' => array(array('type' => 'check', 'name' => 'customer_primary', 'value' => '1', 'checked' => $primary), _hr('This users details will be used as a primary point of contact for this customer. These details will display in the main customer listing for this customer. Also if you send an invoice or a newsletter to this "customer" then this email address will be used.'))); } else { if (isset($show_more_button) && $show_more_button) { $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($user_id, false)); } } $fieldset_data['elements']['fname'] = array('title' => 'First Name', 'fields' => array(array('type' => 'text', 'name' => 'name', 'value' => $user['name']))); $fieldset_data['elements']['last_name'] = array('title' => 'Last Name', 'fields' => array(array('type' => 'text', 'name' => 'last_name', 'value' => $user['last_name']))); $fieldset_data['elements']['email'] = array('title' => 'Email Address', 'fields' => array(array('type' => 'text', 'name' => 'email', 'value' => $user['email']))); $fieldset_data['elements']['phone'] = array('title' => 'Phone', 'fields' => array(array('type' => 'text', 'name' => 'phone', 'value' => $user['phone']))); $fieldset_data['elements']['mobile'] = array('title' => 'Mobile', 'fields' => array(array('type' => 'text', 'name' => 'mobile', 'value' => $user['mobile']))); $fieldset_data['elements']['fax'] = array('title' => 'Fax', 'fields' => array(array('type' => 'text', 'name' => 'fax', 'value' => $user['fax']))); if (class_exists('module_language', false) && isset($user['language'])) { $attr = array(); foreach (module_language::get_languages_attributes() as $langauge) { $attr[$langauge['language_code']] = $langauge['language_name']; } $fieldset_data['elements']['language'] = array('title' => 'Language', 'fields' => array(array('type' => 'select', 'name' => 'language', 'options' => $attr, 'value' => $user['language']))); }
echo htmlspecialchars($company_name); ?> </a> <?php } } else { _e('N/A'); } }); } $columns['customer_name'] = array('title' => $page_type_single . ' Name', 'callback' => function ($customer) { echo module_customer::link_open($customer['customer_id'], true, $customer); }, 'cell_class' => 'row_action'); $columns['primary_contact_name'] = array('title' => 'Primary Contact', 'callback' => function ($customer) { if ($customer['primary_user_id']) { echo module_user::link_open_contact($customer['primary_user_id'], true); } else { echo ''; } }); $columns['phone_number'] = array('title' => 'Phone Number', 'callback' => function ($customer) { if ($customer['primary_user_id']) { module_user::print_contact_summary($customer['primary_user_id'], 'html', array('phone|mobile')); } else { echo ''; } }); $columns['date_created'] = array('title' => 'Date Created', 'callback' => function ($customer) { if ($customer['primary_user_id']) { module_user::print_contact_summary($customer['primary_user_id'], 'html', array('date_created')); } else {
public static function process_password_reset() { // grab our email template and send it to this email address. $email = trim(strtolower($_REQUEST['email'])); $success = false; if (strlen($email) > 4 && strpos($email, '@')) { $users = module_user::get_users(array('email' => $email)); $contacts = module_user::get_contacts(array('email' => $email)); $users = array_merge($users, $contacts); foreach ($users as $user) { // send auto login link for this user. if (strtolower($user['email']) == $email) { $template = module_template::get_template_by_key('password_reset'); $template->assign_values($user); if ($user['customer_id']) { $url = module_user::link_open_contact($user['user_id'], false, $user, true); } else { $url = module_user::link_open($user['user_id'], false, $user, true); } $url .= (strpos($url, '?') ? '&' : '?') . 'reset_password='******'user_id']); $url .= '&auto_login='******'user_id']); $template->assign_values(array('auto_login_url' => $url)); $html = $template->render('html'); $email = module_email::new_email(); $email->replace_values = $user; $email->set_to('user', $user['user_id']); $email->set_subject($template->description); // do we send images inline? $email->set_html($html); if ($email->send()) { // it worked successfully!! $success = true; } else { /// log err? echo 'failed to send email, sorry'; exit; } } } } if ($success || !module_config::c('password_reset_debug', 0)) { set_message('Please check your email for password reset instructions.'); } else { echo 'No users found matching ' . htmlspecialchars($email); exit; } redirect_browser(_BASE_HREF); }
/** * @static * @param $args * @return array * * The newsletter system requests updated customer / user data from this group plugin. * It does this when building the member list, and also */ public static function newsletter_callback($args) { if (!isset($args['owner_table']) || !$args['owner_table']) { return array(); } switch ($args['owner_table']) { case 'user': if ((int) $args['owner_id'] > 0) { $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name"; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " ,c.credit "; $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= ' FROM `' . _DB_PREFIX . "user` pu"; $sql .= " LEFT JOIN `" . _DB_PREFIX . "customer` c ON pu.customer_id = c.customer_id"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= " WHERE pu.user_id = " . (int) $args['owner_id']; $user = qa1($sql); if (!is_array($user) || !isset($user['user_id']) || !$user['user_id']) { return false; } if (isset($args['basic']) && $args['basic']) { return $user; } // $name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name'])); // $user['first_name'] = array_shift($name_parts); // $user['last_name'] = implode(' ',$name_parts); // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } // get extras for the customer. if (isset($user['customer_id']) && $user['customer_id'] > 0) { $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } if ($user['customer_id']) { $user['_edit_link'] = module_user::link_open_contact($user['user_id'], false, $user); } else { $user['_edit_link'] = module_user::link_open($user['user_id'], false, $user); } return $user; } break; case 'customer': if (module_config::c('newsletter_send_all_customer_contacts', 1)) { // update - we use the above 'user' callback and return a listing for each contact in the array. // using the special _multi flag hack to tell our newsletter plugin that this result contains multiple entries. $users = array('_multi' => true); $sql = "SELECT u.user_id FROM `" . _DB_PREFIX . "user` u WHERE u.customer_id = " . (int) $args['owner_id']; $contacts = qa($sql); foreach ($contacts as $contact) { $data_args = array('owner_id' => $contact['user_id'], 'owner_table' => 'user'); $users[$contact['user_id']] = self::newsletter_callback($data_args); if ($users[$contact['user_id']]) { $users[$contact['user_id']]['data_args'] = json_encode($data_args); } } return $users; } else { $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name"; $sql .= " ,c.credit "; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= " FROM `" . _DB_PREFIX . "customer` c "; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id"; $sql .= " WHERE c.customer_id = " . (int) $args['owner_id']; $user = qa1($sql); if (!$user || !isset($user['customer_id'])) { return array(); } //$name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name'])); //$user['first_name'] = array_shift($name_parts); //$user['last_name'] = implode(' ',$name_parts); if (isset($args['basic']) && $args['basic']) { return $user; } // get extras for the customer. $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } if (isset($user['user_id']) && $user['user_id'] > 0) { // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user); return $user; } case 'website': $sql = "SELECT c.customer_name AS company_name"; $sql .= " ,c.credit "; $sql .= " ,w.name AS website_name"; $sql .= " ,w.url AS website_url"; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " , pu.name AS user_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= " FROM `" . _DB_PREFIX . "website` w "; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "customer` c ON w.customer_id = c.customer_id"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id"; $sql .= " WHERE w.website_id = " . (int) $args['owner_id']; $user = qa1($sql); $name_parts = explode(" ", preg_replace('/\\s+/', ' ', $user['user_name'])); $user['first_name'] = array_shift($name_parts); $user['last_name'] = implode(' ', $name_parts); if (isset($args['basic']) && $args['basic']) { return $user; } // get extras for the website. $extras = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $args['owner_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } // then get extras for the company $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } if (isset($user['user_id']) && $user['user_id'] > 0) { // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user); return $user; case 'ticket': //echo 'Getting ticket for '.$args['owner_id'] . ' and basic is '.var_export($args['basic'],true);exit; return module_ticket::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); case 'member': return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); case 'newsletter_subscription': return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); } return array(); }
?> <table class="tableclass tableclass_form tableclass_full"> <tbody> <?php foreach ($others as $other) { ?> <tr> <td> <input type="hidden" name="link_user_ids[]" value="<?php echo $other['user_id']; ?> "> <!-- todo- checkbox --> <?php echo _l('%s under customer %s', module_user::link_open_contact($other['user_id'], true, $other), module_customer::link_open($other['customer_id'], true)); ?> </td> </tr> <?php } ?> <tr> <td align="center"> <input type="hidden" name="link_customers" id="link_customers" value=""> <input type="button" name="link" value="<?php _e('Link above contacts to this one, and make THIS one primary'); ?> " onclick="$('#link_customers').val('yes'); this.form.submit();">
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 ''; } }); $columns['primary_contact_email'] = array('title' => 'Email Address', 'callback' => function ($vendor) { if ($vendor['primary_user_id']) { module_user::print_contact_summary($vendor['primary_user_id'], 'html', array('email')); } else {
$fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($customer['primary_user_id'], false)); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } else { if (!module_user::can_i('edit', 'All ' . $page_type_single . ' Contacts', 'Customer', 'customer') && $customer['primary_user_id'] != module_security::get_loggedin_id()) { // no permissions to edit. ob_start(); echo '<div class="content_box_wheader"><table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form"><tbody><tr><td>'; ob_start(); module_user::print_contact_summary($customer['primary_user_id'], 'text', array('name', 'last_name', 'email')); $short_user_details = ob_get_clean(); echo '</td></tr></tbody></table></div>'; $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Primary Contact Details', 'responsive' => array('title' => 'Primary Contact', 'summary' => htmlspecialchars($short_user_details))), 'class' => 'tableclass tableclass_form tableclass_full', 'elements_before' => ob_get_clean()); if ($customer['primary_user_id']) { $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($customer['primary_user_id'], false)); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } else { module_user::print_contact_form($customer['primary_user_id']); } } } else { // hack to create new contact details. module_user::print_contact_form(false); } /*** ADDRESS **/ if (class_exists('module_address', false)) { module_address::print_address_form($customer_id, 'customer', 'physical', 'Address'); }
public static function handle_import_row($row, $debug, $add_to_group, $extra_options) { $debug_string = ''; if (!isset($row['name'])) { $row['name'] = ''; } if (!isset($row['url'])) { $row['url'] = ''; } if (isset($row['website_id']) && (int) $row['website_id'] > 0) { // check if this ID exists. $website = self::get_website($row['website_id']); if (!$website || $website['website_id'] != $row['website_id']) { $row['website_id'] = 0; } } if (!isset($row['website_id']) || !$row['website_id']) { $row['website_id'] = 0; } if (isset($row['name']) && strlen(trim($row['name']))) { // we have a website name! // search for a website based on name. $website = get_single('website', 'name', $row['name']); if ($website && $website['website_id'] > 0) { $row['website_id'] = $website['website_id']; } } else { if (isset($row['url'])) { $row['name'] = $row['url']; } } if (!$row['website_id'] && isset($row['url']) && strlen(trim($row['url']))) { // we have a url! find a match too. $website = get_single('website', 'url', $row['url']); if ($website && $website['website_id'] > 0) { $row['website_id'] = $website['website_id']; } } if (!strlen($row['name']) && !strlen($row['url'])) { $debug_string .= _l('No website data to import'); if ($debug) { echo $debug_string; } return false; } // duplicates. //print_r($extra_options);exit; if (isset($extra_options['duplicates']) && $extra_options['duplicates'] == 'ignore' && (int) $row['website_id'] > 0) { if ($debug) { $debug_string .= _l('Skipping import, duplicate of website %s', self::link_open($row['website_id'], true)); echo $debug_string; } // don't import duplicates return false; } $row['customer_id'] = 0; // todo - support importing of this id? nah if (isset($row['customer_name']) && strlen(trim($row['customer_name'])) > 0) { // check if this customer exists. $customer = get_single('customer', 'customer_name', $row['customer_name']); if ($customer && $customer['customer_id'] > 0) { $row['customer_id'] = $customer['customer_id']; $debug_string .= _l('Linked to customer %s', module_customer::link_open($row['customer_id'], true)) . ' '; } else { $debug_string .= _l('Create new customer: %s', htmlspecialchars($row['customer_name'])) . ' '; } } else { $debug_string .= _l('No customer') . ' '; } if ($row['website_id']) { $debug_string .= _l('Replace existing website: %s', self::link_open($row['website_id'], true)) . ' '; } else { $debug_string .= _l('Insert new website: %s', htmlspecialchars($row['url'])) . ' '; } $customer_primary_user_id = 0; if ($row['customer_id'] > 0 && isset($row['customer_contact_email']) && strlen(trim($row['customer_contact_email']))) { $users = module_user::get_users(array('customer_id' => $row['customer_id'] > 0)); foreach ($users as $user) { if (strtolower(trim($user['email'])) == strtolower(trim($row['customer_contact_email']))) { $customer_primary_user_id = $user['user_id']; $debug_string .= _l('Customer primary contact is: %s', module_user::link_open_contact($customer_primary_user_id, true)) . ' '; break; } } } if ($debug) { echo $debug_string; return true; } if (isset($extra_options['duplicates']) && $extra_options['duplicates'] == 'ignore' && $row['customer_id'] > 0) { // don't update customer record with new one. } else { if (isset($row['customer_name']) && strlen(trim($row['customer_name'])) > 0 || $row['customer_id'] > 0) { // update customer record with new one. $row['customer_id'] = update_insert('customer_id', $row['customer_id'], 'customer', $row); if (isset($row['customer_contact_fname']) || isset($row['customer_contact_email'])) { $data = array('customer_id' => $row['customer_id']); if (isset($row['customer_contact_fname'])) { $data['name'] = $row['customer_contact_fname']; } if (isset($row['customer_contact_lname'])) { $data['last_name'] = $row['customer_contact_lname']; } if (isset($row['customer_contact_email'])) { $data['email'] = $row['customer_contact_email']; } if (isset($row['customer_contact_phone'])) { $data['phone'] = $row['customer_contact_phone']; } $customer_primary_user_id = update_insert("user_id", $customer_primary_user_id, "user", $data); module_customer::set_primary_user_id($row['customer_id'], $customer_primary_user_id); } } } $website_id = (int) $row['website_id']; // check if this ID exists. $website = self::get_website($website_id); if (!$website || $website['website_id'] != $website_id) { $website_id = 0; } $website_id = update_insert("website_id", $website_id, "website", $row); // ad notes if possible if (isset($row['notes']) && strlen(trim($row['notes']))) { if (class_exists('module_note', false) && module_note::is_plugin_enabled()) { module_note::save_note(array('owner_table' => 'website', 'owner_id' => $website_id, 'note' => trim($row['notes']), 'note_time' => time())); } } // handle any extra fields. $extra = array(); foreach ($row as $key => $val) { if (!strlen(trim($val))) { continue; } if (strpos($key, 'extra:') !== false) { $extra_key = str_replace('extra:', '', $key); if (strlen($extra_key)) { $extra[$extra_key] = $val; } } } if ($extra) { foreach ($extra as $extra_key => $extra_val) { // does this one exist? $existing_extra = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $website_id, 'extra_key' => $extra_key)); $extra_id = false; foreach ($existing_extra as $key => $val) { if ($val['extra_key'] == $extra_key) { $extra_id = $val['extra_id']; } } $extra_db = array('extra_key' => $extra_key, 'extra' => $extra_val, 'owner_table' => 'website', 'owner_id' => $website_id); $extra_id = (int) $extra_id; update_insert('extra_id', $extra_id, 'extra', $extra_db); } } foreach ($add_to_group as $group_id => $tf) { module_group::add_to_group($group_id, $website_id, 'website'); } return $website_id; }
<form action="" method="post"> <input type="hidden" name="_process" value="save_security_role" /> <input type="hidden" name="security_role_id" value="<?php echo $security_role_id; ?> " /> <?php /** ROLE DETAILS */ $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Role Details'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array()); $fieldset_data['elements']['name'] = array('title' => 'Name', 'fields' => array(array('type' => 'text', 'name' => 'name', 'value' => $security_role['name']))); if ((int) $security_role_id > 0) { $fieldset_data['elements']['users'] = array('title' => 'Name', 'fields' => array(function () use($security_role_id) { $users = module_user::get_users(array('security_role_id' => $security_role_id)); $contacts = module_user::get_contacts(array('security_role_id' => $security_role_id)); $url1 = module_user::link_open_contact(false); $url1 .= strpos($url1, '?') ? '&' : '?'; $url2 = module_user::link_open(false); $url2 .= strpos($url1, '?') ? '&' : '?'; _e('There are <a href="%s">%s customer contacts</a> and <a href="%s">%s system users</a> with this role.', $url1 . 'search[security_role_id]=' . (int) $security_role_id, count($contacts), $url2 . 'search[security_role_id]=' . (int) $security_role_id, count($users)); })); } $fieldset_data['elements']['defaults'] = array('title' => 'Load Defaults', 'fields' => array(array('type' => 'select', 'name' => 'load_defaults', 'value' => '', 'options' => array('{"Change Request|change_request|Change Requests|Permissions":["view"],"Customer|customer|Customers|Permissions":["view"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Invoice|invoice|Invoices|Permissions":["view"],"Job|job|Jobs|Permissions":["view"],"Job|job|Job Tasks|Permissions":["view"],"Ticket|ticket|Tickets|Permissions":["view","create"],"Website|website|Websites|Permissions":["view"],"Customer Data Access|config|Only customer I am assigned to as a contact|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks require admin approval|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only Contact Accounts|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"]}' => _l('Customer View Only'), '{"Company|company|Company|Permissions":["view"],"Customer|customer|Customers|Permissions":["view","edit","create"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view"],"Customer|customer|Customer Groups|Permissions":["view","edit","create"],"File|file|Files|Permissions":["view","edit","create"],"File|file|File Comments|Permissions":["view","create"],"Invoice|invoice|Invoices|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Job|job|Jobs|Permissions":["view","edit","create"],"Job|job|Job Notes|Permissions":["view","edit","create"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create"],"Job|job|Job Advanced|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"Pin|pin|Header Pin|Permissions":["view","edit","create","delete"],"Ticket|ticket|Tickets|Permissions":["view","edit","create"],"User|user|User Notes|Permissions":["view","edit","create"],"Website|website|Websites|Permissions":["view","edit","create"],"Website|website|Website Notes|Permissions":["view","edit","create"],"Website|website|Website Groups|Permissions":["view","edit","create"],"Company Data Access|config|Only companies I am assigned to in staff area|drop_down":["view"],"Customer Data Access|config|Only customers from companies I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from Jobs I have access to|drop_down":["view"],"Job Data Access|config|Only jobs I am assigned to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only My Account|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"]}' => _l('Staff Member'), '{"Company|company|Company|Permissions":["view"],"Customer|customer|Customers|Permissions":["view","edit","create"],"Customer|user|Contacts|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Customer|customer|Customer Groups|Permissions":["view","edit","create"],"Customer|customer|All Lead Contacts|Permissions":["view","edit"],"Customer|customer|Lead Groups|Permissions":["view","edit","create"],"Customer|customer|All Lead Notes|Permissions":["view","edit","create"],"File|file|Files|Permissions":["view","edit","create"],"File|file|File Comments|Permissions":["view","create"],"Invoice|invoice|Invoices|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Job|job|Jobs|Permissions":["view","edit","create"],"Job|job|Job Notes|Permissions":["view","edit","create"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create"],"Job|job|Job Advanced|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"Pin|pin|Header Pin|Permissions":["view","edit","create","delete"],"Ticket|ticket|Tickets|Permissions":["view","edit","create"],"User|user|User Notes|Permissions":["view","edit","create"],"Vendor|user|Contacts|Permissions":["view","edit"],"Vendor|vendor|Vendors|Permissions":["view"],"Vendor|vendor|All Vendor Contacts|Permissions":["view"],"Website|website|Websites|Permissions":["view","edit","create"],"Website|website|Website Notes|Permissions":["view","edit","create"],"Website|website|Website Groups|Permissions":["view","edit","create"],"Calendar Data Access|config|Only from Customers or assigned items|drop_down":["view"],"Company Data Access|config|All companies in system|drop_down":["view"],"Customer Data Access|config|Only customers I am assigned to as a staff member|drop_down":["view"],"File Data Access|config|Only files from customers I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from customers I have access to|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Quote Data Access|config|Quotes from customers I have access to|drop_down":["view"],"Quote Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Quote Task Data Access|config|All tasks within a quote|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|All Contact and User Accounts|drop_down":["view"],"Vendor Data Access|config|Only vendor I am assigned to as a contact|drop_down":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"],"User Specific|config|Receive File Comment Alerts|checkbox":["view"]}' => _l('Staff Member Improved'), '{"Calendar|calendar|Calendar|Permissions":["view","edit","create"],"Company|company|Company|Permissions":["view"],"Config|user|Users|Permissions":["view","edit"],"Config|user|Users Passwords|Permissions":["view","edit","create"],"Config|user|Staff Settings|Permissions":["edit"],"Customer|user|Contacts|Permissions":["view","edit","create","delete"],"Customer|customer|Customers|Permissions":["view","edit","create","delete"],"Customer|customer|Leads|Permissions":["view","edit","create"],"Customer|customer|All Customer Notes|Permissions":["view","edit","create","delete"],"Customer|customer|All Customer Contacts|Permissions":["view","edit"],"Customer|customer|Customer Groups|Permissions":["view","edit","create","delete"],"Customer|customer|Export Customers|Permissions":["view"],"Customer|customer|Import Customers|Permissions":["view"],"Customer|customer|Customer Staff|Permissions":["edit"],"Customer|customer|Customer Credit|Permissions":["edit"],"Customer|customer|Export Leads|Permissions":["view"],"Customer|customer|Import Leads|Permissions":["view"],"Customer|customer|All Lead Contacts|Permissions":["view","edit"],"Customer|customer|Lead Groups|Permissions":["view","delete"],"Customer|customer|All Lead Notes|Permissions":["delete"],"File|file|Files|Permissions":["view","edit","create","delete"],"File|file|File Comments|Permissions":["view","create","delete"],"File|file|File Approval|Permissions":["edit"],"Finance|finance|Dashboard Finance Summary|Permissions":["view"],"Invoice|invoice|Invoices|Permissions":["view","edit","create","delete"],"Invoice|invoice|Invoice Notes|Permissions":["view","edit","create","delete"],"Invoice|invoice|Invoice Payments|Permissions":["edit","create"],"Invoice|invoice|Export Invoices|Permissions":["view"],"Job|job|Jobs|Permissions":["view","edit","create","delete"],"Job|job|Job Notes|Permissions":["view","edit","create","delete"],"Job|job|Job Tasks|Permissions":["view","edit","create"],"Job|job|Job Groups|Permissions":["view","edit","create","delete"],"Job|job|Job Advanced|Permissions":["view"],"Job|job|Export Job Tasks|Permissions":["view"],"Job|job|Import Job Tasks|Permissions":["view"],"Job|job|Export Jobs|Permissions":["view"],"Job|job|Import Jobs|Permissions":["view"],"Job Discussion|job_discussion|Job Discussions|Permissions":["view"],"User|user|User Notes|Permissions":["view","edit","create"],"Website|website|Websites|Permissions":["view","edit","create","delete"],"Website|website|Website Notes|Permissions":["view","edit","create","delete"],"Website|website|Website Groups|Permissions":["view","edit","create","delete"],"Website|website|Export Websites|Permissions":["view"],"Website|website|Import Websites|Permissions":["view"],"Calendar Data Access|config|Only from Customers or assigned items|drop_down":["view"],"Company Data Access|config|Only companies I am assigned to in staff area|drop_down":["view"],"Customer Data Access|config|Only customers from companies I have access to|drop_down":["view"],"File Data Access|config|Only files from customers I have access to|drop_down":["view"],"Invoice Data Access|config|Invoices from customers I have access to|drop_down":["view"],"Job Data Access|config|Jobs from customers I have access to|drop_down":["view"],"Job Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Job Task Data Access|config|All tasks within a job|drop_down":["view"],"Quote Data Access|config|Quotes from customers I have access to|drop_down":["view"],"Quote Task Creation|config|Created tasks do not require approval|drop_down":["view"],"Quote Task Data Access|config|All tasks within a quote|drop_down":["view"],"Ticket Access|config|Only tickets from my customer account|drop_down":["view"],"User Account Access|config|Only Contact Accounts|drop_down":["view"],"Vendor Data Access|config|Only vendors from companies I have access to|drop_down":["view"],"User Specific|config|Show Quick Search|checkbox":["view"],"User Specific|config|Show Dashboard Alerts|checkbox":["view"],"User Specific|config|Show Dashboard Todo List|checkbox":["view"],"User Specific|config|Receive File Upload Alerts|checkbox":["view"],"User Specific|config|Can User Login|checkbox":["view"],"User Specific|config|Receive File Comment Alerts|checkbox":["view"]}' => _l('Reseller')), 'help' => 'This will override any options selected below and replace them with defaults. You can change the selected permissions once the defaults are loaded'))); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); /** PERMIOSSIONS */ ob_start(); hook_handle_callback('layout_column_half', 1); ?>