Esempio n. 1
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
 */
if (!module_invoice::can_i('edit', 'Invoice Settings', 'Config')) {
    redirect_browser(_BASE_HREF);
}
ob_start();
$templates = module_template::get_templates();
$invoice_templates = array();
$invoice_templates['external_invoice'] = 1;
$invoice_templates['credit_note_external'] = 1;
$invoice_templates['invoice_payment_receipt'] = 1;
$invoice_templates['invoice_print'] = 1;
$invoice_templates['invoice_print_basic'] = 1;
$invoice_templates['invoice_task_list'] = 1;
$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;
Esempio n. 2
0
         echo " ";
         echo '<span class="';
         if ($job['total_amount_due'] > 0) {
             echo 'error_text';
         } else {
             echo 'success_text';
         }
         echo '">';
         if ($job['total_amount'] > 0) {
             echo dollar($job['total_amount'], true, $job['currency_id']);
         }
         echo '</span>';
         echo "<br>";
     }
 });
 if (module_invoice::can_i('view', 'Invoices')) {
     $columns['invoice'] = array('title' => 'Invoice', 'callback' => function ($quote) use(&$job_ids) {
         foreach ($job_ids as $job_id) {
             foreach (module_invoice::get_invoices(array('job_id' => $job_id)) as $invoice) {
                 $invoice = module_invoice::get_invoice($invoice['invoice_id']);
                 if (!$invoice) {
                     continue;
                 }
                 echo module_invoice::link_open($invoice['invoice_id'], true);
                 echo " ";
                 echo '<span class="';
                 if ($invoice['total_amount_due'] > 0) {
                     echo 'error_text';
                 } else {
                     echo 'success_text';
                 }
Esempio n. 3
0
        include 'includes/plugin_finance/pages/finance_invoice_edit.php';
    }
}
// invoice_id check
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'onclick' => "\$('#form_redirect').val('" . (!$invoice_id && isset($_REQUEST['job_id']) && (int) $_REQUEST['job_id'] > 0 ? module_job::link_open($_REQUEST['job_id']) : module_invoice::link_open(false)) . "');", 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save'))));
if ((int) $invoice_id) {
    if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
        $form_actions['elements'][] = array('type' => 'save_button', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Receipt'));
    } else {
        $form_actions['elements'][] = array('type' => 'submit', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Invoice'));
    }
    if (function_exists('convert_html2pdf')) {
        if (!module_invoice::can_i('edit', 'Invoices')) {
            $form_actions['elements'][] = array('type' => 'button', 'class' => 'submit_button no_permissions', 'name' => 'butt_print', 'value' => _l('Print PDF'), 'onclick' => "window.location.href='" . module_invoice::link_public_print($invoice_id) . "';");
        } else {
            $form_actions['elements'][] = array('type' => 'submit', 'class' => 'submit_button', 'name' => 'butt_print', 'value' => _l('Print PDF'));
        }
    }
}
if ((int) $invoice_id && module_invoice::can_i('delete', 'Invoices')) {
    $form_actions['elements'][] = array('type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete'));
}
$form_actions['elements'][] = array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . module_invoice::link_open(false) . "';");
echo module_form::generate_form_actions($form_actions);
?>



</form>
Esempio n. 4
0
" />
    <input type="hidden" name="quote_id" value="<?php 
echo (int) $job['quote_id'];
?>
" />


    <?php 
$fields = array('fields' => array('name' => 'Name'));
module_form::set_required($fields);
//module_form::set_default_field('task_desc_new');
module_form::set_default_field('job_name');
module_form::prevent_exit(array('valid_exits' => array('.submit_button', '.save_task', '.delete', '.task_defaults')));
hook_handle_callback('layout_column_half', 1, '35');
/**** JOB DETAILS ****/
$fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Job Details'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => 'Job Title', 'field' => array('type' => 'text', 'name' => 'name', 'value' => $job['name'])), 'type' => array('title' => 'Type', 'field' => array('type' => 'select', 'name' => 'type', 'value' => $job['type'], 'blank' => false, 'options' => module_job::get_types(), 'allow_new' => true)), 'hourly_rate' => array('title' => 'Hourly Rate', 'ignore' => !module_invoice::can_i('view', 'Invoices'), 'field' => array('type' => 'currency', 'name' => 'hourly_rate', 'value' => number_out($job['hourly_rate']))), 'status' => array('title' => 'Status', 'field' => array('type' => 'select', 'name' => 'status', 'value' => $job['status'], 'blank' => false, 'options' => module_job::get_statuses(), 'allow_new' => true)), 'date_quote' => array('title' => 'Quote Date', 'ignore' => !module_config::c('job_allow_quotes', 0), 'field' => array('type' => 'date', 'name' => 'date_quote', 'value' => print_date($job['date_quote']), 'help' => 'This is the date the Job was quoted to the Customer. Once this Job Quote is approved, the Start Date will be set below.')), 'date_start' => array('title' => 'Start Date', 'field' => array('type' => 'date', 'name' => 'date_start', 'value' => print_date($job['date_start']), 'help' => 'This is the date the Job is scheduled to start work. This can be a date in the future. If you have the Calendar, this is the date that will be used for the Calendar event.')), 'time_start' => array('title' => 'Start Time', 'ignore' => !(class_exists('module_calendar', false) && module_config::c('job_show_times', 1)), 'field' => array('type' => 'time', 'name' => 'time_start', 'value' => isset($job['time_start']) ? $job['time_start'] : '', 'help' => 'This is the time the Job is scheduled to start.  If you have the Calendar, this is the time that will be used for the Calendar event.')), 'time_end' => array('title' => 'End Time', 'ignore' => !(class_exists('module_calendar', false) && module_config::c('job_show_times', 1)), 'field' => array('type' => 'time', 'name' => 'time_end', 'value' => isset($job['time_end']) ? $job['time_end'] : '', 'help' => 'This is the time the Job is scheduled to finish.  If you have the Calendar, this is the time that will be used for the Calendar event.')), 'date_due' => array('title' => 'Due Date', 'field' => array('type' => 'date', 'name' => 'date_due', 'value' => print_date($job['date_due']))), 'date_completed' => array('title' => 'Finished Date', 'field' => array('type' => 'date', 'name' => 'date_completed', 'value' => print_date($job['date_completed']))), 'user_id' => array('title' => 'Staff Member', 'ignore' => !module_config::c('job_allow_staff_assignment', 1), 'field' => array('type' => 'select', 'options' => $staff_member_rel, 'name' => 'user_id', 'value' => $job['user_id'], 'blank' => false, 'help' => 'Assign a staff member to this job. You can also assign individual tasks to different staff members. Staff members are users who have EDIT permissions on Job Tasks.'))), 'extra_settings' => array('owner_table' => 'job', 'owner_key' => 'job_id', 'owner_id' => $job['job_id'], 'layout' => 'table_row', 'allow_new' => module_job::can_i('create', 'Jobs'), 'allow_edit' => module_job::can_i('create', 'Jobs')));
$incrementing = false;
if (!isset($job['taxes']) || !count($job['taxes'])) {
    $job['taxes'][] = array();
    // at least have 1?
}
foreach ($job['taxes'] as $tax) {
    if (isset($tax['increment']) && $tax['increment']) {
        $incrementing = true;
    }
}
ob_start();
?>

    <span class="job_tax_increment">
        <input type="checkbox" name="tax_increment_checkbox" id="tax_increment_checkbox" value="1" <?php 
Esempio n. 5
0
 public static function bulk_handle_delete()
 {
     if (isset($_REQUEST['bulk_action']) && isset($_REQUEST['bulk_action']['delete']) && $_REQUEST['bulk_action']['delete'] == 'yes' && module_form::check_secure_key() && module_invoice::can_i('delete', 'Invoices')) {
         // confirm deletion of these tickets:
         $invoice_ids = isset($_REQUEST['invoice_bulk_operation']) && is_array($_REQUEST['invoice_bulk_operation']) ? $_REQUEST['invoice_bulk_operation'] : array();
         foreach ($invoice_ids as $invoice_id => $k) {
             if ($k != 'yes') {
                 unset($invoice_ids[$invoice_id]);
             } else {
                 $invoice_ids[$invoice_id] = module_invoice::link_open($invoice_id, true);
             }
         }
         if (count($invoice_ids) > 0) {
             if (module_form::confirm_delete('invoice_id', _l("Really delete invoices: %s", implode(', ', $invoice_ids)), self::link_open(false))) {
                 foreach ($invoice_ids as $invoice_id => $invoice_number) {
                     self::delete_invoice($invoice_id);
                 }
                 set_message(_l("%s invoices deleted successfully", count($invoice_ids)));
                 redirect_browser(self::link_open(false));
             }
         }
     }
 }
Esempio n. 6
0
                                </td>
                            </tr>
                        <?php 
        }
        ?>

                    </tbody>
                </table>
                <?php 
    }
    ?>

                    </div>
                    <?php 
    $fieldset_data = array('heading' => array('title' => 'Job Invoices:', 'type' => 'h3'), 'elements_before' => ob_get_clean());
    if (module_invoice::can_i('create', 'Invoices')) {
        $fieldset_data['heading']['button'] = array('title' => _l('Create New Invoice'), 'url' => '#', 'id' => 'job_generate_invoice_button');
    }
    echo module_form::generate_fieldset($fieldset_data);
}
if (class_exists('module_finance', false) && module_finance::is_plugin_enabled() && module_finance::can_i('view', 'Finance') && (int) $job_id > 0 && module_finance::is_enabled() && is_file('includes/plugin_finance/pages/finance_job_edit.php')) {
    include 'includes/plugin_finance/pages/finance_job_edit.php';
}
?>


