<?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 */ $job_safe = true; // stop including files directly. if (!module_job::can_i('view', 'Jobs')) { echo 'permission denied'; return; } if (isset($_REQUEST['job_id'])) { if (isset($_REQUEST['email_staff'])) { include module_theme::include_ucm("includes/plugin_job/pages/job_admin_email_staff.php"); } else { if (isset($_REQUEST['email'])) { include module_theme::include_ucm("includes/plugin_job/pages/job_admin_email.php"); } else { if ((int) $_REQUEST['job_id'] > 0) { include module_theme::include_ucm("includes/plugin_job/pages/job_admin_edit.php"); //include("job_admin_edit.php"); } else { include module_theme::include_ucm("includes/plugin_job/pages/job_admin_create.php"); //include("job_admin_create.php"); }
</tbody> </table> </div> <?php $fieldset_data['elements_before'] = ob_get_clean(); } echo module_form::generate_fieldset($fieldset_data); } } // show the jobs linked to this website. if (module_job::is_plugin_enabled() && module_job::can_i('view', 'Jobs')) { $jobs = module_job::get_jobs(array('website_id' => $website_id)); if (count($jobs) || module_job::can_i('create', 'Jobs')) { $h = array('type' => 'h3', 'title' => module_config::c('project_name_single', 'Website') . ' Jobs'); if (module_job::can_i('create', 'Jobs')) { $h['button'] = array('title' => 'New Job', 'url' => module_job::link_generate('new', array('arguments' => array('website_id' => $website_id)))); } $fieldset_data = array('heading' => $h); if (count($jobs)) { $c = 0; ob_start(); ?> <div class="content_box_wheader"> <table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_rows tableclass_full"> <thead> <tr> <th> <?php
$show_split_hours = false; $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); if (module_job::job_task_has_split_hours($job_id, $job, $task_id, $task_data)) { if ($task_data['staff_split']) { // has saved this task - using database detauls } else { // use defaults above. $task_data['staff_hours'] = $task_data['hours']; $task_data['staff_amount'] = $task_data['amount']; } if (module_job::can_i('view', 'Job Split Pricing')) { $show_split_hours = true; // do we show the staff_ settings or default them to the job settings? } else { $hours_prefix = 'staff_'; } } ?> <tr class="task_row_<?php echo $task_id; ?> task_preview<?php echo $percentage >= 1 ? ' tasks_completed' : ''; ?> <?php echo $task_editable ? ' task_editable' : '';
?> <td valign="top" style="padding:0.3em 0;"> <input type="text" name="job_task[<?php echo $task_id; ?> ][task_order]" value="<?php echo $task_data['task_order']; ?> " size="3" class="edit_task_order"> </td> <?php } ?> <td> <?php if ($task_editable && module_job::can_i('delete', 'Job Tasks')) { ?> <a href="#" onclick="if(confirm('<?php _e('Delete Task?'); ?> ')){$(this).parent().find('input').val('<?php echo _TASK_DELETE_KEY; ?> '); $('#job_task_form')[0].submit();} return false;" class="delete ui-state-default ui-corner-all ui-icon ui-icon-trash" style="display:inline-block; float:right;">[x]</a> <?php } ?> <input type="text" class="edit_task_description" name="job_task[<?php echo $task_id; ?> ][description]" value="<?php
?> " id="taxable_t_new"> <input type="hidden" name="job_task[new][manual_task_type]" value="-1" id="manual_task_type_new"> </td> </tr> </tbody> <?php } ?> <?php $c = 0; $task_number = 0; foreach ($job_tasks as $task_id => $task_data) { $task_number++; if (module_security::is_page_editable() && module_job::can_i('edit', 'Job Tasks')) { ?> <tbody id="task_edit_<?php echo $task_id; ?> " style="display:none;" class="task_edit"></tbody> <?php } else { $task_editable = false; } echo module_job::generate_task_preview($job_id, $job, $task_id, $task_data, false, array('from_quote' => isset($_REQUEST['from_quote_id']))); ?> <input type="hidden" name="job_task[new<?php echo $task_number;
private static function save_job_tasks($job_id, $data) { $result = array('status' => false); $check_completed = false; $job_data = false; $job_task_creation_permissions = self::get_job_task_creation_permissions(); // check for new tasks or changed tasks. $tasks = self::get_tasks($job_id); if (isset($data['job_task']) && is_array($data['job_task'])) { foreach ($data['job_task'] as $task_id => $task_data) { if (isset($task_data['manual_percent']) && strlen($task_data['manual_percent']) == 0) { unset($task_data['manual_percent']); } $original_task_id = $task_id; $task_id = (int) $task_id; if (!is_array($task_data)) { continue; } if ($task_id > 0 && !isset($tasks[$task_id])) { $task_id = 0; // creating a new task on this job. } if (!isset($task_data['description']) || $task_data['description'] == '' || $task_data['description'] == _TASK_DELETE_KEY) { if ($task_id > 0 && $task_data['description'] == _TASK_DELETE_KEY) { // remove task. // but onyl remove it if it hasn't been invoiced. if (isset($tasks[$task_id]) && $tasks[$task_id]['invoiced']) { // it has been invoiced! dont remove it. set_error('Unable to remove an invoiced task'); $result['status'] = 'error'; break; // break out of loop saving tasks. } else { $sql = "DELETE FROM `" . _DB_PREFIX . "task` WHERE task_id = '{$task_id}' AND job_id = {$job_id} LIMIT 1"; query($sql); $sql = "DELETE FROM `" . _DB_PREFIX . "task_log` WHERE task_id = '{$task_id}'"; query($sql); $result['status'] = 'deleted'; $result['task_id'] = $task_id; } } continue; } // add / save this task. $task_data['job_id'] = $job_id; if (module_job::job_task_only_show_split_hours($job_id, $job_data, $task_id, $task_data)) { if (isset($task_data['hours']) && !isset($task_data['staff_hours'])) { $task_data['staff_hours'] = $task_data['hours']; $task_data['staff_amount'] = $task_data['amount']; } if (isset($task_data['hours'])) { unset($task_data['hours']); unset($task_data['amount']); } } if (isset($task_data['hours'])) { $task_data['hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['hours']) : $task_data['hours']; } if (isset($task_data['staff_hours'])) { $task_data['staff_hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['staff_hours']) : $task_data['staff_hours']; } if (isset($task_data['log_hours'])) { $task_data['log_hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['log_hours']) : $task_data['log_hours']; } // remove the amount of it equals the hourly rate. if (isset($task_data['amount']) && $task_data['amount'] != 0 && isset($task_data['hours']) && $task_data['hours'] > 0) { if (isset($data['hourly_rate']) && $task_data['amount'] - $task_data['hours'] * $data['hourly_rate'] == 0) { unset($task_data['amount']); } } if (isset($task_data['staff_amount']) && $task_data['staff_amount'] != 0 && isset($task_data['staff_hours']) && $task_data['staff_hours'] > 0) { if (isset($data['staff_hourly_rate']) && $task_data['staff_amount'] - $task_data['staff_hours'] * $data['staff_hourly_rate'] == 0) { unset($task_data['staff_amount']); } } // check if we haven't unticked a non-hourly task if (isset($task_data['fully_completed_t']) && $task_data['fully_completed_t']) { if (!isset($task_data['fully_completed']) || !$task_data['fully_completed']) { // we have unchecked that tickbox $task_data['fully_completed'] = 0; } else { if (isset($tasks[$task_id]) && !$tasks[$task_id]['fully_completed']) { // we completed a preveiously incomplete task. // chekc if this task has a custom percentage filled in, we remove this custom percentage. if (isset($task_data['manual_percent']) && $task_data['manual_percent'] >= 0) { $task_data['manual_percent'] = -1; } // hack: if we haven't logged any hours for this, we log the number of hours. // if we have logged some hours already then we don't log anything extra. // this is so they can log 0.5hours for a 1 hour completed task etc.. if (isset($task_data['hours']) && $task_data['hours'] > 0 && (!isset($task_data['log_hours']) || !$task_data['log_hours'])) { $logged_hours = 0; foreach (get_multiple('task_log', array('job_id' => $job_id, 'task_id' => $task_id)) as $task_log) { $logged_hours += $task_log['hours']; } if ($logged_hours == 0) { $task_data['log_hours'] = $task_data['hours']; } } } } $check_completed = true; } // check if we haven't unticked a billable task if (isset($task_data['billable_t']) && $task_data['billable_t'] && !isset($task_data['billable'])) { $task_data['billable'] = 0; } // set default taxable status if (!$task_id && !isset($task_data['taxable_t'])) { // we're creating a new task. $task_data['taxable'] = module_config::c('task_taxable_default', 1); } if (isset($task_data['taxable_t']) && $task_data['taxable_t'] && !isset($task_data['taxable'])) { $task_data['taxable'] = 0; } if (isset($task_data['completed']) && $task_data['completed'] > 0) { // check the completed date of all our tasks. $check_completed = true; } if (!$task_id && isset($task_data['new_fully_completed']) && $task_data['new_fully_completed']) { $task_data['fully_completed'] = 1; // is this bad for set amount tasks? if (!isset($task_data['date_done']) || !$task_data['date_done']) { $task_data['date_done'] = print_date(time()); } if (isset($task_data['hours'])) { $task_data['log_hours'] = $task_data['hours']; } $check_completed = true; } // todo: move the task creation code into a public method so that the public user can add tasks to their jobs. if (!$task_id && module_security::is_logged_in() && !module_job::can_i('create', 'Job Tasks')) { continue; // dont allow new tasks. } // check if the user is allowed to create new tasks. // check the approval status of jobs switch ($job_task_creation_permissions) { case _JOB_TASK_CREATION_NOT_ALLOWED: if (!$task_id) { continue; // dont allow new tasks. } break; case _JOB_TASK_CREATION_REQUIRES_APPROVAL: $task_data['approval_required'] = 1; break; case _JOB_TASK_CREATION_WITHOUT_APPROVAL: // no action required . break; } if (isset($tasks[$task_id]) && $tasks[$task_id]['approval_required'] == 2) { // task has been rejected, saving it again for approval. $task_data['approval_required'] = 1; } $task_id = update_insert('task_id', $task_id, 'task', $task_data); // todo - fix cross task job boundary issue. meh. $result['task_id'] = $task_id; if ($task_id != $original_task_id) { $result['status'] = 'created'; } else { $result['status'] = 'edited'; } if ($task_id && isset($task_data['log_hours']) && (double) $task_data['log_hours'] > 0) { // we are increasing the task complete hours by the amount specified in log hours. // log a new task record, and incrase the "completed" column. //$original_task_data = $tasks[$task_id]; //$task_data['completed'] = $task_data['completed'] + $task_data['log_hours']; // only log hours if it's an hourly task. if (!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) { if (!$job_data) { $job_data = self::get_job($job_id); } $task_data['manual_task_type'] = $job_data['default_task_type']; } if ($task_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT) { update_insert('task_log_id', 'new', 'task_log', array('task_id' => $task_id, 'job_id' => $job_id, 'hours' => (double) $task_data['log_hours'], 'log_time' => time())); $result['log_hours'] = $task_data['log_hours']; } } } } if ($check_completed) { self::update_job_completion_status($job_id); } module_cache::clear('job'); return $result; }
<tbody class="job_task_wrapper"> <?php $c = 0; $task_number = 0; $show_hours_summary = false; foreach ($job_tasks as $task_id => $task_data) { if ($task_data['manual_task_type'] < 0) { $job_tasks[$task_id]['manual_task_type'] = $job['default_task_type']; } if ($job_tasks[$task_id]['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT) { $show_hours_summary = true; } $task_number++; //module_security::is_page_editable() && if (module_job::can_i('edit', 'Job Tasks')) { $task_editable = true; } else { $task_editable = false; } echo module_job::generate_task_preview($job_id, $job, $task_id, $task_data, $task_editable); } ?> </tbody> </table> <?php if ((int) $job_id > 0) { ?> <div id="job_summary"> <?php echo module_job::generate_job_summary($job_id, $job, $show_hours_summary);
echo $header_button['id']; ?> "> <!-- <?php echo $header_button['title']; ?> --> <i class="fa fa-<?php echo $header_button['fa-icon']; ?> "></i> </a> </li> <?php } if (class_exists('module_job', false) && module_job::can_i('view', 'Jobs')) { if ($job_todo_cache = module_cache::get('job', 'job_todo_header_cache')) { echo $job_todo_cache; } else { ob_start(); $this_alerts = array(); $todo_list = module_job::get_tasks_todo(); $x = 0; if (count($todo_list) > 0) { ?> <li class="dropdown tasks-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-tasks"></i> <span class="label label-danger"><?php
hook_handle_callback('invoice_sidebar', $invoice_id); ?> <?php } ?> <?php if ($invoice_id && $invoice_id != 'new') { $note_summary_owners = array(); // generate a list of all possible notes we can display for this invoice. // display all the notes which are owned by all the sites we have access to module_note::display_notes(array('title' => 'Credit Note Notes', 'owner_table' => 'invoice', 'owner_id' => $invoice_id, 'view_link' => module_invoice::link_open($invoice_id), 'public' => array('enabled' => true, 'title' => 'Public', 'text' => 'Yes, show this note in invoice', 'help' => 'If this is ticked then this note will be available to the customer and will be included in the {INVOICE_NOTES} shortcode in the invoice template.'))); if (module_job::can_i('edit', 'Invoices')) { module_email::display_emails(array('title' => 'Credit Note Emails', 'search' => array('invoice_id' => $invoice_id))); } } ?> <?php if ((int) $invoice_id > 0 && (!$invoice['date_sent'] || $invoice['date_sent'] == '0000-00-00') && module_security::is_page_editable()) { ?> <h3 class="error_text"><?php _e('Send Credit Note'); ?> </h3>
echo dollar($job['total_amount_outstanding'], true, $job['currency_id']); ?> </span> </td> <td> </td> </tr> <?php } ?> </tbody> </table> <?php } else { if ($job['staff_total_amount'] > 0 && !module_job::can_i('view', 'Job Split Pricing')) { } else { ?> <?php echo _l('%s Hours Total', $job['total_hours']); ?> <?php if ($job['total_hours_overworked']) { ?> <?php echo _l('(%s Hours Over)', $job['total_hours_overworked']); ?> <?php } ?> <br/>
</td> </tr> <?php } ?> <?php // not sure what I was going to put in this hook. hook_handle_callback('invoice_details_footer', $invoice_id); ?> </tbody> <?php module_extra::display_extras(array('owner_table' => 'invoice', 'owner_key' => 'invoice_id', 'owner_id' => $invoice['invoice_id'], 'layout' => 'table_row', 'allow_new' => module_job::can_i('create', 'Invoices'), 'allow_edit' => module_job::can_i('create', 'Invoices'))); ?> </table> <?php if ((int) $invoice_id > 0) { ?> <?php hook_handle_callback('invoice_sidebar', $invoice_id); ?>
} }); if (class_exists('module_website', false) && module_website::is_plugin_enabled() && module_website::can_i('view', module_config::c('project_name_plural', 'Websites'))) { $colspan++; $columns['invoice_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($invoice) { if (isset($invoice['website_ids'])) { foreach ($invoice['website_ids'] as $website_id) { if ((int) $website_id > 0) { echo module_website::link_open($website_id, true); echo '<br/>'; } } } }); } if (module_job::is_plugin_enabled() && module_job::can_i('view', 'Jobs')) { $columns['invoice_job'] = array('title' => 'Job', 'callback' => function ($invoice) { foreach ($invoice['job_ids'] as $job_id) { if ((int) $job_id > 0) { echo module_job::link_open($job_id, true); $job_data = module_job::get_job($job_id); if ($job_data['date_start'] && $job_data['date_start'] != '0000-00-00' && $job_data['date_renew'] && $job_data['date_renew'] != '0000-00-00') { _e(' (%s to %s)', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew'])))); } echo "<br/>\n"; } } hook_handle_callback('invoice_admin_list_job', $invoice['invoice_id']); }); } if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
<?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 (!$job_safe) { die('failed'); } if (!module_job::can_i('edit', 'Jobs')) { die('no perms'); } $job_id = (int) $_REQUEST['job_id']; $staff_id = (int) $_REQUEST['staff_id']; $staff = module_user::get_user($staff_id); $job = module_job::get_job($job_id); $job_tasks = module_job::get_tasks($job_id); // template for sending emails. // are we sending the paid one? or the dueone. $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'job_staff_email'; $template = module_template::get_template_by_key($template_name); $job['job_name'] = $job['name']; $job['staff_name'] = $staff['name']; $job['job_url'] = module_job::link_open($job_id); $job['job_tasks'] = '<ul>'; $job['task_count'] = 0;
<form action="" method="post"> <?php $search_bar = array('elements' => array('name' => array('title' => _l('Job 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_job::get_types())), 'status' => array('title' => _l('Status:'), 'field' => array('type' => 'select', 'name' => 'search[status]', 'value' => isset($search['status']) ? $search['status'] : '', 'options' => module_job::get_statuses())), 'completed' => array('title' => _l('Completed:'), 'field' => array('type' => 'select', 'name' => 'search[completed]', 'value' => isset($search['completed']) ? $search['completed'] : '', 'options' => array(1 => _l('Both Completed and Non-Completed Jobs'), 2 => _l('Only Completed Jobs'), 3 => _l('Only Non-Completed Jobs')))))); $staff = module_user::get_staff_members(); if (count($staff) > 0) { $search_bar['elements'][] = array('title' => _l('Staff:'), 'field' => array('type' => 'select', 'name' => 'search[user_id]', 'value' => isset($search['user_id']) ? $search['user_id'] : '', 'options' => $staff, 'options_array_id' => 'name')); } if (module_config::c('job_allow_quotes', 0)) { $search_bar['elements']['completed']['field']['options'][4] = _l('Only Quoted Jobs'); } if (class_exists('module_extra', false)) { $search_bar['extra_fields'] = 'job'; } if (class_exists('module_group', false) && module_job::can_i('view', 'Job Groups')) { $search_bar['elements']['group_id'] = array('title' => false, 'field' => array('type' => 'select', 'name' => 'search[group_id]', 'value' => isset($search['group_id']) ? $search['group_id'] : '', 'options' => module_group::get_groups('job'), 'options_array_id' => 'name', 'blank' => _l(' - Group - '))); } echo module_form::search_bar($search_bar); /** START TABLE LAYOUT **/ $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['job_title'] = array('title' => 'Job Title', 'callback' => function ($job) { echo module_job::link_open($job['job_id'], true, $job); }, 'cell_class' => 'row_action'); $columns['job_start_date'] = array('title' => 'Date', 'callback' => function ($job) { echo print_date($job['date_start']); //is there a renewal date? if (isset($job['date_renew']) && $job['date_renew'] && $job['date_renew'] != '0000-00-00') { _e(' to %s', print_date(strtotime("-1 day", strtotime($job['date_renew'])))); }
echo _l('This Quote has been converted into a Job: %s.', module_job::link_open($j['job_id'], true, $j)); ?> <br/> </p> <?php } ?> </div> <?php $fieldset_data = array('heading' => array('title' => _l('Quote Jobs'), 'type' => 'h3'), 'elements_before' => ob_get_clean()); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); } if ($quote['date_approved'] != '0000-00-00' && module_job::can_i('create', 'Jobs') && (!count($jobs) || module_config::c('quote_allow_multi_jobs', 0))) { ob_start(); ?> <div class="tableclass_form content"> <div style="text-align: center"> <?php $form_actions = array('class' => 'custom_actions action_bar_single', 'elements' => array(array('type' => 'button', 'name' => 'butt_convert_to_job', 'value' => _l('Convert this Quote into a Job'), 'onclick' => "window.location.href='" . module_job::link_open('new', false) . "&from_quote_id={$quote_id}'; return false;"))); echo module_form::generate_form_actions($form_actions); ?> </div> </div> <?php $fieldset_data = array('heading' => array('title' => _l('Quote Has Been Approved'), 'type' => 'h3'), 'elements_before' => ob_get_clean()); echo module_form::generate_fieldset($fieldset_data);
} ?> <input type="checkbox" name="finance_category_new_checked" value="new"> <input type="text" name="finance_category_new" value=""> <?php })); if (class_exists('module_company', false) && module_company::can_i('view', 'Company') && module_company::is_enabled()) { $companys = module_company::get_companys(); $companys_rel = array(); foreach ($companys as $company) { $companys_rel[$company['company_id']] = $company['name']; } $fieldset_data['elements'][] = array('title' => 'Company', 'field' => array('type' => 'select', 'name' => 'company_id', 'value' => isset($finance['company_id']) ? $finance['company_id'] : '', 'options' => $companys_rel, 'blank' => _l(' - Default - '), 'help' => 'Link this finance item with an individual company. It is better to select a Customer below and assign the Customer to a Company.')); } if (module_config::c('finance_link_to_jobs', 1) && module_job::can_i('view', 'Jobs')) { $fieldset_data['elements'][] = array('title' => 'Linked Customer', 'fields' => array(function () use(&$finance, $locked) { echo print_select_box(module_customer::get_customers(), 'customer_id', $finance['customer_id'], '', _l(' - None - '), 'customer_name'); ?> <script type="text/javascript"> $(function(){ $('#customer_id').change(function(){ // change our customer id. var new_customer_id = $(this).val(); $.ajax({ type: 'POST', url: '<?php echo module_job::link_open(false); ?> ',