示例#1
0
unset($menu_type);
unset($current_link);
unset($menu_allow_nesting);
?>
        <?php 
if (isset($show_quick_search) && $show_quick_search) {
    ?>
        <?php 
    if (module_security::getcred() && module_security::can_user(module_security::get_loggedin_id(), 'Show Quick Search') && $display_mode != 'mobile') {
        if (module_config::c('global_search_focus', 1) == 1) {
            module_form::set_default_field('ajax_search_text');
        }
        ?>
            <li>
                <div id="quick_search_box">
                    <div id="quick_search_placeholder"><div><?php 
        _e('Quick Search:');
        ?>
</div></div>
                    <input type="text" name="quick_search" id="ajax_search_text" size="10" value="">
                    <div id="ajax_search_result"></div>
                </div>
            </li>
         <?php 
    }
    handle_hook('top_menu_end');
}
?>
	</ul>
    <div class="menu_clear"></div>
</div>
示例#2
0
	<input type="hidden" name="customer_id" value="<?php 
echo $user['customer_id'];
?>
" />


    <?php 
module_form::print_form_auth();
module_form::prevent_exit(array('valid_exits' => array('.submit_button')));
module_form::set_required(array('fields' => array('name' => 'Name', 'email' => 'Email')));
hook_handle_callback('layout_column_half', 1);
$title = 'User Details';
include module_theme::include_ucm('includes/plugin_user/pages/contact_admin_form.php');
if (module_config::c('users_have_address', 0)) {
    ob_start();
    handle_hook("address_block", $module, "physical", "user", "user_id");
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Address'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
}
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' => 'User 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' => 'User 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')) {
 * IP Address: 67.79.165.254
 */
