Example #1
0
        delete_po($_SESSION['PO']->order_no);
    }
    $_SESSION['PO']->clear_items();
    $_SESSION['PO'] = new purch_order();
    display_note(tr("This purchase order has been cancelled."), 0, 1);
    hyperlink_params($path_to_root . "/purchasing/po_entry_items.php", tr("Enter a new purchase order"), "NewOrder=Yes");
    echo "<br>";
    end_page();
    exit;
}
//---------------------------------------------------------------------------------------------------
if (isset($_GET['Delete']) || isset($_GET['Edit'])) {
    copy_from_po();
}
if (isset($_GET['Delete'])) {
    handle_delete_item();
}
//---------------------------------------------------------------------------------------------------
function check_data()
{
    if (!check_num('qty', 0)) {
        display_error(tr("The quantity of the order item must be numeric and not less than zero."));
        set_focus('qty');
        return false;
    }
    if (!check_num('price', 0)) {
        display_error(tr("The price entered must be numeric and not less than zero."));
        set_focus('price');
        return false;
    }
    if (!is_date($_POST['req_del_date'])) {
    line_start_focus();
}
//-----------------------------------------------------------------------------------------------
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    $amount = ($_SESSION['pay_items']->trans_type == ST_BANKPAYMENT ? 1 : -1) * input_num('amount');
    $_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']);
    line_start_focus();
}
//-----------------------------------------------------------------------------------------------
$id = find_submit('Delete');
if ($id != -1) {
    handle_delete_item($id);
}
if (isset($_POST['AddItem'])) {
    handle_new_item();
}
if (isset($_POST['UpdateItem'])) {
    handle_update_item();
}
if (isset($_POST['CancelItemChanges'])) {
    line_start_focus();
}
if (isset($_POST['go'])) {
    display_quick_entries($_SESSION['pay_items'], $_POST['person_id'], input_num('totamount'), $_SESSION['pay_items']->trans_type == ST_BANKPAYMENT ? QE_PAYMENT : QE_DEPOSIT);
    $_POST['totamount'] = price_format(0);
    $Ajax->activate('totamount');
    line_start_focus();