예제 #1
0
                                        <?php 
            }
            ?>

                                    </td><td>
                                        <input type="text" name="invoice_invoice_payment[<?php 
            echo $invoice_payment_id;
            ?>
][method]" value="<?php 
            echo htmlspecialchars($invoice_payment_data['method']);
            ?>
" size="20">
                                    </td>
                                    <td nowrap="">
                                        <?php 
            echo '<input type="text" name="invoice_invoice_payment[' . $invoice_payment_id . '][amount]" value="' . number_out($invoice_payment_data['amount']) . '" id="' . $invoice_payment_id . 'invoice_paymentamount" class="currency">';
            ?>

                                        <?php 
            echo print_select_box(get_multiple('currency', '', 'currency_id'), 'invoice_invoice_payment[' . $invoice_payment_id . '][currency_id]', $invoice_payment_data['currency_id'], '', false, 'code');
            ?>

                                    </td>
                                    <td>
                                        <?php 
            $notes = '';
            $details = false;
            if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) {
                $details = @unserialize($invoice_payment_data['data']);
                if ($details && isset($details['custom_notes'])) {
                    $notes = $details['custom_notes'];
예제 #2
0
 public static function save_invoice($invoice_id, $data)
 {
     if (!(int) $invoice_id && isset($data['job_id']) && $data['job_id']) {
         $linkedjob = module_job::get_job($data['job_id']);
         $data['currency_id'] = $linkedjob['currency_id'];
         $data['customer_id'] = $linkedjob['customer_id'];
     }
     if ($invoice_id) {
         // used when working out the hourly rate fix below
         $original_invoice_data = self::get_invoice($invoice_id);
     } else {
         $original_invoice_data = 0;
     }
     $invoice_id = update_insert("invoice_id", $invoice_id, "invoice", $data);
     if ($invoice_id) {
         module_cache::clear('invoice');
         // save the invoice tax rates (copied to finance.php)
         if (isset($data['tax_ids']) && isset($data['tax_names']) && $data['tax_percents']) {
             $existing_taxes = get_multiple('invoice_tax', array('invoice_id' => $invoice_id), 'invoice_tax_id', 'exact', 'order');
             $order = 1;
             foreach ($data['tax_ids'] as $key => $val) {
                 if (isset($data['tax_percents'][$key]) && $data['tax_percents'][$key] == 0) {
                     // we are not saving this particular tax item because it has a 0% tax rate
                 } else {
                     if ((int) $val > 0 && isset($existing_taxes[$val])) {
                         // this means we are trying to update an existing record on the invoice_tax table, we confirm this id matches this invoice.
                         $invoice_tax_id = $val;
                         unset($existing_taxes[$invoice_tax_id]);
                         // so we know which ones to remove from the end.
                     } else {
                         $invoice_tax_id = false;
                         // create new record
                     }
                     $invoice_tax_data = array('invoice_id' => $invoice_id, 'percent' => isset($data['tax_percents'][$key]) ? $data['tax_percents'][$key] : 0, 'amount' => 0, 'name' => isset($data['tax_names'][$key]) ? $data['tax_names'][$key] : 'TAX', 'order' => $order++, 'increment' => isset($data['tax_increment_checkbox']) && $data['tax_increment_checkbox'] ? 1 : 0);
                     $invoice_tax_id = update_insert('invoice_tax_id', $invoice_tax_id, 'invoice_tax', $invoice_tax_data);
                 }
             }
             foreach ($existing_taxes as $existing_tax) {
                 delete_from_db('invoice_tax', array('invoice_id', 'invoice_tax_id'), array($invoice_id, $existing_tax['invoice_tax_id']));
             }
         }
         $invoice_data = self::get_invoice($invoice_id);
         if (!$invoice_data) {
             set_error('No permissions to access invoice.');
             return $invoice_id;
         }
         // check for new invoice_items or changed invoice_items.
         $invoice_items = self::get_invoice_items($invoice_id, $invoice_data);
         if (isset($data['invoice_invoice_item']) && is_array($data['invoice_invoice_item'])) {
             foreach ($data['invoice_invoice_item'] as $invoice_item_id => $invoice_item_data) {
                 $invoice_item_id = (int) $invoice_item_id;
                 if (!is_array($invoice_item_data)) {
                     continue;
                 }
                 if ($invoice_item_id > 0 && !isset($invoice_items[$invoice_item_id])) {
                     continue;
                 }
                 // wrong invoice_item save - will never happen.
                 if (!isset($invoice_item_data['description']) || $invoice_item_data['description'] == '') {
                     if ($invoice_item_id > 0) {
                         // remove invoice_item.
                         $sql = "DELETE FROM `" . _DB_PREFIX . "invoice_item` WHERE invoice_item_id = '{$invoice_item_id}' AND invoice_id = {$invoice_id} LIMIT 1";
                         query($sql);
                     }
                     continue;
                 }
                 // add / save this invoice_item.
                 $invoice_item_data['invoice_id'] = $invoice_id;
                 // what type of task is this?
                 $invoice_task_type = isset($invoice_item_data['manual_task_type']) && $invoice_item_data['manual_task_type'] >= 0 ? $invoice_item_data['manual_task_type'] : $invoice_data['default_task_type'];
                 $invoice_item_data['hours_mins'] = 0;
                 if (isset($invoice_item_data['hours']) && $invoice_task_type == _TASK_TYPE_HOURS_AMOUNT) {
                 }
                 if (isset($invoice_item_data['hours']) && $invoice_task_type == _TASK_TYPE_HOURS_AMOUNT && function_exists('decimal_time_in')) {
                     $invoice_item_data['hours'] = decimal_time_in($invoice_item_data['hours']);
                     if (strpos($invoice_item_data['hours'], ':') !== false) {
                         $invoice_item_data['hours_mins'] = str_replace(":", ".", $invoice_item_data['hours']);
                     }
                 } else {
                     if (isset($invoice_item_data['hours']) && strlen($invoice_item_data['hours'])) {
                         $invoice_item_data['hours'] = number_in($invoice_item_data['hours']);
                     } else {
                         $invoice_item_data['hours'] = 0;
                     }
                 }
                 // number formatting
                 //print_r($invoice_item_data);
                 if (isset($invoice_item_data['hourly_rate']) && strlen($invoice_item_data['hourly_rate'])) {
                     $invoice_item_data['hourly_rate'] = number_in($invoice_item_data['hourly_rate'], module_config::c('task_amount_decimal_places', -1));
                 }
                 //print_r($invoice_item_data);exit;
                 // somenew hacks here to support out new method of creating an item.
                 // the 'amount' column is never edited any more
                 // this column is now always automatically calculated based on
                 // 'hours' and 'hourly_rate'
                 if (!isset($invoice_item_data['amount'])) {
                     if ($invoice_task_type == _TASK_TYPE_AMOUNT_ONLY) {
                         // ignore the quantity field all together.
                         $invoice_item_data['amount'] = $invoice_item_data['hourly_rate'];
                         $invoice_item_data['hourly_rate'] = 0;
                     } else {
                         if (isset($invoice_item_data['hourly_rate']) && strlen($invoice_item_data['hourly_rate']) > 0) {
                             // if we have inputted an hourly rate (ie: not left empty)
                             if (isset($invoice_item_data['hours']) && strlen($invoice_item_data['hours']) == 0) {
                                 // no hours entered (eg: empty) so we treat whatever was in 'hourly_rate' as the amount
                                 $invoice_item_data['amount'] = $invoice_item_data['hourly_rate'];
                             } else {
                                 if (isset($invoice_item_data['hours']) && strlen($invoice_item_data['hours']) > 0) {
                                     // hours inputted, along with hourly rate. work out the new amount.
                                     $invoice_item_data['amount'] = round($invoice_item_data['hours'] * $invoice_item_data['hourly_rate'], module_config::c('currency_decimal_places', 2));
                                 }
                             }
                         }
                     }
                 }
                 if ($invoice_task_type == _TASK_TYPE_HOURS_AMOUNT) {
                     if ($invoice_item_data['hourly_rate'] == $invoice_data['hourly_rate'] || isset($original_invoice_data['hourly_rate']) && $invoice_item_data['hourly_rate'] == $original_invoice_data['hourly_rate']) {
                         $invoice_item_data['hourly_rate'] = -1;
                     }
                 }
                 // remove the amount of it equals the hourly rate.
                 /*if(isset($invoice_item_data['amount']) && isset($invoice_item_data['hours']) && $invoice_item_data['amount'] > 0 && $invoice_item_data['hours'] > 0){
                       if($invoice_item_data['amount'] - ($invoice_item_data['hours'] * $data['hourly_rate']) == 0){
                           unset($invoice_item_data['amount']);
                       }
                   }*/
                 // check if we haven't unticked a non-hourly invoice_item
                 /*if(isset($invoice_item_data['completed_t']) && $invoice_item_data['completed_t'] && !isset($invoice_item_data['completed'])){
                       $invoice_item_data['completed'] = 0;
                   }*/
                 if (!isset($invoice_item_data['taxable_t'])) {
                     $invoice_item_data['taxable'] = module_config::c('task_taxable_default', 1);
                 } else {
                     if (isset($invoice_item_data['taxable_t']) && $invoice_item_data['taxable_t'] && !isset($invoice_item_data['taxable'])) {
                         $invoice_item_data['taxable'] = 0;
                     }
                 }
                 if (!strlen($invoice_item_data['hours'])) {
                     $invoice_item_data['hours'] = 0;
                 }
                 $invoice_item_data['hourly_rate'] = number_out($invoice_item_data['hourly_rate'], false, module_config::c('task_amount_decimal_places', -1));
                 $invoice_item_data['hours'] = number_out($invoice_item_data['hours']);
                 $invoice_item_data['amount'] = number_out($invoice_item_data['amount']);
                 update_insert('invoice_item_id', $invoice_item_id, 'invoice_item', $invoice_item_data);
             }
         }
         $last_payment_time = 0;
         if (isset($data['invoice_invoice_payment']) && is_array($data['invoice_invoice_payment'])) {
             foreach ($data['invoice_invoice_payment'] as $invoice_payment_id => $invoice_payment_data) {
                 $invoice_payment_id = (int) $invoice_payment_id;
                 if (!is_array($invoice_payment_data)) {
                     continue;
                 }
                 if (isset($invoice_payment_data['amount'])) {
                     $invoice_payment_data['amount'] = number_in($invoice_payment_data['amount']);
                     // toggle between 'normal' and 'refund' payment types
                     if (isset($invoice_payment_data['payment_type'])) {
                         if ($invoice_payment_data['amount'] < 0 && $invoice_payment_data['payment_type'] == _INVOICE_PAYMENT_TYPE_NORMAL) {
                             // this is a refund.
                             $invoice_payment_data['payment_type'] = _INVOICE_PAYMENT_TYPE_REFUND;
                         } else {
                             if ($invoice_payment_data['payment_type'] == _INVOICE_PAYMENT_TYPE_REFUND) {
                                 $invoice_payment_data['payment_type'] = _INVOICE_PAYMENT_TYPE_NORMAL;
                             }
                         }
                     }
                 }
                 // check this invoice payment actually matches this invoice.
                 $invoice_payment_data_existing = false;
                 if ($invoice_payment_id > 0) {
                     $invoice_payment_data_existing = get_single('invoice_payment', array('invoice_payment_id', 'invoice_id'), array($invoice_payment_id, $invoice_id));
                     if (!$invoice_payment_data_existing || $invoice_payment_data_existing['invoice_payment_id'] != $invoice_payment_id || $invoice_payment_data_existing['invoice_id'] != $invoice_id) {
                         $invoice_payment_id = 0;
                         $invoice_payment_data_existing = false;
                     }
                 }
                 if (!isset($invoice_payment_data['amount']) || $invoice_payment_data['amount'] == '' || $invoice_payment_data['amount'] == 0) {
                     // || $invoice_payment_data['amount'] <= 0
                     if ($invoice_payment_id > 0) {
                         // if this is a customer credit payment, return that back to the customer account.
                         if ($invoice_payment_data_existing && $invoice_data['customer_id']) {
                             switch ($invoice_payment_data_existing['payment_type']) {
                                 case _INVOICE_PAYMENT_TYPE_CREDIT:
                                     module_customer::add_credit($invoice_data['customer_id'], $invoice_payment_data_existing['amount'], 'Refunded credit from invoice payment');
                                     break;
                             }
                         }
                         // remove invoice_payment.
                         $sql = "DELETE FROM `" . _DB_PREFIX . "invoice_payment` WHERE invoice_payment_id = '{$invoice_payment_id}' AND invoice_id = {$invoice_id} LIMIT 1";
                         query($sql);
                         // delete any existing transactions from the system as well.
                         hook_handle_callback('invoice_payment_deleted', $invoice_payment_id, $invoice_id);
                     }
                     continue;
                 }
                 if (!$invoice_payment_id && (!isset($_REQUEST['add_payment']) || $_REQUEST['add_payment'] != 'go')) {
                     continue;
                     // not saving a new one.
                 }
                 // add / save this invoice_payment.
                 $invoice_payment_data['invoice_id'] = $invoice_id;
                 // $invoice_payment_data['currency_id'] = $invoice_data['currency_id'];
                 $last_payment_time = max($last_payment_time, strtotime(input_date($invoice_payment_data['date_paid'])));
                 if (isset($invoice_payment_data['custom_notes'])) {
                     $details = @unserialize($invoice_payment_data['data']);
                     if (!is_array($details)) {
                         $details = array();
                     }
                     $details['custom_notes'] = $invoice_payment_data['custom_notes'];
                     $invoice_payment_data['data'] = serialize($details);
                 }
                 $invoice_payment_data['amount'] = number_out($invoice_payment_data['amount']);
                 update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', $invoice_payment_data);
             }
         }
         if (!$last_payment_time) {
             $last_payment_time = strtotime(date('Y-m-d'));
         }
         // check if the invoice has been paid
         module_cache::clear('invoice');
         //module_cache::clear_cache(); // this helps fix the bug where part payments are not caulcated a correct paid date.
         $invoice_data = self::get_invoice($invoice_id);
         if (!$invoice_data) {
             set_error('No permissions to access invoice.');
             return $invoice_id;
         }
         if ((!$invoice_data['date_paid'] || $invoice_data['date_paid'] == '0000-00-00') && $invoice_data['total_amount_due'] <= 0 && ($invoice_data['total_amount_paid'] > 0 || $invoice_data['discount_amount'] > 0) && (!$invoice_data['date_cancel'] || $invoice_data['date_cancel'] == '0000-00-00')) {
             // find the date of the last payment history.
             // if the sent date is null also update that.
             $date_sent = $invoice_data['date_sent'];
             if (!$date_sent || $date_sent == '0000-00-00') {
                 $date_sent = date('Y-m-d', $last_payment_time);
             }
             update_insert("invoice_id", $invoice_id, "invoice", array('date_paid' => date('Y-m-d', $last_payment_time), 'date_sent' => $date_sent, 'status' => _l('Paid')));
             // hook for our ticketing plugin to mark a priority support ticket as paid.
             // or anything else down the track.
             module_cache::clear('invoice');
             handle_hook('invoice_paid', $invoice_id);
             if (module_config::c('invoice_automatic_receipt', 1)) {
                 // send receipt to customer.
                 self::email_invoice_to_customer($invoice_id);
             }
         }
         if ($invoice_data['total_amount_due'] > 0) {
             // update the status to unpaid.
             update_insert("invoice_id", $invoice_id, "invoice", array('date_paid' => '', 'status' => $invoice_data['status'] == _l('Paid') ? module_config::s('invoice_status_default', 'New') : $invoice_data['status']));
         }
         if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
             module_extra::save_extras('invoice', 'invoice_id', $invoice_id);
         }
         if ($invoice_data['customer_id']) {
             //module_cache::clear_cache();
             module_cache::clear('invoice');
             module_customer::update_customer_status($invoice_data['customer_id']);
         }
         hook_handle_callback('invoice_saved', $invoice_id, $invoice_data);
     }
     module_cache::clear('invoice');
     module_cache::clear('job');
     return $invoice_id;
 }
예제 #3
0
            echo $hours_value !== false ? $hours_value : '-';
        }
    }
}
if ($show_split_hours) {
    echo '<br/>';
    if ($task_data['staff_hours'] == 0 && $task_data['manual_task_type'] == _TASK_TYPE_AMOUNT_ONLY) {
        // only amount, no hours or qty
    } else {
        // are the logged hours different to the billed hours?
        // are we completed too?
        if ($task_data['staff_hours'] != 0) {
            if ($task_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT && function_exists('decimal_time_out')) {
                $hours_value = decimal_time_out($task_data['staff_hours']);
            } else {
                $hours_value = number_out($task_data['staff_hours'], true);
            }
        } else {
            $hours_value = false;
        }
        if ($percentage == 1 && $task_data['completed'] < $task_data['staff_hours']) {
            echo '<span class="">';
            echo $hours_value !== false ? $hours_value : '-';
            echo '</span>';
        } else {
            if ($percentage == 1 && $task_data['completed'] > $task_data['staff_hours']) {
                echo '<span class="">';
                echo $hours_value !== false ? $hours_value : '-';
                echo '</span>';
            } else {
                echo $hours_value !== false ? $hours_value : '-';
            ?>
						</td>
					</tr>
					<tr>
						<th>
							<?php 
            _e('Payment Amount');
            ?>
						</th>
						<td>
							<?php 
            if (module_config::c('invoice_allow_payment_amount_adjustment', 1)) {
                echo currency('<input type="text" name="payment_amount" value="' . number_out($invoice['total_amount_due']) . '" class="currency">', true, $invoice['currency_id']);
            } else {
                echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']);
                echo '<input type="hidden" name="payment_amount" value="' . number_out($invoice['total_amount_due']) . '">';
            }
            ?>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>
							<input type="submit" name="pay" value="<?php 
            _e('Make Payment');
            ?>
"
							       class="submit_button save_button">
						</td>
					</tr>
					</tbody>
예제 #5
0
    _h('The default is hourly rate + amount. This will show the "Hours" column along with an "Amount" column. Inputing a number of hours will auto complete the price based on the job hourly rate. <br>Quantity and Amount will allow you to input a Quantity (eg: 2) and an Amount (eg: $100) and the final price will be $200 (Quantity x Amount). The last option "Amount Only" will just have the amount column for manual input of price. Change the advanced setting "default_task_type" between 0, 1 and 2 to change the default here.');
    ?>


                        </td>
                    </tr>
		            <tr>
		                <th>
		                    <?php 
    _e('Discount Amount');
    ?>

		                </th>
		                <td>
		                    <?php 
    echo !module_security::is_page_editable() ? '<span class="currency">' . dollar($job['discount_amount'], true, $job['currency_id']) . '</span>' : currency('<input type="text" name="discount_amount" value="' . number_out($job['discount_amount']) . '" class="currency">');
    ?>

		                    <?php 
    _h('Here you can apply a before tax discount to this job. You can name this anything, eg: DISCOUNT, CREDIT, REFUND, etc..');
    ?>

		                </td>
		            </tr>
		            <tr>
		                <th>
		                    <?php 
    _e('Discount Name');
    ?>

		                </th>
예제 #6
0
파일: job.php 프로젝트: sgh1986915/php-crm
    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);
    }
예제 #7
0
            <input type="hidden" name="job_task[<?php 
    echo $task_id;
    ?>
][completed]" value="<?php 
    echo $task_data['completed'];
    ?>
">
            <br/>
            <?php 
    // show a log of any existing hours against this task.
    $task_logs = module_job::get_task_log($task_id);
    foreach ($task_logs as $task_log) {
        if (function_exists('decimal_time_out')) {
            $hours_value = decimal_time_out($task_log['hours']);
        } else {
            $hours_value = number_out($task_log['hours'], true);
        }
        echo _l('%s hrs <span class="text_shrink">%s</a> - <span class="text_shrink">%s</span>', $hours_value, print_date($task_log['log_time'], true), $staff_member_rel[$task_log['create_user_id']]);
        ?>
 <a href="#" class="error_text" onclick="return delete_task_hours(<?php 
        echo $task_id;
        ?>
,<?php 
        echo $task_log['task_log_id'];
        ?>
);">x</a> <?php 
        echo '<br/>';
    }
}
?>
        </div>
