Example #1
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     $today = date2sql(Today());
     $sql = "SELECT bank_act, bank_account_name, SUM(amount) balance FROM " . TB_PREF . "bank_trans bt" . " INNER JOIN " . TB_PREF . "bank_accounts ba ON bt.bank_act = ba.id" . " WHERE trans_date < '{$today}'" . " AND inactive <> 1";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " GROUP BY bank_act, bank_account_name" . " ORDER BY bank_account_name";
     $result = db_query($sql);
     br();
     $th = array(_("Account"), _("Balance"));
     start_table(TABLESTYLE, "width=98%");
     table_header($th);
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         label_cell($myrow["bank_account_name"]);
         amount_cell($myrow['balance']);
         end_row();
     }
     end_table(1);
 }
Example #2
0
function display_customer_summary($customer_record)
{
    global $table_style;
    $past1 = get_company_pref('past_due_days');
    $past2 = 2 * $past1;
    if ($customer_record["dissallow_invoices"] != 0) {
        echo "<center><font color=red size=4><b>" . tr("CUSTOMER ACCOUNT IS ON HOLD") . "</font></b></center>";
    }
    $nowdue = "1-" . $past1 . " " . tr('Days');
    $pastdue1 = $past1 + 1 . "-" . $past2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $past2 . " " . tr('Days');
    start_table("width=80% {$table_style}");
    $th = array(tr("Currency"), tr("Terms"), tr("Current"), $nowdue, $pastdue1, $pastdue2, tr("Total Balance"));
    table_header($th);
    start_row();
    label_cell($customer_record["curr_code"]);
    label_cell($customer_record["terms"]);
    amount_cell($customer_record["Balance"] - $customer_record["Due"]);
    amount_cell($customer_record["Due"] - $customer_record["Overdue1"]);
    amount_cell($customer_record["Overdue1"] - $customer_record["Overdue2"]);
    amount_cell($customer_record["Overdue2"]);
    amount_cell($customer_record["Balance"]);
    end_row();
    end_table();
}
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     include_once $path_to_root . "/reporting/includes/class.graphic.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     if (!isset($this->top)) {
         $this->top = 10;
     }
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM((trans.ov_amount + trans.ov_discount) * rate) AS total, s.supplier_id, s.supp_name FROM\n            " . TB_PREF . "supp_trans AS trans, " . TB_PREF . "suppliers AS s WHERE trans.supplier_id=s.supplier_id\n            AND (trans.type = " . ST_SUPPINVOICE . " OR trans.type = " . ST_SUPPCREDIT . ")\n            AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}' ";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= "GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id " . " LIMIT " . $this->top;
     $result = db_query($sql);
     if ($this->graph_type == 'Table') {
         $th = array(_("Supplier"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             $name = $myrow["supplier_id"] . " " . $myrow["supp_name"];
             label_cell($name);
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(1);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $name = $myrow["supplier_id"] . " " . $myrow["supp_name"];
             $pg->x[$i] = $name;
             $pg->y[$i] = $myrow['total'];
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Supplier");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 2;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
Example #4
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/reporting/includes/class.graphic.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     if (!isset($this->top)) {
         $this->top = 10;
     }
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM((ov_amount + ov_discount) * rate * IF(trans.type = " . ST_CUSTCREDIT . ", -1, 1)) AS total,d.debtor_no, d.name" . " FROM " . TB_PREF . "debtor_trans AS trans, " . TB_PREF . "debtors_master AS d" . " WHERE trans.debtor_no=d.debtor_no" . " AND (trans.type = " . ST_SALESINVOICE . " OR trans.type = " . ST_CUSTCREDIT . ")" . " AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}'";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no " . " LIMIT " . $this->top;
     $result = db_query($sql);
     if ($this->graph_type == 'Table') {
         $th = array(null, _("Customer"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         $i = 0;
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             label_cell(viewer_link($myrow["debtor_no"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"]));
             label_cell(viewer_link($myrow["name"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"]));
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(1);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $pg->x[$i] = $myrow["debtor_no"] . " " . $myrow["name"];
             $pg->y[$i] = $myrow['total'];
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Customer");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 2;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
Example #5
0
 function render($id, $title)
 {
     global $path_to_root;
     if (!isset($this->top)) {
         $this->top = 10;
     }
     global $path_to_root;
     $pg = new graph();
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM\n            " . TB_PREF . "gl_trans AS t," . TB_PREF . "dimensions AS d WHERE\n            (t.dimension_id = d.id OR t.dimension2_id = d.id) AND\n            t.tran_date >= '{$begin1}' AND t.tran_date <= '{$today1}' ";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= "GROUP BY d.id ORDER BY total DESC LIMIT " . $this->top;
     $result = db_query($sql, "Transactions could not be calculated");
     if ($this->graph_type == 'Table') {
         $title = _("Top 10 Dimensions in fiscal year");
         br(2);
         display_heading($title);
         br();
         $th = array(_("Dimension"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             label_cell($myrow['reference'] . " " . $myrow["name"]);
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(2);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $pg->x[$i] = $myrow['reference'] . " " . $myrow["name"];
             $pg->y[$i] = abs($myrow['total']);
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Dimension");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 5;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
Example #6
0
function display_po_receive_items()
{
    div_start('grn_items');
    start_table(TABLESTYLE, "colspan=7 width='90%'");
    $th = array(_("Item Code"), _("Description"), _("Ordered"), _("Units"), _("Received"), _("Outstanding"), _("This Delivery"), _("Price"), _("Total"));
    table_header($th);
    /*show the line items on the order with the quantity being received for modification */
    $total = 0;
    $k = 0;
    //row colour counter
    if (count($_SESSION['PO']->line_items) > 0) {
        foreach ($_SESSION['PO']->line_items as $ln_itm) {
            alt_table_row_color($k);
            $qty_outstanding = $ln_itm->quantity - $ln_itm->qty_received;
            if (!isset($_POST['Update']) && !isset($_POST['ProcessGoodsReceived']) && $ln_itm->receive_qty == 0) {
                //If no quantites yet input default the balance to be received
                $ln_itm->receive_qty = $qty_outstanding;
            }
            $line_total = $ln_itm->receive_qty * $ln_itm->price;
            $total += $line_total;
            label_cell($ln_itm->stock_id);
            if ($qty_outstanding > 0) {
                text_cells(null, $ln_itm->stock_id . "Desc", $ln_itm->item_description, 30, 50);
            } else {
                label_cell($ln_itm->item_description);
            }
            $dec = get_qty_dec($ln_itm->stock_id);
            qty_cell($ln_itm->quantity, false, $dec);
            label_cell($ln_itm->units);
            qty_cell($ln_itm->qty_received, false, $dec);
            qty_cell($qty_outstanding, false, $dec);
            if ($qty_outstanding > 0) {
                qty_cells(null, $ln_itm->line_no, number_format2($ln_itm->receive_qty, $dec), "align=right", null, $dec);
            } else {
                label_cell(number_format2($ln_itm->receive_qty, $dec), "align=right");
            }
            amount_decimal_cell($ln_itm->price);
            amount_cell($line_total);
            end_row();
        }
    }
    $colspan = count($th) - 1;
    $display_sub_total = price_format($total);
    label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right");
    $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost'), true);
    $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['PO']->tax_included);
    $display_total = price_format($total + input_num('freight_cost') + $tax_total);
    start_row();
    label_cells(_("Amount Total"), $display_total, "colspan={$colspan} align='right'", "align='right'");
    end_row();
    end_table();
    div_end();
}
Example #7
0
function display_po_receive_items()
{
    global $table_style;
    start_table("colspan=7 {$table_style} width=90%");
    $th = array(tr("Item Code"), tr("Description"), tr("Ordered"), tr("Units"), tr("Received"), tr("Outstanding"), tr("This Delivery"), tr("Price"), tr("Total"));
    table_header($th);
    /*show the line items on the order with the quantity being received for modification */
    $total = 0;
    $k = 0;
    //row colour counter
    if (count($_SESSION['PO']->line_items) > 0) {
        foreach ($_SESSION['PO']->line_items as $ln_itm) {
            alt_table_row_color($k);
            $qty_outstanding = $ln_itm->quantity - $ln_itm->qty_received;
            if ($ln_itm->receive_qty == 0) {
                //If no quantites yet input default the balance to be received
                $ln_itm->receive_qty = $qty_outstanding;
            }
            $line_total = $ln_itm->receive_qty * $ln_itm->price;
            $total += $line_total;
            label_cell($ln_itm->stock_id);
            if ($qty_outstanding > 0) {
                text_cells(null, $ln_itm->stock_id . "Desc", $ln_itm->item_description, 30, 50);
            } else {
                label_cell($ln_itm->item_description);
            }
            qty_cell($ln_itm->quantity);
            label_cell($ln_itm->units);
            qty_cell($ln_itm->qty_received);
            qty_cell($qty_outstanding);
            if ($qty_outstanding > 0) {
                qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right");
            } else {
                qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right", "disabled");
            }
            amount_cell($ln_itm->price);
            amount_cell($line_total);
            end_row();
        }
    }
    $display_total = number_format2($total, user_price_dec());
    label_row(tr("Total value of items received"), $display_total, "colspan=8 align=right", "nowrap align=right");
    end_table();
}
Example #8
0
function display_supplier_summary($supplier_record)
{
    $past1 = get_company_pref('past_due_days');
    $past2 = 2 * $past1;
    $nowdue = "1-" . $past1 . " " . _('Days');
    $pastdue1 = $past1 + 1 . "-" . $past2 . " " . _('Days');
    $pastdue2 = _('Over') . " " . $past2 . " " . _('Days');
    start_table(TABLESTYLE, "width='80%'");
    $th = array(_("Currency"), _("Terms"), _("Current"), $nowdue, $pastdue1, $pastdue2, _("Total Balance"));
    table_header($th);
    start_row();
    label_cell($supplier_record["curr_code"]);
    label_cell($supplier_record["terms"]);
    amount_cell($supplier_record["Balance"] - $supplier_record["Due"]);
    amount_cell($supplier_record["Due"] - $supplier_record["Overdue1"]);
    amount_cell($supplier_record["Overdue1"] - $supplier_record["Overdue2"]);
    amount_cell($supplier_record["Overdue2"]);
    amount_cell($supplier_record["Balance"]);
    end_row();
    end_table(1);
}
Example #9
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     $today = date2sql(Today());
     $sql = "SELECT trans.trans_no, trans.reference, trans.tran_date, trans.due_date, debtor.debtor_no,\n            debtor.name, branch.br_name, debtor.curr_code,\n            (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount) AS total,\n            (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) AS remainder,\n            DATEDIFF('{$today}', trans.due_date) AS days\n            FROM " . TB_PREF . "debtor_trans as trans, " . TB_PREF . "debtors_master as debtor,\n                " . TB_PREF . "cust_branch as branch\n            WHERE debtor.debtor_no = trans.debtor_no AND trans.branch_code = branch.branch_code\n                AND trans.type = " . ST_SALESINVOICE . " AND (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) > " . FLOAT_COMP_DELTA . "\n                AND DATEDIFF('{$today}', trans.due_date) > 0 ORDER BY days DESC";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $result = db_query($sql);
     $title = db_num_rows($result) . _(" Overdue Sales Invoices");
     br(1);
     display_heading($title);
     br();
     $th = array("#", _("Date"), _("Due Date"), _("Customer"), _("Currency"), _("Total"), _("Remainder"), _("Days"));
     start_table(TABLESTYLE, "width=98%");
     table_header($th);
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         label_cell(get_trans_view_str(ST_SALESINVOICE, $myrow["trans_no"]));
         label_cell(sql2date($myrow['tran_date']));
         label_cell(sql2date($myrow['due_date']));
         $name = $myrow["debtor_no"] . " " . $myrow["name"];
         label_cell($name);
         label_cell($myrow['curr_code']);
         amount_cell($myrow['total']);
         amount_cell($myrow['remainder']);
         label_cell($myrow['days'], "align='right'");
         end_row();
     }
     end_table(1);
 }
end_table(1);
//-----------------------------------------------------------------------------------
echo "<hr/>\n";
$result = get_all_requisition_details(get_post('requisitionid'));
start_form();
start_table(TABLESTYLE, "width=50%");
$th = array(_("Item Code"), _("Item Name"), _("Purpose"), _("Qrder Quantity"), _("Estimate Price"), "", "");
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["item_code"]);
    label_cell($myrow["description"]);
    label_cell($myrow["purpose"]);
    label_cell($myrow["order_quantity"]);
    amount_cell($myrow["estimate_price"]);
    edit_button_cell("Edit" . $myrow['requisition_detail_id'], _("Edit"));
    delete_button_cell("Delete" . $myrow['requisition_detail_id'], _("Delete"));
    end_row();
}
end_table(1);
//-----------------------------------------------------------------------------------
start_table(TABLESTYLE2);
if ($selected_id != -1) {
    if ($Mode == 'Edit') {
        //editing an existing status code
        $myrow = get_requisition_detail($selected_id);
        $_POST['item_code'] = $myrow["item_code"];
        $_POST['purpose'] = $myrow["purpose"];
        $_POST['order_quantity'] = $myrow["order_quantity"];
        $_POST['estimate_price'] = $myrow["estimate_price"];
Example #11
0
function edit_allocations_for_transaction($type, $trans_no)
{
    global $table_style;
    start_form(false, true);
    display_heading(sprintf(tr("Allocation of %s # %d"), systypes::name($_SESSION['alloc']->type), $_SESSION['alloc']->trans_no));
    display_heading($_SESSION['alloc']->person_name);
    display_heading2(tr("Date:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
    display_heading2(tr("Total:") . " <b>" . price_format($_SESSION['alloc']->amount) . "</b>");
    echo "<br>";
    if (count($_SESSION['alloc']->allocs) > 0) {
        start_table($table_style);
        $th = array(tr("Transaction Type"), tr("#"), tr("Date"), tr("Due Date"), tr("Amount"), tr("Other Allocations"), tr("This Allocation"), tr("Left to Allocate"), "", "");
        table_header($th);
        $k = $counter = $total_allocated = 0;
        foreach ($_SESSION['alloc']->allocs as $allocn_item) {
            alt_table_row_color($k);
            label_cell(systypes::name($allocn_item->type));
            label_cell(get_trans_view_str($allocn_item->type, $allocn_item->type_no));
            label_cell($allocn_item->date_, "align=right");
            label_cell($allocn_item->due_date, "align=right");
            amount_cell($allocn_item->amount);
            amount_cell($allocn_item->amount_allocated);
            if (!check_num('amount' . $counter)) {
                $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
            }
            amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]);
            $un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6);
            hidden("un_allocated" . $counter, $un_allocated);
            amount_cell($un_allocated);
            label_cell("<a href='#' name=Alloc{$counter} onclick='allocate_all(this.name.substr(5));return true;'>" . tr("All") . "</a>");
            label_cell("<a href='#' name=DeAll{$counter} onclick='allocate_none(this.name.substr(5));return true;'>" . tr("None") . "</a>");
            end_row();
            $total_allocated += input_num('amount' . $counter);
            $counter++;
        }
        label_row(tr("Total Allocated"), price_format($total_allocated), "colspan=6 align=right", "nowrap align=right id='total_allocated'");
        if ($_SESSION['alloc']->amount - $total_allocated < 0) {
            $font1 = "<font color=red>";
            $font2 = "</font>";
        } else {
            $font1 = $font2 = "";
        }
        $left_to_allocate = $_SESSION['alloc']->amount - $total_allocated;
        $left_to_allocate = price_format($left_to_allocate);
        label_row(tr("Left to Allocate"), $font1 . $left_to_allocate . $font2, "colspan=6 align=right ", "nowrap align=right id='left_to_allocate'");
        end_table(1);
        hidden('TotalNumberOfAllocs', $counter);
        //		hidden('left_to_allocate', $left_to_allocate);
        submit_center_first('UpdateDisplay', tr("Update"));
        submit('Process', tr("Process"));
    } else {
        display_note(tr("There are no unsettled transactions to allocate."), 0, 1);
    }
    submit_center_last('Cancel', tr("Back to Allocations"));
    end_form();
}
Example #12
0
        alt_table_row_color($k);
        label_cell(get_trans_view_str(ST_SUPPRECEIVE, $myrow["id"]));
        label_cell($myrow["reference"]);
        label_cell(sql2date($myrow["delivery_date"]));
        end_row();
    }
    end_table();
}
$invoice_result = get_po_invoices_credits($_GET['trans_no']);
$k = 0;
if (db_num_rows($invoice_result) > 0) {
    echo "</td><td valign=top>";
    // outer table
    display_heading2(_("Invoices/Credits"));
    start_table(TABLESTYLE);
    $th = array(_("#"), _("Date"), _("Total"));
    table_header($th);
    while ($myrow = db_fetch($invoice_result)) {
        alt_table_row_color($k);
        label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
        label_cell(sql2date($myrow["tran_date"]));
        amount_cell($myrow["Total"]);
        end_row();
    }
    end_table();
}
echo "</td></tr>";
end_table(1);
// outer table
//----------------------------------------------------------------------------------------------------
end_page(true, false, false, ST_PURCHORDER, $_GET['trans_no']);
    }
}
echo "<hr>";
div_start('summary');
start_table(TABLESTYLE);
$th = array(_("Reconcile Date"), _("Beginning<br>Balance"), _("Ending<br>Balance"), _("Account<br>Total"), _("Reconciled<br>Amount"), _("Difference"));
table_header($th);
start_row();
date_cells("", "reconcile_date", _('Date of bank statement to reconcile'), get_post('bank_date') == '', 0, 0, 0, null, true);
amount_cells_ex("", "beg_balance", 15);
amount_cells_ex("", "end_balance", 15);
$reconciled = input_num('reconciled');
$difference = input_num("end_balance") - input_num("beg_balance") - $reconciled;
amount_cell($total);
amount_cell($reconciled, false, '', "reconciled");
amount_cell($difference, false, '', "difference");
end_row();
end_table();
div_end();
echo "<hr>";
//------------------------------------------------------------------------------------------------
if (!isset($_POST['bank_account'])) {
    $_POST['bank_account'] = "";
}
$sql = get_sql_for_bank_account_reconcile($_POST['bank_account'], get_post('reconcile_date'));
$act = get_bank_account($_POST["bank_account"]);
display_heading($act['bank_account_name'] . " - " . $act['bank_curr_code']);
$cols = array(_("Type") => array('fun' => 'systype_name', 'ord' => ''), _("#") => array('fun' => 'trans_view', 'ord' => ''), _("Reference"), _("Date") => 'date', _("Debit") => array('align' => 'right', 'fun' => 'fmt_debit'), _("Credit") => array('align' => 'right', 'insert' => true, 'fun' => 'fmt_credit'), _("Person/Item") => array('fun' => 'fmt_person'), array('insert' => true, 'fun' => 'gl_view'), "X" => array('insert' => true, 'fun' => 'rec_checkbox'));
$table =& new_db_pager('trans_tbl', $sql, $cols);
$table->width = "80%";
display_db_pager($table);
Example #14
0
    // check if it's an overdue work order
    if (date_diff(Today(), sql2date($myrow["due_date"]), "d") > 0) {
        $row_text = "class='overduebg'";
    }
    start_row($row_text);
    $mpage = $path_to_root . "/dimensions/dimension_entry.php?" . SID . "trans_no=" . $myrow["id"];
    label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"]));
    label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"], $myrow["reference"]));
    label_cell($myrow["name"]);
    label_cell($myrow["type_"]);
    label_cell(sql2date($myrow["date_"]));
    label_cell(sql2date($myrow["due_date"]));
    if (!$outstanding_only) {
        label_cell($myrow["closed"] ? tr("Yes") : tr("No"));
    }
    amount_cell($row[0]);
    if ($myrow["closed"] == 0) {
        label_cell("<a href='{$mpage}'>" . tr("Edit") . "</a>");
    }
    end_row();
    $j++;
    if ($j == 12) {
        $j = 1;
        table_header($th);
    }
    //end of page full new headings if
}
//end of while loop
end_table(1);
//---------------------------------------------------------------------------------
end_page();
 function render($id, $title)
 {
     global $path_to_root, $systypes_array;
     include_once $path_to_root . "/includes/ui.inc";
     $start_date = add_days(Today(), -$this->days_past);
     $end_date = add_days(Today(), $this->days_future);
     $result = get_bank_trans_for_bank_account($this->bank_act, $start_date, $end_date);
     start_table(TABLESTYLE, 'width=98%');
     $th = array(_("#"), _("Date"), _("Receipt"), _("Payment"), _("Balance"), _("Person/Item"), _("Memo"), "");
     table_header($th);
     $bfw = get_balance_before_for_bank_account($this->bank_act, $start_date);
     $credit = $debit = 0;
     start_row("class='inquirybg' style='font-weight:bold'");
     label_cell(_("Opening Balance") . " - " . $start_date, "colspan=4");
     display_debit_or_credit_cells($bfw);
     label_cell("");
     label_cell("", "colspan=2");
     end_row();
     $running_total = $bfw;
     if ($bfw > 0) {
         $debit += $bfw;
     } else {
         $credit += $bfw;
     }
     $j = 1;
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         $running_total += $myrow["amount"];
         label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
         $trandate = sql2date($myrow["trans_date"]);
         label_cell($trandate);
         display_debit_or_credit_cells($myrow["amount"]);
         amount_cell($running_total);
         label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"]));
         label_cell(get_comments_string($myrow["type"], $myrow["trans_no"]));
         label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
         end_row();
         if ($myrow["amount"] > 0) {
             $debit += $myrow["amount"];
         } else {
             $credit += $myrow["amount"];
         }
         if ($j == 12) {
             $j = 1;
             table_header($th);
         }
         $j++;
     }
     //end of while loop
     start_row("class='inquirybg' style='font-weight:bold'");
     label_cell(_("Ending Balance") . " - " . $end_date, "colspan=4");
     amount_cell($debit + $credit);
     label_cell("");
     label_cell("", "colspan=2");
     end_row();
     end_table(2);
 }
Example #16
0
}
//------------------------------------------------------------------------------------------------
$sql = "SELECT * FROM salesman";
$result = db_query($sql, "could not get sales persons");
start_table("{$table_style} width=60%");
$th = array(tr("Name"), tr("Phone"), tr("Fax"), tr("Email"), tr("Provision"), tr("Break Pt."), tr("Provision") . " 2", "", "");
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["salesman_name"]);
    label_cell($myrow["salesman_phone"]);
    label_cell($myrow["salesman_fax"]);
    label_cell($myrow["salesman_email"]);
    label_cell(percent_format($myrow["provision"]) . " %", "nowrap align=right");
    amount_cell($myrow["break_pt"]);
    label_cell(percent_format($myrow["provision2"]) . " %", "nowrap align=right");
    edit_link_cell(SID . "selected_id=" . $myrow["salesman_code"]);
    delete_link_cell(SID . "selected_id=" . $myrow["salesman_code"] . "&delete=1");
    end_row();
}
//END WHILE LIST LOOP
end_table();
//------------------------------------------------------------------------------------------------
hyperlink_no_params($_SERVER['PHP_SELF'], tr("New Sales Person"));
//------------------------------------------------------------------------------------------------
start_form();
if (isset($selected_id)) {
    //editing an existing Sales-person
    $sql = "SELECT *  FROM salesman WHERE salesman_code='{$selected_id}'";
    $result = db_query($sql, "could not get sales person");
Example #17
0
function display_profit_and_loss()
{
    global $path_to_root, $sel;
    if (!isset($_POST['Dimension'])) {
        $_POST['Dimension'] = 0;
    }
    if (!isset($_POST['Dimension2'])) {
        $_POST['Dimension2'] = 0;
    }
    $dimension = $_POST['Dimension'];
    $dimension2 = $_POST['Dimension2'];
    $from = $_POST['TransFromDate'];
    $to = $_POST['TransToDate'];
    $compare = $_POST['Compare'];
    if (isset($_POST["AccGrp"]) && strlen($_POST['AccGrp']) > 0) {
        $drilldown = 1;
    } else {
        $drilldown = 0;
    }
    // Root level
    $dec = 0;
    $pdec = user_percent_dec();
    if ($compare == 0 || $compare == 2) {
        $end = $to;
        if ($compare == 2) {
            $begin = $from;
        } else {
            $begin = begin_fiscalyear();
        }
    } elseif ($compare == 1) {
        $begin = add_months($from, -12);
        $end = add_months($to, -12);
    }
    div_start('pl_tbl');
    start_table(TABLESTYLE, "width=50%");
    $tableheader = "<tr>\n        <td class='tableheader'>" . _("Group/Account Name") . "</td>\n        <td class='tableheader'>" . _("Period") . "</td>\n\t\t<td class='tableheader'>" . $sel[$compare] . "</td>\n\t\t<td class='tableheader'>" . _("Achieved %") . "</td>\n        </tr>";
    if (!$drilldown) {
        $parent = -1;
        $classper = 0.0;
        $classacc = 0.0;
        $salesper = 0.0;
        $salesacc = 0.0;
        //Get classes for PL
        $classresult = get_account_classes(false, 0);
        while ($class = db_fetch($classresult)) {
            $class_per_total = 0;
            $class_acc_total = 0;
            $convert = get_class_type_convert($class["ctype"]);
            //Print Class Name
            table_section_title($class["class_name"], 4);
            echo $tableheader;
            //Get Account groups/types under this group/type
            $typeresult = get_account_types(false, $class['cid'], -1);
            while ($accounttype = db_fetch($typeresult)) {
                $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root);
                $class_per_total += $TypeTotal[0];
                $class_acc_total += $TypeTotal[1];
                if ($TypeTotal[0] != 0 || $TypeTotal[1] != 0) {
                    $url = "<a href='{$path_to_root}/gl/inquiry/profit_loss.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Compare=" . $compare . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&AccGrp=" . $accounttype['id'] . "'>" . $accounttype['id'] . " " . $accounttype['name'] . "</a>";
                    alt_table_row_color($k);
                    label_cell($url);
                    amount_cell($TypeTotal[0] * $convert);
                    amount_cell($TypeTotal[1] * $convert);
                    amount_cell(Achieve($TypeTotal[0], $TypeTotal[1]));
                    end_row();
                }
            }
            //Print Class Summary
            start_row("class='inquirybg' style='font-weight:bold'");
            label_cell(_('Total') . " " . $class["class_name"]);
            amount_cell($class_per_total * $convert);
            amount_cell($class_acc_total * $convert);
            amount_cell(Achieve($class_per_total, $class_acc_total));
            end_row();
            $salesper += $class_per_total;
            $salesacc += $class_acc_total;
        }
        start_row("class='inquirybg' style='font-weight:bold'");
        label_cell(_('Calculated Return'));
        amount_cell($salesper * -1);
        amount_cell($salesacc * -1);
        amount_cell(achieve($salesper, $salesacc));
        end_row();
    } else {
        //Level Pointer : Global variable defined in order to control display of root
        global $levelptr;
        $levelptr = 0;
        $accounttype = get_account_type($_POST["AccGrp"]);
        $classid = $accounttype["class_id"];
        $class = get_account_class($classid);
        $convert = get_class_type_convert($class["ctype"]);
        //Print Class Name
        table_section_title($_POST["AccGrp"] . " " . get_account_type_name($_POST["AccGrp"]), 4);
        echo $tableheader;
        $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root);
    }
    end_table(1);
    // outer table
    div_end();
}
Example #18
0
    }
    if ($dim > 1) {
        label_cell(get_dimension_string($myrow['dimension2_id'], true));
    }
    display_debit_or_credit_cells($myrow['amount']);
    label_cell($myrow['memo_']);
    end_row();
    if ($myrow['amount'] > 0) {
        $debit += $myrow['amount'];
    } else {
        $credit += $myrow['amount'];
    }
}
if ($heading_shown) {
    start_row("class='inquirybg' style='font-weight:bold'");
    label_cell(_("Total"), "colspan=2");
    if ($dim >= 1) {
        label_cell('');
    }
    if ($dim > 1) {
        label_cell('');
    }
    amount_cell($debit);
    amount_cell(-$credit);
    label_cell('');
    end_row();
    end_table(1);
}
//end of while loop
is_voided_display($_GET['type_id'], $_GET['trans_no'], _("This transaction has been voided."));
end_page(true, false, false, $_GET['type_id'], $_GET['trans_no']);
function display_credit_items()
{
    start_form();
    hidden('cart_id');
    start_table(TABLESTYLE2, "width=80%", 5);
    echo "<tr><td>";
    // outer table
    start_table(TABLESTYLE, "width=100%");
    start_row();
    label_cells(_("Customer"), $_SESSION['Items']->customer_name, "class='tableheader2'");
    label_cells(_("Branch"), get_branch_name($_SESSION['Items']->Branch), "class='tableheader2'");
    label_cells(_("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'");
    end_row();
    start_row();
    //	if (!isset($_POST['ref']))
    //		$_POST['ref'] = $Refs->get_next(11);
    if ($_SESSION['Items']->trans_no == 0) {
        ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'");
    } else {
        label_cells(_("Reference"), $_SESSION['Items']->reference, "class='tableheader2'");
    }
    label_cells(_("Crediting Invoice"), get_customer_trans_view_str(ST_SALESINVOICE, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'");
    if (!isset($_POST['ShipperID'])) {
        $_POST['ShipperID'] = $_SESSION['Items']->ship_via;
    }
    label_cell(_("Shipping Company"), "class='tableheader2'");
    shippers_list_cells(null, 'ShipperID', $_POST['ShipperID']);
    //	if (!isset($_POST['sales_type_id']))
    //	  $_POST['sales_type_id'] = $_SESSION['Items']->sales_type;
    //	label_cell(_("Sales Type"), "class='tableheader2'");
    //	sales_types_list_cells(null, 'sales_type_id', $_POST['sales_type_id']);
    end_row();
    end_table();
    echo "</td><td>";
    // outer table
    start_table(TABLESTYLE, "width=100%");
    if ($_SESSION['Items']->custom_num != '') {
        text_row(_("Credit Memo No."), 'custom_num', $_SESSION['Items']->custom_num, null, "class='tableheader2'");
    } else {
        text_row(_("Credit Memo No."), 'custom_num', '', null, "class='tableheader2'");
    }
    //moodlearning
    label_row(_("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'");
    date_row(_("Credit Note Date"), 'CreditDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'");
    end_table();
    echo "</td></tr>";
    end_table(1);
    // outer table
    div_start('credit_items');
    start_table(TABLESTYLE, "width=80%");
    $th = array(_("Item Code"), _("Item Description"), _("Invoiced Quantity"), _("Units"), _("Credited"), _("Credit Quantity"), _("Price"), _("Discount %"), _("Total"));
    //Karen edited Credited
    table_header($th);
    $k = 0;
    //row colour counter
    foreach ($_SESSION['Items']->line_items as $line_no => $ln_itm) {
        if ($ln_itm->quantity == $ln_itm->qty_done) {
            continue;
            // this line was fully credited/removed
        }
        alt_table_row_color($k);
        //	view_stock_status_cell($ln_itm->stock_id); alternative view
        label_cell($ln_itm->stock_id);
        text_cells(null, 'Line' . $line_no . 'Desc', $ln_itm->item_description, 30, 50);
        $dec = get_qty_dec($ln_itm->stock_id);
        qty_cell($ln_itm->quantity, false, $dec);
        label_cell($ln_itm->units);
        label_cell($ln_itm->qty_done);
        //Karen edited
        amount_cells(null, 'Line' . $line_no, number_format2($ln_itm->qty_dispatched, $dec), null, null, $dec);
        $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent);
        amount_cell($ln_itm->price);
        percent_cell($ln_itm->discount_percent * 100);
        amount_cell($line_total);
        end_row();
    }
    if (!check_num('ChargeFreightCost')) {
        $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost);
    }
    $colspan = 8;
    //Karen edited 7
    start_row();
    label_cell(_("Credit Shipping Cost"), "colspan={$colspan} align=right");
    small_amount_cells(null, "ChargeFreightCost", price_format(get_post('ChargeFreightCost', 0)));
    end_row();
    /*moodlearning*/
    start_row();
    label_cell(_("Bulk Discount"), "colspan={$colspan} align=right");
    small_amount_cells(null, "bulk_dis", $_SESSION['Items']->bulk_discount);
    end_row();
    /*           */
    $inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
    $discount = input_num('bulk_dis') / 100;
    $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost']));
    label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right");
    $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost']));
    $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['Items']->tax_included);
    /*moodlearning*/
    $total = $inv_items_total + input_num('ChargeFreightCost') + $tax_total;
    $tot = price_format($total - $total * $discount);
    /*             */
    $display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total);
    label_row(_("Credit Note Total"), $tot, "colspan={$colspan} align=right", "align=right");
    //moodlearning edit $tot
    end_table();
    div_end();
}
 function pager(&$pager)
 {
     global $use_popup_windows, $use_date_picker, $path_to_root;
     $pager->select_records();
     div_start("_{$pager->name}_span");
     $headers = array();
     foreach ($pager->columns as $num_col => $col) {
         // record status control column is displayed only when control checkbox is on
         if (isset($col['head']) && ($col['type'] != 'inactive' || get_post('show_inactive'))) {
             if (!isset($col['ord'])) {
                 $headers[] = $col['head'];
             } else {
                 $icon = $col['ord'] == 'desc' ? 'sort_desc.gif' : ($col['ord'] == 'asc' ? 'sort_asc.gif' : 'sort_none.gif');
                 $headers[] = navi_button($pager->name . '_sort_' . $num_col, $col['head'], true, $icon);
             }
         }
     }
     /* show a table of records returned by the sql */
     start_table(TABLESTYLE, "width={$pager->width}");
     table_header($headers);
     if ($pager->header_fun) {
         // if set header handler
         start_row("class='{$pager->header_class}'");
         $fun = $pager->header_fun;
         if (method_exists($pager, $fun)) {
             $h = $pager->{$fun}($pager);
         } elseif (function_exists($fun)) {
             $h = $fun($pager);
         }
         foreach ($h as $c) {
             // draw header columns
             $pars = isset($c[1]) ? $c[1] : '';
             label_cell($c[0], $pars);
         }
         end_row();
     }
     $cc = 0;
     // row colour counter
     foreach ($pager->data as $line_no => $row) {
         $marker = $pager->marker;
         if ($marker && $marker($row)) {
             start_row("class='{$pager->marker_class}'");
         } else {
             alt_table_row_color($cc);
         }
         foreach ($pager->columns as $k => $col) {
             $coltype = $col['type'];
             $cell = isset($col['name']) ? $row[$col['name']] : '';
             if (isset($col['fun'])) {
                 // use data input function if defined
                 $fun = $col['fun'];
                 if (method_exists($pager, $fun)) {
                     $cell = $pager->{$fun}($row, $cell);
                 } elseif (function_exists($fun)) {
                     $cell = $fun($row, $cell);
                 } else {
                     $cell = '';
                 }
             }
             switch ($coltype) {
                 // format column
                 case 'time':
                     label_cell($cell, "width=40");
                     break;
                 case 'date':
                     label_cell(sql2date($cell), "align='center' nowrap");
                     break;
                 case 'dstamp':
                     // time stamp displayed as date
                     label_cell(sql2date(substr($cell, 0, 10)), "align='center' nowrap");
                     break;
                 case 'tstamp':
                     // time stamp - FIX user format
                     label_cell(sql2date(substr($cell, 0, 10)) . ' ' . substr($cell, 10), "align='center'");
                     break;
                 case 'percent':
                     percent_cell($cell);
                     break;
                 case 'amount':
                     if ($cell == '') {
                         label_cell('');
                     } else {
                         amount_cell($cell, false);
                     }
                     break;
                 case 'qty':
                     if ($cell == '') {
                         label_cell('');
                     } else {
                         qty_cell($cell, false, isset($col['dec']) ? $col['dec'] : null);
                     }
                     break;
                 case 'email':
                     email_cell($cell, isset($col['align']) ? "align='" . $col['align'] . "'" : null);
                     break;
                 case 'rate':
                     label_cell(number_format2($cell, user_exrate_dec()), "align=center");
                     break;
                 case 'inactive':
                     if (get_post('show_inactive')) {
                         $pager->inactive_control_cell($row);
                     }
                     break;
                 default:
                     // case 'text':
                     if (isset($col['align'])) {
                         label_cell($cell, "align='" . $col['align'] . "'");
                     } else {
                         label_cell($cell);
                     }
                 case 'skip':
                     // column not displayed
             }
         }
         end_row();
     }
     // end of while loop
     if ($pager->footer_fun) {
         // if set footer handler
         start_row("class='{$pager->footer_class}'");
         $fun = $pager->footer_fun;
         if (method_exists($pager, $fun)) {
             $h = $pager->{$fun}($pager);
         } elseif (function_exists($fun)) {
             $h = $fun($pager);
         }
         foreach ($h as $c) {
             // draw footer columns
             $pars = isset($c[1]) ? $c[1] : '';
             label_cell($c[0], $pars);
         }
         end_row();
     }
     start_row("class='navibar'");
     $colspan = count($pager->columns);
     $inact = @$pager->inactive_ctrl == true ? ' ' . checkbox(null, 'show_inactive', null, true) . _("Show also Inactive") : '';
     end_row();
     end_table();
     $but_pref = $pager->name . '_page_';
     // 			if (@$pager->inactive_ctrl)
     // 				submit('Update', _('Update'), true, '', null); // inactive update
     $context = array('first' => $this->pager_button($but_pref . 'first', _('&laquo;'), $pager->first_page), 'previous' => $this->pager_button($but_pref . 'prev', _('&lsaquo;'), $pager->prev_page), 'next' => $this->pager_button($but_pref . 'next', _('&rsaquo;'), $pager->next_page), 'last' => $this->pager_button($but_pref . 'last', _('&raquo;'), $pager->last_page));
     $from = ($pager->curr_page - 1) * $pager->page_len + 1;
     $to = $from + $pager->page_len - 1;
     if ($to > $pager->rec_count) {
         $to = $pager->rec_count;
     }
     $all = $pager->rec_count;
     // 			echo sprintf(_('Records %d-%d of %d'), $from, $to, $all);
     // 			echo $inact;
     // 			echo "</td>";
     echo ThemeBootstrap::get()->renderBlock('controls.twig.html', 'pager', $context);
     /*
     		if ($pager->rec_count) {
     			echo "<td colspan=$colspan class='navibar' style='border:none;padding:3px;'>";
     			echo "<div style='float:right;'>";
     			$but_pref = $pager->name . '_page_';
     			start_table();
     			start_row();
     			if (@$pager->inactive_ctrl)
     				submit('Update', _('Update'), true, '', null); // inactive update
     			echo navi_button_cell($but_pref . 'first', _('First'), $pager->first_page, 'right');
     			echo navi_button_cell($but_pref . 'prev', _('Prev'), $pager->prev_page, 'right');
     			echo navi_button_cell($but_pref . 'next', _('Next'), $pager->next_page, 'right');
     			echo navi_button_cell($but_pref . 'last', _('Last'), $pager->last_page, 'right');
     			end_row();
     			end_table();
     			echo "</div>";
     			$from = ($pager->curr_page - 1) * $pager->page_len + 1;
     			$to = $from + $pager->page_len - 1;
     			if ($to > $pager->rec_count)
     				$to = $pager->rec_count;
     			$all = $pager->rec_count;
     			echo sprintf(_('Records %d-%d of %d'), $from, $to, $all);
     			echo $inact;
     			echo "</td>";
     		} else {
     			label_cell(_('No records') . $inact, "colspan=$colspan class='navibar'");
     		}
     */
     if (isset($pager->marker_txt)) {
         display_note($pager->marker_txt, 0, 1, "class='{$pager->notice_class}'");
     }
     div_end();
     return true;
 }
Example #21
0
function display_dimension_topten()
{
    global $path_to_root;
    $pg = new graph();
    $begin = begin_fiscalyear();
    $today = Today();
    $begin1 = date2sql($begin);
    $today1 = date2sql($today);
    $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM\n\t\t\t" . TB_PREF . "gl_trans AS t," . TB_PREF . "dimensions AS d WHERE\n\t\t\t(t.dimension_id = d.id OR t.dimension2_id = d.id) AND\n\t\t\tt.tran_date >= '{$begin1}' AND t.tran_date <= '{$today1}' GROUP BY d.id ORDER BY total DESC LIMIT 10";
    $result = db_query($sql, "Transactions could not be calculated");
    $title = _("Top 10 Dimensions in fiscal year");
    br(2);
    display_heading($title);
    br();
    $th = array(_("Dimension"), _("Amount"));
    start_table(TABLESTYLE, "width=30%");
    table_header($th);
    $k = 0;
    //row colour counter
    $i = 0;
    while ($myrow = db_fetch($result)) {
        alt_table_row_color($k);
        $name = $myrow['reference'] . " " . $myrow["name"];
        label_cell($name);
        amount_cell($myrow['total']);
        $pg->x[$i] = $name;
        $pg->y[$i] = abs($myrow['total']);
        $i++;
        end_row();
    }
    end_table(2);
    $pg->title = $title;
    $pg->axis_x = _("Dimension");
    $pg->axis_y = _("Amount");
    $pg->graphic_1 = $today;
    $pg->type = 5;
    $pg->skin = 1;
    $pg->built_in = false;
    $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
    $pg->display($filename, true);
    start_table(TABLESTYLE);
    start_row();
    echo "<td>";
    echo "<img src='{$filename}' border='0' alt='{$title}'>";
    echo "</td>";
    end_row();
    end_table(1);
}
Example #22
0
function display_balance_sheet()
{
    global $path_to_root;
    $from = begin_fiscalyear();
    $to = $_POST['TransToDate'];
    if (!isset($_POST['Dimension'])) {
        $_POST['Dimension'] = 0;
    }
    if (!isset($_POST['Dimension2'])) {
        $_POST['Dimension2'] = 0;
    }
    $dimension = $_POST['Dimension'];
    $dimension2 = $_POST['Dimension2'];
    $lconvert = $econvert = 1;
    if (isset($_POST["AccGrp"]) && strlen($_POST['AccGrp']) > 0) {
        $drilldown = 1;
    } else {
        $drilldown = 0;
    }
    // Root level
    div_start('balance_tbl');
    start_table(TABLESTYLE, "width='30%'");
    if (!$drilldown) {
        $equityclose = 0.0;
        $lclose = 0.0;
        $calculateclose = 0.0;
        $parent = -1;
        //Get classes for BS
        $classresult = get_account_classes(false, 1);
        while ($class = db_fetch($classresult)) {
            $classclose = 0.0;
            $convert = get_class_type_convert($class["ctype"]);
            $ctype = $class["ctype"];
            $classname = $class["class_name"];
            //Print Class Name
            table_section_title($class["class_name"]);
            //Get Account groups/types under this group/type
            $typeresult = get_account_types(false, $class['cid'], -1);
            while ($accounttype = db_fetch($typeresult)) {
                $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dimension, $dimension2, $drilldown, $path_to_root);
                //Print Summary
                if ($TypeTotal != 0) {
                    $url = "<a href='{$path_to_root}/gl/inquiry/balance_sheet.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&AccGrp=" . $accounttype['id'] . "'>" . $accounttype['id'] . " " . $accounttype['name'] . "</a>";
                    alt_table_row_color($k);
                    label_cell($url);
                    amount_cell($TypeTotal * $convert);
                    end_row();
                }
                $classclose += $TypeTotal;
            }
            //Print Class Summary
            start_row("class='inquirybg' style='font-weight:bold'");
            label_cell(_('Total') . " " . $class["class_name"]);
            amount_cell($classclose * $convert);
            end_row();
            if ($ctype == CL_EQUITY) {
                $equityclose += $classclose;
                $econvert = $convert;
            }
            if ($ctype == CL_LIABILITIES) {
                $lclose += $classclose;
                $lconvert = $convert;
            }
            $calculateclose += $classclose;
        }
        if ($lconvert == 1) {
            $calculateclose *= -1;
        }
        //Final Report Summary
        $url = "<a href='{$path_to_root}/gl/inquiry/profit_loss.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&Compare=0'>" . _('Calculated Return') . "</a>";
        start_row("class='inquirybg' style='font-weight:bold'");
        label_cell($url);
        amount_cell($calculateclose);
        end_row();
        start_row("class='inquirybg' style='font-weight:bold'");
        label_cell(_('Total') . " " . _('Liabilities') . _(' and ') . _('Equities'));
        amount_cell($lclose * $lconvert + $equityclose * $econvert + $calculateclose);
        end_row();
    } else {
        //Level Pointer : Global variable defined in order to control display of root
        global $levelptr;
        $levelptr = 0;
        $accounttype = get_account_type($_POST["AccGrp"]);
        $classid = $accounttype["class_id"];
        $class = get_account_class($classid);
        $convert = get_class_type_convert($class["ctype"]);
        //Print Class Name
        table_section_title($_POST["AccGrp"] . " " . get_account_type_name($_POST["AccGrp"]));
        $classclose = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dimension, $dimension2, $drilldown, $path_to_root);
    }
    end_table(1);
    // outer table
    div_end();
}
    $dec = get_qty_dec($ln_itm->stock_id);
    qty_cell($ln_itm->quantity, false, $dec);
    label_cell($ln_itm->units);
    qty_cell($ln_itm->qty_done, false, $dec);
    if (isset($_POST['clear_quantity'])) {
        $ln_itm->qty_dispatched = 0;
    }
    $_POST['Line' . $line] = $ln_itm->qty_dispatched;
    /// clear post so value displayed in the fiel is the 'new' quantity
    small_qty_cells(null, 'Line' . $line, qty_format($ln_itm->qty_dispatched, $ln_itm->stock_id, $dec), null, null, $dec);
    $display_discount_percent = percent_format($ln_itm->discount_percent * 100) . "%";
    $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent);
    amount_cell($ln_itm->price);
    label_cell($ln_itm->tax_type_name);
    label_cell($display_discount_percent, "nowrap align=right");
    amount_cell($line_total);
    end_row();
}
$_POST['ChargeFreightCost'] = get_post('ChargeFreightCost', price_format($_SESSION['Items']->freight_cost));
$colspan = 9;
start_row();
label_cell(_("Shipping Cost"), "colspan={$colspan} align=right");
small_amount_cells(null, 'ChargeFreightCost', $_SESSION['Items']->freight_cost);
end_row();
$inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
$display_sub_total = price_format($inv_items_total + input_num('ChargeFreightCost'));
label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right");
$taxes = $_SESSION['Items']->get_taxes(input_num('ChargeFreightCost'));
$tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['Items']->tax_included);
$display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total);
label_row(_("Amount Total"), $display_total, "colspan={$colspan} align=right", "align=right");
Example #24
0
function show_results()
{
    global $path_to_root, $systypes_array;
    if (!isset($_POST["account"])) {
        $_POST["account"] = null;
    }
    $act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : "";
    $dim = get_company_pref('use_dimension');
    /*Now get the transactions  */
    if (!isset($_POST['Dimension'])) {
        $_POST['Dimension'] = 0;
    }
    if (!isset($_POST['Dimension2'])) {
        $_POST['Dimension2'] = 0;
    }
    $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null, input_num('amount_min'), input_num('amount_max'));
    $colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4");
    if ($_POST["account"] != null) {
        display_heading($_POST["account"] . "&nbsp;&nbsp;&nbsp;" . $act_name);
    }
    // Only show balances if an account is specified AND we're not filtering by amounts
    $show_balances = $_POST["account"] != null && input_num("amount_min") == 0 && input_num("amount_max") == 0;
    start_table(TABLESTYLE);
    $first_cols = array(_("Type"), _("#"), _("Date"));
    if ($_POST["account"] == null) {
        $account_col = array(_("Account"));
    } else {
        $account_col = array();
    }
    if ($dim == 2) {
        $dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2");
    } else {
        if ($dim == 1) {
            $dim_cols = array(_("Dimension"));
        } else {
            $dim_cols = array();
        }
    }
    if ($show_balances) {
        $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"));
    } else {
        $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo"));
    }
    $th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols);
    table_header($th);
    if ($_POST["account"] != null && is_account_balancesheet($_POST["account"])) {
        $begin = "";
    } else {
        $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
        if (date1_greater_date2($begin, $_POST['TransFromDate'])) {
            $begin = $_POST['TransFromDate'];
        }
        $begin = add_days($begin, -1);
    }
    $bfw = 0;
    if ($show_balances) {
        $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
        start_row("class='inquirybg'");
        label_cell("<b>" . _("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}");
        display_debit_or_credit_cells($bfw, true);
        label_cell("");
        label_cell("");
        end_row();
    }
    $running_total = $bfw;
    $j = 1;
    $k = 0;
    //row colour counter
    while ($myrow = db_fetch($result)) {
        alt_table_row_color($k);
        $running_total += $myrow["amount"];
        $trandate = sql2date($myrow["tran_date"]);
        label_cell($systypes_array[$myrow["type"]]);
        label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
        label_cell($trandate);
        if ($_POST["account"] == null) {
            label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"]));
        }
        if ($dim >= 1) {
            label_cell(get_dimension_string($myrow['dimension_id'], true));
        }
        if ($dim > 1) {
            label_cell(get_dimension_string($myrow['dimension2_id'], true));
        }
        label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"]));
        display_debit_or_credit_cells($myrow["amount"]);
        if ($show_balances) {
            amount_cell($running_total);
        }
        if ($myrow['memo_'] == "") {
            $myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']);
        }
        label_cell($myrow['memo_']);
        end_row();
        $j++;
        if ($j == 12) {
            $j = 1;
            table_header($th);
        }
    }
    //end of while loop
    if ($show_balances) {
        start_row("class='inquirybg'");
        label_cell("<b>" . _("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}");
        display_debit_or_credit_cells($running_total, true);
        label_cell("");
        label_cell("");
        end_row();
    }
    end_table(2);
    if (db_num_rows($result) == 0) {
        display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1);
    }
}
$k = 0;
while ($myrow = db_fetch($vresult)) {
    alt_table_row_color($k);
    label_cell($myrow["asset_name"]);
    label_cell($myrow["asset_serial"]);
    label_cell($myrow["valuation_year"]);
    amount_cell($myrow["asset_value"]);
    amount_cell($myrow["value_change"]);
    end_row();
}
end_table(1);
end_form();
// ---------------------------------------------------------------------------------------------
$aresult = get_year_amortisation($_POST['year']);
start_form();
start_table(TABLESTYLE, "width=75%");
$th = array(_("Name"), _("Serial Number"), _("Year"), _("Asset Value"), _("Depreciation"));
inactive_control_column($th);
table_header($th);
$k = 0;
while ($myrow = db_fetch($aresult)) {
    alt_table_row_color($k);
    label_cell($myrow["asset_name"]);
    label_cell($myrow["asset_serial"]);
    label_cell($myrow["amortisation_year"]);
    amount_cell($myrow["asset_value"]);
    amount_cell($myrow["amount"]);
    end_row();
}
end_table(1);
end_page();
function show_results()
{
    global $path_to_root;
    /*Now get the transactions  */
    div_start('trans_tbl');
    start_table(TABLESTYLE);
    $netAmounts = check_value('NetAmounts');
    if ($netAmounts) {
        $net = _("Net");
    } else {
        $net = _("Gross");
    }
    $th = array(_("Type"), _("Description"), _("Tax") . "<br>" . _("Amount"), $net . "<br>" . _("Outputs") . "/" . _("Inputs"));
    table_header($th);
    $k = 0;
    $total = 0;
    $bdate = date2sql($_POST['TransFromDate']);
    $edate = date2sql($_POST['TransToDate']);
    $taxes = get_tax_cash_summary($_POST['TransFromDate'], $_POST['TransToDate']);
    while ($tx = db_fetch($taxes)) {
        $payable = $tx['payable'];
        $collectible = $tx['collectible'];
        $net = $collectible + $payable;
        $total += $net;
        alt_table_row_color($k);
        label_cell($tx['name'] . " " . $tx['rate'] . "%");
        label_cell(_("Charged on sales") . " (" . _("Output Tax") . "):");
        amount_cell($payable);
        if ($netAmounts) {
            amount_cell($tx['net_output']);
        } else {
            amount_cell($tx['gross_output']);
        }
        end_row();
        alt_table_row_color($k);
        label_cell($tx['name'] . " " . $tx['rate'] . "%");
        label_cell(_("Paid on purchases") . " (" . _("Input Tax") . "):");
        amount_cell($collectible);
        if ($netAmounts) {
            amount_cell($tx['net_input']);
        } else {
            amount_cell($tx['gross_input']);
        }
        end_row();
        alt_table_row_color($k);
        label_cell("<b>" . $tx['name'] . " " . $tx['rate'] . "%</b>");
        label_cell("<b>" . _("Net payable or collectible") . ":</b>");
        amount_cell($net, true);
        label_cell("");
        end_row();
    }
    alt_table_row_color($k);
    label_cell("");
    label_cell("<b>" . _("Total payable or refund") . ":</b>");
    amount_cell($total, true);
    label_cell("");
    end_row();
    end_table(2);
    div_end();
}
function display_grn_items_for_selection()
{
    global $table_style;
    $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, true);
    if (db_num_rows($result) == 0) {
        display_note(tr("There are no outstanding items received from this supplier that have not been invoiced by them."), 0, 1);
        end_page();
        exit;
    }
    /*Set up a table to show the outstanding GRN items for selection */
    start_form(false, true);
    display_heading2(tr("Items Received Yet to be Invoiced"));
    start_table("{$table_style} colspan=7 width=95%");
    $th = array(tr("Delivery"), tr("Sequence #"), tr("P.O."), tr("Item"), tr("Description"), tr("Received On"), tr("Quantity Received"), tr("Quantity Invoiced"), tr("Uninvoiced Quantity"), tr("Order Price"), tr("Total"));
    table_header($th);
    $i = $k = 0;
    while ($myrow = db_fetch($result)) {
        $grn_already_on_invoice = False;
        foreach ($_SESSION['supp_trans']->grn_items as $entered_grn) {
            if ($entered_grn->id == $myrow["id"]) {
                $grn_already_on_invoice = True;
            }
        }
        if ($grn_already_on_invoice == False) {
            alt_table_row_color($k);
            label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
            //text_cells(null, 'grn_item_id', $myrow["id"]);
            submit_cells('grn_item_id', $myrow["id"]);
            label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
            label_cell($myrow["item_code"]);
            label_cell($myrow["description"]);
            label_cell(sql2date($myrow["delivery_date"]));
            qty_cell($myrow["qty_recd"]);
            qty_cell($myrow["quantity_inv"]);
            qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"]);
            amount_cell($myrow["unit_price"]);
            amount_cell(round($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]), user_price_dec()));
            end_row();
            $i++;
            if ($i > 15) {
                $i = 0;
                table_header($th);
            }
        }
    }
    end_table();
}
 table_header($th);
 $k = 0;
 while ($myrow = db_fetch($result)) {
     alt_table_row_color($k);
     label_cell($quick_actions[$myrow['action']]);
     $act_type = strtolower(substr($myrow['action'], 0, 1));
     if ($act_type == 't') {
         label_cells($myrow['tax_name'], '');
     } else {
         label_cell($myrow['dest_id'] . ' ' . $myrow['account_name']);
         if ($act_type == '=') {
             label_cell('');
         } elseif ($act_type == '%') {
             label_cell(number_format2($myrow['amount'], user_exrate_dec()), "nowrap align=right ");
         } else {
             amount_cell($myrow['amount']);
         }
     }
     if ($dim >= 1) {
         label_cell(get_dimension_string($myrow['dimension_id'], true));
     }
     if ($dim > 1) {
         label_cell(get_dimension_string($myrow['dimension2_id'], true));
     }
     edit_button_cell("BEd" . $myrow["id"], _("Edit"));
     delete_button_cell("BDel" . $myrow["id"], _("Delete"));
     end_row();
 }
 end_table(1);
 div_start('edit_line');
 start_table(TABLESTYLE2);
            $th = array(_("Account Code"), _("Account Description"), _("Dimension"), _("Amount"), _("Memo"));
        } else {
            $th = array(_("Account Code"), _("Account Description"), _("Amount"), _("Memo"));
        }
    }
    table_header($th);
    $k = 0;
    //row colour counter
    $total_amount = 0;
    while ($item = db_fetch($items)) {
        if ($item["account"] != $to_trans["account_code"]) {
            alt_table_row_color($k);
            label_cell($item["account"]);
            label_cell($item["account_name"]);
            if ($dim >= 1) {
                label_cell(get_dimension_string($item['dimension_id'], true));
            }
            if ($dim > 1) {
                label_cell(get_dimension_string($item['dimension2_id'], true));
            }
            amount_cell(-$item["amount"]);
            label_cell($item["memo_"]);
            end_row();
            $total_amount += $item["amount"];
        }
    }
    label_row(_("Total"), number_format2(-$total_amount, user_price_dec()), "colspan=" . (2 + $dim) . " align=right", "align=right");
    end_table(1);
    display_allocations_from($to_trans['person_type_id'], $to_trans['person_id'], 2, $trans_no, $to_trans['settled_amount']);
}
end_page(true, false, false, ST_BANKDEPOSIT, $trans_no);
function display_allocatable_transactions()
{
    global $table_style, $path_to_root;
    start_form();
    /* show all outstanding receipts and credits to be allocated */
    /*Clear any previous allocation records */
    if (isset($_SESSION['alloc'])) {
        unset($_SESSION['alloc']->allocs);
        unset($_SESSION['alloc']);
    }
    if (!isset($_POST['supplier_id'])) {
        $_POST['supplier_id'] = get_global_supplier();
    }
    echo "<center>" . tr("Select a Supplier: ") . "&nbsp;&nbsp;";
    supplier_list('supplier_id', $_POST['supplier_id'], true, true);
    echo "<br>";
    check(tr("Show Settled Items:"), 'ShowSettled', null, true);
    echo "</center><br><br>";
    set_global_supplier($_POST['supplier_id']);
    if (isset($_POST['supplier_id']) && $_POST['supplier_id'] == reserved_words::get_all()) {
        unset($_POST['supplier_id']);
    }
    $settled = false;
    if (check_value('ShowSettled')) {
        $settled = true;
    }
    $supplier_id = null;
    if (isset($_POST['supplier_id'])) {
        $supplier_id = $_POST['supplier_id'];
    }
    $trans_items = get_allocatable_from_supp_transactions($supplier_id, $settled);
    start_table($table_style);
    if (!isset($_POST['supplier_id'])) {
        $th = array(tr("Transaction Type"), tr("#"), tr("Reference"), tr("Date"), tr("Supplier"), tr("Currency"), tr("Total"), tr("Left To Allocate"));
    } else {
        $th = array(tr("Transaction Type"), tr("#"), tr("Reference"), tr("Date"), tr("Total"), tr("Left To Allocate"));
    }
    table_header($th);
    $k = 0;
    //row colour counter
    $has_settled_items = false;
    while ($myrow = db_fetch($trans_items)) {
        if ($myrow["settled"] == 1) {
            start_row("class='settledbg'");
            $has_settled_items = true;
        } else {
            alt_table_row_color($k);
        }
        label_cell(systypes::name($myrow["type"]));
        label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
        label_cell($myrow["reference"]);
        label_cell(sql2date($myrow["tran_date"]));
        if (!isset($_POST['supplier_id'])) {
            label_cell($myrow["supp_name"]);
            label_cell($myrow["curr_code"]);
        }
        amount_cell(-$myrow["Total"]);
        amount_cell(-$myrow["Total"] - $myrow["alloc"]);
        label_cell("<a href='{$path_to_root}/purchasing/allocations/supplier_allocate.php?trans_no=" . $myrow["trans_no"] . "&trans_type=" . $myrow["type"] . "'>" . tr("Allocate") . "</a>");
        end_row();
    }
    end_table();
    if ($has_settled_items) {
        display_note(tr("Marked items are settled."), 0, 1, "class='settledfg'");
    }
    if (db_num_rows($trans_items) == 0) {
        display_note(tr("There are no allocations to be done."), 1, 2);
    }
    end_form();
}