if ($invoice_data['total_amount_due'] > 0) {
    if (module_invoice::is_automatic_paying_invoice($invoice_id)) {
        // auto payment pending...
        ?>
        <p align="center">
            <?php 
        $template_print = module_template::get_template_by_key('invoice_payment_pending');
        echo $template_print->content;
        ?>
	    </p>
        <?php 
    }
    // find all payment methods that are available for invoice payment.
    $payment_methods = handle_hook('get_payment_methods');
    $methods_count = count($payment_methods);
    // work out the payment methods that are allowed for this invoice.
    $payment_methods_online = array();
    $payment_methods_offline = array();
    $default_payment_method = module_config::c('invoice_default_payment_method', 'paymethod_paypal');
    foreach ($payment_methods as $payment_method_id => $payment_method) {
        if ($payment_methods[$payment_method_id]->is_enabled() && $payment_methods[$payment_method_id]->is_allowed_for_invoice($invoice_id)) {
            if ($payment_methods[$payment_method_id]->is_method('online')) {
                $payment_methods_online[] = array('name' => $payment_methods[$payment_method_id]->get_payment_method_name(), 'key' => $payment_methods[$payment_method_id]->module_name, 'description' => $payment_methods[$payment_method_id]->get_invoice_payment_description($invoice_id));
            } else {
                $payment_methods_offline[] = array('name' => $payment_methods[$payment_method_id]->get_payment_method_name(), 'key' => $payment_methods[$payment_method_id]->module_name, 'description' => $payment_methods[$payment_method_id]->get_invoice_payment_description($invoice_id));
            }
        }
    }
    ob_start();
示例#4
0
 public function handle_payment()
 {
     // handle a payment request via post data from
     $invoice_id = (int) $_REQUEST['invoice_id'];
     if (self::is_automatic_paying_invoice($invoice_id)) {
     }
     // resume a failed past payment.
     if (isset($_REQUEST['invoice_payment_id']) && (int) $_REQUEST['invoice_payment_id'] > 0) {
         $invoice_payment_data = module_invoice::get_invoice_payment($_REQUEST['invoice_payment_id']);
         if ($invoice_payment_data['invoice_id'] == $invoice_id && $invoice_payment_data['date_paid'] == '0000-00-00' && $invoice_payment_data['invoice_payment_id'] == $_REQUEST['invoice_payment_id']) {
             // we can resume this incomplete payment.
             // hack to find out which payment method plugin we are using, this is bad!
             $payment_methods = handle_hook('get_payment_methods', $this);
             foreach ($payment_methods as &$payment_method) {
                 if ($payment_method->is_enabled() && $payment_method->is_method('online') && $payment_method->get_payment_method_name() == $invoice_payment_data['method']) {
                     $payment_method_name = $payment_method->module_name;
                     global $plugins;
                     if (isset($plugins[$payment_method_name])) {
                         $plugins['' . $payment_method_name]->start_payment($invoice_id, $invoice_payment_data['amount'] - $invoice_payment_data['fee_total'], $invoice_payment_data['invoice_payment_id']);
                     }
                 }
             }
         }
     } else {
         if (isset($_REQUEST['payment_method']) && $invoice_id && isset($_REQUEST['payment_amount'])) {
             $payment_method = $_REQUEST['payment_method'];
             $payment_amount = number_in($_REQUEST['payment_amount']);
             $invoice_data = $this->get_invoice($invoice_id);
             //&& module_security::can_access_data('invoice',$invoice_data,$invoice_id)
             if ($invoice_id && $payment_method && $payment_amount > 0 && $invoice_data) {
                 // pass this off to the payment module for handling.
                 global $plugins;
                 if (isset($plugins[$payment_method])) {
                     if (class_exists('module_company', false) && isset($invoice_data['company_id']) && (int) $invoice_data['company_id'] > 0) {
                         module_company::set_current_company_id($invoice_data['company_id']);
                     }
                     // delete any previously pending payment methods
                     //$sql = "DELETE FROM `"._DB_PREFIX."invoice_payment` WHERE invoice_id = $invoice_id AND method = '".mysql_real_escape_string($plugins[''.$payment_method]->get_payment_method_name())."' AND currency_id = '".$invoice_data['currency_id']."' ";
                     // insert a temp payment method here.
                     $invoice_payment_id = update_insert('invoice_payment_id', 'new', 'invoice_payment', array('invoice_id' => $invoice_id, 'amount' => $payment_amount, 'currency_id' => $invoice_data['currency_id'], 'method' => $plugins['' . $payment_method]->get_payment_method_name()));
                     module_cache::clear('invoice');
                     $plugins['' . $payment_method]->start_payment($invoice_id, $payment_amount, $invoice_payment_id);
                 }
             }
         }
     }
     // todo - better redirect with errors.
     //redirect_browser($_SERVER['REQUEST_URI']);
 }
示例#5
0
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca, 0a3014a3-2b8f-460b-8850-d6025aa845f8
 * Package Date: 2015-11-25 03:08:08 
 * IP Address: 67.79.165.254
 */
if (isset($_REQUEST['sort_order']) && is_array($_REQUEST['sort_order']) && isset($_REQUEST['auth']) && module_form::get_secure_key() == $_REQUEST['auth'] && module_security::is_logged_in()) {
    module_config::save_config('dash_widgets_sort_' . module_security::get_loggedin_id(), json_encode($_REQUEST['sort_order']));
}
module_config::register_css('theme', 'morris.css', full_link('/includes/plugin_theme_adminlte/css/morris.css'), 12);
module_config::register_css('theme', 'ionicons.min.css', full_link('/includes/plugin_theme_adminlte/css/ionicons.min.css'), 12);
module_config::register_js('theme', 'raphael-min.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/raphael-min.js'), 12);
module_config::register_js('theme', 'morris.min.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/morris.min.js'), 13);
module_config::register_js('theme', 'dashboard.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/dashboard.js'), 14);
$calling_module = 'home';
$home_widgets = handle_hook('dashboard_widgets', $calling_module);
$home_widgets2 = hook_handle_callback('dashboard_widgets');
if (is_array($home_widgets2)) {
    $home_widgets = array_merge($home_widgets, $home_widgets2);
}
// group the widgets into columsn.
// the default columns is 3, but each widget can specify which column group they want to appear in.
// layout the default widget structure in the order we want it to display on the page:
$widget_columns = array();
$widget_columns[4] = array(1 => array(), 2 => array(), 3 => array(), 4 => array());
$widget_columns[1] = array(1 => array());
$widget_columns[2] = array(1 => array(), 2 => array());
$widget_columns[3] = array(1 => array(), 2 => array(), 3 => array());
// then display the welcome message:
module_template::init_template('welcome_message', '<p>
   Hi {USER_NAME}, and Welcome to {SYSTEM_NAME}
示例#6
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename="cal.ics"');
$alerts = array();
$foo = 'calendar';
$results = handle_hook("home_alerts", $foo, true);
if (is_array($results)) {
    foreach ($results as $res) {
        if (is_array($res)) {
            foreach ($res as $r) {
                $alerts[] = $r;
            }
        }
    }
}
echo 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Ultimate Client Manager/Calendar Plugin v1.0//EN
CALSCALE:GREGORIAN
X-WR-CALNAME:' . _l('Alerts') . '
X-WR-TIMEZONE:UTC
示例#7
0
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
// load the address they're trying to access.
$address_id = isset($_REQUEST['address_id']) && (int) $_REQUEST['address_id'] ? (int) $_REQUEST['address_id'] : false;
if ($address_id) {
    $address_data = module_address::get_address_by_id($address_id);
    // load the form using the normal module callback.
    // todo - move this into a static method call instead of all the complicated hooks with optional parameters.
    //module_address::print_address_form($address_id);
    // do a form as well.
    ?>
	<form action="<?php 
    echo $module->link();
    ?>
" method="post">
	<input type="hidden" name="_process" value="save_from_popup">
	<input type="hidden" name="_redirect" class="redirect" value="">
	<?php 
    handle_hook("address_block", $module, $address_data['address_type'], $address_data['owner_table'], false, $address_data['owner_id']);
    ?>
	</form>
	<?php 
}
// exit so ajax load doesn't do everything
exit;
示例#8
0
 public function delete_vendor($vendor_id, $remove_linked_data = true)
 {
     $vendor_id = (int) $vendor_id;
     if ($vendor_id > 0) {
         if (_DEMO_MODE && $vendor_id == 1) {
             set_error('Sorry this is a Demo Vendor. It cannot be changed.');
             redirect_browser(self::link_open($vendor_id));
         }
         $vendor = self::get_vendor($vendor_id);
         if ($vendor && $vendor['vendor_id'] == $vendor_id) {
             // todo: Delete emails (wack these in this vendor_deleted hook)
             hook_handle_callback('vendor_deleted', $vendor_id, $remove_linked_data);
             if (class_exists('module_group', false)) {
                 // remove the vendor from his groups
                 module_group::delete_member($vendor_id, 'vendor');
             }
             if (class_exists('module_extra', false)) {
                 module_extra::delete_extras('vendor', 'vendor_id', $vendor_id);
             }
             // remove the contacts from this vendor
             foreach (module_user::get_contacts(array('vendor_id' => $vendor_id)) as $val) {
                 if ($val['vendor_id'] && $val['vendor_id'] == $vendor_id) {
                     module_user::delete_user($val['user_id']);
                 }
             }
             if (class_exists('module_note', false)) {
                 module_note::note_delete("vendor", 'vendor_id', $vendor_id);
             }
             handle_hook("address_delete", $this, 'all', "vendor", 'vendor_id', $vendor_id);
             // finally delete the main vendor record
             // (this is so the above code works with its sql joins)
             $sql = "DELETE FROM " . _DB_PREFIX . "vendor WHERE vendor_id = '" . $vendor_id . "' LIMIT 1";
             query($sql);
         }
     }
 }
示例#9
0
    }
    ?>


        </td>
    </tr>
</table>

<?php 
}
?>


<?php 
$calling_module = 'home';
handle_hook('dashboard', $calling_module);
?>