</form>
<?php 
// run the custom data hook to display items in this particular hook location
hook_handle_callback('custom_data_hook_location', _CUSTOM_DATA_HOOK_LOCATION_JOB_FOOTER, 'job', $job_id, $job);
hook_handle_callback('layout_column_half', 'end');
Esempio n. 7
0
" size="2" style="width:35px"
                    id="complete_<?php 
    echo $task_id;
    ?>
" tabindex="16"> <?php 
    _e('hours');
    ?>
        <?php 
}
?>
        </div>
    </td>
    <td colspan="2" class="edit_task_options">
        <div>
        <?php 
if ($task_editable && module_invoice::can_i('view', 'Invoices')) {
    ?>
            <input type="hidden" name="job_task[<?php 
    echo $task_id;
    ?>
][billable_t]" value="1">
            <input type="checkbox" name="job_task[<?php 
    echo $task_id;
    ?>
][billable]" value="1" id="billable_t_<?php 
    echo $task_id;
    ?>
" <?php 
    echo $task_data['billable'] ? ' checked' : '';
    ?>
 tabindex="17"> <label for="billable_t_<?php 
Esempio n. 8
0
if (class_exists('module_group', false) && module_customer::can_i('view', $page_type_single . ' Groups')) {
    $columns['customer_group'] = array('title' => 'Group', 'callback' => function ($customer) {
        if (isset($customer['group_sort_customer'])) {
            echo htmlspecialchars($customer['group_sort_customer']);
        } else {
            // find the groups for this customer.
            $groups = module_group::get_groups_search(array('owner_table' => 'customer', 'owner_id' => $customer['customer_id']));
            $g = array();
            foreach ($groups as $group) {
                $g[] = $group['name'];
            }
            echo htmlspecialchars(implode(', ', $g));
        }
    });
}
if (class_exists('module_invoice', false) && module_invoice::can_i('view', 'Invoices') && module_config::c('customer_list_show_invoices', 1)) {
    $columns['customer_invoices'] = array('title' => 'Invoices', 'callback' => function ($customer) {
        $invoices = module_invoice::get_invoices(array('customer_id' => $customer['customer_id']));
        if (count($invoices)) {
            $total_due = 0;
            $total_paid = 0;
            foreach ($invoices as $invoice) {
                $invoice = module_invoice::get_invoice($invoice['invoice_id']);
                $total_due += $invoice['total_amount_due'];
                $total_paid += $invoice['total_amount_paid'];
            }
            $old_customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false;
            $_REQUEST['customer_id'] = $customer['customer_id'];
            echo '<a href="' . module_invoice::link_open(false) . '">' . _l('%s invoice%s: %s', count($invoices), count($invoices) > 1 ? 's' : '', ($total_due > 0 ? '<span class="error_text">' . _l('%s due', dollar($total_due, true, $invoice['currency_id'])) . ' </span>' : '') . ($total_paid > 0 ? '<span class="success_text">' . _l('%s paid', dollar($total_paid, true, $invoice['currency_id'])) . ' </span>' : '')) . '</a>';
            if ($old_customer_id) {
                $_REQUEST['customer_id'] = $old_customer_id;
Esempio n. 9
0
    public function process()
    {
        $errors = array();
        if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['job_id']) {
            $data = self::get_job($_REQUEST['job_id']);
            if (module_form::confirm_delete('job_id', _l("Really delete job: %s", $data['name']), self::link_open($_REQUEST['job_id']))) {
                $this->delete_job($_REQUEST['job_id']);
                set_message("job deleted successfully");
                redirect_browser($this->link_open(false));
            }
        } else {
            if ("ajax_job_list" == $_REQUEST['_process']) {
                $customer_id = isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : 0;
                $res = module_job::get_jobs(array('customer_id' => $customer_id));
                $options = array();
                foreach ($res as $row) {
                    $options[$row['job_id']] = $row['name'];
                }
                echo json_encode($options);
                exit;
            } else {
                if ("ajax_create_invoice" == $_REQUEST['_process']) {
                    $job_id = (int) $_REQUEST['job_id'];
                    $job = self::get_job($job_id, true);
                    $job_tasks = self::get_tasks($job_id);
                    if (!$job || $job['job_id'] != $job_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 ($job['uninvoiced_task_ids'] as $task_id) {
                        if (isset($job_tasks[$task_id])) {
                            ?>

                            <li>
                                <input type="checkbox" id="invoice_create_task_<?php 
                            echo $task_id;
                            ?>
" data-taskid="<?php 
                            echo $task_id;
                            ?>
" class="invoice_create_task" name="invoice_task_id[<?php 
                            echo $task_id;
                            ?>
]" value="1" <?php 
                            echo $job_tasks[$task_id]['fully_completed'] ? 'checked' : '';
                            ?>
>
                                <label for="invoice_create_task_<?php 
                            echo $task_id;
                            ?>
">
                                    (#<?php 
                            echo $job_tasks[$task_id]['task_order'];
                            ?>
)
                                    <?php 
                            echo htmlspecialchars($job_tasks[$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.
                        $job_id = (int) $_REQUEST['job_id'];
                        $job = self::get_job($job_id, true);
                        $job_tasks = self::get_tasks($job_id);
                        if (!$job || $job['job_id'] != $job_id) {
                            exit;
                        }
                        // no permissions.
                        if (!self::can_i('edit', 'Job Tasks')) {
                            exit;
                        }
                        // no permissions
                        if (isset($_REQUEST['toggle_completed'])) {
                            $task_id = (int) $_REQUEST['task_id'];
                            $task_data = $job_tasks[$task_id];
                            $result = array();
                            if ($task_data && $task_data['job_id'] == $job_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 job task
                                    $this->save_job_tasks($job_id, array('job_task' => array($task_id => $task_data)));
                                    $result['success'] = 1;
                                    $result['job_id'] = $job_id;
                                    $result['task_id'] = $task_id;
                                    $result['message'] = $task_data['fully_completed'] ? _l('Task marked as complete') : _l('Task marked as incomplete');
                                    $email_status = self::send_job_task_email($job_id, $result['task_id'], 'toggle');
                                    if ($email_status !== false) {
                                        $result['message'] .= is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : _l(' and email sent to customer');
                                    }
                                }
                            }
                            echo json_encode($result);
                            exit;
                        } else {
                            if (isset($_REQUEST['delete_task_log_id']) && (int) $_REQUEST['delete_task_log_id'] > 0) {
                                $task_id = (int) $_REQUEST['task_id'];
                                $task_log_id = (int) $_REQUEST['delete_task_log_id'];
                                $sql = "DELETE FROM `" . _DB_PREFIX . "task_log` WHERE task_id = '{$task_id}' AND task_log_id = '{$task_log_id}' LIMIT 1";
                                query($sql);
                                echo 'done';
                            } else {
                                if (isset($_REQUEST['update_task_order'])) {
                                    // updating the task orders for this task..
                                    $task_order = (array) $_REQUEST['task_order'];
                                    foreach ($task_order as $task_id => $new_order) {
                                        if ((int) $new_order > 0 && isset($job_tasks[$task_id])) {
                                            update_insert('task_id', $task_id, 'task', array('task_order' => (int) $new_order));
                                        }
                                    }
                                    echo 'done';
                                } else {
                                    $task_id = (int) $_REQUEST['task_id'];
                                    $task_data = $job_tasks[$task_id];
                                    $task_editable = !$task_data['invoiced'];
                                    $job_task_creation_permissions = module_job::get_job_task_creation_permissions();
                                    // 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 job 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($job['default_task_type'])) {
                                        // use the job task type
                                        $task_data['manual_task_type'] = $job['default_task_type'];
                                    }
                                    $percentage = self::get_percentage($task_data);
                                    if (isset($_REQUEST['get_preview'])) {
                                        $after_task_id = $task_id;
                                        // this will put it right back where it started.
                                        $previous_task_id = 0;
                                        $job_tasks = self::get_tasks($job_id);
                                        $show_hours_summary = false;
                                        foreach ($job_tasks as $k => $v) {
                                            if ($v['manual_task_type'] < 0) {
                                                $job_tasks[$k]['manual_task_type'] = $job['default_task_type'];
                                            }
                                            if ($job_tasks[$k]['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT) {
                                                $show_hours_summary = true;
                                            }
                                        }
                                        foreach ($job_tasks as $k => $v) {
                                            // find out where this new task position is!
                                            if ($k == $task_id) {
                                                $after_task_id = $previous_task_id;
                                                break;
                                            }
                                            $previous_task_id = $k;
                                        }
                                        $create_invoice_button = '';
                                        //if($job['total_amount_invoicable'] > 0 && module_invoice::can_i('create','Invoices')){
                                        if (count($job['uninvoiced_task_ids']) && module_invoice::can_i('create', 'Invoices')) {
                                            //href="'.module_invoice::link_generate('new',array('arguments'=>array( 'job_id' => $job_id, ))).'"
                                            $create_invoice_button = '<a class="submit_button save_button uibutton job_generate_invoice_button" onclick="return ucm.job.generate_invoice();">' . _l('Create Invoice') . '</a>';
                                        }
                                        $result = array('task_id' => $task_id, 'after_task_id' => $after_task_id, 'html' => self::generate_task_preview($job_id, $job, $task_id, $task_data), 'summary_html' => self::generate_job_summary($job_id, $job, $show_hours_summary), 'create_invoice_button' => $create_invoice_button);
                                        echo json_encode($result);
                                    } else {
                                        $show_task_numbers = module_config::c('job_show_task_numbers', 1) && $job['auto_task_numbers'] != 2;
                                        ob_start();
                                        include 'pages/ajax_task_edit.php';
                                        $result = array('task_id' => $task_id, 'hours' => isset($_REQUEST['hours']) ? (double) $_REQUEST['hours'] : 0, 'html' => ob_get_clean());
                                        echo json_encode($result);
                                    }
                                }
                            }
                        }
                        exit;
                    } else {
                        if ("save_job_tasks_ajax" == $_REQUEST['_process']) {
                            // do everything via ajax. trickery!
                            // dont bother saving the job. it's already created.
                            $job_id = (int) $_REQUEST['job_id'];
                            $job_data = self::get_job($job_id);
                            if (!$job_id || !$job_data || $job_data['job_id'] != $job_id) {
                                set_error('Permission denied');
                                exit;
                            }
                            $result = $this->save_job_tasks($job_id, $_POST);
                            $job_data = self::get_job($job_id, false);
                            //if(!$job_data || $job_data['job_id'] != $job_id)
                            $new_status = self::update_job_completion_status($job_id);
                            $new_status = addcslashes(htmlspecialchars($new_status), "'");
                            //module_cache::clear_cache();
                            $new_job_data = self::get_job($job_id, false);
                            // 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['task_id'] > 0) {
                                        // support for job task completion email.
                                        $email_status = self::send_job_task_email($job_id, $result['task_id'], 'created');
                                        ?>

                        <script type="text/javascript">
                            parent.refresh_task_preview(<?php 
                                        echo (int) $result['task_id'];
                                        ?>
);
                            parent.clear_create_form();
                            parent.ucm.add_message('<?php 
                                        _e('New task created successfully');
                                        echo is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : ($email_status ? _l(' and email sent to customer') : '');
                                        ?>
');
                            parent.ucm.display_messages(true);
                            <?php 
                                        if ($job_data['status'] != $new_status) {
                                            ?>
parent.jQuery('#status').val('<?php 
                                            echo $new_status;
                                            ?>
').change();<?php 
                                        }
                                        ?>

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

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

                        <script type="text/javascript">
                            top.location.href = '<?php 
                                        echo $this->link_open($_REQUEST['job_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($_REQUEST['job_id']);
                                    ?>
';
                        <?php 
                                    if ($job_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($_REQUEST['job_id']);
                                    ?>
';
                    </script>
                    <?php 
                                    break;
                                case 'edited':
                                    // we changed a task (ie: completed?);
                                    // update this task above.
                                    if ((int) $result['task_id'] > 0) {
                                        $email_status = self::send_job_task_email($job_id, $result['task_id'], 'edited');
                                        ?>

                        <script type="text/javascript">
                            parent.canceledittask();
                            //parent.refresh_task_preview(<?php 
                                        echo (int) $result['task_id'];
                                        ?>
);
                            parent.ucm.add_message('<?php 
                                        _e('Task saved successfully');
                                        echo is_array($email_status) && isset($email_status['message']) ? $email_status['message'] : ($email_status ? _l(' and email sent to customer') : '');
                                        ?>
');
                            parent.ucm.display_messages(true);
                            <?php 
                                        if ($job_data['status'] != $new_status) {
                                            ?>
parent.jQuery('#status').val('<?php 
                                            echo $new_status;
                                            ?>
').change();<?php 
                                        }
                                        ?>

                            <?php 
                                        if ($new_job_data['date_completed'] != $job_data['date_completed']) {
                                            ?>
parent.jQuery('#date_completed').val('<?php 
                                            echo print_date($new_job_data['date_completed']);
                                            ?>
').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 ($job_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;
                        } else {
                            if ("save_job" == $_REQUEST['_process']) {
                                $job_id = (int) $_REQUEST['job_id'];
                                if ((int) $job_id > 0) {
                                    $original_job_data = self::get_job($job_id, false);
                                    if (!$original_job_data || $original_job_data['job_id'] != $job_id) {
                                        $original_job_data = array();
                                        $job_id = false;
                                    }
                                } else {
                                    $original_job_data = array();
                                    $job_id = false;
                                }
                                // check create permissions.
                                if (!$job_id && !self::can_i('create', 'Jobs')) {
                                    // user not allowed to create jobs.
                                    set_error('Unable to create new Jobs');
                                    redirect_browser(self::link_open(false));
                                } else {
                                    if ($job_id && !self::can_i('edit', 'Jobs')) {
                                        // user not allowed to create jobs.
                                        set_error('Unable to edit Jobs');
                                        redirect_browser(self::link_open(false));
                                    }
                                }
                                $job_id = $this->save_job($job_id, $_POST);
                                // 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('job_task' => array());
                                                foreach ($task_data as $task) {
                                                    $task['job_id'] = $job_id;
                                                    if ($task['date_due'] && $task['date_due'] != '0000-00-00') {
                                                        $diff_time = strtotime($task['date_due']) - $task['saved_time'];
                                                        $task['date_due'] = date('Y-m-d', time() + $diff_time);
                                                    }
                                                    $new_task_data['job_task'][] = $task;
                                                }
                                                $this->save_job_tasks($job_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($job_id);
                                                $cached_task_data = array();
                                                foreach ($task_data as $task) {
                                                    unset($task['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;
                                    }
                                }
                                // check if we are generating any renewals
                                if (isset($_REQUEST['generate_renewal']) && $_REQUEST['generate_renewal'] > 0) {
                                    $new_job_id = $this->renew_job($job_id);
                                    set_message("Job renewed successfully");
                                    redirect_browser($this->link_open($new_job_id));
                                }
                                if (isset($_REQUEST['butt_create_deposit']) && isset($_REQUEST['job_deposit']) && $_REQUEST['job_deposit'] > 0) {
                                    if (strpos($_REQUEST['job_deposit'], '%') !== false) {
                                        $job_data = module_job::get_job($job_id);
                                        $percent = (int) str_replace('%', '', $_REQUEST['job_deposit']);
                                        $_REQUEST['job_deposit'] = number_out($job_data['total_amount'] * ($percent / 100));
                                    }
                                    // create an invoice for this job.
                                    $url = module_invoice::link_generate('new', array('arguments' => array('job_id' => $job_id, 'as_deposit' => 1, 'amount_due' => number_in($_REQUEST['job_deposit']), 'description' => str_replace('{JOB_NAME}', $_POST['name'], module_config::c('job_deposit_text', 'Deposit for job: {JOB_NAME}')))));
                                    redirect_browser($url);
                                }
                                set_message("Job saved successfully");
                                redirect_browser(isset($_REQUEST['_redirect']) && !empty($_REQUEST['_redirect']) ? $_REQUEST['_redirect'] : $this->link_open($job_id));
                            }
                        }
                    }
                }
            }
        }
        if (!count($errors)) {
            redirect_browser($_REQUEST['_redirect']);
            exit;
        }
        print_error($errors, true);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
        echo _l('Credit: %s', dollar($invoice['total_amount_credit'], true, $invoice['currency_id']));
        ?>
</span>
            <?php 
    }
});
if (class_exists('module_extra', false)) {
    ob_start();
    $colspan2 += module_extra::print_table_header('invoice');
    // used in the footer calc.
    ob_end_clean();
    $table_manager->display_extra('invoice', function ($invoice) {
        module_extra::print_table_data('invoice', $invoice['invoice_id']);
    });
}
if (module_invoice::can_i('edit', 'Invoices')) {
    $colspan2++;
    // used in the footer
    $columns['row_bulk_action'] = array('title' => ' ', 'callback' => function ($invoice) {
        echo '<input type="checkbox" name="invoice_bulk_operation[' . $invoice['invoice_id'] . ']" value="yes">';
    });
}
$table_manager->set_columns($columns);
$table_manager->row_callback = function ($row_data) {
    // load the full vendor data before displaying each row so we have access to more details
    if (isset($row_data['invoice_id']) && (int) $row_data['invoice_id'] > 0) {
        return module_invoice::get_invoice($row_data['invoice_id']);
    }
    return array();
};
$table_manager->set_rows($invoices);
Esempio n. 12
0
}
// end can i view job tasks
?>


                <?php 
if (module_invoice::can_i('view', 'Invoices') && (int) $job_id > 0) {
    ?>

                <h3><?php 
    _e('Job Invoices:');
    ?>
</h3>
                <div class="content_box_wheader">
                    <span id="create_invoice_button"><?php 
    if ($job['total_amount_invoicable'] > 0 && module_invoice::can_i('create', 'Invoices')) {
        ?>

                        <p align="center"><a class="submit_button save_button ui-button" href="<?php 
        echo module_invoice::link_generate('new', array('arguments' => array('job_id' => $job_id)));
        ?>
"><?php 
        echo _l('Create %s Invoice', dollar($job['total_amount_invoicable'], true, $job['currency_id']));
        ?>
</a>
                        </p>
                        <?php 
    }
    ?>
</span>
                    <?php