function get_customer_details_to_order(&$order, $customer_id, $branch_id)
{
+ global $SysPrefs;
+
$ret_error = "";
$myrow = get_customer_to_order($customer_id);
$order->set_delivery($myrow["default_ship_via"], $myrow["br_name"],
$address);
- if ($order->trans_type == ST_SALESINVOICE || $order->trans_type == ST_SALESORDER) {
+ if ($order->trans_type == ST_SALESINVOICE) {
$order->due_date = get_invoice_duedate($order->payment, $order->document_date);
}
+ elseif ($order->trans_type == ST_SALESORDER)
+ $order->due_date = add_days($order->document_date, $SysPrefs->default_delivery_required_by());
+ elseif ($order->trans_type == ST_SALESQUOTE)
+ $order->due_date = add_days($order->document_date, $SysPrefs->default_quote_valid_days());
+
if($order->payment_terms['cash_sale']) {
$order->set_location($order->pos["pos_location"], $order->pos["location_name"]);
} else
$order->set_location($myrow["default_location"], $myrow["location_name"]);
-
+
return $ret_error;
}
function display_order_summary($title, &$order, $editable_items=false)
{
- global $SysPrefs;
display_heading($title);
$k = 0; //row colour counter
$id = find_submit('Edit');
- $has_marked = false;
- foreach ($order->line_items as $line_no=>$stock_item)
+
+ $low_stock = $order->check_qoh($_POST['OrderDate'], $_POST['Location']);
+ foreach ($order->get_items() as $line_no=>$stock_item)
{
$line_total = round($stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent),
$qoh_msg = '';
if (!$editable_items || $id != $line_no)
{
- if (!$SysPrefs->allow_negative_stock() && is_inventory_item($stock_item->stock_id)) {
- $qoh = get_qoh_on_date($stock_item->stock_id,
- $_POST['Location'], $_POST['delivery_date']);
- if ($stock_item->qty_dispatched > $qoh)
- {
- // oops, we don't have enough of one of the component items
- start_row("class='stockmankobg'");
- $qoh_msg .= $stock_item->stock_id . " - " . $stock_item->item_description . ": " .
- _("Quantity On Hand") . " = "
- . number_format2($qoh, get_qty_dec($stock_item->stock_id)) . '<br>';
- $has_marked = true;
- } else
- alt_table_row_color($k);
- } else {
+ if (in_array($stock_item->stock_id, $low_stock))
+ start_row("class='stockmankobg'"); // notice low stock status
+ else
alt_table_row_color($k);
- }
view_stock_status_cell($stock_item->stock_id);
end_row();
end_table();
- if ($has_marked) {
+ if ($low_stock)
display_note(_("Marked items have insufficient quantities in stock as on day of delivery."), 0, 1, "class='stockmankofg'");
- if ($order->trans_type!=30 && !$SysPrefs->allow_negative_stock())
- display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:")
- . '<br>'. $qoh_msg);
- }
+
div_end();
}
$row = get_customer_to_order($_POST['customer_id']);
if ($row['dissallow_invoices'] == 1)
$customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.");
-
}
}
table_section(2);
- if (!is_company_currency($order->customer_currency))
+ if (!is_company_currency($order->customer_currency) && in_array($order->trans_type, array(ST_SALESINVOICE, ST_CUSTDELIVERY)))
{
label_row(_("Customer Currency:"), $order->customer_currency);
- exchange_rate_display($order->customer_currency, get_company_currency(),
+ exchange_rate_display(get_company_currency(), $order->customer_currency,
($editable ? $_POST['OrderDate'] : $order->document_date));
}
label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
table_section(3);
- if ($order->pos['cash_sale'] || $order->pos['credit_sale']) {
+ if (($order->pos['cash_sale'] || $order->pos['credit_sale'])
+ && !$order->is_started()) {
// editable payment type
if (get_post('payment') !== $order->payment) {
$order->payment = get_post('payment');
$paymcat = !$order->pos['cash_sale'] ? PM_CREDIT :
(!$order->pos['credit_sale'] ? PM_CASH : PM_ANY);
// all terms are available for SO
- sale_payment_list_cells(_('Payment:'), 'payment',
- (in_array($order->trans_type, array(ST_SALESQUOTE, ST_SALESORDER))
- ? PM_ANY : $paymcat), null);
+ $is_order = in_array($order->trans_type, array(ST_SALESQUOTE, ST_SALESORDER));
+ sale_payment_list_cells(_('Payment:'), 'payment', $is_order ? PM_ANY : $paymcat, null, true, $is_order);
} else {
- label_cells(_('Payment:'), $order->payment_terms['terms']);
+ label_cells(_('Payment:'), $order->payment_terms['terms'], "class='label'");
}
if($editable) {
}
else // prepare new line
{
- sales_items_list_cells(null,'stock_id', null, false, true);
+ sales_items_list_cells(null,'stock_id', null, false, true, true);
if (list_updated('stock_id')) {
$Ajax->activate('price');
$Ajax->activate('units');
label_row(_("Cash account:"), $order->pos['bank_account_name']);
textarea_row(_("Comments:"), "Comments", $order->Comments, 31, 5);
end_table();
+ hidden('delivery_date', $order->due_date);
} else {
if ($order->trans_type==ST_SALESINVOICE)
{
table_section(1);
locations_list_row(_("Deliver from Location:"), 'Location', null, false, true);
+ if ($order->payment_terms['days_before_due'] < 0)
+ {
+ $Ajax->addUpdate('items_table', 'prep_amount', price_format($order->get_trans_total())); // bind to items_table update
+ if (!$order->is_started())
+ amount_row(_("Pre-Payment Required:"), 'prep_amount');
+ else
+ label_row(_("Pre-Payment Required:"), price_format($order->prep_amount), "class='label'");
+ }
if (list_updated('Location'))
$Ajax->activate('items_table');
date_row($delname, 'delivery_date',
$order->trans_type==ST_SALESORDER ? _('Enter requested day of delivery')
: $order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : '');
- text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40,
+ text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 50, 60,
_('Additional identifier for delivery e.g. name of receiving person'));
textarea_row(_("Address:"), 'delivery_address', $order->delivery_address, 35, 5,
div_end();
}
-?>
\ No newline at end of file