예제 #1
0
function print_GL_transactions()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $fromacc = $_POST['PARAM_2'];
    $toacc = $_POST['PARAM_3'];
    if ($dim == 2) {
        $dimension = $_POST['PARAM_4'];
        $dimension2 = $_POST['PARAM_5'];
        $comments = $_POST['PARAM_6'];
        $orientation = $_POST['PARAM_7'];
        $destination = $_POST['PARAM_8'];
    } else {
        if ($dim == 1) {
            $dimension = $_POST['PARAM_4'];
            $comments = $_POST['PARAM_5'];
            $orientation = $_POST['PARAM_6'];
            $destination = $_POST['PARAM_7'];
        } else {
            $comments = $_POST['PARAM_4'];
            $orientation = $_POST['PARAM_5'];
            $destination = $_POST['PARAM_6'];
        }
    }
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation);
    $dec = 2;
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
    if ($dim == 2) {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    } elseif ($dim == 1) {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    } else {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    }
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc));
        }
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $accounts = get_gl_accounts($fromacc, $toacc);
    while ($account = db_fetch($accounts)) {
        if (is_account_balancesheet($account["account_code"])) {
            $begin = "";
        } else {
            $begin = get_fiscalyear_begin_for_date($from);
            if (date1_greater_date2($begin, $from)) {
                $begin = $from;
            }
            $begin = add_days($begin, -1);
        }
        $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
        $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
        $rows = db_num_rows($trans);
        if ($prev_balance == 0.0 && $rows == 0) {
            continue;
        }
        $rep->Font('bold');
        $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2);
        $rep->TextCol(4, 6, _('Opening Balance'));
        if ($prev_balance > 0.0) {
            $rep->AmountCol(7, 8, abs($prev_balance), $dec);
        } else {
            $rep->AmountCol(8, 9, abs($prev_balance), $dec);
        }
        $rep->Font();
        $total = $prev_balance;
        $rep->NewLine(2);
        if ($rows > 0) {
            while ($myrow = db_fetch($trans)) {
                $total += $myrow['amount'];
                $type_name = $systypes_array[$myrow["type"]];
                if ($type_name == "Customer Payment") {
                    $rep->TextCol(0, 1, "CRB", -2);
                }
                if ($type_name == "Cash Disbursement/Check Voucher") {
                    $rep->TextCol(0, 1, "CDB", -2);
                }
                if ($type_name == "Journal Entry") {
                    $rep->TextCol(0, 1, "JB", -2);
                }
                if ($type_name == "Customer Credit Note") {
                    $type_name = "Credit Memo";
                }
                if ($type_name == "Sales Invoice") {
                    $type_name = "Invoice";
                } else {
                    if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") {
                        $rep->TextCol(0, 1, $type_name, -2);
                    }
                }
                $reference = get_reference($myrow["type"], $myrow["type_no"]);
                $rep->TextCol(1, 2, $reference);
                $rep->TextCol(2, 3, $myrow['type_no'], -2);
                $rep->DateCol(3, 4, $myrow["tran_date"], true);
                if ($dim >= 1) {
                    $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id']));
                }
                if ($dim > 1) {
                    $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id']));
                }
                $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false);
                $memo = $myrow['memo_'];
                if ($txt != "") {
                    if ($memo != "") {
                        $txt = $txt . "/" . $memo;
                    }
                } else {
                    $txt = $memo;
                }
                $rep->TextCol(6, 7, $txt, -2);
                if ($myrow['amount'] > 0.0) {
                    $rep->AmountCol(7, 8, abs($myrow['amount']), $dec);
                } else {
                    $rep->AmountCol(8, 9, abs($myrow['amount']), $dec);
                }
                $rep->TextCol(9, 10, number_format2($total, $dec));
                $rep->NewLine();
                if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                    $rep->Line($rep->row - 2);
                    $rep->NewPage();
                }
            }
            $rep->NewLine();
        }
        $rep->Font('bold');
        $rep->TextCol(4, 6, _("Ending Balance"));
        if ($total > 0.0) {
            $rep->AmountCol(7, 8, abs($total), $dec);
        } else {
            $rep->AmountCol(8, 9, abs($total), $dec);
        }
        $rep->Font();
        $rep->Line($rep->row - $rep->lineHeight + 4);
        $rep->NewLine(2, 1);
    }
    $rep->End();
}
function completed_orders_shortcode()
{
    global $wpdb;
    global $gfpdf;
    $output = '';
    $leads = $wpdb->get_results($wpdb->prepare("SELECT wp_tpl_docs.file_url, wp_rg_lead.unique_id, wp_rg_form_meta.display_meta, wp_rg_lead.orderStatus, wp_rg_lead.date_created, wp_rg_lead.id, wp_rg_lead.form_id, wp_rg_form.title, wp_rg_lead.eco_ref, wp_rg_lead.asic_status FROM wp_rg_lead LEFT JOIN wp_rg_form ON wp_rg_lead.form_id = wp_rg_form.id LEFT JOIN wp_tpl_docs ON wp_rg_lead.id = wp_tpl_docs.lead_id LEFT JOIN wp_rg_form_meta ON wp_rg_lead.form_id = wp_rg_form_meta.form_id WHERE wp_rg_lead.created_by = %d AND wp_rg_lead.orderStatus = 'complete' ORDER BY wp_rg_lead.id DESC", wp_get_current_user()->ID));
    $form_id_excluded = array(3, 4, 5, 60, 66, 68, 71);
    foreach ($leads as $lead) {
        if ($lead->form_id == "11" || $lead->form_id == "58" and $lead->eco_ref != "") {
            //is a company incorporation
            switch ($lead->asic_status) {
                case "Order complete":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td>
                          <div class="btn-group">
                          <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Download</a>
                          <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                            <span class="fa fa-caret-down"></span></a>
                          <ul class="dropdown-menu multi-level" style="min-width: 107px;">
                            <li class="dropdown-submenu">
                                <a tabindex="-1" class="btn-xs"href="#"><i class="fa fa-book fa-fw"></i> Documents</a>
                                <ul class="dropdown-menu" style="min-width: 107px;">
                                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getDocs.php?orderid=' . $lead->eco_ref . '">Direct Download</a></li>
                                    <li><a href="https://app.thesmsfacademy.com.au/corp/getDocs.php?orderid=' . $lead->eco_ref . '" class="dropbox-saver" data-filename="' . $lead->eco_ref . '.pdf">Save</a></li>
                                    <li><div class="g-savetodrive" data-filename="' . $lead->eco_ref . '.pdf" data-sitename="TSA Campus" data-src="https://app.thesmsfacademy.com.au/corp/getDocs.php?orderid=' . $lead->eco_ref . '"></div></li>
                            
                                </ul>
                            </li>
                            <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getCert.php?orderid=' . $lead->eco_ref . '"><i class="fa fa-certificate fa-fw"></i> Certificate</a></li>
                            <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getCasFile.php?orderid=' . $lead->eco_ref . '"><i class="fa fa-briefcase fa-fw"></i> CAS File</a></tr></li>
                            
                          </ul></div></tr></form>';
                    break;
                case "complete":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td>
                          <div class="btn-group">
                          <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Download</a>
                          <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                            <span class="fa fa-caret-down"></span></a>
                          <ul class="dropdown-menu" style="min-width: 107px;">
                            <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getDocs.php?orderid=' . $lead->eco_ref . '"><i class="fa fa-book fa-fw"></i> Documents</a></li>
                            <li><a href="https://app.thesmsfacademy.com.au/corp/getDocs.php?orderid=' . $lead->eco_ref . '" class="dropbox-saver"></a></li>
                            <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getCert.php?orderid=' . $lead->eco_ref . '"><i class="fa fa-certificate fa-fw"></i> Certificate</a></li>
                            <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/corp/getCasFile.php?orderid=' . $lead->eco_ref . '"><i class="fa fa-briefcase fa-fw"></i> CAS File</a></tr></li>
                          </ul></div></tr></form>';
                    break;
                case "Submitted to ASIC Temporarily reserved subject to ASIC decision":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td><i class="fa fa-refresh fa-spin"></i> Processing</tr></form>';
                    break;
                case "Submitted to ASIC":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td><i class="fa fa-refresh fa-spin"></i> Processing</tr></form>';
                    break;
                case "Checks":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td></tr></form>';
                    break;
                case "Rejected":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td><button class="btn-danger default btn-xs" style="width: 102px; text-align: left; border:none;" onclick="SetHiddenFormSettingsTPO(' . $lead->id . ', \'update\',\'' . get_action_link($lead->form_id, $lead->id, $wpdb) . '\')"><i class="fa fa-edit"></i> Amend</button></tr></form>';
                    break;
                case "Failed ASIC validation":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td><button class="btn-danger default btn-xs" style="width: 102px; text-align: left; border:none;" onclick="SetHiddenFormSettingsTPO(' . $lead->id . ', \'update\',\'' . get_action_link($lead->form_id, $lead->id, $wpdb) . '\')"><i class="fa fa-edit"></i> Amend</button></tr></form>';
                    break;
                case "Incomplete":
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td><button class="btn default btn-xs purple" style="width: 102px; text-align: left; border:none;" onclick="SetHiddenFormSettingsTPO(' . $lead->id . ', \'update\',\'' . get_action_link($lead->form_id, $lead->id, $wpdb) . '\')"><i class="fa fa-play"></i> Resume</button></tr></form>';
                    break;
                default:
                    $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->asic_status . '</td><td></tr></form>';
            }
        } elseif ($lead->form_id == "52" or $lead->form_id == "6") {
            $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->orderStatus . '</td><td>
                <div class="btn-group">
                  <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Actions</a>
                  <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                    <span class="fa fa-caret-down"></span></a>
                  <ul class="dropdown-menu" style="min-width: 107px;">
                    <li><a class="btn-xs" target="_blank" href="' . $lead->file_url . '"><i class="fa fa-book fa-fw"></i> Get Documents</a></li>
                    <li><a class="btn-xs" href="http://abn.thesmsfacademy.com.au/ABRWeb?uid=' . $lead->unique_id . '" target="_blank"><i class="fa fa-laptop fa-fw"></i> Apply for ABN</a></li>                   
                  </ul></div></tr></form>';
        } elseif ($lead->form_id == "15") {
            $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->orderStatus . '</td><td>
                <div class="btn-group">
                  <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Actions</a>
                  <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                    <span class="fa fa-caret-down"></span></a>
                  <ul class="dropdown-menu" style="min-width: 107px;">
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/?gf_pdf=1&fid=' . $lead->form_id . '&lid=' . $lead->id . '&download=1&template=abp_resolutions.php"><i class="fa fa-book fa-fw"></i> Get Resolutions</a></li>
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/?gf_pdf=1&fid=' . $lead->form_id . '&lid=' . $lead->id . '&download=1&template=abp-pds.php"><i class="fa fa-book fa-fw"></i> Get PDS</a></li>
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/save-time/?fid=' . $lead->form_id . '"><i class="fa fa-book fa-fw"></i> Reuse Data</a></li>
                    
                  </ul></div></tr></form>';
        } elseif ($lead->form_id == "43") {
            $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->orderStatus . '</td><td>
                <div class="btn-group">
                  <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Actions</a>
                  <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                    <span class="fa fa-caret-down"></span></a>
                  <ul class="dropdown-menu" style="min-width: 107px;">
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/?gf_pdf=1&fid=' . $lead->form_id . '&lid=' . $lead->id . '&download=1&template=inv-strategy.php"><i class="fa fa-book fa-fw"></i> Documents</a></li>

                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/save-time/?fid=' . $lead->form_id . '"><i class="fa fa-book fa-fw"></i> Reuse Data</a></li>
                    
                  </ul></div></tr></form>';
        } elseif ($lead->form_id == "56" || $lead->form_id == "53" || $lead->form_id == "65") {
            $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->orderStatus . '</td><td>
                <div class="btn-group">
                  <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Actions</a>
                  <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                            <span class="fa fa-caret-down"></span></a>
                          <ul class="dropdown-menu" style="min-width: 107px;">
                            <li><a class="btn-xs" href="' . get_sit_doc_link($lead->form_id, $lead->id, $wpdb) . '" target="_blank"><i class="fa fa-book fa-fw"></i> Documents</a></li>
                            
                          </ul></div></tr></form>';
        } elseif ($lead->form_id == "60") {
            //Do nothing so that we exclude the ABR.GOV.AU Form
        } else {
            if (!in_array($lead->form_id, $form_id_excluded)) {
                $output .= '<tr><td>' . $lead->form_id . $lead->id . '</td><td>' . get_reference($lead->form_id, $lead->id, $wpdb) . '</td><td>' . get_name($lead->form_id, $lead->id, $wpdb) . '</td><td>' . $lead->title . '</td><td>' . date("d/m/Y", strtotime($lead->date_created)) . '</td><td>' . $lead->orderStatus . '</td><td>
                <div class="btn-group">
                  <a class="btn-xs btn-primary " style="float: left; background-color: #4b8df8;" href="#"><i class="fa fa-download fa-fw"></i> Actions</a>
                  <a class="btn-xs btn-primary  dropdown-toggle" style="float: left; background-color: #4b8df8;" data-toggle="dropdown" href="#">
                    <span class="fa fa-caret-down"></span></a>
                  <ul class="dropdown-menu" style="min-width: 107px;">
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/?gf_pdf=1&fid=' . $lead->form_id . '&lid=' . $lead->id . '&download=1&template=' . $gfpdf->get_template($lead->form_id) . '"><i class="fa fa-book fa-fw"></i> Get Documents</a></li>
                    <li><a class="btn-xs" href="https://app.thesmsfacademy.com.au/save-time/?fid=' . $lead->form_id . '"><i class="fa fa-book fa-fw"></i> Reuse Data</a></li>
                  </ul></div></tr></form>';
            }
        }
    }
    $output = '<script src="/scripts/sorttable.js"></script><table class="table table-striped table-bordered table-advance table-hover sortable" style="width:80%!important;"><thead><tr><th>Order ID</th><th>Reference</th><th>Entity</th><th>Type</th><th>Date</th><th>Status</th><th>Actions</th></tr></thead>' . $output . '</table>';
    $output = $output . '<form name="gravitylist" action="' . get_action_link($lead->form_id, $lead->id, $wpdb) . '" method="post">
        <input type="hidden" id="gform_edit_id" name="gform_edit_id" value="" />
        <input type="hidden" id="gform_edit_mode" name="gform_edit_mode" value="" /></form>';
    return $output;
}
function print_tax_details_cash()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $net = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $rep = new FrontReport(_('Tax Details (Cash Basis)'), "TaxDetails", user_pagesize(), 9, "L");
    $dec = user_price_dec();
    $cols = array(0, 100, 170, 250, 310, 485, 550, 700);
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    if (!$net) {
        $grossAmount = _('Gross');
    } else {
        $grossAmount = _('Net');
    }
    $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Payer/Payee'), _('Tax Amount'), $grossAmount . ' ' . _('Output/Input'));
    if (!$net) {
        $grossAmount = _('Gross Amounts');
    } else {
        $grossAmount = _('Net Amounts');
    }
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Output/input'), 'from' => $grossAmount, 'to' => ''));
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $trans = get_tax_cash_details($from, $to);
    $rows = db_num_rows($trans);
    $rep->Font();
    if ($rows > 0) {
        // Keep a running total as we loop through
        // the transactions.
        $subTotalTax = 0;
        $subTotalGross = 0;
        $total = 0;
        $lastTaxType = '';
        $lastOutput = '';
        $lastRate = 0;
        while ($myrow = db_fetch($trans)) {
            $taxType = $myrow["name"];
            $output = $myrow["Output"];
            if ($taxType != $lastTaxType || $output != $lastOutput) {
                if ($lastTaxType != '') {
                    print_tax_details_cash_subtotals($rep, $lastOutput, $lastTaxType, $lastRate, $subTotalTax, $subTotalGross);
                }
                $lastOutput = $output;
                $lastTaxType = $taxType;
                $lastRate = $myrow['rate'];
                $subTotalTax = 0;
                $subTotalGross = 0;
            }
            $rep->TextCol(0, 1, $systypes_array[$myrow["type"]], -2);
            $reference = get_reference($myrow["type"], $myrow["trans_no"]);
            $rep->TextCol(1, 2, $reference);
            $rep->TextCol(2, 3, $myrow["trans_no"]);
            $rep->DateCol(3, 4, $myrow["trans_date"], true);
            $rep->TextCol(4, 5, payment_person_name($myrow["person_type_id"], $myrow["person_id"], false));
            if ($output == "Output") {
                $payable = $myrow['payable'];
                if (!$net) {
                    $amount = $myrow['gross_output'];
                } else {
                    $amount = $myrow['net_output'];
                }
                $rep->AmountCol(5, 6, $payable, $dec);
                $subTotalTax += $payable;
                $total += $payable;
                $rep->AmountCol(6, 7, $amount, $dec);
                $subTotalGross += $amount;
            } else {
                $collectible = $myrow['collectible'];
                if (!$net) {
                    $amount = $myrow['gross_input'];
                } else {
                    $amount = $myrow['net_input'];
                }
                $rep->AmountCol(5, 6, $collectible, $dec);
                $subTotalTax += $collectible;
                $total += $collectible;
                $rep->AmountCol(6, 7, $amount, $dec);
                $subTotalGross += $amount;
            }
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                $rep->Line($rep->row - 2);
                $rep->NewPage();
            }
        }
        // Print totals
        print_tax_details_cash_subtotals($rep, $lastOutput, $lastTaxType, $lastRate, $subTotalTax, $subTotalGross);
        $rep->Font('bold');
        $rep->TextCol(4, 5, _("Total Payable or Refund"));
        $rep->AmountCol(5, 6, $total, $dec);
        $rep->NewLine(2);
        $rep->Font();
        $rep->NewLine(2);
    }
    $rep->End();
}
예제 #4
0
function print_tax_report()
{
    global $path_to_root, $trans_dir, $Hooks, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $summaryOnly = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $rep = new FrontReport(_('Tax Report'), "TaxReport", user_pagesize(), 9, $orientation);
    if ($summaryOnly == 1) {
        $summary = _('Summary Only');
    } else {
        $summary = _('Detailed Report');
    }
    $res = getTaxTypes();
    $taxes = array();
    while ($tax = db_fetch($res)) {
        $taxes[$tax['id']] = array('in' => 0, 'out' => 0, 'taxin' => 0, 'taxout' => 0);
    }
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $summary, 'to' => ''));
    $cols = array(0, 80, 130, 180, 270, 350, 400, 430, 480, 485, 520);
    $headers = array(_('Trans Type'), _('Ref'), _('Date'), _('Name'), _('Branch Name'), _('Net'), _('Rate'), _('Tax'), '', _('Name'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'left');
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    if (!$summaryOnly) {
        $rep->NewPage();
    }
    $totalnet = 0.0;
    $totaltax = 0.0;
    $transactions = getTaxTransactions($from, $to);
    while ($trans = db_fetch($transactions)) {
        if (in_array($trans['trans_type'], array(ST_CUSTCREDIT, ST_SUPPINVOICE, ST_JOURNAL))) {
            $trans['net_amount'] *= -1;
            $trans['amount'] *= -1;
        }
        if (!$summaryOnly) {
            $rep->TextCol(0, 1, $systypes_array[$trans['trans_type']]);
            if ($trans['memo'] == '') {
                $trans['memo'] = get_reference($trans['trans_type'], $trans['trans_no']);
            }
            $rep->TextCol(1, 2, $trans['memo']);
            $rep->DateCol(2, 3, $trans['tran_date'], true);
            $rep->TextCol(3, 4, $trans['name']);
            $rep->TextCol(4, 5, $trans['br_name']);
            $rep->AmountCol(5, 6, $trans['net_amount'], $dec);
            $rep->AmountCol(6, 7, $trans['rate'], $dec);
            $rep->AmountCol(7, 8, $trans['amount'], $dec);
            $rep->TextCol(9, 10, $trans['taxname']);
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                $rep->Line($rep->row - 2);
                $rep->NewPage();
            }
        }
        if ($trans['trans_type'] == ST_JOURNAL && $trans['amount'] < 0) {
            $taxes[$trans['tax_type_id']]['taxin'] += $trans['amount'];
            $taxes[$trans['tax_type_id']]['in'] += $trans['net_amount'];
        } elseif ($trans['trans_type'] == ST_JOURNAL && $trans['amount'] >= 0) {
            $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount'];
            $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount'];
        } elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT, ST_SALESINVOICE, ST_CUSTCREDIT))) {
            $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount'];
            $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount'];
        } else {
            $taxes[$trans['tax_type_id']]['taxin'] += $trans['amount'];
            $taxes[$trans['tax_type_id']]['in'] += $trans['net_amount'];
        }
        $totalnet += $trans['net_amount'];
        $totaltax += $trans['amount'];
    }
    // Summary
    $cols2 = array(0, 100, 180, 260, 340, 420, 500);
    if ($orientation == 'L') {
        recalculate_cols($cols2);
    }
    $headers2 = array(_('Tax Rate'), _('Outputs'), _('Output Tax'), _('Inputs'), _('Input Tax'), _('Net Tax'));
    $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right');
    $rep->Info($params, $cols2, $headers2, $aligns2);
    //for ($i = 0; $i < count($cols2); $i++)
    //	$rep->cols[$i] = $rep->leftMargin + $cols2[$i];
    $rep->headers = $headers2;
    $rep->aligns = $aligns2;
    $rep->NewPage();
    $taxtotal = 0;
    foreach ($taxes as $id => $sum) {
        $tx = getTaxInfo($id);
        $rep->TextCol(0, 1, $tx['name'] . " " . number_format2($tx['rate'], $dec) . "%");
        $rep->AmountCol(1, 2, $sum['out'], $dec);
        $rep->AmountCol(2, 3, $sum['taxout'], $dec);
        $rep->AmountCol(3, 4, $sum['in'], $dec);
        $rep->AmountCol(4, 5, $sum['taxin'], $dec);
        $rep->AmountCol(5, 6, $sum['taxout'] + $sum['taxin'], $dec);
        $taxtotal += $sum['taxout'] + $sum['taxin'];
        $rep->NewLine();
    }
    $rep->Font('bold');
    $rep->NewLine();
    $rep->Line($rep->row + $rep->lineHeight);
    $rep->TextCol(3, 5, _("Total payable or refund"));
    $rep->AmountCol(5, 6, $taxtotal, $dec);
    $rep->Line($rep->row - 5);
    $rep->Font();
    $rep->NewLine();
    hook_tax_report_done();
    $rep->End();
}
예제 #5
0
function print_list_of_journal_entries()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $systype = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 100, 240, 300, 400, 460, 520, 580);
    $headers = array(_('Type/Account'), _('Reference') . '/' . _('Account Name'), _('Date/Dim.'), _('Person/Item/Memo'), _('Debit'), _('Credit'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $systype == -1 ? _('All') : $systypes_array[$systype], 'to' => ''));
    $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    if ($systype == -1) {
        $systype = null;
    }
    $trans = get_gl_transactions($from, $to, -1, null, 0, 0, $systype);
    $typeno = $type = 0;
    $debit = $credit = 0.0;
    $totdeb = $totcre = 0.0;
    while ($myrow = db_fetch($trans)) {
        if ($type != $myrow['type'] || $typeno != $myrow['type_no']) {
            if ($typeno != 0) {
                $rep->Line($rep->row += 6);
                $rep->NewLine();
                $rep->AmountCol(4, 5, $debit, $dec);
                $rep->AmountCol(5, 6, abs($credit), $dec);
                $totdeb += $debit;
                $totcre += $credit;
                $debit = $credit = 0.0;
                $rep->Line($rep->row -= 4);
                $rep->NewLine();
            }
            $typeno = $myrow['type_no'];
            $type = $myrow['type'];
            $TransName = $systypes_array[$myrow['type']];
            $rep->TextCol(0, 1, $TransName . " # " . $myrow['type_no']);
            $rep->TextCol(1, 2, get_reference($myrow['type'], $myrow['type_no']));
            $rep->DateCol(2, 3, $myrow['tran_date'], true);
            $coms = payment_person_name($myrow["person_type_id"], $myrow["person_id"]);
            $memo = get_comments_string($myrow['type'], $myrow['type_no']);
            if ($memo != '') {
                if ($coms == "") {
                    $coms = $memo;
                } else {
                    $coms .= " / " . $memo;
                }
            }
            $rep->TextColLines(3, 6, $coms);
            $rep->NewLine();
        }
        $rep->TextCol(0, 1, $myrow['account']);
        $rep->TextCol(1, 2, $myrow['account_name']);
        $dim_str = get_dimension_string($myrow['dimension_id']);
        $dim_str2 = get_dimension_string($myrow['dimension2_id']);
        if ($dim_str2 != "") {
            $dim_str .= "/" . $dim_str2;
        }
        $rep->TextCol(2, 3, $dim_str);
        $rep->TextCol(3, 4, $myrow['memo_']);
        if ($myrow['amount'] > 0.0) {
            $debit += $myrow['amount'];
            $rep->AmountCol(4, 5, abs($myrow['amount']), $dec);
        } else {
            $credit += $myrow['amount'];
            $rep->AmountCol(5, 6, abs($myrow['amount']), $dec);
        }
        $rep->NewLine(1, 2);
    }
    if ($typeno != 0) {
        $rep->Line($rep->row += 6);
        $rep->NewLine();
        $rep->AmountCol(4, 5, $debit, $dec);
        $rep->AmountCol(5, 6, abs($credit), $dec);
        $totdeb += $debit;
        $totcre += $credit;
        $rep->Line($rep->row -= 4);
        $rep->NewLine();
        $rep->TextCol(0, 4, _("Total"));
        $rep->AmountCol(4, 5, $totdeb, $dec);
        $rep->AmountCol(5, 6, abs($totcre), $dec);
        $rep->Line($rep->row -= 4);
    }
    $rep->End();
}