Пример #1
0
 $sql = "SELECT * FROM fiscal_year WHERE id={$year}";
 $result = db_query($sql, "could not get current fiscal year");
 $fyear = db_fetch($result);
 $begin = sql2date($fyear['begin']);
 $end = sql2date($fyear['end']);
 hidden('begin', $begin);
 hidden('end', $end);
 $total = $btotal = $ltotal = 0;
 for ($i = 0, $date_ = $begin; date1_greater_date2($end, $date_); $i++) {
     start_row();
     $_POST['amount' . $i] = number_format2(get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0);
     label_cell($date_);
     if (!isset($_POST['amount' . $i])) {
         $_POST['amount' . $i] = '0';
     }
     amount_cells(null, 'amount' . $i, null, 15, null, 0);
     if ($showdims) {
         $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']);
         label_cell(number_format2($d, 0), "nowrap align=right");
         $btotal += $d;
     }
     $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']);
     $total += input_num('amount' . $i);
     $ltotal += $lamount;
     label_cell(number_format2($lamount, 0), "nowrap align=right");
     $date_ = add_months($date_, 1);
     end_row();
 }
 start_row();
 label_cell("<b>" . tr("Total") . "</b>");
 label_cell("<b>" . number_format2($total, 0) . "</b>", 'align=right');
Пример #2
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();
}
Пример #3
0
function display_credit_items()
{
    global $table_style, $table_style2;
    start_form(false, true);
    start_table("{$table_style2} width=80%", 5);
    echo "<tr><td>";
    // outer table
    start_table("{$table_style} width=100%");
    start_row();
    label_cells(tr("Customer"), $_SESSION['Items']->customer_name, "class='tableheader2'");
    label_cells(tr("Branch"), get_branch_name($_SESSION['Items']->Branch), "class='tableheader2'");
    label_cells(tr("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'");
    end_row();
    start_row();
    //	if (!isset($_POST['ref']))
    //		$_POST['ref'] = references::get_next(11);
    if ($_SESSION['Items']->trans_no == 0) {
        ref_cells(tr("Reference"), 'ref', $_SESSION['Items']->reference, "class='tableheader2'");
    } else {
        label_cells(tr("Reference"), $_SESSION['Items']->reference, "class='tableheader2'");
    }
    //    label_cells(tr("Crediting Invoice"), get_customer_trans_view_str(10, $_SESSION['InvoiceToCredit']), "class='tableheader2'");
    label_cells(tr("Crediting Invoice"), get_customer_trans_view_str(10, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'");
    if (!isset($_POST['ShipperID'])) {
        $_POST['ShipperID'] = $_SESSION['Items']->ship_via;
    }
    label_cell(tr("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(tr("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("{$table_style} width=100%");
    label_row(tr("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'");
    date_row(tr("Credit Note Date"), 'CreditDate', null, 0, 0, 0, "class='tableheader2'");
    end_table();
    echo "</td></tr>";
    end_table(1);
    // outer table
    start_table("{$table_style} width=80%");
    $th = array(tr("Item Code"), tr("Item Description"), tr("Invoiced Quantity"), tr("Units"), tr("Credit Quantity"), tr("Price"), tr("Discount %"), tr("Total"));
    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
        }
        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);
        qty_cell($ln_itm->quantity);
        label_cell($ln_itm->units);
        amount_cells(null, 'Line' . $line_no, qty_format($ln_itm->qty_dispatched));
        $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);
    }
    start_row();
    label_cell(tr("Credit Shipping Cost"), "colspan=7 align=right");
    amount_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6);
    end_row();
    $inv_items_total = $_SESSION['Items']->get_items_total_dispatch();
    $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost']));
    label_row(tr("Sub-total"), $display_sub_total, "colspan=7 align=right", "align=right");
    $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost']));
    $tax_total = display_edit_tax_items($taxes, 7, $_SESSION['Items']->tax_included);
    $display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total);
    label_row(tr("Credit Note Total"), $display_total, "colspan=7 align=right", "align=right");
    end_table();
}
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();
}
Пример #5
0
}
end_table();
//-----------------------------------------------------------------------------------------
if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "") {
    $myrow = get_grn_item_detail($_POST['grn_item_id']);
    echo "<br>";
    display_heading2(tr("Delivery Item Selected For Adding To A Supplier Credit Note"));
    start_table("{$table_style} width=80%");
    $th = array(tr("Sequence #"), tr("Item"), tr("Qty Already Invoiced"), tr("Quantity to Credit"), tr("Order Price"), tr("Credit Price"));
    table_header($th);
    start_row();
    label_cell($_POST['grn_item_id']);
    label_cell($myrow['item_code'] . " " . $myrow['description']);
    qty_cell($myrow["quantity_inv"]);
    qty_cells(null, 'This_QuantityCredited', qty_format(max($myrow['quantity_inv'], 0)));
    amount_cell($myrow['unit_price']);
    amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
    end_row();
    end_table(1);
    submit_center('AddGRNToTrans', tr("Add to Credit Note"));
    hidden('GRNNumber', $_POST['grn_item_id']);
    hidden('item_code', $myrow['item_code']);
    hidden('item_description', $myrow['description']);
    hidden('qty_recd', $myrow['qty_recd']);
    hidden('prev_quantity_inv', $myrow['quantity_inv']);
    hidden('order_price', $myrow['unit_price']);
    hidden('std_cost_unit', $myrow['std_cost_unit']);
    hidden('po_detail_item', $myrow['po_detail_item']);
}
end_form();
end_page();