Example #1
0
function gl_payment_controls()
{
    global $table_style2;
    $home_currency = get_company_currency();
    start_form(false, true);
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    bank_accounts_list_row(tr("From Account:"), 'FromBankAccount', null, true);
    bank_accounts_list_row(tr("To Account:"), 'ToBankAccount', null, true);
    date_row(tr("Transfer Date:"), 'DatePaid');
    $from_currency = get_bank_account_currency($_POST['FromBankAccount']);
    $to_currency = get_bank_account_currency($_POST['ToBankAccount']);
    if ($from_currency != "" && $to_currency != "" && $from_currency != $to_currency) {
        amount_row(tr("Amount:"), 'amount', null, null, $from_currency);
        exchange_rate_display($from_currency, $to_currency, $_POST['DatePaid']);
    } else {
        amount_row(tr("Amount:"), 'amount');
    }
    echo "</table>";
    echo "</td><td valign=top class='tableseparator'>";
    // outer table
    echo "<table>";
    bank_trans_types_list_row(tr("Transfer Type:"), 'TransferType', null);
    ref_row(tr("Reference:"), 'ref', references::get_next(systypes::bank_transfer()));
    textarea_row(tr("Memo:"), 'memo_', null, 40, 4);
    end_table(1);
    echo "</td></tr>";
    end_table(1);
    // outer table
    submit_center('AddPayment', tr("Enter Transfer"));
    end_form();
}
Example #2
0
function display_controls()
{
    global $table_style2;
    start_form(false, true);
    if (!isset($_POST['supplier_id'])) {
        $_POST['supplier_id'] = get_global_supplier(false);
    }
    if (!isset($_POST['DatePaid'])) {
        $_POST['DatePaid'] = Today();
        if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
            $_POST['DatePaid'] = end_fiscalyear();
        }
    }
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    bank_accounts_list_row(tr("From Bank Account:"), 'bank_account', null, true);
    amount_row(tr("Amount of Payment:"), 'amount');
    amount_row(tr("Amount of Discount:"), 'discount');
    date_row(tr("Date Paid") . ":", 'DatePaid');
    echo "</table>";
    echo "</td><td valign=top class='tableseparator'>";
    // outer table
    echo "<table>";
    supplier_list_row(tr("Payment To:"), 'supplier_id', null, false, true);
    set_global_supplier($_POST['supplier_id']);
    $supplier_currency = get_supplier_currency($_POST['supplier_id']);
    $bank_currency = get_bank_account_currency($_POST['bank_account']);
    if ($bank_currency != $supplier_currency) {
        exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']);
    }
    bank_trans_types_list_row(tr("Payment Type:"), 'PaymentType', null);
    ref_row(tr("Reference:"), 'ref', references::get_next(22));
    text_row(tr("Memo:"), 'memo_', null, 52, 50);
    echo "</table>";
    echo "</td></tr>";
    end_table(1);
    // outer table
    submit_center('ProcessSuppPayment', tr("Enter Payment"));
    if ($bank_currency != $supplier_currency) {
        display_note(tr("The amount and discount are in the bank account's currency."), 2, 0);
    }
    end_form();
}
    }
    // if unassembling, negate quantity
    if ($_POST['ProductionType'] == 0) {
        $_POST['quantity'] = -$_POST['quantity'];
    }
    $id = work_order_produce($_POST['selected_id'], $_POST['ref'], $_POST['quantity'], $_POST['date_'], $_POST['memo_'], $close_wo);
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$id}");
}
//-------------------------------------------------------------------------------------
display_wo_details($_POST['selected_id']);
//-------------------------------------------------------------------------------------
start_form();
hidden('selected_id', $_POST['selected_id']);
//hidden('WOReqQuantity', $_POST['WOReqQuantity']);
if (!isset($_POST['quantity']) || $_POST['quantity'] == '') {
    $_POST['quantity'] = max($wo_details["units_reqd"] - $wo_details["units_issued"], 0);
}
start_table();
ref_row(tr("Reference:"), 'ref', references::get_next(29));
if (!isset($_POST['ProductionType'])) {
    $_POST['ProductionType'] = 1;
}
yesno_list_row(tr("Type:"), 'ProductionType', $_POST['ProductionType'], tr("Produce Finished Items"), tr("Return Items to Work Order"));
text_row(tr("Quantity:"), 'quantity', $_POST['quantity'], 13, 15);
date_row(tr("Date:"), 'date_');
textarea_row(tr("Memo:"), 'memo_', null, 40, 3);
end_table(1);
submit_center_first('Process', tr("Process"));
submit_center_last('ProcessAndClose', tr("Process And Close Order"));
end_form();
end_page();
Example #4
0
function read_customer_data()
{
    $sql = "SELECT debtors_master.pymt_discount,\n\t\tcredit_status.dissallow_invoices\n\t\tFROM debtors_master, credit_status\n\t\tWHERE debtors_master.credit_status = credit_status.id\n\t\t\tAND debtors_master.debtor_no = '" . $_POST['customer_id'] . "'";
    $result = db_query($sql, "could not query customers");
    $myrow = db_fetch($result);
    $_POST['HoldAccount'] = $myrow["dissallow_invoices"];
    $_POST['pymt_discount'] = $myrow["pymt_discount"];
    $_POST['ref'] = references::get_next(12);
}
Example #5
0
    $_POST['memo_'] = "";
    $_POST['units_issued'] = $myrow["units_issued"];
    $_POST['Costs'] = price_format($myrow["Costs"]);
    $_POST['memo_'] = get_comments_string(systypes::work_order(), $selected_id);
    hidden('wo_ref', $_POST['wo_ref']);
    hidden('units_issued', $_POST['units_issued']);
    hidden('released', $_POST['released']);
    hidden('released_date', $_POST['released_date']);
    hidden('selected_id', $selected_id);
    hidden('old_qty', $myrow["units_reqd"]);
    hidden('old_stk_id', $myrow["stock_id"]);
    label_row(tr("Reference:"), $_POST['wo_ref']);
    label_row(tr("Type:"), wo_types::name($_POST['type']));
} else {
    $_POST['units_issued'] = $_POST['released'] = 0;
    ref_row(tr("Reference:"), 'wo_ref', references::get_next(systypes::work_order()));
    wo_types_list_row(tr("Type:"), 'type', $_POST['type']);
}
if ($_POST['released'] == true) {
    hidden('stock_id', $_POST['stock_id']);
    hidden('StockLocation', $_POST['StockLocation']);
    hidden('type', $_POST['type']);
    label_row(tr("Item:"), $myrow["StockItemName"]);
    label_row(tr("Destination Location:"), $myrow["location_name"]);
} else {
    stock_manufactured_items_list_row(tr("Item:"), 'stock_id', null);
    locations_list_row(tr("Destination Location:"), 'StockLocation', null);
}
if (!isset($_POST['quantity'])) {
    $_POST['quantity'] = qty_format(1);
}
if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) {
    $ci = new Cart(10, $_GET['InvoiceNumber'], true);
    if ($ci == null) {
        display_error(tr("This invoice can not be credited using the automatic facility."));
        display_error("Please report that a duplicate debtor_trans header record was found for invoice " . key($ci->src_docs));
        echo "<br><br>";
        processing_end();
        exit;
    }
    //valid invoice record returned from the entered invoice number
    $ci->trans_type = 11;
    $ci->src_docs = $ci->trans_no;
    $ci->src_date = $ci->document_date;
    $ci->trans_no = 0;
    $ci->document_date = Today();
    $ci->reference = references::get_next(11);
    for ($line_no = 0; $line_no < count($ci->line_items); $line_no++) {
        $ci->line_items[$line_no]->qty_dispatched = '0';
    }
    $_SESSION['Items'] = $ci;
    copy_from_cart();
} elseif (isset($_GET['ModifyCredit']) && $_GET['ModifyCredit'] > 0) {
    $_SESSION['Items'] = new Cart(11, $_GET['ModifyCredit']);
    copy_from_cart();
} elseif (!processing_active()) {
    /* This page can only be called with an invoice number for crediting*/
    die(tr("This page can only be opened if an invoice has been selected for crediting."));
} else {
    foreach ($_SESSION['Items']->line_items as $line_no => $itm) {
        if (isset($_POST['Line' . $line_no])) {
            if (check_num('Line' . $line_no, $itm->quantity - $itm->qty_done)) {
Example #7
0
    if ($myrow["closed"] == 1) {
        display_error(tr("This dimension is closed and cannot be edited."));
        exit;
    }
    $_POST['ref'] = $myrow["reference"];
    $_POST['closed'] = $myrow["closed"];
    $_POST['name'] = $myrow["name"];
    $_POST['type_'] = $myrow["type_"];
    $_POST['date_'] = sql2date($myrow["date_"]);
    $_POST['due_date'] = sql2date($myrow["due_date"]);
    $_POST['memo_'] = get_comments_string(systypes::dimension(), $selected_id);
    hidden('ref', $_POST['ref']);
    label_row(tr("Dimension Reference:"), $_POST['ref']);
    hidden('selected_id', $selected_id);
} else {
    ref_row(tr("Dimension Reference:"), 'ref', references::get_next(systypes::dimension()));
}
text_row_ex(tr("Name") . ":", 'name', 50, 75);
$dim = get_company_pref('use_dimension');
number_list_row(tr("Type"), 'type_', null, 1, $dim);
date_row(tr("Start Date") . ":", 'date_');
date_row(tr("Date Required By") . ":", 'due_date', null, sys_prefs::default_dimension_required_by());
textarea_row(tr("Memo:"), 'memo_', null, 40, 5);
end_table(1);
submit_add_or_update_center($selected_id == -1);
if ($selected_id != -1) {
    echo "<br>";
    submit_center_first('close', tr("Close This Dimension"));
    submit_center_last('delete', tr("Delete This Dimension"));
}
end_form();
Example #8
0
     $row = db_fetch_row($result);
     if (!$row) {
         add_item_code($code, $id, $description, $cat, $qty, $foreign);
     } else {
         update_item_code($row[0], $code, $id, $description, $cat, $qty, $foreign);
     }
     $k++;
 }
 if ($type == 'ITEM') {
     $dim = 0;
     if ($qty != '') {
         $dim = get_dimension_by_name($qty);
         if ($dim == -1) {
             $date = Today();
             $due = add_days($date, sys_prefs::default_dimension_required_by());
             $ref = references::get_next(systypes::dimension());
             $dim = add_dimension($ref, $qty, 1, $date, $due, "Added due to Item Import");
             $dim_n++;
         }
     }
     $sql = "SELECT stock_id FROM " . TB_PREF . "stock_master WHERE stock_id='{$id}'";
     $result = db_query($sql, "item could not be retrieved");
     $row = db_fetch_row($result);
     if (!$row) {
         $sql = "INSERT INTO " . TB_PREF . "stock_master (stock_id, description, long_description, category_id,\n\t\t\t\t\t    tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,\n\t\t\t\t\t    adjustment_account, assembly_account, dimension_id, dimension2_id)\n\t\t\t\t\t    VALUES ('{$id}', " . db_escape($description) . ", '',\n\t\t\t\t\t    '{$cat}', {$_POST['tax_type_id']}, '{$units}', '{$mb_flag}',\n\t\t\t\t\t    '{$_POST['sales_account']}', '{$_POST['inventory_account']}', '{$_POST['cogs_account']}',\n\t\t\t\t\t    '{$_POST['adjustment_account']}', '{$_POST['assembly_account']}', {$dim}, 0)";
         db_query($sql, "The item could not be added");
         if ($mb_flag == "M" || $mb_flag == "B") {
             $sql = "INSERT INTO " . TB_PREF . "loc_stock (loc_code, stock_id) VALUES ('{$_POST['location']}', '{$id}')";
             db_query($sql, "The item locstock could not be added");
         }
         $i++;
Example #9
0
function create_cart($type, $trans_no)
{
    processing_start();
    $doc_type = $type;
    if ($type != 30 && $trans_no != 0) {
        // this is template
        $doc_type = 30;
        $doc = new Cart(30, array($trans_no));
        $doc->trans_type = $type;
        $doc->trans_no = 0;
        if ($type == 10) {
            $doc->due_date = get_invoice_duedate($doc->customer_id, $doc->document_date);
        } else {
            $doc->due_date = $doc->document_date = Today();
        }
        $doc->reference = references::get_next($doc->trans_type);
        $doc->Comments = '';
        foreach ($doc->line_items as $line_no => $line) {
            $doc->line_items[$line_no]->qty_done = 0;
        }
        $_SESSION['Items'] = $doc;
    } else {
        $_SESSION['Items'] = new Cart($type, array($trans_no));
    }
    copy_from_cart();
}
Example #10
0
    hyperlink_params($path_to_root . "/sales/inquiry/sales_deliveries_view.php", tr("Select A Different Delivery"), "OutstandingOnly=1");
    display_footer_exit();
}
//-----------------------------------------------------------------------------
if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
    $ord = new Cart(30, $_GET['OrderNumber'], true);
    /*read in all the selected order into the Items cart  */
    if ($ord->count_items() == 0) {
        hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", tr("Select a different sales order to delivery"), "OutstandingOnly=1");
        die("<br><b>" . tr("This order has no items. There is nothing to delivery.") . "</b>");
    }
    $ord->trans_type = 13;
    $ord->src_docs = $ord->trans_no;
    $ord->order_no = key($ord->trans_no);
    $ord->trans_no = 0;
    $ord->reference = references::get_next(13);
    $_SESSION['Items'] = $ord;
    copy_from_cart();
} elseif (isset($_GET['ModifyDelivery']) && $_GET['ModifyDelivery'] > 0) {
    $_SESSION['Items'] = new Cart(13, $_GET['ModifyDelivery']);
    if ($_SESSION['Items']->count_items() == 0) {
        hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", tr("Select a different delivery"), "OutstandingOnly=1");
        echo "<br><center><b>" . tr("This delivery has all items invoiced. There is nothing to modify.") . "</center></b>";
        display_footer_exit();
    }
    copy_from_cart();
} elseif (!processing_active()) {
    /* This page can only be called with an order number for invoicing*/
    display_error(tr("This page can only be opened if an order or delivery note has been selected. Please select it first."));
    hyperlink_params("{$path_to_root}/sales/inquiry/sales_orders_view.php", tr("Select a Sales Order to Delivery"), "OutstandingOnly=1");
    end_page();
Example #11
0
    if (isset($_GET['BatchInvoice'])) {
        $src = $_SESSION['DeliveryBatch'];
        unset($_SESSION['DeliveryBatch']);
    } else {
        $src = array($_GET['DeliveryNumber']);
    }
    /*read in all the selected deliveries into the Items cart  */
    $dn = new Cart(13, $src, true);
    if ($dn->count_items() == 0) {
        hyperlink_params($path_to_root . "/sales/inquiry/sales_deliveries_view.php", tr("Select a different delivery to invoice"), "OutstandingOnly=1");
        die("<br><b>" . tr("There are no delivered items with a quantity left " . "to invoice. There is nothing left to invoice.") . "</b>");
    }
    $dn->trans_type = 10;
    $dn->src_docs = $dn->trans_no;
    $dn->trans_no = 0;
    $dn->reference = references::get_next(10);
    $dn->due_date = get_invoice_duedate($dn->customer_id, $dn->document_date);
    $_SESSION['Items'] = $dn;
    copy_from_cart();
} elseif (isset($_GET['ModifyInvoice']) && $_GET['ModifyInvoice'] > 0) {
    if (get_parent_trans(10, $_GET['ModifyInvoice']) == 0) {
        // 1.xx compatibility hack
        echo "<center><br><b>" . tr("There in no delivery notes for this invoice.<br>\n\t\tMost likely this invoice was created in Front Accounting version prior to 2.0\n\t\tand therefore can not be modified.") . "</b></center>";
        display_footer_exit();
    }
    processing_start();
    $_SESSION['Items'] = new Cart(10, $_GET['ModifyInvoice']);
    if ($_SESSION['Items']->count_items() == 0) {
        echo "<center><br><b>" . tr("All quantities on this invoice has been " . "credited. There is nothing to modify on this invoice") . "</b></center>";
        display_footer_exit();
    }