示例#1
0
    </td>
</tr>
<?php 
}
$replace['quote_summary'] = ob_get_clean();
/* START QUOTE LINE ITEMS */
$task_decimal_places = module_config::c('task_amount_decimal_places', -1);
if ($task_decimal_places < 0) {
    $task_decimal_places = false;
    // use default currency dec places.
}
$task_decimal_places_trim = module_config::c('task_amount_decimal_places_trim', 0);
$all_item_row_html = '';
$item_count = 0;
// changed from 1
foreach (module_quote::get_quote_items($quote_id, $quote) as $quote_item_id => $quote_item_data) {
    $row_replace = array('item_odd_or_even' => $item_count++ % 2 ? 'odd' : 'even', 'item_number' => '', 'item_description' => '', 'item_tax' => 0, 'item_tax_rate' => '');
    if (isset($quote_item_data['task_order']) && $quote_item_data['task_order'] > 0) {
        $row_replace['item_number'] = $quote_item_data['task_order'];
    } else {
        $row_replace['item_number'] = $item_count;
    }
    $row_replace['item_description'] .= htmlspecialchars($quote_item_data['description']);
    if (module_config::c('quote_show_long_desc', 1)) {
        $long_description = $quote_item_data['long_description'];
        if ($long_description != '') {
            $row_replace['item_description'] .= '<br/><em>' . forum_text($long_description) . '</em>';
        }
    }
    /*if(isset($quote_item_data['date_done']) && $quote_item_data['date_done'] != '0000-00-00'){
          $row_replace['item_date'] .= print_date($quote_item_data['date_done']);
示例#2
0
 public static function get_tasks($job_id, $order_by = 'task')
 {
     if ((int) $job_id <= 0) {
         // are we creating a job from a quote?
         if (isset($_REQUEST['from_quote_id']) && (int) $_REQUEST['from_quote_id'] > 0) {
             $quote_id = (int) $_REQUEST['from_quote_id'];
             $quote_data = module_quote::get_quote($quote_id);
             $quote_tasks = module_quote::get_quote_items($quote_id, $quote_data);
             foreach ($quote_tasks as $quote_task_id => $quote_task) {
                 $quote_tasks[$quote_task_id]['invoiced'] = 0;
                 $quote_tasks[$quote_task_id]['task_id'] = 0;
                 $quote_tasks[$quote_task_id]['job_id'] = 0;
                 $quote_tasks[$quote_task_id]['completed'] = 0;
                 $quote_tasks[$quote_task_id]['date_due'] = false;
                 $quote_tasks[$quote_task_id]['approval_required'] = false;
             }
             return $quote_tasks;
         }
         return array();
     }
     if (isset(self::$job_tasks_cache[$job_id])) {
         return self::$job_tasks_cache[$job_id];
     }
     $sql = "SELECT t.*, t.task_id AS id, i.invoice_item_id AS invoiced, i.invoice_id AS invoice_id ";
     $sql .= ", SUM(tl.hours) AS `completed` ";
     $sql .= ", inv.name AS invoice_number";
     $sql .= ", u.name AS user_name";
     $sql .= ", j.name AS job_name";
     $sql .= ", j.default_task_type";
     $sql .= ", j.user_id AS job_user_id";
     $sql .= " FROM `" . _DB_PREFIX . "task` t ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "task_log` tl ON t.task_id = tl.task_id";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "invoice_item` i ON t.task_id = i.task_id ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "invoice` inv ON i.invoice_id = inv.invoice_id ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "user` u ON t.user_id = u.user_id ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "job` j ON t.job_id = j.job_id";
     $sql .= " WHERE t.`job_id` = " . (int) $job_id;
     // permissions
     $job_task_permissions = self::get_job_task_access_permissions();
     switch ($job_task_permissions) {
         case _JOB_TASK_ACCESS_ASSIGNED_ONLY:
             $sql .= " AND t.`user_id` = " . (int) module_security::get_loggedin_id();
             break;
     }
     $sql .= " GROUP BY t.task_id ";
     switch ($order_by) {
         case 'task':
             $sql .= " ORDER BY t.task_order, t.date_due ASC ";
             break;
         case 'date':
             $sql .= " ORDER BY t.date_due ASC ";
             break;
     }
     $res = qa($sql, false);
     // permission hack to
     foreach ($res as $rid => $r) {
         $job_data = array('user_id' => $r['job_user_id']);
         if ($r['staff_split'] && module_job::job_task_only_show_split_hours($job_id, $job_data, $r['task_id'], $r)) {
             //                $res[$rid]['hours'] = $r['staff_hours'];
             //                $res[$rid]['amount'] = $r['staff_amount'];
             // others here
         }
     }
     self::$job_tasks_cache[$job_id] = $res;
     return self::$job_tasks_cache[$job_id];
     //return get_multiple("task",array('job_id'=>$job_id),"task_id","exact","task_id");
 }
示例#3
0
$quote_id = (int) $quote['quote_id'];
$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 ($quote_id > 0 && $quote['quote_id'] == $quote_id) {
    $module->page_title = _l('Quote: %s', $quote['name']);
} else {
    $module->page_title = _l('Quote: %s', _l('New'));
}
// check permissions.
if (class_exists('module_security', false)) {
    module_security::sanatise_data('quote', $quote);
}
$quote_tasks = module_quote::get_quote_items($quote_id, $quote);
if (class_exists('module_import_export', false)) {
    if (module_quote::can_i('view', 'Export Quote Tasks')) {
        module_import_export::enable_pagination_hook(array('name' => 'Quote Tasks Export', 'fields' => array('Quote Name' => 'quote_name', 'Task ID' => 'quote_task_id', 'Order' => 'task_order', 'Short Description' => 'description', 'Long Description' => 'long_description', 'Hours' => 'hours', 'Amount' => 'amount', 'Billable' => 'billable', 'Staff Member' => 'user_name')));
        if (isset($_REQUEST['import_export_go']) && $_REQUEST['import_export_go'] == 'yes') {
            // do the task export.
            module_import_export::run_pagination_hook($quote_tasks);
        }
    }
    if (module_quote::can_i('view', 'Import Quote Tasks')) {
        $import_tasks_link = module_import_export::import_link(array('callback' => 'module_quote::handle_import_tasks', 'name' => 'Quote Tasks', 'quote_id' => $quote_id, 'return_url' => $_SERVER['REQUEST_URI'], 'fields' => array('Task ID' => array('quote_task_id', false, 'The existing system ID for this task. Will overwrite existing task ID. Leave blank to create new task.'), 'Order' => array('task_order', false, 'The numerical order the tasks will appear in.'), 'Short Description' => array('description', true), 'Long Description' => 'long_description', 'Hours' => 'hours', 'Hours Completed' => 'completed', 'Amount' => 'amount', 'Billable' => array('billable', false, '1 for billable, 0 for non-billable'), 'Staff Member' => array('user_name', false, 'One of: ' . implode(', ', $staff_member_rel)))));
    }
}
?>