<?php 
if (get_display_mode() == 'mobile') {
    ?>

<!-- end page -->
<p>
    <a href="?display_mode=desktop"><?php 
    _e('Switch to desktop mode');
    ?>
</a>
</p>
<?php 
示例#10
0
?>

								</th>
								<td>
									<input type="text" name="email" value="<?php 
echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '';
?>
" style="width:90%">
								</td>
							</tr>
						</tbody>
					</table>


                    <?php 
handle_hook('ticket_create', $ticket_id);
?>



					<h3><?php 
echo _l('Ticket Details');
?>
</h3>

					<table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full">
						<tbody>
                            <?php 
if (module_config::c('ticket_public_show_type_dropdown', 1)) {
    ?>
示例#11
0
 public function delete_customer($customer_id, $remove_linked_data = true)
 {
     $customer_id = (int) $customer_id;
     if ($customer_id > 0) {
         if (_DEMO_MODE && $customer_id == 1) {
             set_error('Sorry this is a Demo Customer. It cannot be changed.');
             redirect_browser(self::link_open($customer_id));
         }
         $customer = self::get_customer($customer_id);
         if ($customer && $customer['customer_id'] == $customer_id) {
             // todo: Delete emails (wack these in this customer_deleted hook)
             hook_handle_callback('customer_deleted', $customer_id, $remove_linked_data);
             if (class_exists('module_group', false)) {
                 // remove the customer from his groups
                 module_group::delete_member($customer_id, 'customer');
             }
             if (class_exists('module_extra', false)) {
                 module_extra::delete_extras('customer', 'customer_id', $customer_id);
             }
             // remove the contacts from this customer
             foreach (module_user::get_contacts(array('customer_id' => $customer_id)) as $val) {
                 if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                     module_user::delete_user($val['user_id']);
                 }
             }
             // remove staff
             delete_from_db('customer_user_rel', 'customer_id', $customer_id);
             if (class_exists('module_note', false)) {
                 module_note::note_delete("customer", 'customer_id', $customer_id);
             }
             handle_hook("address_delete", $this, 'all', "customer", 'customer_id', $customer_id);
             // todo, check the 'delete' permission on each one of these 'delete' method calls
             // do that better when we remove each of these and put them into the customer delete hook
             if ($remove_linked_data) {
                 if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
                     foreach (module_website::get_websites(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             module_website::delete_website($val['website_id']);
                         }
                     }
                 }
                 if (class_exists('module_job', false) && module_job::is_plugin_enabled()) {
                     foreach (module_job::get_jobs(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             module_job::delete_job($val['job_id']);
                         }
                     }
                 }
                 if (class_exists('module_invoice', false) && module_invoice::is_plugin_enabled()) {
                     foreach (module_invoice::get_invoices(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             module_invoice::delete_invoice($val['invoice_id']);
                         }
                     }
                 }
                 if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
                     foreach (module_quote::get_quotes(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             module_quote::delete_quote($val['quote_id']);
                         }
                     }
                 }
                 //handle_hook("file_delete",$this,"customer",'customer_id',$customer_id);
             } else {
                 // instead of deleting these records we just update them to customer_id = 0
                 if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
                     foreach (module_website::get_websites(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             update_insert('website_id', $val['website_id'], 'website', array('customer_id' => 0));
                         }
                     }
                 }
                 if (class_exists('module_job', false) && module_job::is_plugin_enabled()) {
                     foreach (module_job::get_jobs(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             update_insert('job_id', $val['job_id'], 'job', array('customer_id' => 0));
                         }
                     }
                 }
                 if (class_exists('module_invoice', false) && module_invoice::is_plugin_enabled()) {
                     foreach (module_invoice::get_invoices(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             update_insert('invoice_id', $val['invoice_id'], 'invoice', array('customer_id' => 0));
                         }
                     }
                 }
                 if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
                     foreach (module_quote::get_quotes(array('customer_id' => $customer_id)) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             update_insert('quote_id', $val['quote_id'], 'quote', array('customer_id' => 0));
                         }
                     }
                 }
                 if (class_exists('module_file', false) && module_file::is_plugin_enabled()) {
                     foreach (module_file::get_files(array('owner_id' => $customer_id, 'owner_table' => 'customer')) as $val) {
                         if ($val['customer_id'] && $val['customer_id'] == $customer_id) {
                             update_insert('file_id', $val['file_id'], 'file', array('owner_id' => 0, 'owner_table' => ''));
                         }
                     }
                 }
             }
             // finally delete the main customer record
             // (this is so the above code works with its sql joins)
             $sql = "DELETE FROM " . _DB_PREFIX . "customer WHERE customer_id = '" . $customer_id . "' LIMIT 1";
             query($sql);
         }
     }
 }
示例#12
0
 public static function get_dashboard_alerts($dashboard_alerts = array())
 {
     // these can be cached.
     /*$cache_key = "dash_alerts_".module_security::get_loggedin_id();
       $cache_timeout = module_config::c('dashboard_cache_timeout',120);
       if($dashboard_alerts = module_cache::get('dashboard',$cache_key)){
            return $dashboard_alerts;
        }*/
     //echo "Dashboard alerts returned was ";print_r($dashboard_alerts);exit;
     if (!count($dashboard_alerts) && module_security::can_user(module_security::get_loggedin_id(), 'Show Dashboard Alerts')) {
         $results = handle_hook("home_alerts");
         if (is_array($results)) {
             $alerts = array();
             foreach ($results as $res) {
                 if (is_array($res)) {
                     foreach ($res as $r) {
                         $alerts[] = $r;
                     }
                 }
             }
             // sort the alerts
             function sort_alert($a, $b)
             {
                 if (isset($a['time']) && isset($b['time'])) {
                     return $a['time'] > $b['time'];
                 }
                 if (isset($a['date']) && isset($b['date'])) {
                     return strtotime($a['date']) > strtotime($b['date']);
                 }
                 return 0;
             }
             uasort($alerts, 'sort_alert');
             foreach ($alerts as $alert) {
                 $group_key = isset($alert['group']) ? $alert['group'] : $alert['item'];
                 if (!isset($dashboard_alerts[$group_key])) {
                     $dashboard_alerts[$group_key] = array();
                 }
                 $dashboard_alerts[$group_key][] = $alert;
             }
         }
     }
     $limit = module_config::c('dashboard_tabs_group_limit', 0);
     $items_to_hide = json_decode(module_config::c('_dashboard_item_hide' . module_security::get_loggedin_id(), '{}'), true);
     if (!is_array($items_to_hide)) {
         $items_to_hide = array();
     }
     if (isset($_REQUEST['hide_item']) && strlen($_REQUEST['hide_item'])) {
         $items_to_hide[] = $_REQUEST['hide_item'];
         module_config::save_config('_dashboard_item_hide' . module_security::get_loggedin_id(), json_encode($items_to_hide));
     }
     $all_listing = array();
     foreach ($dashboard_alerts as $key => $val) {
         // see if any of these "$val" alert entries are marked as hidden
         if (!isset($_REQUEST['show_hidden'])) {
             foreach ($val as $k => $v) {
                 $hide_key = md5($v['link'] . $v['item'] . $v['name']);
                 $dashboard_alerts[$key][$k]['hide_key'] = $val[$k]['hide_key'] = $hide_key;
                 if (in_array($hide_key, $items_to_hide)) {
                     unset($val[$k]);
                     unset($dashboard_alerts[$key][$k]);
                 }
             }
         }
         if (count($val) > $limit) {
             // this one gets it's own tab!
         } else {
             // this one goes into the all_listing bin
             $all_listing = array_merge($all_listing, $val);
             unset($dashboard_alerts[$key]);
         }
     }
     if (count($all_listing)) {
         $dashboard_alerts = array(_l('Alerts') => $all_listing) + $dashboard_alerts;
     }
     ksort($dashboard_alerts);
     //module_cache::put('dashboard',$cache_key,$dashboard_alerts,$cache_timeout);
     return $dashboard_alerts;
 }
