コード例 #1
0
include('quote_public.php');
$quote['quote_tasks'] = ob_get_clean();*/
// generate the PDF ready for sending.
$pdf = module_quote::generate_pdf($quote_id);
// find available "to" recipients.
// customer contacts.
$to_select = false;
if ($quote['customer_id']) {
    $customer = module_customer::get_customer($quote['customer_id']);
    $quote['customer_name'] = $customer['customer_name'];
    $to = module_user::get_contacts(array('customer_id' => $quote['customer_id']));
    if ($quote['contact_user_id']) {
        $primary = module_user::get_user($quote['contact_user_id']);
        if ($primary) {
            $to_select = $primary['email'];
        }
    } else {
        if ($customer['primary_user_id']) {
            $primary = module_user::get_user($customer['primary_user_id']);
            if ($primary) {
                $to_select = $primary['email'];
            }
        }
    }
} else {
    $to = array();
}
$template->assign_values($quote);
ob_start();
module_email::print_compose(array('title' => _l('Email Quote: %s', $quote['name']), 'find_other_templates' => 'quote_email', 'current_template' => $template_name, 'customer_id' => $quote['customer_id'], 'quote_id' => $quote['quote_id'], 'debug_message' => 'Sending quote as email', 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_quote::link_open($quote_id), 'cancel_url' => module_quote::link_open($quote_id), 'attachments' => array(array('path' => $pdf, 'name' => basename($pdf), 'preview' => module_quote::link_public_print($quote_id)))));
コード例 #2
0
ファイル: note.php プロジェクト: sgh1986915/php-crm
 function handle_hook($hook, $calling_module = false, $owner_table = false, $key_name = false, $key_value = false, $rel_data = false)
 {
     switch ($hook) {
         case "home_alerts":
             $alerts = array();
             if (module_config::c('allow_note_reminders', 1)) {
                 // find any jobs that are past the due date and dont have a finished date.
                 $key = _l('Note Reminder');
                 if (class_exists('module_dashboard', false)) {
                     module_dashboard::register_group($key, array('columns' => array('name' => _l('Reminder'), 'type' => _l('Type'), 'full_link' => _l('Link'), 'date' => _l('Date'), 'days' => _l('Date'))));
                 }
                 $sql = "SELECT * FROM `" . _DB_PREFIX . "note` n ";
                 $sql .= " WHERE n.`reminder` = 1 AND n.note_time < " . (int) strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days') . "";
                 $sql .= " AND ( n.`user_id` = 0 OR n.`user_id` = " . module_security::get_loggedin_id() . ")";
                 $sql .= " ORDER BY n.note_time ASC";
                 $tasks = qa($sql);
                 foreach ($tasks as $task) {
                     $alert_res = process_alert(date('Y-m-d', $task['note_time']), $key);
                     if ($alert_res) {
                         $alert_res['link'] = $task['rel_data'];
                         // fix for linking when changing folder.
                         $alert_res['type'] = _l(ucwords($task['owner_table']));
                         switch ($task['owner_table']) {
                             case 'user':
                                 $user = module_user::get_user($task['owner_id']);
                                 if ($user['customer_id'] || $user['vendor_id']) {
                                     $alert_res['link'] = module_user::link_open_contact($task['owner_id'], false, $user);
                                     $alert_res['full_link'] = module_user::link_open_contact($task['owner_id'], true, $user);
                                     $alert_res['type'] = _l('Contact');
                                 } else {
                                     $alert_res['link'] = module_user::link_open($task['owner_id'], false, $user);
                                     $alert_res['full_link'] = module_user::link_open($task['owner_id'], true, $user);
                                 }
                                 break;
                             case 'invoice':
                                 $invoice_data = module_invoice::get_invoice($task['owner_id'], true);
                                 if (!$invoice_data || !isset($invoice_data['invoice_id']) || $invoice_data['invoice_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_invoice::link_open($task['owner_id'], false, $invoice_data);
                                 $alert_res['full_link'] = module_invoice::link_open($task['owner_id'], true, $invoice_data);
                                 break;
                             case 'quote':
                                 $quote_data = module_quote::get_quote($task['owner_id'], true);
                                 if (!$quote_data || !isset($quote_data['quote_id']) || $quote_data['quote_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_quote::link_open($task['owner_id'], false, $quote_data);
                                 $alert_res['full_link'] = module_quote::link_open($task['owner_id'], true, $quote_data);
                                 break;
                             case 'website':
                                 $website_data = module_website::get_website($task['owner_id']);
                                 if (!$website_data || !isset($website_data['website_id']) || $website_data['website_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_website::link_open($task['owner_id'], false);
                                 $alert_res['full_link'] = module_website::link_open($task['owner_id'], true);
                                 break;
                             case 'customer':
                                 $customer_data = module_customer::get_customer($task['owner_id']);
                                 if (!$customer_data || !isset($customer_data['customer_id']) || $customer_data['customer_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_customer::link_open($task['owner_id'], false, $customer_data);
                                 $alert_res['full_link'] = module_customer::link_open($task['owner_id'], true, $customer_data);
                                 break;
                             case 'vendor':
                                 $vendor_data = module_vendor::get_vendor($task['owner_id']);
                                 if (!$vendor_data || !isset($vendor_data['vendor_id']) || $vendor_data['vendor_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_vendor::link_open($task['owner_id'], false, $vendor_data);
                                 $alert_res['full_link'] = module_vendor::link_open($task['owner_id'], true, $vendor_data);
                                 break;
                             case 'job':
                                 $job_data = module_job::get_job($task['owner_id']);
                                 if (!$job_data || !isset($job_data['job_id']) || $job_data['job_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_job::link_open($task['owner_id'], false, $job_data);
                                 $alert_res['full_link'] = module_job::link_open($task['owner_id'], true, $job_data);
                                 break;
                                 // todo - add others.
                         }
                         $alert_res['name'] = $task['note'];
                         $alert_res['date'] = print_date($alert_res['date']);
                         $alert_res['time'] = $task['note_time'];
                         $alerts[] = $alert_res;
                     }
                 }
             }
             return $alerts;
             break;
             /*case "note_list":
             				if($owner_id && $owner_id != 'new'){
             
             					$note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id));
             					foreach($note_items as &$note_item){
             						// do it in loop here because of $this issues in static method below.
             						// instead of include file below.
             						$note_item['html'] = $this->print_note($note_item['note_id']);
             					}
             					include("pages/note_list.php");
             				}else{
             					echo 'Please save first before creating notes.';
             				}
             				break;*/
         /*case "note_list":
         				if($owner_id && $owner_id != 'new'){
         
         					$note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id));
         					foreach($note_items as &$note_item){
         						// do it in loop here because of $this issues in static method below.
         						// instead of include file below.
         						$note_item['html'] = $this->print_note($note_item['note_id']);
         					}
         					include("pages/note_list.php");
         				}else{
         					echo 'Please save first before creating notes.';
         				}
         				break;*/
         case "note_delete":
             // find the key we are saving this address against.
             $owner_id = (int) $key_value;
             if (!$owner_id || $owner_id == 'new') {
                 // find one in the post data.
                 if (isset($_REQUEST[$key_name])) {
                     $owner_id = $_REQUEST[$key_name];
                 }
             }
             $note_hash = md5($owner_id . '|' . $owner_table);
             // just for posting unique arrays.
             if ($owner_table && $owner_id) {
                 $this->note_delete($owner_table, $owner_id);
             }
             break;
     }
 }
コード例 #3
0
                    <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');
            ?>
</a>
                        <?php 
        }
        ?>

                    </td>
                </tr>
                <?php 
    }
    ?>
コード例 #4
0
}
print_heading($header);
?>



<form action="" method="post">

<?php 
$search_bar = array('elements' => array('name' => array('title' => _l('Quote Title:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '', 'size' => 30)), 'type' => array('title' => _l('Type:'), 'field' => array('type' => 'select', 'name' => 'search[type]', 'value' => isset($search['type']) ? $search['type'] : '', 'options' => module_quote::get_types())), 'status' => array('title' => _l('Status:'), 'field' => array('type' => 'select', 'name' => 'search[status]', 'value' => isset($search['status']) ? $search['status'] : '', 'options' => module_quote::get_statuses())), 'accepted' => array('title' => _l('Accepted:'), 'field' => array('type' => 'select', 'name' => 'search[accepted]', 'value' => isset($search['accepted']) ? $search['accepted'] : '', 'options' => array(1 => _l('Both Accepted and Un-Accepted Quotes'), 2 => _l('Only Accepted Quotes'), 3 => _l('Only Un-Accepted Quotes'))))));
echo module_form::search_bar($search_bar);
/** START TABLE LAYOUT **/
$table_manager = module_theme::new_table_manager();
$columns = array();
$columns['quote_title'] = array('title' => 'Quote Title', 'callback' => function ($quote) {
    echo module_quote::link_open($quote['quote_id'], true, $quote);
}, 'cell_class' => 'row_action');
$columns['quote_start_date'] = array('title' => 'Create Date', 'callback' => function ($quote) {
    echo print_date($quote['date_create']);
});
$columns['quote_completed_date'] = array('title' => 'Accepted Date', 'callback' => function ($quote) {
    echo print_date($quote['date_approved']);
});
if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
    $columns['quote_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($quote) {
        echo module_website::link_open($quote['website_id'], true);
    });
}
if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
    $columns['quote_customer'] = array('title' => 'Customer', 'callback' => function ($quote) {
        echo module_customer::link_open($quote['customer_id'], true);
コード例 #5
0
// are we sending the paid one? or the dueone.
$template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'quote_staff_email';
$template = module_template::get_template_by_key($template_name);
$quote['quote_name'] = $quote['name'];
$quote['staff_name'] = $staff['name'];
$quote['quote_url'] = module_quote::link_open($quote_id);
$quote['quote_tasks'] = '<ul>';
$quote['task_count'] = 0;
foreach ($quote_tasks as $quote_task) {
    if ($quote_task['user_id'] != $staff_id) {
        continue;
    }
    $quote['quote_tasks'] .= '<li><strong>' . $quote_task['description'] . '</strong>';
    $quote['quote_tasks'] .= ' <br/>';
    if ($quote_task['long_description']) {
        $quote['quote_tasks'] .= _l('Notes:') . ' <em>' . $quote_task['long_description'] . '</em><br/>';
    }
    if ($quote_task['hours']) {
        $quote['quote_tasks'] .= _l('Hours:') . ' ' . $quote_task['hours'] . '<br/>';
    }
    $quote['quote_tasks'] .= '</li>';
    $quote['task_count']++;
}
$quote['quote_tasks'] .= '</ul>';
// find available "to" recipients.
// customer contacts.
$to = array();
$to[] = array('name' => $staff['name'], 'email' => $staff['email']);
$template->assign_values($quote);
module_email::print_compose(array('title' => _l('Email Quote: %s', $quote['name']), 'find_other_templates' => 'quote_staff_email', 'current_template' => $template_name, 'quote_id' => $quote['quote_id'], 'debug_message' => 'Sending quote to staff', 'to' => $to, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_quote::link_open($quote_id), 'cancel_url' => module_quote::link_open($quote_id)));
コード例 #6
0
        }
    }
});
if (!isset($_REQUEST['customer_id'])) {
    $columns['file_customer'] = array('title' => 'Customer', 'callback' => function ($file) {
        echo module_customer::link_open($file['customer_id'], true);
    });
}
if (class_exists('module_job', false)) {
    $columns['file_job'] = array('title' => 'Job', 'callback' => function ($file) {
        echo module_job::link_open($file['job_id'], true);
    });
}
if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
    $columns['file_quote'] = array('title' => 'Quote', 'callback' => function ($file) {
        echo module_quote::link_open($file['quote_id'], true);
    });
}
$columns['file_date_added'] = array('title' => 'Date Added', 'callback' => function ($file) {
    echo _l('%s by %s', print_date($file['date_created']), module_user::link_open($file['create_user_id'], true));
});
if (module_file::can_i('edit', 'Files')) {
    $columns['file_action'] = array('title' => ' ', 'callback' => function ($file) {
        echo '<input type="checkbox" name="bulk_operation[' . $file['file_id'] . ']" value="yes">';
    });
}
if (class_exists('module_extra', false)) {
    $table_manager->display_extra('file', function ($file) {
        module_extra::print_table_data('file', $file['file_id']);
    });
}
コード例 #7
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);
    }
コード例 #8
0
}
$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'];
}
if (!isset($file['staff_ids']) || !is_array($file['staff_ids']) || !count($file['staff_ids'])) {
    $file['staff_ids'] = array(false);
    if (count($staff_member_rel) == 1) {
        $file['staff_ids'] = array(key($staff_member_rel));
    }
}
$fieldset_data['elements'][] = array('title' => 'Staff', 'fields' => array(array('type' => 'hidden', 'name' => 'staff_ids_save', 'value' => 1), '<div id="staff_ids_holder" style="float:left;">', array('type' => 'select', 'name' => 'staff_ids[]', 'options' => $staff_member_rel, 'multiple' => 'staff_ids_holder', 'values' => $file['staff_ids']), '</div>', function () use(&$file) {
    if ($file['quote_id']) {
        echo ' ';
        echo '<a href="' . module_quote::link_open($file['quote_id'], false) . '">' . _l('Open Quote &raquo;') . '</a>';
    }
}, array('type' => 'html', 'value' => '', 'help' => 'Assign a staff member to this file. Staff members are users who have EDIT permissions on Job Tasks. Click the plus sign to add more staff members. You can apply the "Only Assigned Staff" permission in User Role settings to restrict staff members to these files.<br><br>If there are assigned staff members then those members will be the only ones to receive notifications when a change is made to the file. If no staff are assigned to this file then anyone with the "Receive Alerts" permission will receive file change/comment alerts.')));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
hook_handle_callback('layout_column_half', 2);
$fieldset_data = array('heading' => array('title' => _l('Bucket Description'), 'type' => 'h3'), 'elements' => array(array('field' => array('type' => 'wysiwyg', 'name' => 'description', 'value' => $file['description']))));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
if ((int) $file_id > 0) {
    if (module_file::can_i('edit', 'Files')) {
        module_email::display_emails(array('title' => 'File Emails', 'search' => array('file_id' => $file_id)));
    }
    ob_start();
    $search = array();
    $search['bucket_parent_file_id'] = $file_id;
コード例 #9
0
        ?>
            <td><?php 
        foreach ($module->get_data_link_keys() as $key) {
            if (isset($data[$key]) && (int) $data[$key] > 0) {
                switch ($key) {
                    case 'customer_id':
                        echo module_customer::link_open($data[$key], true);
                        break;
                    case 'job_id':
                        echo module_job::link_open($data[$key], true);
                        break;
                    case 'invoice_id':
                        echo module_invoice::link_open($data[$key], true);
                        break;
                    case 'quote_id':
                        echo module_quote::link_open($data[$key], true);
                        break;
                    case 'file_id':
                        echo module_file::link_open($data[$key], true);
                        break;
                }
            }
        }
        ?>
</td>
            <?php 
    }
    /*<td><a href="<?php echo $module->link('',array("data_record_id"=>$data['data_record_id'],"customer_id"=>isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false)); ?>"><?php echo $module->format_record_id($data['data_type_id'],$data['data_record_id']); ?></a></td>
      <td><?php echo $data['status']; ?></td>
      <td><?php echo print_date($data['date_updated']); ?></td>
      <?php */
コード例 #10
0
        $other_templates = array();
        foreach (module_template::get_templates() as $possible_template) {
            if (strpos($possible_template['template_key'], $find_other_templates) !== false) {
                // found another one!
                $other_templates[$possible_template['template_key']] = $possible_template['template_key'];
                // $possible_template['description'];
            }
        }
        if (count($other_templates) > 1) {
            $fieldset_data['elements'][] = array('title' => 'PDF Template', 'field' => array('type' => 'select', 'options' => $other_templates, 'name' => 'quote_template_print', 'value' => $current_template, 'help' => 'Choose the default template for PDF printing and PDF emailing. Name your custom templates quote_pdf_SOMETHING for them to appear in this listing.'));
        }
    }
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
}
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'onclick' => "\$('#form_redirect').val('" . module_quote::link_open(false) . "');", 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !$quote_id || !function_exists('convert_html2pdf'), 'type' => 'submit', 'name' => 'butt_print', 'value' => _l('Print PDF')), array('ignore' => !$quote_id, 'type' => 'submit', 'name' => 'butt_email', 'value' => _l('Email')), array('ignore' => !((int) $quote_id && module_quote::can_i('create', 'Quotes')), 'type' => 'submit', 'name' => 'butt_duplicate', 'value' => _l('Duplicate')), array('ignore' => !((int) $quote_id && module_quote::can_i('delete', 'Quotes')), 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . module_quote::link_open(false) . "';")));
echo module_form::generate_form_actions($form_actions);
if ($do_perm_finish_check) {
    // we call our permission check
    // render finish method here instead of in index.php
    // this allows quote task edit permissions without quote edit permissions.
    // HOPE THIS WORKS! :)
    module_security::render_page_finished();
}
hook_handle_callback('layout_column_half', 2, '65');
/**** DEPOSIT INVOICE *****/
if ($quote_id > 0) {
    $jobs = module_job::get_jobs(array('quote_id' => $quote_id));
    if (count($jobs)) {
        ob_start();
        ?>
コード例 #11
0
ファイル: ticket_billing.php プロジェクト: sgh1986915/php-crm
 * 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()) {
        $quote_list = '';
        foreach ($quotes as $quote) {
            $quote_list .= module_quote::link_open($quote['quote_id'], true, $quote) . ' (<a href="#" onclick="ucm.ticket.add_to_message($(this).data(\'link\'));return false;" data-link="<a href=\'' . module_quote::link_public($quote['quote_id']) . '\'>View Quote</a>">insert link</a>) <br/>';
        }
        $fieldset_data['elements'][] = array('title' => _l('Quotes'), 'fields' => array($quote_list, array('type' => 'button', 'name' => 'new_quote', 'value' => _l('New'), 'onclick' => "window.location.href='" . module_quote::link_open('new', false) . "&ticket_id=" . $ticket_id . "';")));
    }
    echo module_form::generate_fieldset($fieldset_data);
}