コード例 #1
0
        if (class_exists('module_subscription', false)) {
            $members_subscriptions = module_subscription::get_subscriptions_by('website', $website_id);
            foreach ($members_subscriptions as $subscription_id => $subscription_info) {
                $history = module_subscription::get_subscription_history($subscription_id, 'website', $website_id);
                foreach ($history as $h) {
                    if (is_array($h) && isset($h['invoice_id']) && $h['invoice_id']) {
                        $note_summary_owners['invoice'][$h['invoice_id']] = $h['invoice_id'];
                    }
                }
            }
        }
        module_note::display_notes(array('title' => module_config::c('project_name_single', 'Website') . ' Notes', 'owner_table' => 'website', 'owner_id' => $website_id, 'view_link' => module_website::link_open($website_id), 'display_summary' => true, 'summary_owners' => $note_summary_owners));
    }
    if (class_exists('module_quote', false) && module_quote::is_plugin_enabled() && module_quote::can_i('view', 'Quotes')) {
        // show the jobs linked to this website.
        $quotes = module_quote::get_quotes(array('website_id' => $website_id));
        if (count($quotes) || module_quote::can_i('create', 'Quotes')) {
            $h = array('type' => 'h3', 'title' => module_config::c('project_name_single', 'Website') . ' Quotes');
            if (module_quote::can_i('create', 'Quotes')) {
                $h['button'] = array('title' => 'New Quote', 'url' => module_quote::link_generate('new', array('arguments' => array('website_id' => $website_id))));
            }
            $fieldset_data = array('heading' => $h);
            if (count($quotes)) {
                $c = 0;
                ob_start();
                ?>

				    <div class="content_box_wheader">
					    <table border="0" cellspacing="0" cellpadding="2"
					           class="tableclass tableclass_rows tableclass_full">
						    <thead>
コード例 #2
0
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!$quote_safe) {
    die('denied');
}
$search = isset($_REQUEST['search']) && is_array($_REQUEST['search']) ? $_REQUEST['search'] : array();
if (isset($_REQUEST['customer_id'])) {
    $search['customer_id'] = $_REQUEST['customer_id'];
}
if (!isset($search['completed'])) {
    $search['completed'] = module_config::c('quote_search_completed_default', 1);
}
$quotes = module_quote::get_quotes($search);
if (class_exists('module_table_sort', false)) {
    // get full quote data.
    // todo: only grab data if we're sorting by something
    // that isn't in the default invoice listing.
    foreach ($quotes as $quote_id => $quote) {
        $quotes[$quote_id] = array_merge($quote, module_quote::get_quote($quote['quote_id']));
        $quotes[$quote_id]['website_name'] = $quote['website_name'];
    }
    module_table_sort::enable_pagination_hook(array('table_id' => 'quote_list', 'sortable' => array('quote_title' => array('field' => 'name', 'current' => 1), 'quote_start_date' => array('field' => 'date_create'), 'quote_completed_date' => array('field' => 'date_approved'), 'quote_website' => array('field' => 'website_name'), 'quote_customer' => array('field' => 'customer_name'), 'quote_type' => array('field' => 'type'), 'quote_status' => array('field' => 'status'), 'quote_progress' => array('field' => 'total_percent_complete'), 'quote_total' => array('field' => 'total_amount'), 'quote_total_amount_invoiced' => array('field' => 'total_amount_invoiced'), 'quote_group' => array('group_sort' => true, 'owner_table' => 'quote', 'owner_id' => 'quote_id'))));
}
// hack to add a "export" option to the pagination results.
if (class_exists('module_import_export', false) && module_quote::can_i('view', 'Export Quotes')) {
    module_import_export::enable_pagination_hook(array('name' => 'Quote Export', 'fields' => array('Quote ID' => 'quote_id', 'Quote Title' => 'name', 'Hourly Rate' => 'hourly_rate', 'Start Date' => 'date_create', 'Completed Date' => 'date_approved', module_config::c('project_name_single', 'Website') . ' Name' => 'website_name', 'Customer Name' => 'customer_name', 'Type' => 'type', 'Status' => 'status', 'Staff Member' => 'staff_member', 'Tax Name' => 'total_tax_name', 'Tax Percent' => 'total_tax_rate', 'Renewal Date' => 'date_renew'), 'extra' => array('owner_table' => 'quote', 'owner_id' => 'quote_id')));
}
$header = array('title' => _l('Customer Quotes'), 'main' => true, 'button' => array());
コード例 #3
0
                </tr>
                <?php 
    if (class_exists('module_quote', false) && module_quote::is_plugin_enabled() && module_quote::can_i('view', 'Quotes')) {
        ?>

                <tr>
                    <th>
                        <?php 
        echo _l('Assign Quote');
        ?>

                    </th>
                    <td>
                        <?php 
        $c = array();
        $quotes = module_quote::get_quotes(array('customer_id' => $job['customer_id']));
        foreach ($quotes as $quote) {
            $c[$quote['quote_id']] = $quote['name'];
        }
        echo print_select_box($c, 'quote_id', $job['quote_id']);
        ?>

                        <?php 
        if ($job['quote_id'] && module_quote::can_i('view', 'Quotes')) {
            ?>

                        <a href="<?php 
            echo module_quote::link_open($job['quote_id'], false);
            ?>
"><?php 
            _e('Open');
コード例 #4
0
ファイル: quote.php プロジェクト: sgh1986915/php-crm
    public function process()
    {
        $errors = array();
        if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['quote_id']) {
            $data = self::get_quote($_REQUEST['quote_id']);
            if (module_form::confirm_delete('quote_id', "Really delete quote: " . $data['name'], self::link_open($_REQUEST['quote_id']))) {
                $this->delete_quote($_REQUEST['quote_id']);
                set_message("quote deleted successfully");
                redirect_browser($this->link_open(false));
            }
        } else {
            if ("ajax_quote_list" == $_REQUEST['_process']) {
                $customer_id = isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : 0;
                $res = module_quote::get_quotes(array('customer_id' => $customer_id));
                $options = array();
                foreach ($res as $row) {
                    $options[$row['quote_id']] = $row['name'];
                }
                echo json_encode($options);
                exit;
            } else {
                if ("ajax_create_invoice" == $_REQUEST['_process']) {
                    $quote_id = (int) $_REQUEST['quote_id'];
                    $quote = self::get_quote($quote_id, true);
                    $quote_tasks = self::get_tasks($quote_id);
                    if (!$quote || $quote['quote_id'] != $quote_id) {
                        exit;
                    }
                    // no permissions.
                    if (!module_invoice::can_i('create', 'Invoices')) {
                        exit;
                    }
                    // no permissions
                    ob_start();
                    ?>

            <p><?php 
                    _e('Please select which tasks to generate an invoice for:');
                    ?>
</p>
                <ul>
                    <?php 
                    foreach ($quote['uninvoiced_quote_task_ids'] as $quote_task_id) {
                        if (isset($quote_tasks[$quote_task_id])) {
                            ?>

                            <li>
                                <input type="checkbox" id="invoice_create_task_<?php 
                            echo $quote_task_id;
                            ?>
" data-taskid="<?php 
                            echo $quote_task_id;
                            ?>
" class="invoice_create_task" name="invoice_quote_task_id[<?php 
                            echo $quote_task_id;
                            ?>
]" value="1" <?php 
                            echo $quote_tasks[$quote_task_id]['fully_completed'] ? 'checked' : '';
                            ?>
>
                                <label for="invoice_create_task_<?php 
                            echo $quote_task_id;
                            ?>
">
                                    (#<?php 
                            echo $quote_tasks[$quote_task_id]['task_order'];
                            ?>
)
                                    <?php 
                            echo htmlspecialchars($quote_tasks[$quote_task_id]['description']);
                            ?>

                                </label>
                            </li>
                        <?php 
                        }
                    }
                    ?>

                </ul>
            <?php 
                    $html = ob_get_clean();
                    echo $html;
                    exit;
                } else {
                    if ("ajax_task" == $_REQUEST['_process']) {
                        // we are requesting editing a task.
                        $quote_id = (int) $_REQUEST['quote_id'];
                        $quote = self::get_quote($quote_id, true);
                        $quote_tasks = self::get_tasks($quote_id);
                        if (!$quote || $quote['quote_id'] != $quote_id) {
                            exit;
                        }
                        // no permissions.
                        if (!self::can_i('edit', 'Quote Tasks')) {
                            exit;
                        }
                        // no permissions
                        if (isset($_REQUEST['toggle_completed'])) {
                            $quote_task_id = (int) $_REQUEST['quote_task_id'];
                            $task_data = $quote_tasks[$quote_task_id];
                            $result = array();
                            if ($task_data && $task_data['quote_id'] == $quote_id) {
                                if ($task_data['invoiced'] && $task_data['fully_completed']) {
                                    // dont allow to 'uncompleted' fully completed invoice tasks
                                } else {
                                    // it is editable.
                                    $task_data['fully_completed_t'] = 1;
                                    $task_data['fully_completed'] = $task_data['fully_completed'] ? 0 : 1;
                                    // save a single quote task
                                    $this->save_quote_tasks($quote_id, array('quote_task' => array($quote_task_id => $task_data)));
                                    $result['success'] = 1;
                                    $result['quote_id'] = $quote_id;
                                    $result['quote_task_id'] = $quote_task_id;
                                }
                            }
                            echo json_encode($result);
                            exit;
                        } else {
                            if (isset($_REQUEST['update_task_order'])) {
                                // updating the task orders for this task..
                                $task_order = (array) $_REQUEST['task_order'];
                                foreach ($task_order as $quote_task_id => $new_order) {
                                    if ((int) $new_order > 0 && isset($quote_tasks[$quote_task_id])) {
                                        update_insert('quote_task_id', $quote_task_id, 'quote_task', array('task_order' => (int) $new_order));
                                    }
                                }
                                echo 'done';
                            } else {
                                $quote_task_id = (int) $_REQUEST['quote_task_id'];
                                $task_data = $quote_tasks[$quote_task_id];
                                $task_editable = true;
                                // todo - load this select box in via javascript from existing one on page.
                                $staff_members = module_user::get_staff_members();
                                $staff_member_rel = array();
                                foreach ($staff_members as $staff_member) {
                                    $staff_member_rel[$staff_member['user_id']] = $staff_member['name'];
                                }
                                // new different formats for quote data.
                                $task_data['manual_task_type_real'] = $task_data['manual_task_type'];
                                if ((!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) && isset($quote['default_task_type'])) {
                                    // use the quote task type
                                    $task_data['manual_task_type'] = $quote['default_task_type'];
                                }
                                if (isset($_REQUEST['get_preview'])) {
                                    $after_quote_task_id = $quote_task_id;
                                    // this will put it right back where it started.
                                    $previous_quote_task_id = 0;
                                    $quote_tasks = self::get_tasks($quote_id);
                                    foreach ($quote_tasks as $k => $v) {
                                        // find out where this new task position is!
                                        if ($k == $quote_task_id) {
                                            $after_quote_task_id = $previous_quote_task_id;
                                            break;
                                        }
                                        $previous_quote_task_id = $k;
                                    }
                                    $create_invoice_button = '';
                                    //if($quote['total_amount_invoicable'] > 0 && module_invoice::can_i('create','Invoices')){
                                    if (count($quote['uninvoiced_quote_task_ids']) && module_invoice::can_i('create', 'Invoices')) {
                                        //href="'.module_invoice::link_generate('new',array('arguments'=>array( 'quote_id' => $quote_id, ))).'"
                                        $create_invoice_button = '<a class="submit_button save_button uibutton quote_generate_invoice_button" onclick="return ucm.quote.generate_invoice();">' . _l('Create Invoice') . '</a>';
                                    }
                                    $result = array('quote_task_id' => $quote_task_id, 'after_quote_task_id' => $after_quote_task_id, 'html' => self::generate_task_preview($quote_id, $quote, $quote_task_id, $task_data), 'summary_html' => self::generate_quote_summary($quote_id, $quote), 'create_invoice_button' => $create_invoice_button);
                                    echo json_encode($result);
                                } else {
                                    $show_task_numbers = module_config::c('quote_show_task_numbers', 1) && $quote['auto_task_numbers'] != 2;
                                    ob_start();
                                    include 'pages/ajax_task_edit.php';
                                    $result = array('quote_task_id' => $quote_task_id, 'hours' => isset($_REQUEST['hours']) ? (double) $_REQUEST['hours'] : 0, 'html' => ob_get_clean());
                                    echo json_encode($result);
                                }
                            }
                        }
                        exit;
                    } else {
                        if ("save_quote" == $_REQUEST['_process']) {
                            $save_status = $this->save_quote($_REQUEST['quote_id'], $_POST);
                            $quote_id = isset($save_status['quote_id']) ? $save_status['quote_id'] : false;
                            if (!$quote_id) {
                                set_error('Failed to save quote');
                                redirect_browser(module_quote::link_open(false));
                            }
                            // look for the new tasks flag.
                            if (isset($_REQUEST['default_task_list_id']) && isset($_REQUEST['default_tasks_action'])) {
                                switch ($_REQUEST['default_tasks_action']) {
                                    case 'insert_default':
                                        if ((int) $_REQUEST['default_task_list_id'] > 0) {
                                            $default = self::get_default_task($_REQUEST['default_task_list_id']);
                                            $task_data = $default['task_data'];
                                            $new_task_data = array('quote_task' => array());
                                            foreach ($task_data as $task) {
                                                $task['quote_id'] = $quote_id;
                                                $new_task_data['quote_task'][] = $task;
                                            }
                                            $this->save_quote_tasks($quote_id, $new_task_data);
                                        }
                                        break;
                                    case 'save_default':
                                        $new_default_name = trim($_REQUEST['default_task_list_id']);
                                        if ($new_default_name != '') {
                                            // time to save it!
                                            $task_data = self::get_tasks($quote_id);
                                            $cached_task_data = array();
                                            foreach ($task_data as $task) {
                                                unset($task['quote_task_id']);
                                                unset($task['date_done']);
                                                unset($task['invoice_id']);
                                                unset($task['task_order']);
                                                unset($task['create_user_id']);
                                                unset($task['update_user_id']);
                                                unset($task['date_created']);
                                                unset($task['date_updated']);
                                                $task['saved_time'] = time();
                                                $cached_task_data[] = $task;
                                                /*$cached_task_data[] = array(
                                                      'hours' => $task['hours'],
                                                      'amount' => $task['amount'],
                                                      'billable' => $task['billable'],
                                                      'fully_completed' => $task['fully_completed'],
                                                      'description' => $task['description'],
                                                      'long_description' => $task['long_description'],
                                                      'date_due' => $task['date_due'],
                                                      'user_id' => $task['user_id'],
                                                      'approval_required' => $task['approval_required'],
                                                      'task_order' => $task['task_order'],
                                                      'saved_time' => time(),
                                                  );*/
                                            }
                                            self::save_default_tasks((int) $_REQUEST['default_task_list_id'], $new_default_name, $cached_task_data);
                                            unset($task_data);
                                        }
                                        break;
                                }
                            }
                            if (isset($_REQUEST['save_ajax_task'])) {
                                // do everything via ajax. trickery!
                                if ($quote_id <= 0) {
                                    die('Shouldnt happen');
                                }
                                //$result     = $this->save_quote_tasks( $quote_id, $_POST );
                                $result = isset($save_status['task_result']) ? $save_status['task_result'] : false;
                                $quote_data = self::get_quote($quote_id, false);
                                $new_status = self::update_quote_completion_status($quote_id);
                                $new_status = addcslashes(htmlspecialchars($new_status), "'");
                                //module_cache::clear_cache();
                                $new_quote_data = self::get_quote($quote_id, false);
                                if ($quote_id != $_REQUEST['quote_id']) {
                                    ?>

					<script type="text/javascript">
						top.location.href = '<?php 
                                    echo $this->link_open($quote_id);
                                    ?>
&added=true';
					</script>
					<?php 
                                    exit;
                                }
                                // we now have to edit the parent DOM to reflect these changes.
                                // what were we doing? adding a new task? editing an existing task?
                                switch ($result['status']) {
                                    case 'created':
                                        // we added a new task.
                                        // add a new task to the bottom (OR MID WAY!) through the task list.
                                        if ((int) $result['quote_task_id'] > 0) {
                                            ?>

							<script type="text/javascript">
								parent.refresh_task_preview(<?php 
                                            echo (int) $result['quote_task_id'];
                                            ?>
);
								parent.clear_create_form();
								parent.ucm.add_message('<?php 
                                            _e('New task created successfully');
                                            ?>
');
								parent.ucm.display_messages(true);
								<?php 
                                            if ($quote_data['status'] != $new_status) {
                                                ?>
parent.jQuery('#status').val('<?php 
                                                echo $new_status;
                                                ?>
').change();
								<?php 
                                            }
                                            ?>

								<?php 
                                            if ($new_quote_data['date_approved'] != $quote_data['date_approved']) {
                                                ?>
parent.jQuery('#date_approved').val('<?php 
                                                echo print_date($new_quote_data['date_approved']);
                                                ?>
').change();
								<?php 
                                            }
                                            ?>

							</script>
						<?php 
                                        } else {
                                            set_error('New task creation failed.');
                                            ?>

							<script type="text/javascript">
								top.location.href = '<?php 
                                            echo $this->link_open($quote_id);
                                            ?>
&added=true';
							</script>
						<?php 
                                        }
                                        break;
                                    case 'deleted':
                                        // we deleted a task.
                                        set_message('Task removed successfully');
                                        ?>

						<script type="text/javascript">
							top.location.href = '<?php 
                                        echo $this->link_open($quote_id);
                                        ?>
';
							<?php 
                                        if ($quote_data['status'] != $new_status) {
                                            ?>
parent.jQuery('#status').val('<?php 
                                            echo $new_status;
                                            ?>
').change();
							<?php 
                                        }
                                        ?>

						</script>
						<?php 
                                        break;
                                    case 'error':
                                        set_error('Something happened while trying to save a task. Unknown error.');
                                        // something happened, refresh the parent browser frame
                                        ?>

						<script type="text/javascript">
							top.location.href = '<?php 
                                        echo $this->link_open($quote_id);
                                        ?>
';
						</script>
						<?php 
                                        break;
                                    case 'edited':
                                        // we changed a task (ie: completed?);
                                        // update this task above.
                                        if ((int) $result['quote_task_id'] > 0) {
                                            ?>

							<script type="text/javascript">
								parent.canceledittask();
								//parent.refresh_task_preview(<?php 
                                            echo (int) $result['quote_task_id'];
                                            ?>
);
								parent.ucm.add_message('<?php 
                                            _e('Task saved successfully');
                                            ?>
');
								parent.ucm.display_messages(true);
								<?php 
                                            if ($quote_data['status'] != $new_status) {
                                                ?>
parent.jQuery('#status').val('<?php 
                                                echo $new_status;
                                                ?>
').change();
								<?php 
                                            }
                                            ?>

								<?php 
                                            if ($new_quote_data['date_approved'] != $quote_data['date_approved']) {
                                                ?>
parent.jQuery('#date_approved').val('<?php 
                                                echo print_date($new_quote_data['date_approved']);
                                                ?>
').change();
								<?php 
                                            }
                                            ?>

							</script>
						<?php 
                                        } else {
                                            ?>

							<script type="text/javascript">
								parent.canceledittask();
								parent.ucm.add_error('<?php 
                                            _e('Unable to save task');
                                            ?>
');
								parent.ucm.display_messages(true);
								<?php 
                                            if ($quote_data['status'] != $new_status) {
                                                ?>
parent.jQuery('#status').val('<?php 
                                                echo $new_status;
                                                ?>
').change();
								<?php 
                                            }
                                            ?>

							</script>
						<?php 
                                        }
                                        break;
                                    default:
                                        ?>

							<script type="text/javascript">
								parent.ucm.add_error('<?php 
                                        _e('Unable to save task. Please check required fields.');
                                        ?>
');
								parent.ucm.display_messages(true);
							</script>
						<?php 
                                        break;
                                }
                                exit;
                            }
                            if (isset($_REQUEST['butt_print']) && $_REQUEST['butt_print']) {
                                redirect_browser(module_quote::link_public_print($quote_id));
                            }
                            if (isset($_REQUEST['butt_email']) && $_REQUEST['butt_email']) {
                                redirect_browser(module_quote::link_generate($quote_id, array('arguments' => array('email' => 1))));
                            }
                            if (isset($_REQUEST['butt_duplicate']) && $_REQUEST['butt_duplicate'] && module_quote::can_i('create', 'Quotes')) {
                                $new_quote_id = module_quote::duplicate_quote($quote_id);
                                set_message('Quote duplicated successfully');
                                redirect_browser(module_quote::link_generate($new_quote_id));
                            }
                            set_message("Quote saved successfully");
                            //redirect_browser($this->link_open($quote_id));
                            redirect_browser(isset($_REQUEST['_redirect']) && !empty($_REQUEST['_redirect']) ? $_REQUEST['_redirect'] : $this->link_open($quote_id));
                        }
                    }
                }
            }
        }
        if (!count($errors)) {
            redirect_browser($_REQUEST['_redirect']);
            exit;
        }
        print_error($errors, true);
    }
コード例 #5
0
                $file['job_id'] = false;
            }
        } else {
            $file['job_id'] = false;
        }
    }
    $fieldset_data['elements'][] = array('title' => 'Job', 'fields' => array(array('type' => 'select', 'name' => 'job_id', 'value' => $file['job_id'], 'options' => $c), function () use(&$file) {
        if ($file['job_id']) {
            echo ' ';
            echo '<a href="' . module_job::link_open($file['job_id'], false) . '">' . _l('Open Job &raquo;') . '</a>';
        }
    }));
}
if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
    $c = array();
    $res = module_quote::get_quotes(array('customer_id' => $file['customer_id']));
    foreach ($res as $row) {
        $c[$row['quote_id']] = $row['name'];
    }
    if ($file['quote_id'] && !isset($c[$file['quote_id']])) {
        // this file is related to another quote. from another customer.
        $related_quote = module_quote::get_quote($file['quote_id'], false, true);
        if ($related_quote && $related_quote['quote_id'] == $file['quote_id']) {
            $related_customer = module_customer::get_customer($related_quote['customer_id'], true);
            if ($related_customer && $related_customer['customer_id'] == $related_quote['customer_id']) {
                $c[$file['quote_id']] = _l('%s (from %s)', $related_quote['name'], $related_customer['customer_name']);
            } else {
                $file['quote_id'] = false;
            }
        } else {
            $file['quote_id'] = false;
コード例 #6
0
ファイル: customer.php プロジェクト: sgh1986915/php-crm
 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);
         }
     }
 }
コード例 #7
0
ファイル: ticket_billing.php プロジェクト: sgh1986915/php-crm
/** 
 * 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
 */
if ($ticket_id > 0 && module_config::c('ticket_allow_billing', 1) && module_ticket::can_edit_tickets()) {
    $done_in_ticket_billing = true;
    $responsive_summary = array();
    $quotes = array();
    if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
        $quotes = module_quote::get_quotes(array('ticket_id' => $ticket_id));
        foreach ($quotes as $quote) {
            $responsive_summary[] = module_quote::link_open($quote['quote_id'], true, $quote);
        }
    }
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Ticket Billing', 'responsive' => array('summary' => implode(', ', $responsive_summary))), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array());
    $c = array();
    $res = module_customer::get_customers();
    while ($row = array_shift($res)) {
        $c[$row['customer_id']] = $row['customer_name'];
    }
    if ($ticket['customer_id'] < 0) {
        $ticket['customer_id'] = false;
    }
    $fieldset_data['elements'][] = array('title' => _l('Customer'), 'fields' => array(array('type' => 'select', 'name' => 'change_customer_id', 'value' => $ticket['customer_id'], 'options' => $c), array('type' => 'button', 'name' => 'new_customer', 'value' => _l('New'), 'onclick' => "window.location.href='" . module_customer::link_open('new', false) . "&move_user_id=" . $ticket['user_id'] . "';")));
    if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {