X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_delivery.php;h=114f3d4a9ccf0331f207d1c8561ae9bcb0cf06d9;hb=6a490756f95863cd9c86884cd65caa45b1d42e5d;hp=30e359193d6e25253d0ac1ed60d4084b235cb30b;hpb=e1d91c5f52b71addb04721c16a972084e2a33f22;p=fa-stable.git
diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php
index 30e35919..114f3d4a 100644
--- a/sales/customer_delivery.php
+++ b/sales/customer_delivery.php
@@ -106,7 +106,7 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
$_SESSION['Items'] = new Cart(ST_CUSTDELIVERY, $_GET['ModifyDelivery']);
if ($_SESSION['Items']->count_items() == 0) {
- hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php",
+ hyperlink_params($path_to_root . "/sales/inquiry/customer_inquiry.php",
_("Select a different delivery"), "OutstandingOnly=1");
echo "
" . _("This delivery has all items invoiced. There is nothing to modify.") .
"";
@@ -167,12 +167,6 @@ function check_data()
set_focus('ref');
return false;
}
-
- if ($_SESSION['Items']->trans_no==0 && !is_new_reference($_POST['ref'], ST_CUSTDELIVERY)) {
- display_error(_("The entered reference is already in use."));
- set_focus('ref');
- return false;
- }
}
if ($_POST['ChargeFreightCost'] == "") {
$_POST['ChargeFreightCost'] = price_format(0);
@@ -301,7 +295,6 @@ function check_qoh()
//------------------------------------------------------------------------------
if (isset($_POST['process_delivery']) && check_data() && check_qoh()) {
-
$dn = &$_SESSION['Items'];
if ($_POST['bo_policy']) {
@@ -314,16 +307,23 @@ if (isset($_POST['process_delivery']) && check_data() && check_qoh()) {
copy_to_cart();
if ($newdelivery) new_doc_date($dn->document_date);
$delivery_no = $dn->write($bo_policy);
-
- processing_end();
- if ($newdelivery) {
- meta_forward($_SERVER['PHP_SELF'], "AddedID=$delivery_no");
- } else {
- meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$delivery_no");
+ if ($delivery_no == -1)
+ {
+ display_error(_("The entered reference is already in use."));
+ set_focus('ref');
}
+ else
+ {
+ processing_end();
+ if ($newdelivery) {
+ meta_forward($_SERVER['PHP_SELF'], "AddedID=$delivery_no");
+ } else {
+ meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$delivery_no");
+ }
+ }
}
-if (isset($_POST['Update']) || isset($_POST['_Location_update'])) {
+if (isset($_POST['Update']) || isset($_POST['_Location_update']) || isset($_POST['qty'])) {
$Ajax->activate('Items');
}
//------------------------------------------------------------------------------
@@ -440,24 +440,30 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) {
if ($ln_itm->quantity==$ln_itm->qty_done) {
continue; //this line is fully delivered
}
- // if it's a non-stock item (eg. service) don't show qoh
- $show_qoh = true;
- if ($SysPrefs->allow_negative_stock() || !has_stock_holding($ln_itm->mb_flag) ||
- $ln_itm->qty_dispatched == 0) {
- $show_qoh = false;
+ if(isset($_POST['_Location_update']) || isset($_POST['clear_quantity']) || isset($_POST['reset_quantity'])) {
+ // reset quantity
+ $ln_itm->qty_dispatched = $ln_itm->quantity-$ln_itm->qty_done;
}
+ // if it's a non-stock item (eg. service) don't show qoh
+ $row_classes = null;
+ if (has_stock_holding($ln_itm->mb_flag) && $ln_itm->qty_dispatched) {
+ // It's a stock : call get_dispatchable_quantity hook to get which quantity to preset in the
+ // quantity input box. This allows for example a hook to modify the default quantity to what's dispatchable
+ // (if there is not enough in hand), check at other location or other order people etc ...
+ // This hook also returns a 'reason' (css classes) which can be used to theme the row.
- if ($show_qoh) {
$qoh = get_qoh_on_date($ln_itm->stock_id, $_POST['Location'], $_POST['DispatchDate']);
- }
+ $q_class = hook_get_dispatchable_quantity($ln_itm, $_POST['Location'], $_POST['DispatchDate'], $qoh);
+ // Skip line if needed
+ if($q_class === 'skip') continue;
+ if(is_array($q_class)) {
+ list($ln_itm->qty_dispatched, $row_classes) = $q_class;
+ $has_marked = true;
+ }
- if ($show_qoh && ($ln_itm->qty_dispatched > $qoh)) {
- // oops, we don't have enough of one of the component items
- start_row("class='stockmankobg'");
- $has_marked = true;
- } else {
- alt_table_row_color($k);
}
+
+ alt_table_row_color($k, $row_classes);
view_stock_status_cell($ln_itm->stock_id);
if ($ln_itm->descr_editable)
@@ -470,6 +476,10 @@ foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) {
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) . "%";
@@ -521,9 +531,15 @@ textarea_row(_("Memo"), 'Comments', null, 50, 4);
end_table(1);
div_end();
submit_center_first('Update', _("Update"),
- _('Refresh document page'), true);
+ _('Refresh document page'), true);
+if(isset($_POST['clear_quantity'])) {
+ submit('reset_quantity', _('Reset quantity'), true, _('Refresh document page'));
+}
+else {
+ submit('clear_quantity', _('Clear quantity'), true, _('Refresh document page'));
+}
submit_center_last('process_delivery', _("Process Dispatch"),
- _('Check entered data and save document'), 'default');
+ _('Check entered data and save document'), 'default');
end_form();