Esempio n. 1
0
 public static function get_statistics_tax($search)
 {
     // we grab a search on the transactions (the same as clicking search on the transactions page)
     // and filter out tax from those results here.
     $results = module_finance::get_finances($search);
     return $results;
 }
Esempio n. 2
0
        ?>

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

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


</form>
<?php 
// run the custom data hook to display items in this particular hook location
hook_handle_callback('custom_data_hook_location', _CUSTOM_DATA_HOOK_LOCATION_JOB_FOOTER, 'job', $job_id, $job);
hook_handle_callback('layout_column_half', 'end');
?>


<?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
 */
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename="cal.ics"');
$search = array();
// todo - pass any ical options through to search
$recent_transactions = module_finance::get_finances($search);
// are we showing income or expense?
echo 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Ultimate Client Manager/Calendar Plugin v1.0//EN
CALSCALE:GREGORIAN
X-WR-CALNAME:' . (isset($options['credit']) && $options['credit'] ? _l('Credit') . ' ' : '') . (isset($options['debit']) && $options['debit'] ? _l('Debit') . ' ' : '') . 'Financial Transactions
X-WR-TIMEZONE:UTC
';
//$local_timezone_string = date('e');
//$local_timezone = new DateTimeZone($local_timezone_string);
//$local_time = new DateTime("now", $local_timezone);
$timezone_hours = module_config::c('timezone_hours', 0);
foreach ($recent_transactions as $recent_transaction) {
    if ($recent_transaction['credit'] <= 0 && $recent_transaction['debit'] <= 0) {
        continue;
Esempio n. 4
0
        echo $category['finance_category_id'];
        ?>
"><?php 
        echo htmlspecialchars($category['name']);
        ?>
</label> <br/>
                        <?php 
    }
    ?>

                    <input type="checkbox" name="finance_category_new_checked" value="new">
                    <input type="text" name="finance_category_new" value="">
                </div> &nbsp;
	<?php 
    $header_cats = ob_get_clean();
    $header_rows[] = array('sort_date' => array('data' => '<input type="text" name="transaction_date" class="date_field" value="' . print_date(time()) . '"> '), 'sort_name' => array('data' => '<input type="text" name="name" id="new_transaction_name">'), 'finance_description' => array('data' => '<input type="text" name="description">'), 'finance_customer' => array('data' => ''), 'sort_credit' => array('data' => currency('') . '<input type="text" name="credit" class="currency">', 'cell_class' => 'success_text'), 'sort_debit' => array('data' => currency('') . '<input type="text" name="debit" class="currency">', 'cell_class' => 'error_text'), 'sort_account' => array('data' => print_select_box(module_finance::get_accounts(), 'finance_account_id', '', '', true, 'name', true)), 'finance_categories' => array('data' => $header_cats), 'finance_tick' => array('data' => '<input type="submit" name="addnew" value="' . _l('Quick Add') . '" class="small_button">'));
    $table_manager->set_header_rows($header_rows);
}
$table_manager->set_rows($recent_transactions);
if (module_config::c('finance_list_show_totals', 1)) {
    $footer_rows = array();
    foreach ($finance_credit_total + $finance_debit_total as $currency_id => $foo) {
        $currency = get_single('currency', 'currency_id', $currency_id);
        $footer_rows[] = array('sort_date' => array('data' => ' ', 'cell_colspan' => 3), 'finance_customer' => array('data' => '<strong>' . _l('%s Totals:', $currency && isset($currency['code']) ? $currency['code'] : '') . '</strong>', 'cell_class' => 'text-right'), 'sort_credit' => array('data' => '<strong>' . dollar(isset($finance_credit_total[$currency_id]) ? $finance_credit_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'sort_debit' => array('data' => '<strong>' . dollar(isset($finance_debit_total[$currency_id]) ? $finance_debit_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'sort_account' => array('data' => ' ', 'cell_colspan' => 4));
    }
    $footer_rows[] = array('sort_date' => array('data' => ' ', 'cell_colspan' => 8), 'finance_tick' => array('data' => '<input type="button" name="link" value="' . _l('Link') . '" class="small_button" onclick="$(\'#link_go\').val(\'go\'); $(\'#quick_add_form\')[0].submit();">
						<input type="hidden" name="link_go" value="0" id="link_go">
                        ' . _hr('Combine transactions together. eg: an invoice payment history with corresponding bank statement transaction. Transactions need to be the same dollar amount to link successfully.'), 'cell_colspan' => 4));
    $table_manager->set_footer_rows($footer_rows);
}
$table_manager->pagination = true;
Esempio n. 5
0
 public static function get_finance_summary($week_start, $week_end, $multiplyer = 1, $row_limit = 7)
 {
     $cache_key = 'finance_sum_' . md5(module_security::get_loggedin_id() . '_' . serialize(func_get_args()));
     $cache_timeout = module_config::c('cache_objects', 60);
     if ($cached_item = module_cache::get('finance', $cache_key)) {
         return $cached_item;
     }
     $base_href = module_finance::link_generate(false, array('full' => false, 'page' => 'dashboard_popup', 'arguments' => array('display_mode' => 'ajax')), array('foo'));
     $base_href .= '&';
     /*$base_href .= (strpos($base_href,'?')!==false) ? '&' : '?';
       $base_href .= 'display_mode=ajax&';
       $base_href .= 'home_page_stats=true&';*/
     // init structure:
     if ($multiplyer > 1) {
         $row_limit++;
     }
     for ($x = 0; $x < $row_limit; $x++) {
         //$time = strtotime("+$x days",strtotime($week_start));
         $time = strtotime("+" . $x * $multiplyer . " days", strtotime($week_start));
         $data[date("Ymd", $time)] = array("day" => $time, "hours" => 0, "amount" => 0, "amount_invoiced" => 0, "amount_paid" => 0, "amount_spent" => 0);
         if (class_exists('module_envato', false)) {
             $data[date("Ymd", $time)]['envato_earnings'] = 0;
         }
     }
     $data['total'] = array('day' => _l('Totals:'), 'week' => _l('Totals:'), 'hours' => 0, 'amount' => 0, 'amount_invoiced' => 0, 'amount_paid' => 0, 'amount_spent' => 0);
     if (class_exists('module_envato', false)) {
         $data['total']['envato_earnings'] = 0;
     }
     if (class_exists('module_job', false)) {
         module_debug::log(array('title' => 'Finance Dashboard Job', 'data' => ''));
         // find all task LOGS completed within these dayes
         $sql = "SELECT t.task_id, tl.date_created, t.hours AS task_hours, t.amount, tl.hours AS hours_logged, p.job_id, p.hourly_rate, t.date_done ";
         //            $sql .= " FROM `"._DB_PREFIX."task_log` tl ";
         //            $sql .= " LEFT JOIN `"._DB_PREFIX."task` t ON tl.task_id = t.task_id ";
         $sql .= " FROM `" . _DB_PREFIX . "task` t";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "task_log` tl ON t.task_id = tl.task_id ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "job` p ON t.job_id = p.job_id";
         $sql .= " WHERE ( (tl.date_created >= '{$week_start}' AND tl.date_created < '{$week_end}') OR (t.fully_completed = 1 AND t.date_done >= '{$week_start}' AND t.date_done < '{$week_end}') )";
         $sql .= " AND t.job_id IN ( ";
         $valid_job_ids = module_job::get_valid_job_ids();
         if (count($valid_job_ids)) {
             foreach ($valid_job_ids as $valid_job_id) {
                 $sql .= (int) $valid_job_id['job_id'] . ", ";
             }
             $sql = rtrim($sql, ', ');
         } else {
             $sql .= ' NULL ';
         }
         $sql .= " ) ";
         //            echo $sql;
         $tasks = query($sql);
         $logged_tasks = array();
         while ($r = mysql_fetch_assoc($tasks)) {
             if (!$r['date_created']) {
                 $r['date_created'] = $r['date_done'];
             }
             if ($multiplyer > 1) {
                 $week_day = date('w', strtotime($r['date_created'])) - 1;
                 $r['date_created'] = date('Y-m-d', strtotime('-' . $week_day . ' days', strtotime($r['date_created'])));
             }
             $key = date("Ymd", strtotime($r['date_created']));
             if (!isset($data[$key])) {
                 // for some reason we're getting results here that shouldn't be in the list
                 // for now we just skip these results until I figure out why (only had 1 guy report this error, maybe misconfig)
                 continue;
             }
             // copied from dashboard_popup_hours_logged.php
             // needed get_tasks call to do the _JOB_TASK_ACCESS_ASSIGNED_ONLY permission check
             $jobtasks = module_job::get_tasks($r['job_id']);
             $task = isset($jobtasks[$r['task_id']]) ? $jobtasks[$r['task_id']] : false;
             if (!$task) {
                 continue;
             }
             if (!isset($task['manual_task_type']) || $task['manual_task_type'] < 0) {
                 $task['manual_task_type'] = $task['default_task_type'];
             }
             if (isset($r['hours_logged']) && $r['hours_logged'] > 0) {
                 if ($r['hours_logged'] == $task['completed']) {
                     // this listing is the only logged hours for this task.
                     if ($task['fully_completed']) {
                         // task complete, we show the final amount and hours.
                         if ($task['amount'] > 0) {
                             if ($task['manual_task_type'] == _TASK_TYPE_QTY_AMOUNT) {
                                 $display_amount = $task['amount'] * $task['hours'];
                             } else {
                                 $display_amount = $task['amount'];
                             }
                         } else {
                             $display_amount = $r['task_hours'] * $r['hourly_rate'];
                         }
                     } else {
                         // task isn't fully completed yet, just use hourly rate for now.
                         $display_amount = $r['hours_logged'] * $r['hourly_rate'];
                     }
                 } else {
                     // this is part of a bigger log of hours for this single task.
                     $display_amount = $r['hours_logged'] * $r['hourly_rate'];
                 }
                 $hours_logged = $r['task_hours'] > 0 ? $r['hours_logged'] : 0;
             } else {
                 // there are no logged hours for this particular task, but it is set to completed.
                 // we just assume it is completed on this day.
                 if ($task['amount'] > 0) {
                     if ($task['manual_task_type'] == _TASK_TYPE_QTY_AMOUNT) {
                         $display_amount = $task['amount'] * $task['hours'];
                     } else {
                         $display_amount = $task['amount'];
                     }
                 } else {
                     $display_amount = $r['task_hours'] * $r['hourly_rate'];
                 }
                 $hours_logged = $task['hours'];
             }
             $data[$key]['amount'] += $display_amount;
             $data['total']['amount'] += $display_amount;
             $data[$key]['hours'] += $hours_logged;
             $data['total']['hours'] += $hours_logged;
             /*$hourly_rate = $r['hourly_rate'];
               if($hours_logged > 0 && $r['amount'] > 0 && $hourly_rate > 0){
                   // there is a custom amount assigned to thsi task.
                   // only calculate this amount if the full hours is complete.
                   $hourly_rate = $r['amount'] / $r['task_hours'];
               }
               if($hours_logged > 0 && $hourly_rate > 0){
                   $data[$key]['amount'] += ($hours_logged * $hourly_rate);
                   $data['total']['amount'] += ($hours_logged * $hourly_rate);
               }*/
         }
     }
     module_debug::log(array('title' => 'Finance Dashboard Invoices', 'data' => ''));
     // find invoices sent this week.
     $sql = "SELECT i.* ";
     $sql .= " FROM `" . _DB_PREFIX . "invoice` i ";
     $sql .= " LEFT JOIN `" . _DB_PREFIX . "invoice_item` ii ON i.invoice_id = ii.invoice_id ";
     if (class_exists('module_job', false)) {
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "task` t ON ii.task_id = t.task_id ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "job` p ON t.job_id = p.job_id ";
     }
     $sql .= " WHERE (i.date_create >= '{$week_start}' AND i.date_create <= '{$week_end}')";
     $sql .= " GROUP BY i.invoice_id";
     // todo - sql in here to limit what they can see.
     $invoices = query($sql);
     // group invoices into days of the week.
     while ($invoice_data = mysql_fetch_assoc($invoices)) {
         //$invoice_data = module_invoice::get_invoice($i['invoice_id']);
         if ($invoice_data) {
             if ($multiplyer > 1) {
                 $week_day = date('w', strtotime($invoice_data['date_create'])) - 1;
                 $invoice_data['date_create'] = date('Y-m-d', strtotime('-' . $week_day . ' days', strtotime($invoice_data['date_create'])));
             }
             $key = date("Ymd", strtotime($invoice_data['date_create']));
             if (!isset($data[$key])) {
                 // for some reason we're getting results here that shouldn't be in the list
                 // for now we just skip these results until I figure out why (only had 1 guy report this error, maybe misconfig)
                 continue;
             }
             if (isset($data[$key])) {
                 $data[$key]['amount_invoiced'] += $invoice_data['c_total_amount'];
                 $data['total']['amount_invoiced'] += $invoice_data['c_total_amount'];
             }
         }
     }
     module_debug::log(array('title' => 'Finance Dashboard Finances', 'data' => ''));
     // find all payments made this week.
     // we also have to search for entries in the new "finance" table and make sure we dont double up here.
     $finance_records = module_finance::get_finances(array('date_from' => $week_start, 'date_to' => $week_end));
     foreach ($finance_records as $finance_record) {
         if (isset($finance_record['payment_type']) && ($finance_record['payment_type'] == _INVOICE_PAYMENT_TYPE_OVERPAYMENT_CREDIT || $finance_record['payment_type'] == _INVOICE_PAYMENT_TYPE_CREDIT)) {
             // CODE COPIED FROM FINANCE_LIST.PHP
             // dont add these ones to the totals on the dashboard
             continue;
         }
         if ($finance_record['credit'] > 0) {
             if ($multiplyer > 1) {
                 $week_day = date('w', strtotime($finance_record['transaction_date'])) - 1;
                 $finance_record['transaction_date'] = date('Y-m-d', strtotime('-' . $week_day . ' days', strtotime($finance_record['transaction_date'])));
             }
             $key = date("Ymd", strtotime($finance_record['transaction_date']));
             if (isset($data[$key])) {
                 $data[$key]['amount_paid'] += $finance_record['amount'];
                 $data['total']['amount_paid'] += $finance_record['amount'];
             }
         }
         if ($finance_record['debit'] > 0) {
             if ($multiplyer > 1) {
                 $week_day = date('w', strtotime($finance_record['transaction_date'])) - 1;
                 $finance_record['transaction_date'] = date('Y-m-d', strtotime('-' . $week_day . ' days', strtotime($finance_record['transaction_date'])));
             }
             $key = date("Ymd", strtotime($finance_record['transaction_date']));
             if (isset($data[$key])) {
                 $data[$key]['amount_spent'] += $finance_record['amount'];
                 $data['total']['amount_spent'] += $finance_record['amount'];
             }
         }
     }
     module_debug::log(array('title' => 'Finance Dashboard DONE!', 'data' => ''));
     /*$sql = "SELECT p.* ";
       $sql .= " FROM `"._DB_PREFIX."invoice_payment` p ";
       $sql .= " WHERE (p.date_paid >= '$week_start' AND p.date_paid <= '$week_end')";
       // todo - sql in here to limit what they can see.
       $payments = query($sql);
       // group invoices into days of the week.
       while($payment = mysql_fetch_assoc($payments)){
           //$invoice_data = module_invoice::get_invoice($i['invoice_id']);
           if($multiplyer > 1){
               $week_day = date('w',strtotime($payment['date_paid'])) - 1;
               $payment['date_paid'] = date('Y-m-d',strtotime('-'.$week_day.' days',strtotime($payment['date_paid'])));
           }
           $key = date("Ymd",strtotime($payment['date_paid']));
           if(isset($data[$key])){
               $data[$key]['amount_paid'] += $payment['amount'];
               $data['total']['amount_paid'] += $payment['amount'];
           }
       }*/
     if (class_exists('module_envato', false)) {
         $envato_currency = "USD";
         $envato = new envato_api();
         $local_currency = $envato->read_setting("local_currency", "AUD");
         $currency_convert_multiplier = $envato->currency_convert($envato_currency, $local_currency);
         // find summary of earnings between these dates in the envato statement.
         $week_start_time = strtotime($week_start);
         $week_end_time = strtotime($week_end);
         $sql = "SELECT * FROM `" . _DB_PREFIX . "envato_statement` s WHERE `time` >= '{$week_start_time}' AND `time` <= {$week_end_time}";
         $sql .= " AND ( `type` = 'sale' OR `type` = 'referral_cut' )";
         foreach (qa($sql) as $sale) {
             $sale_time = $sale['time'];
             if ($multiplyer > 1) {
                 $week_day = date('w', $sale_time) - 1;
                 $sale_time = strtotime('-' . $week_day . ' days', $sale_time);
             }
             $key = date("Ymd", $sale_time);
             if (!isset($data[$key])) {
                 continue;
             }
             $data[$key]['envato_earnings'] += round($currency_convert_multiplier * $sale['earnt'], 2);
             $data['total']['envato_earnings'] += round($currency_convert_multiplier * $sale['earnt'], 2);
             /*if($sale['type']=='sale'){
                   $sales_count++;
               }
               $sales_amount+= $sale['earnt'];*/
         }
     }
     if ($multiplyer > 1) {
         // dont want totals on previous weeks listing
         unset($data['total']);
     }
     foreach ($data as $data_id => $row) {
         //$row['amount'] = dollar($row['amount']);
         $row['chart_amount'] = $row['amount'];
         $row['amount'] = currency((int) $row['amount']);
         $row['chart_amount_invoiced'] = $row['amount_invoiced'];
         $row['amount_invoiced'] = currency((int) $row['amount_invoiced']);
         $row['chart_amount_paid'] = $row['amount_paid'];
         $row['amount_paid'] = currency((int) $row['amount_paid']);
         $row['chart_amount_spent'] = $row['amount_spent'];
         $row['amount_spent'] = currency((int) $row['amount_spent']);
         if (class_exists('module_envato', false)) {
             $row['chart_envato_earnings'] = $row['envato_earnings'];
             $row['envato_earnings'] = currency((int) $row['envato_earnings']);
         }
         // combine together
         $row['chart_hours'] = $row['hours'];
         $row['hours'] = sprintf('%s (%s)', $row['hours'], $row['amount']);
         if (is_numeric($row['day'])) {
             $time = $row['day'];
             $date = date('Y-m-d', $time);
             $row['date'] = $date;
             if ($multiplyer > 1) {
                 $date .= '|' . date('Y-m-d', strtotime('+' . $multiplyer . ' days', $time));
             }
             //$row['hours'] = '<a href="'.$base_href.'w=hours&date='.$date.'" class="summary_popup">'. _l('%s hours',$row['hours']) . '</a>';
             $row['hours_link'] = '<a href="' . $base_href . 'w=hours&date=' . $date . '" class="summary_popup">' . $row['hours'] . '</a>';
             $row['amount_link'] = '<a href="' . $base_href . 'w=hours&date=' . $date . '" class="summary_popup">' . $row['amount'] . '</a>';
             $row['amount_invoiced_link'] = '<a href="' . $base_href . 'w=amount_invoiced&date=' . $date . '" class="summary_popup">' . $row['amount_invoiced'] . '</a>';
             $row['amount_paid_link'] = '<a href="' . $base_href . 'w=amount_paid&date=' . $date . '" class="summary_popup">' . $row['amount_paid'] . '</a>';
             $row['amount_spent_link'] = '<a href="' . $base_href . 'w=amount_spent&date=' . $date . '" class="summary_popup">' . $row['amount_spent'] . '</a>';
             $row['day'] = _l(date('D', $time)) . ' ' . date('j', $time) . _l(date('S', $time));
             $row['week'] = _l(date('M', $time)) . ' ' . date('j', $time) . _l(date('S', $time));
             // if it's today.
             if ($time == strtotime(date("Y-m-d"))) {
                 $row['highlight'] = true;
             }
         } else {
         }
         $data[$data_id] = $row;
     }
     module_cache::put('finance', $cache_key, $data, $cache_timeout);
     return $data;
 }
Esempio n. 6
0
        ?>
');" <?php 
    }
    ?>
><?php 
    _e('Record this transaction');
    ?>
</a>
                    <?php 
    _e('(this will schedule the next reminder)');
    ?>
                </td>
            </tr>
            <?php 
}
?>

        </tbody>
    </table>
<?php 
$fieldset_data = array('heading' => array('title' => _l('Recurring Transaction'), 'type' => 'h2', 'main' => true), 'elements_before' => ob_get_clean());
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete'), 'onclick' => "return confirm('" . _l('Really delete this record?') . "');"), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . module_finance::link_open_recurring(false) . "';")));
echo module_form::generate_form_actions($form_actions);
?>



</form>
     ?>
             </td>
             <td>
                 <?php 
     if (isset($r['invoice_id']) && $r['invoice_id'] > 0) {
         echo module_invoice::link_open($r['invoice_id'], true);
     }
     ?>
             </td>
             <?php 
 } else {
     if (isset($r['finance_id'])) {
         ?>
             <td colspan="3">
                 <?php 
         echo module_finance::link_open($r['finance_id'], true);
         ?>
                 
                 <?php 
         echo htmlspecialchars($r['description']);
         ?>
             </td>
             <?php 
     }
 }
 ?>
             <td>
                 <?php 
 $total += $r['amount'];
 echo dollar($r['amount']);
 ?>
Esempio n. 8
0
    } else {
        _e(' (%s days)', $days);
    }
    //}
    ?>
                <?php 
    if ($show_record_button) {
        ?>
                </a>
                <?php 
    }
    ?>
            </td>
            <td class="row_action">
                <?php 
    echo isset($recurring['url']) && $recurring['url'] ? $recurring['url'] : module_finance::link_open_recurring($recurring['finance_recurring_id'], true, $recurring);
    ?>
            </td>
            <td>
                <?php 
    if ($recurring['type'] == 'i') {
        $balance += $recurring['amount'];
        ?>
<span class="success_text">+<?php 
        echo dollar($recurring['amount'], true, $recurring['currency_id']);
        ?>
</span><?php 
    }
    ?>
            </td>
            <td>
Esempio n. 9
0
    ?>
            </td>
            <td>
                <?php 
    echo $recurring['categories'];
    ?>
            </td>
            <td>
                <?php 
    echo dollar($balance);
    ?>
            </td>
            <td>
                <?php 
    if ($show_record_button) {
        $link = module_finance::link_open_record_recurring($recurring['finance_recurring_id']);
        $_SESSION['_finance_recurring_ids'][] = array($recurring['finance_recurring_id'], $link);
        ?>
                <a href="<?php 
        echo $link;
        ?>
" class="uibutton"<?php 
        if ($days > 10) {
            ?>
 onclick="return confirm('<?php 
            echo addcslashes(_l('This transaction is not due for %s days, are you sure you want to record it?', $days), "'");
            ?>
');" <?php 
        }
        ?>
><?php 
Esempio n. 10
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
//include("top_menu.php");
$module->page_title = _l('Finance');
$links = array();
$menu_position = 1;
array_unshift($links, array("name" => "Transactions", 'm' => 'finance', 'p' => 'finance', 'default_page' => 'finance_list', 'order' => $menu_position++, 'menu_include_parent' => 0, 'allow_nesting' => 0, 'args' => array('finance_id' => false)));
if (module_finance::can_i('view', 'Finance Upcoming')) {
    array_unshift($links, array("name" => "Upcoming Payments", 'm' => 'finance', 'p' => 'recurring', 'order' => $menu_position++, 'menu_include_parent' => 0, 'allow_nesting' => 1, 'args' => array('finance_id' => false, 'finance_recurring_id' => false)));
}
Esempio n. 11
0
 }
 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']);
         }
     }
     $this_taxes = module_finance::sanatise_taxes($invoice_item_data['taxes'], $invoice_item_data['invoice_item_amount']);
     $this_taxes_amounts = array();
     $this_taxes_rates = array();
     if (!count($this_taxes)) {
         $this_taxes = array('amount' => 0, 'percent' => 0);
     }
     foreach ($this_taxes as $this_tax) {
         $this_taxes_amounts[] = dollar($this_tax['amount'], true, $invoice['currency_id']);
         $this_taxes_rates[] = $this_tax['percent'] . '%';
     }
     $row_replace['item_tax'] = implode(', ', $this_taxes_amounts);
     $row_replace['item_tax_rate'] = implode(', ', $this_taxes_rates);
 }
 $this_item_row_html = $item_row_html;
 $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html);
 // we pass this through the template system so we can make use of things like arithmatic.
    }
    if (strlen($recurring['name'])) {
        $recurring['name'] = '(' . $recurring['name'] . ")";
    }
    // start looping up to our cutout.
    $time = strtotime($timezone_hours . ' hours', strtotime($recurring['next_due_date']));
    while ($time < $limit_timestamp) {
        echo 'BEGIN:VEVENT
UID:' . md5(mt_rand(1, 100)) . '@ultimateclientmanager.com
';
        // work out the UTC time for this event, based on the timezome we have set in the configuration options
        echo 'DTSTAMP:' . date('Ymd') . 'T090000Z
DTSTART;VALUE=DATE:' . date('Ymd', $time) . '
DTEND;VALUE=DATE:' . date('Ymd', strtotime('+1 day', $time)) . '
SUMMARY:' . ($recurring['type'] == 'i' ? '+' . dollar($recurring['amount']) : '') . ($recurring['type'] == 'e' ? '-' . dollar($recurring['amount']) : '') . " " . $recurring['name'] . '
DESCRIPTION:' . preg_replace('#[\\r\\n]+#', "<br>", $recurring['description']) . ' <br><a href="' . module_finance::link_open_recurring($recurring['finance_recurring_id']) . '">' . _('Open Link') . '</a>
END:VEVENT
';
        // increase the time to the next recurring event.
        if ($recurring['next_due_date'] == '0000-00-00' || !$recurring['days'] && !$recurring['months'] && !$recurring['years']) {
            // it's a once off..
            break;
            // ignore anym ore in this loop.
        } else {
            // work out when the next one will be.
            $next_time = $time;
            $next_time = strtotime('+' . abs((int) $recurring['days']) . ' days', $next_time);
            $next_time = strtotime('+' . abs((int) $recurring['months']) . ' months', $next_time);
            $next_time = strtotime('+' . abs((int) $recurring['years']) . ' years', $next_time);
            $time = $next_time;
        }
Esempio n. 13
0
                </tr>
                </thead>
                <tbody>
                <?php 
$c = 0;
$displayed_finance_ids = array();
// keep track of which parent / child finance ids have been displayed.
$displayed_invoice_payment_ids = array();
// keep track of which parent / child invoice_payment ids have been displayed.
foreach ($recent_transactions_pagination['rows'] as $finance) {
    $c++;
    $link_rowspan = 1;
    $description_rowspan = 1;
    $shared_description = $finance['description'];
    if (isset($finance['finance_id']) && $finance['finance_id']) {
        $finance_record = module_finance::get_finance($finance['finance_id']);
        if (count($finance_record['linked_invoice_payments'])) {
            $link_rowspan += count($finance_record['linked_invoice_payments']);
        }
        if (count($finance_record['linked_finances'])) {
            $link_rowspan += count($finance_record['linked_finances']);
        }
        // a little hack to find if we use a shared description.
        if ($link_rowspan > 1 && count($finance_record['linked_invoice_payments'])) {
            foreach ($finance_record['linked_invoice_payments'] as $this_finance_record) {
                if (strlen(trim($shared_description)) && strlen(trim(strip_tags($this_finance_record['description']))) > 0 && trim(strip_tags($shared_description)) != trim(strip_tags($this_finance_record['description']))) {
                    $description_rowspan = 1;
                    $shared_description = $finance['description'];
                    break;
                } else {
                    $description_rowspan++;
Esempio n. 14
0
    echo !trim($transaction['name']) ? 'N/A' : htmlspecialchars($transaction['name']);
    ?>
</a>
                    </td>
                    <td>
                        <?php 
    echo $transaction['description'];
    ?>
                    </td>
                    <td>
                        <span class="success_text"><?php 
    echo $transaction['credit'] > 0 ? '+' . dollar($transaction['credit'], true, $transaction['currency_id']) : '';
    ?>
</span>
                    </td>
                    <td>
                        <span class="error_text"><?php 
    echo $transaction['debit'] > 0 ? '-' . dollar($transaction['debit'], true, $transaction['currency_id']) : '';
    ?>
</span>
                    </td>
                </tr>
            <?php 
}
?>
        </tbody>
    </table>
</div>
<?php 
$fieldset_data = array('heading' => array('title' => 'Job Finances:', 'type' => 'h3', 'button' => array('title' => _l('Add New'), 'url' => module_finance::link_open('new') . '&from_job_id=' . $job_id)), 'elements_before' => ob_get_clean());
echo module_form::generate_fieldset($fieldset_data);
Esempio n. 15
0
?>

</tr>
</thead>
<tbody>
<?php 
$c = 0;
$total_by_currency = array();
$total = array('transaction_count' => 0, 'total_credit' => 0, 'total_sub_credit' => 0, 'total_credit_tax' => array(), 'total_debit' => 0, 'total_sub_debit' => 0, 'total_debit_tax' => array());
// calc taxes and stuff first loop, then display later.
foreach ($tax_reports as $finance) {
    if (isset($finance['finance_id']) && $finance['finance_id']) {
        $finance_record = module_finance::get_finance($finance['finance_id']);
    } else {
        if (isset($finance['invoice_payment_id']) && $finance['invoice_payment_id'] > 0) {
            $finance_record = module_finance::get_finance(false, true, $finance['invoice_payment_id']);
        } else {
            $finance_record = false;
        }
    }
    if (!isset($total_by_currency[$finance['currency_id']])) {
        $total_by_currency[$finance['currency_id']] = $total;
    }
    $total_by_currency[$finance['currency_id']]['transaction_count']++;
    ?>

    <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
        <td>
Esempio n. 16
0
/** 
 * 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
 */
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename="cal.ics"');
$show_previous_weeks = module_config::c('dashboard_income_previous_weeks', 7);
$date_start = date('Y-m-d', mktime(1, 0, 0, date('m'), date('d') - date('w') - ($show_previous_weeks + 2) * 7 + 1, date('Y')));
$date_end = date('Y-m-d', strtotime('-1 day', mktime(1, 0, 0, date('m'), date('d') + (6 - date('w')) - 2 * 7 + 2, date('Y'))));
$result = module_finance::get_finance_summary($date_start, $date_end, 7, $show_previous_weeks);
/*
print_r($result);
echo 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Ultimate Client Manager/Calendar Plugin v1.0//EN
CALSCALE:GREGORIAN
X-WR-CALNAME:'._l('Dashboard Summary').'
X-WR-TIMEZONE:UTC
';
//$local_timezone_string = date('e');
//$local_timezone = new DateTimeZone($local_timezone_string);
//$local_time = new DateTime("now", $local_timezone);
$timezone_hours = module_config::c('timezone_hours',0);
        $time = strtotime($timezone_hours.' hours',strtotime($alert['date']));
        echo 'BEGIN:VEVENT
Esempio n. 17
0
" target="_blank"><?php 
    echo module_calendar::link_calendar('finance_transactions', array('credit' => 1));
    ?>
</a> <br/>
    Debit Transactions: <a href="<?php 
    echo module_calendar::link_calendar('finance_transactions', array('debit' => 1));
    ?>
" target="_blank"><?php 
    echo module_calendar::link_calendar('finance_transactions', array('debit' => 1));
    ?>
</a>
</p>
<hr>

<p><?php 
    _e('Here are the URL\'s for <strong>Recurring Finance Transactions</strong> (ie: anything upcoming in the <a href="%s">recurring transactions listing</a> page).', module_finance::link_open_recurring(false));
    ?>
</p>
<p>
    Credit Transactions: <a href="<?php 
    echo module_calendar::link_calendar('finance_recurring', array('credit' => 1));
    ?>
" target="_blank"><?php 
    echo module_calendar::link_calendar('finance_recurring', array('credit' => 1));
    ?>
</a> <br/>
    Debit Transactions: <a href="<?php 
    echo module_calendar::link_calendar('finance_recurring', array('debit' => 1));
    ?>
" target="_blank"><?php 
    echo module_calendar::link_calendar('finance_recurring', array('debit' => 1));
            ?>
</td>
                    <td><?php 
            echo isset($row['hours_link']) ? $row['hours_link'] : $row['hours'];
            ?>
</td>
                    <td><?php 
            echo isset($row['amount_invoiced_link']) ? $row['amount_invoiced_link'] : $row['amount_invoiced'];
            ?>
</td>
                    <td><?php 
            echo isset($row['amount_paid_link']) ? $row['amount_paid_link'] : $row['amount_paid'];
            ?>
</td>
                    <?php 
            if (module_finance::is_expense_enabled()) {
                ?>
                        <td><?php 
                echo isset($row['amount_spent_link']) ? $row['amount_spent_link'] : $row['amount_spent'];
                ?>
</td>
                    <?php 
            }
            ?>
                    <?php 
            if (class_exists('module_envato', false) && module_config::c('envato_include_in_dashbaord', 1)) {
                ?>
                    <td><?php 
                echo isset($row['envato_earnings_link']) ? $row['envato_earnings_link'] : $row['envato_earnings'];
                ?>
</td>
Esempio n. 19
0
         $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();
     if (!count($this_taxes)) {
         $this_taxes = array('amount' => 0, 'percent' => 0);
     }
     foreach ($this_taxes as $this_tax) {
         $this_taxes_amounts[] = dollar($this_tax['amount'], true, $quote['currency_id']);
         $this_taxes_rates[] = $this_tax['percent'] . '%';
     }
     $row_replace['item_tax'] = implode(', ', $this_taxes_amounts);
     $row_replace['item_tax_rate'] = implode(', ', $this_taxes_rates);
 }
 $this_item_row_html = $item_row_html;
 $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html);
 // we pass this through the template system so we can make use of things like arithmatic.
Esempio n. 20
0
</a>
                                    </td>
                                </tr>
                        <?php 
    }
    ?>

                        </tbody>
					</table>
                        </div>

                        <?php 
    $fieldset_data = array('heading' => array('title' => _l('Invoice Payment History'), 'type' => 'h3'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
    if (class_exists('module_finance', false) && module_finance::is_plugin_enabled() && module_finance::can_i('view', 'Finance') && module_finance::is_enabled() && is_file('includes/plugin_finance/pages/finance_invoice_edit.php') && module_config::c('invoice_show_finances', 1)) {
        include 'includes/plugin_finance/pages/finance_invoice_edit.php';
    }
}
// invoice_id check
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'onclick' => "\$('#form_redirect').val('" . (!$invoice_id && isset($_REQUEST['job_id']) && (int) $_REQUEST['job_id'] > 0 ? module_job::link_open($_REQUEST['job_id']) : module_invoice::link_open(false)) . "');", 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save'))));
if ((int) $invoice_id) {
    if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
        $form_actions['elements'][] = array('type' => 'save_button', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Receipt'));
    } else {
        $form_actions['elements'][] = array('type' => 'submit', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Invoice'));
    }
    if (function_exists('convert_html2pdf')) {
        if (!module_invoice::can_i('edit', 'Invoices')) {
            $form_actions['elements'][] = array('type' => 'button', 'class' => 'submit_button no_permissions', 'name' => 'butt_print', 'value' => _l('Print PDF'), 'onclick' => "window.location.href='" . module_invoice::link_public_print($invoice_id) . "';");
Esempio n. 21
0
    $fieldset_data['elements'][] = array('title' => 'Linked Staff', 'fields' => array(function () use(&$finance, $locked, $linked_staff_members) {
        ?>
 <input type="hidden" name="job_staff_expense" value="<?php 
        echo isset($finance['job_staff_expense']) ? (int) $finance['job_staff_expense'] : '';
        ?>
">
                    <?php 
        echo print_select_box($linked_staff_members, 'user_id', isset($finance['user_id']) ? $finance['user_id'] : 0, '', _l(' - None - '));
        if (isset($finance['user_id']) && $finance['user_id']) {
            echo ' <a href="' . module_user::link_open($finance['user_id'], false) . '">' . _l('Open User') . '</a>';
        }
    }));
}
$fieldset_data['elements'][] = array('title' => 'Attachment', 'fields' => array(function () use(&$finance, $locked, $finance_id) {
    if ((int) $finance_id > 0) {
        module_file::display_files(array('owner_table' => 'finance', 'owner_id' => $finance_id, 'layout' => 'gallery', 'editable' => module_security::is_page_editable() && module_finance::can_i('edit', 'Finance')));
    } else {
        _e('Please press save first');
    }
}));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save_return', 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save'))));
if ((int) $finance_recurring_id > 0 && isset($_SESSION['_finance_recurring_ids'])) {
    // find if there is a next recurring id
    $next = 0;
    foreach ($_SESSION['_finance_recurring_ids'] as $next_data) {
        if ($next == -1) {
            $next = 1;
            // done.
            $form_actions['elements'][] = array('type' => 'hidden', 'name' => 'recurring_next', 'id' => 'recurring_next', 'value' => '');