! -> Note
$ -> Affected files
+18-Jun-2008 Janusz Dobrowolski
++ Added ajax improvements
+$ /sales/credit_note_entry.php
+ /sales/customer_payments.php
+ /sales/sales_order_entry.php
+ /sales/includes/ui/sales_credit_ui.inc
+ /sales/includes/ui/sales_order_ui.inc
+ /sales/inquiry/customer_allocation_inquiry.php
+ /sales/inquiry/customer_inquiry.php
++ Added optional trigger parameter to div_start()
+$ /includes/ui/ui_controls.inc
++ Added dec attribute ajax update for amount fields
+$ /includes/ui/ui_input.inc
++ Ajaxified stock item types and credit types lists
+$ /includes/ui/ui_lists.inc
+# Fixed onblur for amount fields, extended onchange event handling for selects
+$ /js/inserts.js
+# Fixed addAssign() js handler for nonstandard attributes
+$ /js/utils.js
+
17-Jun-2008 Joe Hunt
! More files with Quantity routines needed fix due to php4 related issue.
$ /includes/current_user.inc
! Added text selection after focus.
$ /js/inserts.js
/js/utils.js
-+ Added submit_on_change option to ref input functions
++ Added submit_on_change option to ref input functions, fixed data picker
$ /includes/ui/ui_input.inc
# Fixed bug in non-js mode for combos type 0 (stock_items_lists).
$ /includes/ui/ui_lists.inc
break;
}
}
-// display_error(htmlentities(print_r($this->aCommands, true)));
+// display_error('Activate:'.htmlentities(print_r($this->triggers, true)));
+// display_error('Commands :'.htmlentities(print_r($this->aCommands, true)));
$GLOBALS['_RESULT'] = $this->aCommands;
// exit();
}
$ajax_divs = array();
-function div_start($id='')
+function div_start($id='', $trigger=null)
{
global $ajax_divs;
- array_push($ajax_divs, $id);
+ array_push($ajax_divs, array($id, $trigger===null ? $id : $trigger));
echo "<div ". ($id !='' ? "id='$id'" : '').">";
ob_start();
}
if (count($ajax_divs))
{
- $id = array_pop($ajax_divs);
- $Ajax->addUpdate($id, $id, ob_get_flush());
+ $div = array_pop($ajax_divs);
+ $Ajax->addUpdate($div[1], $div[0], ob_get_flush());
echo "</div>";
}
}
echo "</td>\n";
$Ajax->addUpdate($name, $name, $_POST[$name]);
+ $Ajax->addAssign($name, $name, 'dec', $dec);
}
$rel = "rel='$search_box'"; // set relation to list
if ($opts['search_submit']) {
-
if (isset($_POST[$search_submit])) {
- $Ajax->activate($name);
+ if (!$opts['async'])
+ $Ajax->activate('_page_body');
+ else
+ $Ajax->activate($name);
}
if ($txt == '') {
if ($spec_option === false)
echo "<td>$label</td>\n";
echo "<td>";
if ($enabled)
- $sel = "<select name='$name' onchange='this.form.submit();'>\n";
+ $sel = "<select name='$name' onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>\n";
+
else
$sel = "<select disabled name='$name'>\n";
if ($selected_id == null)
label_cell($label);
echo "<td><select name='$name'";
if ($submit_on_change)
- echo " onchange='this.form.submit();'>"; // FIX ajax
+ echo " onchange='JsHttpRequest.request(\"_{$name}_update\", this.form);'>";
else
echo ">";
echo "<option " . ($selected == 'Return'?" selected ":"") . " value='Return'>" . _("Items Returned to Inventory Location"). "</option>\n";
}
}
}
- };
- e.onkeydown = function(ev) {
+ };
+ e.onkeydown = function(ev) {
ev = ev||window.event;
key = ev.keyCode||ev.which;
if(key == 13) {
this.blur();
return false;
}
- }
+ }
}
function _update_box(s) {
}
function _set_combo_select(e) {
+ // When combo position is changed via js (eg from searchbox)
+ // no onchange event is generated. To ensure proper change
+ // signaling we must track selectedIndex in onblur handler.
+ e.setAttribute('_last', e.selectedIndex);
e.onblur = function() {
if(this.className=='combo')
_update_box(this);
+ if (this.selectedIndex != this.getAttribute('_last'))
+ this.onchange();
}
e.onchange = function() {
var s = this;
'input.ajaxsubmit,input.editbutton,input.navibutton':
function(e) {
e.onclick = function() {
- JsHttpRequest.request(this);
- return false;
+ JsHttpRequest.request(this);
+ return false;
}
},
'.amount': function(e) {
if(e.onblur==undefined) {
- var dec = e.getAttribute("dec");
e.onblur = function() {
+ var dec = this.getAttribute("dec");
price_format(this.name, get_amount(this.name), dec);
};
}
values[trigger] = 1;
// this is to avoid caching problems
values['_random'] = Math.random()*1234567;
-
JsHttpRequest.query(
'POST '+url, // backend
values,
// seek element by id if there is no elemnt with given name
objElement = document.getElementsByName(id)[0] || document.getElementById(id);
if(cmd=='as') {
- eval("objElement."+property+"=data;");
+ eval("objElement.setAttribute('"+property+"',"+data+");");
} else if(cmd=='up') {
// if(!objElement) debug('No element "'+id+'"');
if (objElement.tagName == 'INPUT' || objElement.tagName == 'TEXTAREA')
//--------------------------------------------------------------------------------
function line_start_focus() {
- set_focus(get_company_pref('no_supplier_list') ? 'stock_id_edit' : 'StockID2');
+ global $Ajax;
+ $Ajax->activate('items_table');
+ set_focus('_stock_id_edit');
}
//-----------------------------------------------------------------------------
processing_start();
$_SESSION['Items'] = new Cart(11,$trans_no);
copy_from_cn();
+ line_start_focus();
}
//-----------------------------------------------------------------------------
display_note(_("For credit notes created to write off the stock, a general ledger account is required to be selected."), 1, 0);
display_note(_("Please select an account to write the cost of the stock off to, then click on Process again."), 1, 0);
exit;
+
}
if (!isset($_POST['WriteOffGLCode'])) {
$_POST['WriteOffGLCode'] = 0;
unset($_POST['AddPaymentItem']);
}
}
-
+if (isset($_POST['_customer_id_button'])) {
+// unset($_POST['branch_id']);
+ $Ajax->activate('branch_id');
+}
//----------------------------------------------------------------------------------------------
if (isset($_POST['AddPaymentItem'])) {
}
}
customer_list_row(_("From Customer:"), 'customer_id', null, false, true);
-
if (db_customer_has_branches($_POST['customer_id'])) {
customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true);
} else {
echo"<br>";
- submit_center('AddPaymentItem', _("Add Payment"));
+ submit_center('AddPaymentItem', _("Add Payment"), true, '', true);
}
echo "<br>";
function display_credit_header(&$order)
{
- global $table_style;
+ global $table_style, $Ajax;
start_table("width=80% $table_style");
echo "<tr><td valign=top>"; // outer table
echo "<table>";
$customer_error = "";
+ $change_prices = 0;
if (!isset($_POST['customer_id']) && (get_global_customer() != reserved_words::get_all()))
$_POST['customer_id'] = get_global_customer();
customer_list_row(_("Customer:"), 'customer_id', null, false, true);
- if ($order->customer_id != $_POST['customer_id'] || $order->sales_type != $_POST['sales_type_id'])
+ if ($order->customer_id != $_POST['customer_id'] /*|| $order->sales_type != $_POST['sales_type_id']*/)
{
// customer has changed
// delete all the order items - drastic but necessary because of
// change of currency, sales type, etc
- $order->clear_items();
+// $order->clear_items();
// clear the branch selection
- unset($_POST['branch_id']);
+// unset($_POST['branch_id']);
+ $_POST['branch_id'] = '';
+ $Ajax->activate('branch_id');
}
- customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true);
+ customer_branches_list_row(_("Branch:"), $_POST['customer_id'],
+ 'branch_id', null, false, true, true);
//if (($_SESSION['credit_items']->order_no == 0) ||
// ($order->customer_id != $_POST['customer_id']) ||
// $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
if (($order->customer_id != $_POST['customer_id']) ||
($order->Branch != $_POST['branch_id']))
- $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
-
+ {
+
+ $old_order = (PHP_VERSION<5) ? $order : clone( $order );
+ $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
+
+ $_POST['Location'] = $order->Location;
+ $_POST['deliver_to'] = $order->deliver_to;
+ $_POST['delivery_address'] = $order->delivery_address;
+ $_POST['phone'] = $order->phone;
+ $Ajax->activate('Location');
+ $Ajax->activate('deliver_to');
+ $Ajax->activate('phone');
+ $Ajax->activate('delivery_address');
+ // change prices if necessary
+ // what about discount in template case?
+ if ($old_order->customer_currency != $order->customer_currency) {
+ $change_prices = 1;
+ }
+ if ($old_order->sales_type != $order->sales_type) {
+ // || $old_order->default_discount!=$order->default_discount
+ $_POST['sales_type'] = $order->sales_type;
+ $Ajax->activate('sales_type_id');
+ $change_prices = 1;
+ }
+ unset($old_order);
+ }
set_global_customer($_POST['customer_id']);
if (!isset($_POST['ref']))
if (!isset($_POST['sales_type_id']))
$_POST['sales_type_id'] = $order->sales_type;
sales_types_list_row(_("Sales Type"), 'sales_type_id', $_POST['sales_type_id'], true);
+
+ if ($order->sales_type != $_POST['sales_type_id']) {
+ $myrow = get_sales_type($_POST['sales_type_id']);
+ $order->set_sales_type($myrow['id'], $myrow['sales_type'],
+ $myrow['tax_included'], $myrow['factor']);
+ $Ajax->activate('sales_type_id');
+ $change_prices = 1;
+ }
+
+ if ($change_prices != 0) {
+ foreach ($order->line_items as $line_no=>$item) {
+ $line = &$order->line_items[$line_no];
+ $line->price = get_price($line->stock_id, $order->customer_currency,
+ $order->sales_type, $order->price_factor, $order->document_date);
+ // $line->discount_percent = $order->default_discount;
+ }
+ $Ajax->activate('items_table');
+ }
label_row(_("Customer Discount:"), ($order->default_discount * 100) . "%");
echo "</table>";
date_row(_("Date:"), 'OrderDate');
-// if (!isset($_POST['tax_group_id']) || $_POST['tax_group_id'] == "")
-// $_POST['tax_group_id'] = $order->tax_group_id;
-// tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null, true);
shippers_list_row(_("Shipping Company:"), 'ShipperID', $order->ship_via);
echo "</table>";
global $table_style, $path_to_root;
display_heading($title);
+ div_start('items_table');
start_table("$table_style width=90%");
$th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
_("Price"), _("Discount %"), _("Total"),'');
amount_cell($line->discount_percent * 100);
amount_cell($line_total);
- edit_button_cell("Edit$line_no", _('Edit'));
- edit_button_cell("Delete$line_no", _('Delete'));
+ edit_button_cell("Edit$line_no", _('Edit'),
+ _('Edit document line'));
+ edit_button_cell("Delete$line_no", _('Delete'),
+ _('Remove line from document'));
end_row();
}
label_row(_("Credit Note Total"), $display_total, "colspan=6 align=right","class='amount'", 2);
end_table();
+ div_end();
}
//---------------------------------------------------------------------------------
function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
{
+ global $Ajax;
alt_table_row_color($rowcounter);
$id = find_submit('Edit');
if ($line_no!=-1 && $line_no == $id)
{
-
$_POST['stock_id'] = $order->line_items[$id]->stock_id;
$_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched, $_POST['stock_id'], $dec);
$_POST['price'] = price_format($order->line_items[$id]->price);
hidden('stock_id', $_POST['stock_id']);
label_cell($_POST['stock_id']);
label_cell($order->line_items[$id]->item_description, "nowrap");
+ $Ajax->activate('items_table');
}
else
{
stock_items_list_cells(null,'stock_id', null, false, true);
+ if(isset($_POST['_stock_id_update'])) {
+ $Ajax->activate('price');
+ $Ajax->activate('qty');
+ $Ajax->activate('units');
+ $Ajax->activate('line_total');
+ }
$item_info = get_item_edit_info($_POST['stock_id']);
$_POST['units'] = $item_info["units"];
-
$_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec);
$_POST['price'] = price_format(get_price($_POST['stock_id'], $order->customer_currency,
$order->sales_type, $order->price_factor, $order->document_date));
$_POST['Disc'] = percent_format($order->default_discount * 100);
}
-
qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
-// if ($order->trans_no!=0) {
-// amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
-// }
+
label_cell($_POST['units']);
amount_cells(null, 'price', null);
small_amount_cells(null, 'Disc', percent_format(0), null, null, user_percent_dec());
if ($id!=-1)
{
- edit_button_cell('UpdateItem', _("Update"));
- edit_button_cell('CancelItemChanges', _("Cancel"));
+ edit_button_cell('UpdateItem', _("Update"),
+ _('Confirm changes'));
+ edit_button_cell('CancelItemChanges', _("Cancel"),
+ _('Cancel changes'));
hidden('line_no', $line_no);
set_focus('qty');
}
else
{
- submit_cells('AddItem', _("Add Item"), "colspan=2");
+ submit_cells('AddItem', _("Add Item"), "colspan=2",
+ _('Add new item to document'), true);
}
end_row();
function credit_options_controls()
{
- global $table_style2;
+ global $table_style2, $Ajax;
echo "<br>";
+
+if (isset($_POST['_CreditType_update']))
+ $Ajax->activate('options');
+
+ div_start('options');
start_table("$table_style2");
credit_type_list_row(_("Credit Note Type"), 'CreditType', null, true);
if (!isset($_POST['Location']))
$_POST['Location'] = $_SESSION['Items']->Location;
locations_list_row(_("Items Returned to Location"), 'Location', $_POST['Location']);
-
}
else
{
textarea_row(_("Memo"), "CreditText", null, 51, 3);
echo "</table>";
+ div_end();
}
if(isset($_POST['_stock_id_update'])) {
$Ajax->activate('price');
$Ajax->activate('units');
+ $Ajax->activate('qty');
$Ajax->activate('line_total');
}
_('Cancel changes'));
hidden('LineNo', $line_no);
set_focus('qty');
- $Ajax->addFocus(true, 'qty');
}
else
{
check_cells(" " . _("show settled:"), 'showSettled', null);
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
set_global_customer($_POST['customer_id']);
$result = get_transactions();
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry'))
{
- display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
- end_page();
- exit;
+ $Ajax->activate('doc_tbl');
}
-
//------------------------------------------------------------------------------------------------
+div_start('doc_tbl');
+if (db_num_rows($result) == 0)
+{
+ display_note(_("The selected customer has no transactions for the given dates."), 1, 1);
+} else {
-start_table("$table_style width='80%'");
+ start_table("$table_style width='80%'");
if ($_POST['customer_id'] == reserved_words::get_all())
$th = array(_("Type"), _("Number"), _("Reference"), _("Order"), _("Date"), _("Due Date"),
//end of page full new headings if
}
//end of while loop
-
end_table(1);
if ($over_due)
display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
-
+}
+div_end();
end_page();
?>
cust_allocations_list_cells(null, 'filterType', $_POST['filterType'], true);
-submit_cells('Refresh Inquiry', _("Search"));
+submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
end_row();
end_table();
}
//------------------------------------------------------------------------------------------------
+
+div_start('totals_tbl');
if ($_POST['customer_id'] != "" && $_POST['customer_id'] != reserved_words::get_all())
{
$customer_record = get_customer_details($_POST['customer_id']);
display_customer_summary($customer_record);
echo "<br>";
}
-
+div_end();
//------------------------------------------------------------------------------------------------
$result = get_transactions();
-if (db_num_rows($result) == 0)
+//------------------------------------------------------------------------------------------------
+if(get_post('RefreshInquiry'))
{
- display_note(_("The selected customer has no transactions for the given dates."), 0, 2);
- end_page();
- exit;
+ $Ajax->activate('trans_tbl');
+ $Ajax->activate('totals_tbl');
}
-
//------------------------------------------------------------------------------------------------
-
print_hidden_script(10);
-start_table("$table_style width='80%'");
+
+div_start('trans_tbl');
+if (db_num_rows($result) == 0)
+{
+ display_note(_("The selected customer has no transactions for the given dates."), 0, 2);
+} else {
+
+ start_table("$table_style width='80%'");
$th = array(_("Type"), _("#"), _("Order"), _("Reference"), _("Date"), _("Due Date"),
_("Customer"), _("Branch"), _("Currency"), _("Debit"), _("Credit"), "", "","","");
-if ($_POST['customer_id'] != reserved_words::get_all()) {
- unset($th[6], $th[8]);
-}
+ if ($_POST['customer_id'] != reserved_words::get_all()) {
+ unset($th[6], $th[8]);
+ }
-table_header($th);
+ table_header($th);
-$j = 1;
-$k = 0; //row colour counter
-$over_due = false;
-while ($myrow = db_fetch($result))
-{
+ $j = 1;
+ $k = 0; //row colour counter
+ $over_due = false;
+ while ($myrow = db_fetch($result))
+ {
if ($myrow['OverDue'] == 1)
{
label_cell('');
end_row();
- $j++;
- if ($j == 12)
- {
- $j = 1;
- table_header($th);
- } //end of page full new headings if
-} //end of transaction while loop
-
-end_table(1);
+ $j++;
+ if ($j == 12)
+ {
+ $j = 1;
+ table_header($th);
+ } //end of page full new headings if
+ } //end of transaction while loop
-if ($over_due)
- display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+ end_table(1);
+ if ($over_due)
+ display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
+}
+div_end();
end_page();
?>
include_once($path_to_root . "/sales/includes/sales_db.inc");
include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
include_once($path_to_root . "/reporting/includes/reporting.inc");
-
$js = '';
if ($use_popup_windows) {
global $Ajax;
$Ajax->activate('items_table');
- $Ajax->addFocus(true, '_stock_id_edit');
set_focus('_stock_id_edit');
}
//--------------------------------------------------------------------------------
line_start_focus();
}
-if (isset($_POST['_customer_id_update']))
- set_focus('branch_id');
//--------------------------------------------------------------------------------
check_db_has_stock_items(_("There are no inventory items defined in the system."));