예제 #8
0
	    <?php 
    if (!isset($search['type']) || $search['type'] == 'ie' || $search['type'] == 'e') {
        ?>

		    <th id="sort_debit"><?php 
        _e('Sub-Total');
        ?>
</th>
			<?php 
        if (isset($available_debit_taxes[$currency_id])) {
            foreach ($available_debit_taxes[$currency_id] as $tax_percent => $tf) {
                ?>

		        <th id="sort_debit_tax"><?php 
                _e('Tax %s%%', number_out($tax_percent, true));
                ?>
</th>
			<?php 
            }
        }
        ?>

		    <th id="sort_debit_total"><?php 
        _e('Total');
        ?>
</th>
	    <?php 
    }
    ?>
예제 #9
0
               $row_replace['item_date'] .= print_date($task['date_done']);
           }else{
               // check if quote has a date.
               if(isset($quote['date_create']) && $quote['date_create'] != '0000-00-00'){
                   $row_replace['item_date'] .= print_date($quote['date_create']);
               }
           }
       }
   }*/
 if ($quote_item_data['manual_task_type'] == _TASK_TYPE_AMOUNT_ONLY) {
     $row_replace['item_qty_or_hours'] = '-';
 } else {
     if ($quote_item_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT && function_exists('decimal_time_out')) {
         $hours_value = decimal_time_out($quote_item_data['hours']);
     } else {
         $hours_value = number_out($quote_item_data['hours'], true);
     }
     $row_replace['item_qty_or_hours'] = $hours_value ? $hours_value : '-';
 }
 if ($quote_item_data['task_hourly_rate'] != 0) {
     $row_replace['item_amount_or_rate'] = dollar($quote_item_data['task_hourly_rate'], true, $quote['currency_id'], $task_decimal_places_trim, $task_decimal_places);
 } else {
     $row_replace['item_amount_or_rate'] = '-';
 }
 $row_replace['item_total'] = dollar($quote_item_data['quote_item_amount'], true, $quote['currency_id']);
 // taxes per item
 if (isset($quote_item_data['taxes']) && is_array($quote_item_data['taxes']) && $quote_item_data['taxable'] && class_exists('module_finance', false)) {
     // this passes off the tax calculation to the 'finance' class, which modifies 'amount' to match the amount of tax applied here.
     $this_taxes = module_finance::sanatise_taxes($quote_item_data['taxes'], $quote_item_data['quote_item_amount']);
     $this_taxes_amounts = array();
     $this_taxes_rates = array();
예제 #10
0
         if (true || $job['total_sub_amount'] != $job['total_sub_amount_taxable']) {
             $rows[] = array('label' => _l('Taxable Amount:'), 'value' => '<span class="currency">' . dollar($job['total_sub_amount_taxable'], true, $job['currency_id']) . '</span>');
         }
         foreach ($job['taxes'] as $job_tax) {
             $rows[] = array('label' => _l('Tax:'), 'value' => '<span class="currency">' . dollar($job_tax['amount'], true, $job['currency_id']) . '</span>', 'extra' => $job_tax['name'] . ' = ' . number_out($job_tax['percent'], module_config::c('tax_trim_decimal', 1), module_config::c('tax_decimal_places', module_config::c('currency_decimal_places', 2))) . '%');
         }
     }
 } else {
     if ($job['discount_type'] == _DISCOUNT_TYPE_AFTER_TAX) {
         $rows[] = array('label' => _l('Sub Total:'), 'value' => '<span class="currency">' . dollar($job['total_sub_amount'], true, $job['currency_id']) . '</span>');
         if (!$hide_tax) {
             if ($job['total_sub_amount'] != $job['total_sub_amount_taxable']) {
                 $rows[] = array('label' => _l('Taxable Amount:'), 'value' => '<span class="currency">' . dollar($job['total_sub_amount_taxable'], true, $job['currency_id']) . '</span>');
             }
             foreach ($job['taxes'] as $job_tax) {
                 $rows[] = array('label' => _l('Tax:'), 'value' => '<span class="currency">' . dollar($job_tax['amount'], true, $job['currency_id']) . '</span>', 'extra' => $job_tax['name'] . ' = ' . number_out($job_tax['percent'], module_config::c('tax_trim_decimal', 1), module_config::c('tax_decimal_places', module_config::c('currency_decimal_places', 2))) . '%');
             }
             if ($job['discount_amount'] > 0 || isset($job['fees']) && count($job['fees'])) {
                 $rows[] = array('label' => _l('Sub Total:'), 'value' => '<span class="currency">' . dollar($job['total_sub_amount'] + $job['total_tax'], true, $job['currency_id']) . '</span>');
             }
         }
         if ($job['discount_amount'] > 0) {
             //if(($discounts_allowed || $job['discount_amount']>0) &&  (!($job_locked && module_security::is_page_editable()) || $job['discount_amount']>0)){
             $rows[] = array('label' => htmlspecialchars(_l($job['discount_description'])), 'value' => '<span class="currency">' . dollar($job['discount_amount'], true, $job['currency_id']) . '</span>');
         }
     }
 }
 // any fees?
 if (isset($job['fees']) && count($job['fees'])) {
     foreach ($job['fees'] as $fee) {
         $rows[] = array('label' => $fee['description'], 'value' => '<span class="currency">' . dollar($fee['total'], true, $job['currency_id']) . '</span>');
예제 #11
0
파일: core.php 프로젝트: sgh1986915/php-crm
 function dollar($number, $show_currency = true, $currency_id = false, $trim_decimals = false, $decimal_places = false)
 {
     return currency(number_out($number, $trim_decimals, $decimal_places), $show_currency, $currency_id);
 }
예제 #12
0
        <?php 
} else {
    if ($task_data['hours'] == 0 && $task_data['manual_task_type'] == _TASK_TYPE_AMOUNT_ONLY) {
        // no hour input
    } else {
        echo $hours_value;
    }
}
?>
    </td>
    <td nowrap="">
        <?php 
if ($task_editable) {
    ?>
            <?php 
    echo currency('<input type="text" name="quote_task[' . $quote_task_id . '][amount]" value="' . ($task_data['amount'] != 0 ? number_out($task_data['amount'], $task_decimal_places_trim, $task_decimal_places) : number_out($task_data['hours'] * $quote['hourly_rate'], $task_decimal_places_trim, $task_decimal_places)) . '" id="' . $quote_task_id . 'taskamount" class="currency" tabindex="13">');
    ?>
        <?php 
} else {
    ?>
            <?php 
    echo $task_data['amount'] != 0 ? dollar($task_data['amount'], true, $quote['currency_id'], $task_decimal_places_trim, $task_decimal_places) : dollar($task_data['hours'] * $quote['hourly_rate'], true, $quote['currency_id'], $task_decimal_places_trim, $task_decimal_places);
    ?>
        <?php 
}
?>
    </td>
    <?php 
if (module_config::c('quote_allow_staff_assignment', 1)) {
    $colspan++;
    ?>
예제 #13
0
             $row_replace['item_date'] .= print_date($task['date_done']);
         } else {
             // check if invoice has a date.
             if (isset($invoice['date_create']) && $invoice['date_create'] != '0000-00-00') {
                 $row_replace['item_date'] .= print_date($invoice['date_create']);
             }
         }
     }
 }
 if ($invoice_item_data['manual_task_type'] == _TASK_TYPE_AMOUNT_ONLY) {
     $row_replace['item_qty_or_hours'] = '-';
 } else {
     if ($invoice_item_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT && function_exists('decimal_time_out')) {
         $hours_value = decimal_time_out($invoice_item_data['hours']);
     } else {
         $hours_value = number_out($invoice_item_data['hours'], true);
     }
     $row_replace['item_qty_or_hours'] = $hours_value ? $hours_value : '-';
 }
 if ($invoice_item_data['task_hourly_rate'] != 0) {
     $row_replace['item_amount_or_rate'] = dollar($invoice_item_data['task_hourly_rate'], true, $invoice['currency_id'], $task_decimal_places_trim, $task_decimal_places);
 } else {
     $row_replace['item_amount_or_rate'] = '-';
 }
 $row_replace['item_total'] = dollar($invoice_item_data['invoice_item_amount'], true, $invoice['currency_id']);
 // taxes per item
 if (isset($invoice_item_data['taxes']) && is_array($invoice_item_data['taxes']) && $invoice_item_data['taxable'] && class_exists('module_finance', false)) {
     // this passes off the tax calculation to the 'finance' class, which modifies 'amount' to match the amount of tax applied here.
     foreach ($invoice_item_data['taxes'] as $key => $val) {
         if (isset($val['amount'])) {
             unset($invoice_item_data['taxes'][$key]['amount']);
예제 #14
0
파일: web.php 프로젝트: kaspernj/knjphpfw
function form_drawInput($args){
	if (is_array($args["value"]) && is_callable($args["value"])){
		$value = call_user_func($args["value"]);
	}elseif(is_array($args["value"]) and ($args["value"]["type"] == "arr_rows" or $args["value"]["type"] == "arr_values")){
		//do nothing.
	}elseif(is_array($args["value"]) && is_object($args["value"][0])){
		$value = $args["value"][0]->$args["value"][1]($args["value"][2]);
	}else{
		if ($args["value"] === null && array_key_exists("default", $args)){
			$value = $args["default"];
		}else{
			$value = $args["value"];
		}
	}
	
	if (is_array($value)){
		$value = null;
	}
	
	if (is_null($value) and array_key_exists("default", $args)){
		$value = $args["default"];
	}
	
	if ($value and $args["value_callback"]){
		if (array_key_exists(1, $args["value_callback"])){
			$value = call_user_func($args["value_callback"][0], $value, $args["value_callback"][1]);
		}else{
			$value = call_user_func($args["value_callback"][0], $value);
		}
	}
	
	if (!$args["type"]){
		$f3 = substr($args["name"], 0, 3);
		if ($f3 == "che"){
			$args["type"] = "checkbox";
		}elseif($f3 == "tex"){
			$args["type"] = "text";
		}elseif($f3 == "sel" or array_key_exists("opts", $args)){
			$args["type"] = "select";
		}elseif($f3 == "fil"){
			$args["type"] = "file";
		}elseif($f3 == "rad"){
			$args["type"] = "radio";
		}
	}
	
	if (!$args["id"]){
		$id = $args["name"];
	}else{
		$id = $args["id"];
	}
	
	if (!$args["type"]){
		$args["type"] = "text";
	}
	
	if ($args["type"] == "password" and !$args["class"]){
		$args["class"] = "input_text";
	}
	
	if (!$args["class"]){
		$args["class"] = "input_" . $args["type"];
	}
	
	if ($args["colspan"]){
		$colspan_cont = $args["colspan"] - 1;
	}
	
	$classes_tr = array();
  if ($args["classes_tr"]){
    $classes_tr = array_merge($classes_tr, $args["classes_tr"]);
  }
  
  if (!array_key_exists("tr", $args) or $args["tr"]){
    if (!empty($classes_tr)){
      ?><tr class="<?php 
echo implode(" ", $classes_tr);
?>
"><?
    }else{
      ?><tr><?
    }
  }
	
	if ($args["title"]){
		$title_html = htmlspecialchars($args["title"]);
	}elseif($args["title_html"]){
		$title_html = $args["title_html"];
	}
	
	if ($args["div"]){
    $title_html = "<div>" . $title_html . "</div>";
	}
	
	$css = array();
	$td_html = "<td class=\"tdc\"";
	if ($args["td_width"]){
    $css["width"] = $args["td_width"];
	}
	if ($args["align"]){
    $css["text-align"] = $args["align"];
  }
  
  if (!empty($css)){
    $td_html .= " style=\"";
    foreach($css as $key => $val){
      $td_html .= $key . ": " . $val . ";";
    }
    $td_html .= "\"";
  }
  
	if ($colspan_cont > 1){
		$td_html .= " colspan=\"" . $colspan_cont . "\"";
	}
	$td_html .= ">";
	
	if ($args["div"]){
    $td_end_html = "</div></td>";
    $td_html .= "<div>";
  }else{
    $td_end_html = "</td>";
	}
	
	$js_tags = "";
	$js_tags_arr = array("onkeyup", "onkeydown", "onchange");
	foreach($js_tags_arr AS $js_tag){
		if ($args[$js_tag]){
			$js_tags .= " " . $js_tag . "=\"" . $args[$js_tag] . "\"";
		}
	}
	
	if (array_key_exists("autocomplete", $args) and !$args["autocomplete"]){
		$js_tags .= " autocomplete=\"off\"";
	}
	
	if ($args["type"] == "numeric"){
		$value = number_out($value, $args["decis"]);
	}
	
	if ($args["classes"]){
		$classes = $args["classes"];
	}else{
		$classes = array();
	}
	
	$classes[] = $args["class"];
	$args["class"] = implode(" ", $classes);
	
	if ($args["type"] == "spacer"){
		?><td colspan="2">&nbsp;</td><?
	}elseif($args["type"] == "checkbox"){
		?>
			<td colspan="2" class="tdcheck">
				<input<?if ($args["disabled"]){?> disabled<?}?> type="<?php 
echo $args["type"];
?>
" name="<?php 
echo $args["name"];
?>
" id="<?php 
echo $id;
?>
"<?if ($value){?> checked="checked"<?}?><?php 
echo $js_tags;
?>
 />
				<label for="<?php 
echo $id;
?>
"><?php 
echo $title_html;
?>
</label>
			</td>
		<?
	}elseif($args["type"] == "select"){
		$etags = "";
		if ($args["multiple"]){
			$etags .= " multiple=\"multiple\"";
		}
		
		if ($args["height"]){
			$etags .= " height=\"" . htmlspecialchars($args["height"]) . "\"";
		}
		
		if (is_null($value) and is_array($args["value"])){
      $value = $args["value"];
    }
		
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<select<?php 
echo $etags;
?>
<?if ($args["size"]){?> size="<?php 
echo htmlspecialchars($args["size"]);
?>
"<?}?> name="<?php 
echo htmlspecialchars($args["name"]);
?>
" id="<?php 
echo htmlspecialchars($id);
?>
" class="<?php 
echo $args["class"];
?>
"<?php 
echo $js_tags;
?>
>
				<?php 
echo select_drawOpts($args["opts"], $value);
?>
				</select>
				<?if ($args["moveable"]){?>
					<div style="padding-top: 3px;">
						<input type="button" value="<?php 
echo _("Up");
?>
" onclick="select_moveup($('#<?php 
echo $id;
?>
'));" />
						<input type="button" value="<?php 
echo _("Down");
?>
" onclick="select_movedown($('#<?php 
echo $id;
?>
'));" />
					</div>
				<?}?>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "imageupload"){
		if ($args["filetype"]){
			$ftype = $args["filetype"];
		}else{
			$ftype = "jpg";
		}
		
		if (!$value){
			$fn = null;
		}else{
			$fn = $args["path"] . "/" . $value . "." . $ftype;
		}
		
		if (!$fn or !file_exists($fn)){
			$found = false;
			$fn_nopic = "images/nopicture.jpg";
			$fn = null;
			
			if (file_exists($fn_nopic)){
				$fn = $fn_nopic;
			}
		}else{
			$found = true;
		}
		
		if ($args["dellink"]){
			$args["dellink"] = str_replace("%value%", $value, $args["dellink"]);
		}
		
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<table class="designtable">
					<tr>
						<td style="width: 100%;">
							<input type="file" name="<?php 
echo htmlspecialchars($args["name"]);
?>
" id="<?php 
echo htmlspecialchars($id);
?>
" class="<?php 
echo htmlspecialchars($args["class"]);
?>
" />
						</td>
						<td>
							<?if ($fn){?>
								<img src="image.php?picture=<?php 
echo urlencode($fn);
?>
&amp;smartsize=80&amp;edgesize=20&amp;equaldim=true" alt="Preview" />
							<?}?>
							<?if ($found and $args["dellink"]){?>
								<div style="text-align: center;">
									<?if (function_exists("gtext")){?>
										(<a href="javascript: if (confirm('<?php 
echo gtext("Do you want to delete the picture?");
?>
')){location.href='<?php 
echo $args["dellink"];
?>
';}"><?php 
echo gtext("delete");
?>
</a>)
									<?}elseif(function_exists("_")){?>
										(<a href="javascript: if (confirm('<?php 
echo _("Do you want to delete the picture?");
?>
')){location.href='<?php 
echo $args["dellink"];
?>
';}"><?php 
echo _("delete");
?>
</a>)
									<?}else{?>
										(<a href="javascript: if (confirm('Do you want to delete the picture?')){location.href='<?php 
echo $args["dellink"];
?>
';}"><?php 
echo _("delete");
?>
</a>)
									<?}?>
								</div>
							<?}?>
						</td>
					</tr>
				</table>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "file"){
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<input type="file" class="input_<?php 
echo $args["type"];
?>
" name="<?php 
echo htmlspecialchars($args["name"]);
?>
" id="<?php 
echo htmlspecialchars($id);
?>
"<?php 
echo $js_tags;
?>
 />
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "textarea"){
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<textarea name="<?php 
echo htmlspecialchars($args["name"]);
?>
" id="<?php 
echo htmlspecialchars($id);
?>
" class="<?php 
echo htmlspecialchars($args["class"]);
?>
"<?if ($args["height"]){?> style="height: <?php 
echo $args["height"];
?>
;"<?}?><?php 
echo $js_tags;
?>
><?php 
echo htmlspecialchars_textarea($value);
?>
</textarea>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "fckeditor"){
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<?
					$fck = new fckeditor($args["name"]);
					
					if ($args["height"]){
						$fck->Height = $args["height"];
					}else{
						$fck->Height = 300;
					}
					
					$fck->Value = $value;
					$fck->Create();
				?>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "radio"){
		$id = $id . "_" . $value;
		?>
			<td class="tdt" colspan="2">
				<input type="radio" id="<?php 
echo htmlspecialchars($id);
?>
" name="<?php 
echo htmlspecialchars($args["name"]);
?>
" value="<?php 
echo htmlspecialchars($args["value"]);
?>
"<?if ($args["checked"]){?> checked="checked"<?}?><?php 
echo $js_tags;
?>
 />
				<label for="<?php 
echo htmlspecialchars($id);
?>
">
					<?php 
echo $title_html;
?>
				</label>
			</td>
		<?
	}elseif($args["type"] == "info"){
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<?php 
echo $value;
?>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "plain"){
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<?php 
echo htmlspecialchars($value);
?>
			<?php 
echo $td_end_html;
?>
		<?
	}elseif($args["type"] == "headline"){
		?>
			<td class="tdheadline" colspan="2">
				<?php 
echo $title_html;
?>
			</td>
		<?
	}else{
		?>
			<td class="tdt">
				<?php 
echo $title_html;
?>
			</td>
			<?php 
echo $td_html;
?>
				<input type="<?php 
echo htmlspecialchars($args["type"]);
?>
"<?if ($args["disabled"]){?> disabled<?}?><?if ($args["maxlength"]){?> maxlength="<?php 
echo $args["maxlength"];
?>
"<?}?> class="<?php 
echo $args["class"];
?>
" id="<?php 
echo htmlspecialchars($id);
?>
" name="<?php 
echo htmlspecialchars($args["name"]);
?>
" value="<?php 
echo htmlspecialchars($value);
?>
"<?php 
echo $js_tags;
?>
 />
			<?php 
echo $td_end_html;
?>
		<?
	}
	
	if (!array_key_exists("tr", $args) or $args["tr"]){
		?></tr><?
	}
	
	if ($args["descr"]){
    $descr = $args["descr"];
    
    if ($args["div"]){
      $descr = "<div class=\"tdd\">" . $descr . "</div>";
    }
    
		?>
			<tr>
				<td colspan="2"<?if (!$args["div"]){?> class="tdd"<?}?>>
					<?php 
echo $descr;
?>
				</td>
			</tr>
		<?
	}
}
예제 #15
0
            ?>
                                </td>
                                <td>
                                    <span class="currency">
                                    <?php 
            echo dollar($job_tax['amount'], true, $job['currency_id']);
            ?>
                                    </span>
                                </td>
                                <td>
                                    <?php 
            echo $job_tax['name'];
            ?>
 =
                                    <?php 
            echo number_out($job_tax['percent'], module_config::c('tax_trim_decimal', 1), module_config::c('tax_decimal_places', module_config::c('currency_decimal_places', 2))) . '%';
            ?>
                                </td>
                            <td colspan="<?php 
            echo $colspan - 1;
            ?>
">
                                &nbsp;
                            </td>
                            </tr>
                        <?php 
        }
    }
    ?>
                        <tr>
                            <td colspan="2">
예제 #16
0
                            <div class="dynamic_block">
                                <input type="hidden" name="tax_ids[]" class="dynamic_clear" value="<?php 
            echo isset($tax['finance_tax_id']) ? (int) $tax['finance_tax_id'] : 0;
            ?>
">
                                <input type="text" name="tax_names[]" class="dynamic_clear" value="<?php 
            echo isset($tax['name']) ? htmlspecialchars($tax['name']) : '';
            ?>
" style="width:30px;" autocomplete="off">
                                @
                                <input type="text" name="tax_percents[]" class="dynamic_clear tax_percent" value="<?php 
            echo isset($tax['percent']) ? htmlspecialchars(number_out($tax['percent'])) : '';
            ?>
" style="width:35px;" autocomplete="off">%
                                <input type="hidden" name="tax_amount[]" class="dynamic_clear tax_amount_input" value="<?php 
            echo isset($tax['amount']) ? htmlspecialchars(number_out($tax['amount'])) : '';
            ?>
">
                                (<?php 
            echo currency('<span class="tax_amount">' . dollar($tax['amount'], false, $finance['currency_id']) . '</span>', true, $finance['currency_id']);
            ?>
)
                                <a href="#" class="add_addit" onclick="seladd(this); ucm.finance.update_finance_total(); return false;">+</a>
                                <a href="#" class="remove_addit" onclick="selrem(this); ucm.finance.update_finance_total(); return false;">-</a>
                            </div>
                        <?php 
        }
        ?>

                        </div>
                        <script type="text/javascript">