示例#13
0
 public function save_user($user_id, $data, $from_public = false)
 {
     $use_master_key = $this->get_contact_master_key();
     if ($from_public) {
         $user_id = 0;
     } else {
         if ($use_master_key && isset($data[$use_master_key]) && $data[$use_master_key]) {
             if (!module_user::can_i('edit', 'Contacts', 'Customer')) {
                 set_error('Unable to edit contacts.');
                 return false;
             }
         } else {
             if (!self::can_i('edit', 'Users', 'Config')) {
                 set_error('Unable to edit users.');
                 return false;
             }
         }
         $user_id = (int) $user_id;
     }
     $temp_user = array();
     if ($user_id > 0) {
         // check permissions
         $temp_user = $this->get_user($user_id, true, false);
         if (!$temp_user || $temp_user['user_id'] != $user_id || isset($temp_user['_perms'])) {
             $user_id = false;
         }
     }
     if (!$user_id && !$from_public) {
         if ($use_master_key && isset($data[$use_master_key]) && $data[$use_master_key]) {
             if (!module_user::can_i('create', 'Contacts', 'Customer')) {
                 set_error('Unable to create new contacts.');
                 return false;
             }
         } else {
             if (!self::can_i('create', 'Users', 'Config')) {
                 set_error('Unable to create new users.');
                 return false;
             }
         }
     } else {
         if ($user_id == 1 && module_security::get_loggedin_id() != 1) {
             set_error('Sorry only the administrator can modify this account');
         }
     }
     // check the customer id is valid assignment to someone who has these perms.
     if (!$from_public) {
         if (isset($data['customer_id']) && (int) $data['customer_id'] > 0) {
             $temp_customer = module_customer::get_customer($data['customer_id']);
             if (!$temp_customer || $temp_customer['customer_id'] != $data['customer_id']) {
                 unset($data['customer_id']);
             }
         }
         if (isset($data['vendor_id']) && (int) $data['vendor_id'] > 0) {
             $temp_vendor = module_vendor::get_vendor($data['vendor_id']);
             if (!$temp_vendor || $temp_vendor['vendor_id'] != $data['vendor_id']) {
                 unset($data['vendor_id']);
             }
         }
     }
     if (isset($data['password'])) {
         unset($data['password']);
     }
     // we do the password hash thing here.
     if (isset($data['password_new']) && strlen($data['password_new'])) {
         // an admin is trying to set the password for this account.
         // same permissions checks as on the user_admin_edit_login.php page
         if (!$user_id || isset($temp_user['password']) && !$temp_user['password'] || module_user::can_i('create', 'Users Passwords', 'Config') || isset($_REQUEST['reset_password']) && $_REQUEST['reset_password'] == module_security::get_auto_login_string($user_id)) {
             // we allow the admin to set a new password without typing in previous password.
             $data['password'] = $data['password_new'];
         } else {
             set_error('Sorry, no permissions to set a new password.');
         }
     } else {
         if ($user_id && isset($data['password_new1']) && isset($data['password_new2']) && strlen($data['password_new1'])) {
             // the user is trying to change their password.
             // only do this if the user has edit password permissions and their password matches.
             if (module_user::can_i('edit', 'Users Passwords', 'Config') || $user_id == module_security::get_loggedin_id()) {
                 if (isset($data['password_old']) && (md5($data['password_old']) == $temp_user['password'] || $data['password_old'] == $temp_user['password'])) {
                     // correct old password
                     // verify new password.
                     if ($data['password_new1'] == $data['password_new2']) {
                         $data['password'] = $data['password_new1'];
                     } else {
                         set_error('Verified password mismatch. Password unchanged.');
                     }
                 } else {
                     set_error('Old password does not match. Password unchanged.');
                 }
             } else {
                 set_error('No permissions to change passwords');
             }
         }
     }
     // and we finally hash our password
     if (isset($data['password']) && strlen($data['password']) > 0) {
         $data['password'] = md5($data['password']);
         // if you change md5 also change it in customer import.
         // todo - salt? meh.
     }
     $user_id = update_insert("user_id", $user_id, "user", $data);
     $use_master_key = $this->get_contact_master_key();
     // this will be customer_id or supplier_id
     if ($use_master_key && (isset($data[$use_master_key]) && $data[$use_master_key])) {
         if ($user_id) {
             if (isset($data['customer_primary']) && $data['customer_primary']) {
                 // update the customer/supplier to mark them as primary or not..
                 switch ($use_master_key) {
                     case 'customer_id':
                         module_customer::set_primary_user_id($data['customer_id'], $user_id);
                         break;
                     case 'vendor_id':
                         module_vendor::set_primary_user_id($data['vendor_id'], $user_id);
                         break;
                 }
             } else {
                 // check if this contact was the old customer/supplier primary and
                 switch ($use_master_key) {
                     case 'customer_id':
                         $customer_data = module_customer::get_customer($data['customer_id']);
                         if ($customer_data['primary_user_id'] == $user_id) {
                             module_customer::set_primary_user_id($data['customer_id'], 0);
                         }
                         break;
                     case 'vendor_id':
                         $vendor_data = module_vendor::get_vendor($data['vendor_id']);
                         if ($vendor_data['primary_user_id'] == $user_id) {
                             module_vendor::set_primary_user_id($data['vendor_id'], 0);
                         }
                         break;
                 }
             }
         }
     }
     if (!$from_public) {
         // hack for linked user accounts.
         if ($user_id && isset($data['link_customers']) && $data['link_customers'] == 'yes' && isset($data['link_user_ids']) && is_array($data['link_user_ids']) && isset($data['email']) && $data['email']) {
             $others = module_user::get_contacts(array('email' => $data['email']));
             foreach ($data['link_user_ids'] as $link_user_id) {
                 if (!(int) $link_user_id) {
                     continue;
                 }
                 if ($link_user_id == $user_id) {
                     continue;
                 }
                 // shouldnt happen
                 foreach ($others as $other) {
                     if ($other['user_id'] == $link_user_id) {
                         // success! they'renot trying to hack us.
                         $sql = "REPLACE INTO `" . _DB_PREFIX . "user_customer_rel` SET user_id = '" . (int) $link_user_id . "', customer_id = '" . (int) $other['customer_id'] . "', `primary` = " . (int) $user_id;
                         query($sql);
                         update_insert('user_id', $link_user_id, 'user', array('linked_parent_user_id' => $user_id));
                     }
                 }
             }
             update_insert('user_id', $user_id, 'user', array('linked_parent_user_id' => $user_id));
         }
         if ($user_id && isset($data['unlink']) && $data['unlink'] == 'yes') {
             $sql = "DELETE FROM `" . _DB_PREFIX . "user_customer_rel` WHERE user_id = '" . (int) $user_id . "'";
             query($sql);
             update_insert('user_id', $user_id, 'user', array('linked_parent_user_id' => 0));
         }
         handle_hook("address_block_save", $this, "physical", "user", "user_id", $user_id);
         handle_hook("address_block_save", $this, "postal", "user", "user_id", $user_id);
         if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
             module_extra::save_extras('user', 'user_id', $user_id);
         }
         // find current role / permissions
         $user_data = $this->get_user($user_id);
         $previous_user_roles = $user_data['roles'];
         $re_save_role_perms = false;
         // hack to support only 1 role (we may support multi-role in the future)
         // TODO: check we have permissions to set this role id, otherwise anyone can set their own role.
         if (isset($_REQUEST['role_id'])) {
             $sql = "DELETE FROM `" . _DB_PREFIX . "user_role` WHERE user_id = '" . (int) $user_id . "'";
             query($sql);
             if ((int) $_REQUEST['role_id'] > 0) {
                 if (!isset($previous_user_roles[$_REQUEST['role_id']])) {
                     $re_save_role_perms = (int) $_REQUEST['role_id'];
                 }
                 $_REQUEST['role'] = array($_REQUEST['role_id'] => 1);
             }
         }
         // save users roles (support for multi roles in future - but probably will never happen)
         if (isset($_REQUEST['role']) && is_array($_REQUEST['role'])) {
             foreach ($_REQUEST['role'] as $role_id => $tf) {
                 $this->add_user_to_role($user_id, $role_id);
             }
         }
         if ($re_save_role_perms) {
             // copy role permissiosn to user permissions
             $sql = "DELETE FROM `" . _DB_PREFIX . "user_perm` WHERE user_id = " . (int) $user_id;
             query($sql);
             // update - we are not relying on these permissions any more.
             // if the user has a role assigned, we use those permissions period
             // we ignore all permissions in the user_perm table if the user has a role.
             // if the user doesn't have a role, then we use these user_perm permissions.
             /*$security_role = module_security::get_security_role($re_save_role_perms);
             		foreach($security_role['permissions'] as $security_permission_id => $d){
             			$sql = "INSERT INTO `"._DB_PREFIX."user_perm` SET user_id = ".(int)$user_id.", security_permission_id = '".(int)$security_permission_id."'";
             			foreach(module_security::$available_permissions as $perm){
             				$sql .= ", `".$perm."` = ".(int)$d[$perm];
             			}
             			query($sql);
             		}*/
         } else {
             if (isset($_REQUEST['permission']) && is_array($_REQUEST['permission'])) {
                 $sql = "DELETE FROM `" . _DB_PREFIX . "user_perm` WHERE user_id = '" . (int) $user_id . "'";
                 query($sql);
                 // update permissions for this user.
                 foreach ($_REQUEST['permission'] as $security_permission_id => $permissions) {
                     $actions = array();
                     foreach (module_security::$available_permissions as $permission) {
                         if (isset($permissions[$permission]) && $permissions[$permission]) {
                             $actions[$permission] = 1;
                         }
                     }
                     $sql = "REPLACE INTO `" . _DB_PREFIX . "user_perm` SET user_id = '" . (int) $user_id . "', security_permission_id = '" . (int) $security_permission_id . "' ";
                     foreach ($actions as $permission => $tf) {
                         $sql .= ", `" . mysql_real_escape_string($permission) . "` = 1";
                     }
                     query($sql);
                 }
             }
         }
         /*global $plugins;
         		if($user_id && isset($data['user_type_id']) && $data['user_type_id'] == 1 && $data['site_id']){
         			// update the site.
         			$plugins['site']->set_primary_user_id($data['site_id'],$user_id);
         		}else{
         			//this use isn't (or isnt any more) the sites primary user.
         			// unset this if he was the primary user before
         			$site_data = $plugins['site']->get_site($data['site_id']);
         			if(isset($site_data['primary_user_id']) && $site_data['primary_user_id'] == $user_id){
         				$plugins['site']->set_primary_user_id($data['site_id'],0);
         			}
         		}*/
         // save the company information if it's available
         if (class_exists('module_company', false) && module_company::can_i('edit', 'Company') && module_company::is_enabled() && module_user::can_i('edit', 'User')) {
             if (isset($_REQUEST['available_user_company']) && is_array($_REQUEST['available_user_company'])) {
                 $selected_companies = isset($_POST['user_company']) && is_array($_POST['user_company']) ? $_POST['user_company'] : array();
                 foreach ($_REQUEST['available_user_company'] as $company_id => $tf) {
                     if (!isset($selected_companies[$company_id]) || !$selected_companies[$company_id]) {
                         // remove user from this company
                         module_company::delete_user($company_id, $user_id);
                     } else {
                         // add user to this company (if they are not already existing)
                         module_company::add_user_to_company($company_id, $user_id);
                     }
                 }
             }
         }
     }
     module_cache::clear('user');
     return $user_id;
 }
