X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_credit_invoice.php;h=8ccbb6e9cfcf217faab43851b7b535f91d20ada3;hb=3e2a432dd72688dbac39a07716201b2b00c16c8b;hp=8d5a104a459e80029a88d176b21ea26f38814645;hpb=c16b7a0f7aa17722568a0695e2fd03a362998372;p=fa-stable.git diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index 8d5a104a..8ccbb6e9 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -99,7 +99,10 @@ function can_process() set_focus('ChargeFreightCost'); return false; } - + if (!check_quantities()) { + display_error(_("Selected quantity cannot be less than zero nor more than quantity not credited yet.")); + return false; + } return true; } @@ -140,14 +143,23 @@ if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { } elseif (!processing_active()) { /* This page can only be called with an invoice number for crediting*/ die (_("This page can only be opened if an invoice has been selected for crediting.")); -} else { +} elseif (!check_quantities()) { + display_error(_("Selected quantity cannot be less than zero nor more than quantity not credited yet.")); +} + +function check_quantities() +{ + $ok =1; 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))) { + if (check_num('Line'.$line_no, 0, $itm->quantity)) { $_SESSION['Items']->line_items[$line_no]->qty_dispatched = input_num('Line'.$line_no); } } + else { + $ok = 0; + } if (isset($_POST['Line'.$line_no.'Desc'])) { $line_desc = $_POST['Line'.$line_no.'Desc']; @@ -156,6 +168,7 @@ if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { } } } + return $ok; } //----------------------------------------------------------------------------- @@ -354,7 +367,7 @@ if (isset($_POST['_CreditType_update'])) } //----------------------------------------------------------------------------- -if (get_post('Update')) +if (get_post('Update')) { $Ajax->activate('credit_items'); }