示例#14
0
    }
    if ((int) $ticket_id > 0) {
        $fieldset_data['elements'][] = array('title' => _l('Public link'), 'fields' => array(function () use($ticket_id) {
            ?>
 <a href="<?php 
            echo module_ticket::link_public($ticket_id);
            ?>
" target="_blank"><?php 
            _e('click here');
            ?>
</a> <?php 
        }));
    }
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
    handle_hook('ticket_sidebar', $ticket_id);
}
// end can edit
hook_handle_callback('layout_column_half', 2, '65');
if ($ticket_id > 0 && module_ticket::can_edit_tickets() && !$ticket['assigned_user_id']) {
    ob_start();
    ?>

            <div class="content_box_wheader" style="padding-bottom: 20px">
                <p>
                    <?php 
    _e('This ticket is not assigned to anyone.');
    ?>
<br/>
                    <?php 
    _e('If you are able to solve this ticket please assign it to yourself.');
示例#15
0
 public static function generate_subscription_invoice($subscription_id, $owner_table, $owner_id, $date, $amount)
 {
     $subscription = self::get_subscription($subscription_id);
     if (!$subscription || $subscription['subscription_id'] != $subscription_id) {
         return false;
     }
     $members_subscriptions = module_subscription::get_subscriptions_by($owner_table, $owner_id);
     /*if($customer_hack){
           $members_subscriptions = module_subscription::get_subscriptions_by_customer($member_id);
       }else{
           $members_subscriptions = module_subscription::get_subscriptions_by_member($member_id);
       }*/
     // we have an ammount! create an invoice for this amount/
     // assign it to a subscription (but not necessary!)
     if ($subscription_id && !isset($members_subscriptions[$subscription_id])) {
         die('Shouldnt happen');
     }
     $history = module_subscription::get_subscription_history($subscription_id, $owner_table, $owner_id);
     // we grab the history of this subscription. if this is the first subscription for this member and the $date is in the past then we update the date to today.
     if (strtotime($date) < strtotime(date('Y-m-d'))) {
         $has_history = false;
         foreach ($history as $h) {
             if (!$h['invoice_id']) {
             } else {
                 $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                 if ($invoice_data['date_cancel'] != '0000-00-00') {
                     continue;
                 }
                 $has_history = true;
                 break;
             }
         }
         if (!$has_history) {
             $date = date('Y-m-d');
         }
     }
     // does this one have a discount/trial ?
     $number_of_past_invoices = 0;
     foreach ($history as $h) {
         if (!$h['invoice_id']) {
         } else {
             $invoice_data = module_invoice::get_invoice($h['invoice_id']);
             if ($invoice_data['date_cancel'] != '0000-00-00') {
                 continue;
             }
             $number_of_past_invoices++;
         }
     }
     //if(isset($subscription['settings']) && isset($subscription['settings']['trial_period']) && $subscription['settings']['trial_period'] > 0 && $number_of_past_invoices < $subscription['settings']['trial_period']){
     //echo $number_of_past_invoices;print_r($subscription['settings']);print_r($history);exit;
     if ($number_of_past_invoices <= 0 && isset($subscription['settings']['trial_price_adjust']) && $subscription['settings']['trial_price_adjust'] != 0) {
         $amount += $subscription['settings']['trial_price_adjust'];
     }
     //}
     //$next_time = self::_calculate_next_time(strtotime($date), $subscription);
     if (isset($members_subscriptions[$subscription_id]['next_due_date']) && $members_subscriptions[$subscription_id]['next_due_date'] != '0000-00-00' && $members_subscriptions[$subscription_id]['next_due_date'] != $date) {
         $time_period = self::_calculate_next_time(strtotime($members_subscriptions[$subscription_id]['next_due_date']), $subscription, true);
     } else {
         $time_period = self::_calculate_next_time(strtotime($date), $subscription, true);
     }
     $subscription_owner_id = $members_subscriptions[$subscription_id]['subscription_owner_id'];
     $amount_currency = $subscription['currency_id'];
     //module_config::c('subscription_currency',1);
     $data = array('subscription_id' => $subscription_id, 'subscription_owner_id' => $subscription_owner_id, 'amount' => $amount, 'currency_id' => $amount_currency, 'invoice_id' => 0, 'from_next_due_date' => $members_subscriptions[$subscription_id]['next_due_date']);
     /*if($customer_hack){
           unset($data['member_id']);
           $data['customer_id'] = $member_id;
       }*/
     $subscription_history_id = update_insert('subscription_history_id', 0, 'subscription_history', $data);
     $customer_id = 0;
     switch ($owner_table) {
         case 'website':
             $website_data = module_website::get_website($owner_id);
             $customer_id = $website_data['customer_id'];
             break;
         case 'customer':
             $customer_id = $owner_id;
             break;
     }
     module_invoice::$new_invoice_number_date = $date;
     // we have to seed the customer id if it exists.
     $_REQUEST['customer_id'] = $customer_id;
     $invoice_data = module_invoice::get_invoice('new', true);
     $invoice_data['customer_id'] = $customer_id;
     // customer_id, website_id, member_id
     $invoice_data[$owner_table . '_id'] = $owner_id;
     /*if($customer_hack){
           $invoice_data['member_id'] = 0;
           $invoice_data['customer_id'] = $member_id;
       }else{
           $invoice_data['member_id'] = $member_id; // added in version 2.31 for invoice integration. eg: emailing invoice
           $invoice_data['customer_id'] = 0;
       }*/
     $invoice_data['user_id'] = 0;
     $invoice_data['currency_id'] = $amount_currency;
     $invoice_data['date_sent'] = '0000-00-00';
     $invoice_data['date_cancel'] = '0000-00-00';
     $invoice_data['date_create'] = $date;
     $invoice_data['default_task_type'] = _TASK_TYPE_AMOUNT_ONLY;
     // todo - option this out to the subscription settings area.
     $invoice_data['date_due'] = date('Y-m-d', strtotime("+" . module_config::c('subscription_invoice_due_date', 0) . " days", strtotime($date)));
     if (strtotime($invoice_data['date_due']) < time()) {
         // due date in the past? hmm, update it from today instead.
         $invoice_data['date_due'] = date('Y-m-d', strtotime("+" . module_config::c('subscription_invoice_due_date', 0) . " days", time()));
     }
     $invoice_data['name'] = !$invoice_data['name'] || module_config::c('subscription_invoice_numeric', 0) ? 'S' . str_pad($subscription_history_id, 6, '0', STR_PAD_LEFT) : $invoice_data['name'];
     // pick a tax rate for this automatic invoice.
     $invoice_data['total_tax_name'] = isset($subscription['settings']) && isset($subscription['settings']['tax_name']) ? $subscription['settings']['tax_name'] : '';
     $invoice_data['total_tax_rate'] = isset($subscription['settings']) && isset($subscription['settings']['tax_amount']) ? $subscription['settings']['tax_amount'] : '';
     $invoice_data['tax_type'] = isset($subscription['settings']) && isset($subscription['settings']['tax_type']) ? $subscription['settings']['tax_type'] : module_config::c('invoice_tax_type', 0);
     $invoice_data['invoice_template_email'] = isset($subscription['settings']) && isset($subscription['settings']['invoice_template_email']) ? $subscription['settings']['invoice_template_email'] : '';
     $invoice_data['invoice_template_print'] = isset($subscription['settings']) && isset($subscription['settings']['invoice_template_print']) ? $subscription['settings']['invoice_template_print'] : '';
     $invoice_data['invoice_invoice_item'] = array('new' => array('description' => $members_subscriptions[$subscription_id]['name'] . $time_period, 'hourly_rate' => $amount, 'completed' => 1, 'manual_task_type' => _TASK_TYPE_AMOUNT_ONLY, 'date_done' => $date));
     $invoice_id = module_invoice::save_invoice('new', $invoice_data);
     if ($invoice_id) {
         // limit payment methods if this has been set in the options area:
         $payment_methods = handle_hook('get_payment_methods');
         foreach ($payment_methods as &$payment_method) {
             if ($payment_method->is_enabled()) {
                 $enabled = isset($subscription['settings']['payment_methods'][$payment_method->module_name]) && $subscription['settings']['payment_methods'][$payment_method->module_name] ? true : (isset($subscription['settings']['payment_methods']) ? false : true);
                 if ($enabled) {
                     $payment_method->set_allowed_for_invoice($invoice_id, 1);
                 } else {
                     $payment_method->set_allowed_for_invoice($invoice_id, 0);
                 }
             }
         }
         update_insert('subscription_history_id', $subscription_history_id, 'subscription_history', array('invoice_id' => $invoice_id));
         module_invoice::add_history($invoice_id, 'Created invoice from subscription #' . str_pad($subscription_history_id, 6, '0', STR_PAD_LEFT) . ' from ' . $owner_table . ' ID# ' . $owner_id);
         self::update_next_due_date($subscription_id, $owner_table, $owner_id);
     } else {
         set_error('failed to create subscription invoice');
     }
     return $invoice_id;
 }
示例#16
0
$invoice_templates['credit_note_pdf'] = 1;
$invoice_templates['invoice_email_due'] = 1;
$invoice_templates['invoice_email_overdue'] = 1;
$invoice_templates['invoice_email_paid'] = 1;
$invoice_templates['credit_note_email'] = 1;
foreach ($templates as $template) {
    if (stripos($template['template_key'], 'invoice')) {
        $invoice_templates[$template['template_key']] = 1;
    }
}
foreach ($invoice_templates as $template_key => $tf) {
    module_template::link_open_popup($template_key);
}
$template_html = ob_get_clean();
$payment_methods_options = array();
$payment_methods = handle_hook('get_payment_methods', $module);
foreach ($payment_methods as $payment_method) {
    if ($payment_method->is_method('online') && $payment_method->is_enabled()) {
        $payment_methods_options[$payment_method->module_name] = $payment_method->get_payment_method_name();
    }
}
$settings = array(array('key' => 'overdue_email_auto', 'default' => '0', 'type' => 'checkbox', 'description' => 'Automatic Overdue Emails', 'help' => 'If this is ticked then by default newly created invoices will be sent automatic overdue notices. This can be disabled/enabled per invoice. See the "Auto Overdue Email" option near "Due Date".'), array('key' => 'invoice_automatic_receipt', 'default' => '1', 'type' => 'checkbox', 'description' => 'Automatic Send Invoice Receipt', 'help' => 'Automatically send the invoice receipt to the customer once the invoice is marked as paid. If this is disabled you will have to go into the invoice and manually send it after payment is received.'), array('key' => 'invoice_template_print_default', 'default' => 'invoice_print', 'type' => 'text', 'description' => 'Default PDF invoice template', 'help' => 'Used for invoice PDF. You can overwrite in the Advanced settings of each invoice.'), array('key' => 'overdue_email_auto_days', 'default' => '3', 'type' => 'text', 'description' => 'Automically send after', 'help' => 'How many days after the invoice is overdue is the automated email sent (set to 0 will send on the date the invoice is due)'), array('key' => 'overdue_email_auto_days_repeat', 'default' => '7', 'type' => 'text', 'description' => 'Automically re-send every', 'help' => 'How many days after the last automatic overdue reminder is the overdue reminder re-sent automatically (set to 0 to disable this option)'), array('key' => 'invoice_automatic_after_time', 'default' => '7', 'type' => 'text', 'description' => 'Hour of day to perform automatic operations', 'help' => 'Enter the hour of day (eg: 7 for 7am, 14 for 2pm) to perform automatic actions - such as renewing invoices, subscriptions, overdue notices, etc...'), array('key' => 'invoice_auto_renew_only_paid_invoices', 'default' => '1', 'type' => 'checkbox', 'description' => 'Only renew paid invoices', 'help' => 'If an invoice (or past subscription invoice) has not been paid then do not renew the next one until original payment has been received.'), array('key' => 'invoice_default_payment_method', 'default' => 'paymethod_paypal', 'type' => 'select', 'options' => $payment_methods_options, 'description' => 'Default Payment Method'), array('key' => 'invoice_due_days', 'default' => '30', 'type' => 'text', 'description' => 'Invoice Due Days', 'help' => 'The number of days used to calculate the "Due Date" on new invoices. Due Date can be overridden per invoice.'), array('key' => 'invoice_name_match_job', 'default' => '0', 'type' => 'checkbox', 'description' => 'Match Invoice with Job Name', 'help' => 'If an invoice is created from a Job, set the Invoice name the same as the job name'), array('key' => 'invoice_incrementing', 'default' => '0', 'type' => 'checkbox', 'description' => 'Incrementing Invoice Numbers', 'help' => 'If this is enabled the system will pick a new invoice number each time. Choose what number to start from below.'), array('key' => 'invoice_incrementing_next', 'default' => '1', 'type' => 'text', 'description' => 'Incrementing Invoice Number', 'help' => 'What will be the next invoice number'), array('key' => 'invoice_task_list_show_date', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Dates on Invoice Items'), array('key' => 'invoice_task_numbers', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Task Numbers on Invoice Items'), array('key' => 'invoice_allow_payment_amount_adjustment', 'default' => '1', 'type' => 'checkbox', 'description' => 'Allow User To Enter Payment Amount', 'help' => 'If this is enabled the user can change the payment amount on invoices. For example, they might want to pay $50 of a $100 invoice with PayPal, and $50 with cash.'), array('type' => 'html', 'description' => 'Templates', 'html' => $template_html));
module_config::print_settings_form(array('heading' => array('title' => 'Invoice Settings', 'type' => 'h2', 'main' => true), 'settings' => $settings));
// find any blank invoices.
$sql = "SELECT * FROM `" . _DB_PREFIX . "invoice` WHERE customer_id IS NULL AND `name` = '' AND `status` = '' AND `date_create` = '0000-00-00' AND `date_sent` = '0000-00-00' AND `date_paid` = '0000-00-00' AND `date_due` = '0000-00-00' AND c_total_amount = 0 ";
$invoices = qa($sql);
$blank_invoices = array();
foreach ($invoices as $invoice) {
    $items = module_invoice::get_invoice_items($invoice['invoice_id']);
    if (empty($items)) {
        $blank_invoices[] = $invoice;
示例#17
0
 private function _handle_save_ticket()
 {
     $ticket_data = $_POST;
     $ticket_id = (int) $_REQUEST['ticket_id'];
     // check security can user edit this ticket
     if ($ticket_id > 0) {
         $test = self::get_ticket($ticket_id);
         if (!$test || $test['ticket_id'] != $ticket_id) {
             $ticket_id = 0;
         }
     }
     // handle some security before passing if off to the save
     if (!self::can_edit_tickets()) {
         // dont allow new "types" to be created
         /*if(isset($ticket_data['type']) && $ticket_data['type']){
               $types = self::get_types();
               $existing=false;
               foreach($types as $type){
                   if($type==$ticket_data['type']){
                       $existing=true;
                   }
               }
               if(!$existing){
                   unset($ticket_data['type']);
               }
           }*/
         if (isset($ticket_data['change_customer_id'])) {
             unset($ticket_data['change_customer_id']);
         }
         if (isset($ticket_data['change_user_id'])) {
             unset($ticket_data['change_user_id']);
         }
         if (isset($ticket_data['ticket_account_id'])) {
             unset($ticket_data['ticket_account_id']);
         }
         if (isset($ticket_data['assigned_user_id'])) {
             unset($ticket_data['assigned_user_id']);
         }
         if (isset($ticket_data['change_status_id'])) {
             unset($ticket_data['change_status_id']);
         }
         if (isset($ticket_data['change_assigned_user_id'])) {
             unset($ticket_data['change_assigned_user_id']);
         }
         if (isset($ticket_data['priority'])) {
             unset($ticket_data['priority']);
         }
         if ($ticket_id > 0 && isset($ticket_data['status_id'])) {
             unset($ticket_data['status_id']);
         }
         if ($ticket_id > 0 && isset($ticket_data['user_id'])) {
             unset($ticket_data['user_id']);
         }
     }
     $ticket_data = array_merge(self::get_ticket($ticket_id), $ticket_data);
     if (isset($_REQUEST['mark_as_unread']) && $_REQUEST['mark_as_unread']) {
         $ticket_data['unread'] = 1;
     }
     if (isset($ticket_data['change_customer_id']) && (int) $ticket_data['change_customer_id'] > 0 && $ticket_data['change_customer_id'] != $ticket_data['customer_id']) {
         // we are changing customer ids
         // todo - some extra logic in here to swap the user contact over to this new customer or something?
         $ticket_data['customer_id'] = $ticket_data['change_customer_id'];
     }
     if (isset($ticket_data['change_user_id']) && (int) $ticket_data['change_user_id'] > 0 && $ticket_data['change_user_id'] != $ticket_data['user_id']) {
         // we are changing customer ids
         // todo - some extra logic in here to swap the user contact over to this new customer or something?
         $ticket_data['user_id'] = $ticket_data['change_user_id'];
     }
     $ticket_id = $this->save_ticket($ticket_id, $ticket_data);
     // run the envato hook incase we're posting data to our sidebar bit.
     ob_start();
     handle_hook('ticket_sidebar', $ticket_id);
     ob_end_clean();
     if (isset($_REQUEST['generate_priority_invoice'])) {
         $invoice_id = $this->generate_priority_invoice($ticket_id);
         redirect_browser(module_invoice::link_public($invoice_id));
     }
     set_message("Ticket saved successfully");
     if (isset($_REQUEST['butt_notify_staff']) && $_REQUEST['butt_notify_staff']) {
         redirect_browser($this->link_open_notify($ticket_id, false, $ticket_data));
     } else {
         if (isset($_REQUEST['mark_as_unread']) && $_REQUEST['mark_as_unread']) {
             $url = $this->link_open(false);
             $url .= (strpos('?', $url) !== false ? '?' : '&') . 'do_last_search';
             redirect_browser($url);
         } else {
             if (isset($_REQUEST['newmsg_next']) && isset($_REQUEST['next_ticket_id']) && (int) $_REQUEST['next_ticket_id'] > 0) {
                 $key = array_search($ticket_id, $_SESSION['_ticket_nextprev']);
                 if ($key !== false) {
                     unset($_SESSION['_ticket_nextprev'][$key]);
                 }
                 redirect_browser($this->link_open($_REQUEST['next_ticket_id']));
             }
             redirect_browser($this->link_open($ticket_id));
         }
     }
 }