Ajax additions
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 23 Jun 2008 21:01:28 +0000 (21:01 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 23 Jun 2008 21:01:28 +0000 (21:01 +0000)
purchasing/allocations/supplier_allocate.php
purchasing/includes/ui/invoice_ui.inc
purchasing/po_receive_items.php
purchasing/supplier_credit.php
purchasing/supplier_credit_grns.php
purchasing/supplier_invoice.php
purchasing/supplier_invoice_grns.php
purchasing/supplier_trans_gl.php
sales/allocations/customer_allocate.php
sales/customer_credit_invoice.php

index 7ca1a76404a03903f4a49723d14bd10cf4370cb5..995b2735da945fc3e30bc1645cb38ebd0663bad2 100644 (file)
@@ -1,17 +1,15 @@
 <?php
 
 $path_to_root="../..";
-include($path_to_root . "/includes/ui/allocation_cart.inc");
 $page_security = 3;
 
+include($path_to_root . "/includes/ui/allocation_cart.inc");
 include_once($path_to_root . "/includes/session.inc");
-
 include_once($path_to_root . "/includes/date_functions.inc");
-
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/banking.inc");
-
 include_once($path_to_root . "/sales/includes/sales_db.inc");
+
 $js = "";
 if ($use_popup_windows)
        $js .= get_js_open_window(900, 500);
@@ -20,7 +18,6 @@ add_js_file('allocate.js');
 
 page(_("Allocate Supplier Payment or Credit Note"), false, false, "", $js);
 
-
 //--------------------------------------------------------------------------------
 
 function clear_allocations()
@@ -30,23 +27,20 @@ function clear_allocations()
                unset($_SESSION['alloc']->allocs);
                unset($_SESSION['alloc']);
        }
-
        session_register("alloc");
 }
-
 //--------------------------------------------------------------------------------
 
 function check_data()
 {
        $total_allocated = 0;
 
-       for ($counter=0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++)
+       for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++)
        {
-
                if (!check_num('amount' . $counter, 0))
                {
                        display_error(_("The entry for one or more amounts is invalid or negative."));
-                       set_focus('amount');
+                       set_focus('amount'.$counter);
                        return false;
                 }
 
@@ -115,7 +109,6 @@ if (isset($_POST['Process']))
                handle_process();
                $_POST['Cancel'] = 1;
        }
-       $Ajax->update('_page_body');
 }
 
 //--------------------------------------------------------------------------------
@@ -125,10 +118,6 @@ if (isset($_POST['Cancel']))
        clear_allocations();
        meta_forward($path_to_root . "/purchasing/allocations/supplier_allocation_main.php");
 }
-if (isset($_POST['UpdateDisplay']))
-{
-       $Ajax->update('_page_body');
-}
 //--------------------------------------------------------------------------------
 
 function get_allocations_for_transaction($type, $trans_no)
@@ -190,6 +179,7 @@ function edit_allocations_for_transaction($type, $trans_no)
 
     echo "<br>";
 
+       div_start('alloc_tbl');
     if (count($_SESSION['alloc']->allocs) > 0)
     {
                start_table($table_style);
@@ -210,20 +200,15 @@ function edit_allocations_for_transaction($type, $trans_no)
                amount_cell($alloc_item->amount);
                amount_cell($alloc_item->amount_allocated);
 
-           if (!isset($_POST['amount' . $counter]) || $_POST['amount' . $counter] == "")
-               $_POST['amount' . $counter] = price_format($alloc_item->current_allocated);
+               $_POST['amount' . $counter] = price_format($alloc_item->current_allocated);
            amount_cells(null, "amount" . $counter, price_format('amount' . $counter));
 
                $un_allocated = round($alloc_item->amount - $alloc_item->amount_allocated, 6);
-               //hidden("un_allocated" . $counter, $un_allocated);
                amount_cell($un_allocated);
                        label_cell("<a href='#' name=Alloc$counter onclick='allocate_all(this.name.substr(5));return true;'>"
                                         . _("All") . "</a>");
                        label_cell("<a href='#' name=DeAll$counter onclick='allocate_none(this.name.substr(5));return true;'>"
                                         . _("None") . "</a>".hidden("un_allocated" . $counter, $un_allocated, false));
-
-//                     label_cell("<a href='#' onclick='forms[0].amount$counter.value=forms[0].un_allocated$counter.value; return true;'>" . _("All") . "</a>");
-//                     label_cell("<a href='#' onclick='forms[0].amount$counter.value=0; return true;'>" . _("None") . "</a>");
                        end_row();
 
            $total_allocated += input_num('amount' . $counter);
@@ -245,22 +230,20 @@ function edit_allocations_for_transaction($type, $trans_no)
                end_table();
 
                hidden('TotalNumberOfAllocs', $counter);
-//             hidden('left_to_allocate', $left_to_allocate);
-       echo "<br><center>";
-               submit('UpdateDisplay', _("Update"), true, '', true);
-               echo "&nbsp;";
-               submit('Process', _("Process"), true, '', true);
-               echo "&nbsp;";
+
+       submit_center_first('UpdateDisplay', _("Refresh"), _('Start again allocation of selected amount'), true);
+               submit('Process', _("Process"), true, _('Process allocations'), true);
+               submit_center_last('Cancel', _("Back to Allocations"),
+                       _('Abandon allocations and return to selection of allocatable amounts'), true);
        }
        else
        {
        display_note(_("There are no unsettled transactions to allocate."), 0, 1);
-       echo "<center>";
+               submit_center('Cancel', _("Back to Allocations"), true,
+                       _('Abandon allocations and return to selection of allocatable amounts'), true);
     }
 
-       submit('Cancel', _("Back to Allocations"), true, '', true);
-       echo "</center><br><br>";
-
+       div_end();
        end_form();
 }
 
@@ -270,6 +253,14 @@ if (isset($_GET['trans_no']) && isset($_GET['trans_type']))
 {
        get_allocations_for_transaction($_GET['trans_type'], $_GET['trans_no']);
 }
+if(get_post('UpdateDisplay'))
+{
+       $trans_no = $_SESSION['alloc']->trans_no;
+       $type = $_SESSION['alloc']->type;
+       clear_allocations();
+       get_allocations_for_transaction($type, $trans_no);
+       $Ajax->activate('alloc_tbl');
+}
 
 if (isset($_SESSION['alloc']))
 {
index b583553f10ec3e66dc4704b03fa340a3fffb1cd9..6b3a0a1290991798f2d6e823dcaff380a37abb88 100644 (file)
@@ -178,12 +178,15 @@ function display_gl_items(&$supp_trans, $mode=0)
        echo "<tr><td align=center><span class='headingtext'>$heading</span></td>";
        if ($mode == 0)
        {
-       submit_cells('InvGL', _("Edit"), "align=right");
+       submit_cells('InvGL', _("Edit"), "align=right",
+                       _('Moves to additional costs posting page'), true);
        }
        echo "</tr></table>";
 
        echo "</td></tr><tr><td>"; // ouer table
 
+       start_form();
+       div_start('gl_items');
        echo "<table width=100% $table_style>";
 
        $dim = get_company_pref('use_dimension');
@@ -221,7 +224,8 @@ function display_gl_items(&$supp_trans, $mode=0)
                        label_cell($entered_gl_code->memo_);
 
                        if ($mode == 1)
-                               delete_link_cell(SID . "Delete=" . $entered_gl_code->Counter);
+                               edit_button_cell("Delete" . $entered_gl_code->Counter, _("Delete"),
+                                         _('Remove line from document'));
 
                        end_row();
 
@@ -245,7 +249,8 @@ function display_gl_items(&$supp_trans, $mode=0)
     echo "</td></tr>";
 
     end_table(); // outertable
-
+       end_form();
+       div_end();
        return $total_gl_value;
 }
 
@@ -281,17 +286,19 @@ function display_grn_items(&$supp_trans, $mode=0)
                $heading = _("Received Items Charged on this Invoice");
        else
                $heading = _("Received Items Credited on this Note");
-
        echo "<table width=100% >";
        echo "<tr><td align=center><span class='headingtext'>$heading</span></td>";
        if ($mode == 0)
        {
-               submit_cells('InvGRN', _("Edit"), "align=right");
+               submit_cells('InvGRN', _("Edit"), "align=right",
+                       _('Moves to GRN selection page'), true);
        }
        echo "</tr></table>";
 
        echo "</td></tr><tr><td>"; // outer table
 
+  div_start('grn_items');
+  start_form();
        echo "<table width=100% $table_style>";
        $th = array(_("Delivery Sequence #"), _("Item"), _("Description"),
                _("Quantity"), _("Price"), _("Line Value"));
@@ -316,7 +323,8 @@ function display_grn_items(&$supp_trans, $mode=0)
                        amount_cell( round($entered_grn->chg_price * abs($entered_grn->this_quantity_inv)), user_price_dec());
 
                        if ($mode == 1)
-                               delete_link_cell(SID . "Delete=" . $entered_grn->id);
+                               edit_button_cell("Delete" . $entered_grn->id, _("Delete"),
+                                         _('Remove item from document'));
 
                        end_row();
 
@@ -335,11 +343,11 @@ function display_grn_items(&$supp_trans, $mode=0)
        label_row(_("Total"), price_format($total_grn_value),
                "colspan=5 align=right", "nowrap align=right");
     echo "</table>";
-
+  end_form();
+  div_end();
     echo "</td></tr>";
 
     end_table(); // outertable
-
        return $total_grn_value;
 }
 
index 039355e4beab455676dbd7cfcc13d1670486f701..d79a5af7cc2c1a2c0f4705b4753d2cda2dfae094 100644 (file)
@@ -47,6 +47,8 @@ if ((!isset($_GET['PONumber']) || $_GET['PONumber'] == 0) && !isset($_SESSION['P
 function display_po_receive_items()
 {
        global $table_style;
+
+       div_start('grn_items');
     start_table("colspan=7 $table_style width=90%");
     $th = array(_("Item Code"), _("Description"), _("Ordered"), _("Units"), _("Received"),
        _("Outstanding"), _("This Delivery"), _("Price"), _("Total"));
@@ -101,6 +103,7 @@ function display_po_receive_items()
     label_row(_("Total value of items received"), $display_total, "colspan=8 align=right",
        "nowrap align=right");
     end_table();
+       div_end();
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -215,7 +218,7 @@ function can_process()
 
 function process_receive_po()
 {
-       global $path_to_root;
+       global $path_to_root, $Ajax;
 
        if (!can_process())
                return;
@@ -229,6 +232,7 @@ function process_receive_po()
                unset($_SESSION['PO']->line_items);
                unset($_SESSION['PO']);
                unset($_POST['ProcessGoodsReceived']);
+               $Ajax->activate('_page_body');
                exit;
        }
 
@@ -276,6 +280,7 @@ if (isset($_POST['Update']) || isset($_POST['ProcessGoodsReceived']))
                        $_SESSION['PO']->line_items[$line->line_no]->item_description = $_POST[$line->stock_id . "Desc"];
                }
        }
+       $Ajax->activate('grn_items');
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -293,11 +298,9 @@ display_grn_summary($_SESSION['PO'], true);
 display_heading(_("Items to Receive"));
 display_po_receive_items();
 
-echo "<br><center>";
-submit('Update', _("Update"));
-echo "&nbsp";
-submit('ProcessGoodsReceived', _("Process Receive Items"));
-echo "</center>";
+echo '<br>';
+submit_center_first('Update', _("Update"), '', true);
+submit_center_last('ProcessGoodsReceived', _("Process Receive Items"), _("Clear all GL entry fields"), true);
 
 end_form();
 
index c16211be0771282ba03f4710d367cc7c96739e19..8ae4e5741bbffb20d441855a65edb64e5e5676fd 100644 (file)
@@ -168,7 +168,7 @@ echo "</td></tr>";
 
 end_table(1); // outer table
 
-submit_center('PostCreditNote', _("Enter Credit Note"));
+submit_center('PostCreditNote', _("Enter Credit Note"), true, '', true);
 echo "<br><br>";
 
 end_form();
index cb50c66f530acf47a44b4a55a36ea4988a53ba26..632255ed61945bcbab913f0d05b082333790f0d6 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 
 $page_security = 5;
-
 $path_to_root="..";
+
 include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
 include_once($path_to_root . "/includes/session.inc");
-
 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
+
 $js = "";
 if ($use_date_picker)
        $js .= get_js_date_picker();
@@ -71,16 +71,17 @@ if (isset($_POST['AddGRNToTrans']))
 }
 
 //-----------------------------------------------------------------------------------------
-
-if (isset($_GET['Delete']))
+$id = find_submit('Delete');
+if ($id != -1)
 {
-       $_SESSION['supp_trans']->remove_grn_from_trans($_GET['Delete']);
+       $_SESSION['supp_trans']->remove_grn_from_trans($id);
+       $Ajax->activate('grn_items');
+       $Ajax->activate('grn_table');
 }
 
 //-----------------------------------------------------------------------------------------
 
 display_grn_items($_SESSION['supp_trans'], 1);
-
 echo "<br>";
 
 hyperlink_no_params("$path_to_root/purchasing/supplier_credit.php", _("Return to Credit Note Entry"));
@@ -104,6 +105,7 @@ if (db_num_rows($result) == 0)
 /*Set up a table to show the GRN items outstanding for selection */
 start_form(false, true);
 
+div_start('grn_table');
 start_table("$table_style width=95%");
 $th = array(_("Delivery"), _("Sequence #"), _("Order"), _("Item Code"), _("Description"),
        _("Delivered"), _("Total Qty Received"), _("Qty Already Invoiced"),
@@ -128,7 +130,7 @@ while ($myrow = db_fetch($result))
                alt_table_row_color($k);
 
                label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
-               submit_cells('grn_item_id', $myrow["id"]);
+               submit_cells('grn_item_id'.$myrow["id"], $myrow["id"], '', '', true);
                label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
         label_cell($myrow["item_code"]);
         label_cell($myrow["description"]);
@@ -150,13 +152,27 @@ while ($myrow = db_fetch($result))
 }
 
 end_table();
+div_end();
 
 //-----------------------------------------------------------------------------------------
+$id = find_submit('grn_item_id');
+if ($id || get_post('AddGRNToTrans'))
+{
+       $Ajax->activate('grn_selector');
+}
+if (get_post('AddGRNToTrans')) 
+{
+       $Ajax->activate('grn_table');
+       $Ajax->activate('grn_items');
+}
+
 
-if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
+div_start('grn_selector');
+$id = find_submit('grn_item_id');
+if ($id != -1)
 {
 
-       $myrow = get_grn_item_detail($_POST['grn_item_id']);
+       $myrow = get_grn_item_detail($id);
 
        echo "<br>";
        display_heading2(_("Delivery Item Selected For Adding To A Supplier Credit Note"));
@@ -166,7 +182,7 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
        table_header($th);
 
        start_row();
-       label_cell($_POST['grn_item_id']);
+       label_cell($id);
     label_cell($myrow['item_code'] . " " . $myrow['description']);
     $dec = get_qty_dec($myrow['item_code']);
     qty_cell($myrow["quantity_inv"], false, $dec);
@@ -176,9 +192,9 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
     end_row();
        end_table(1);
 
-       submit_center('AddGRNToTrans', _("Add to Credit Note"));
+       submit_center('AddGRNToTrans', _("Add to Credit Note"), true, '', true);
 
-       hidden('GRNNumber', $_POST['grn_item_id']);
+       hidden('GRNNumber', $id);
        hidden('item_code', $myrow['item_code']);;
        hidden('item_description', $myrow['description']);
        hidden('qty_recd', $myrow['qty_recd']);
@@ -188,7 +204,9 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
 
        hidden('po_detail_item', $myrow['po_detail_item']);
 }
+div_end();
 
 end_form();
-end_page();
+echo '<br>';
+end_page(false, true);
 ?>
index 915ec27c1b3611157927ea6b1c6f5f8c32e5da32..64a0850f3c531c2125c267afde6f81e16f60e8bc 100644 (file)
@@ -174,7 +174,7 @@ echo "</td></tr>";
 end_table(); // outer table
 
 echo "<br>";
-submit_center('PostInvoice', _("Enter Invoice"));
+submit_center('PostInvoice', _("Enter Invoice"), true, '', true);
 echo "<br>";
 
 end_form();
index 0adbe8e996ec5403c4aee4881b7298afbbdbc4fe..b6d07411c175934a8278686e11dea796f9832b1b 100644 (file)
@@ -2,10 +2,9 @@
 
 $page_security = 5;
 $path_to_root="..";
-include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
 
+include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
 include_once($path_to_root . "/includes/session.inc");
-
 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
 
@@ -14,7 +13,6 @@ if ($use_date_picker)
        $js .= get_js_date_picker();
 page(_("Select Received Items to Add"), false, false, "", $js);
 
-
 if (!isset($_SESSION['supp_trans']))
 {
        display_note("To enter supplier transactions the supplier must first be selected from the supplier selection screen, then the link to enter a supplier credit note must be clicked on.", 1, 0);;
@@ -86,11 +84,11 @@ if (isset($_POST['AddGRNToTrans']))
        {
        if (input_num('this_quantity_inv') >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv']))
        {
-               $complete = True;
+               $complete = true;
        }
        else
        {
-               $complete = False;
+               $complete = false;
        }
 
                $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'],
@@ -102,17 +100,18 @@ if (isset($_POST['AddGRNToTrans']))
 }
 
 //-----------------------------------------------------------------------------------------
-
-if (isset($_GET['Delete']))
+$id = find_submit('Delete');
+if ($id != -1)
 {
-       $_SESSION['supp_trans']->remove_grn_from_trans($_GET['Delete']);
+       $_SESSION['supp_trans']->remove_grn_from_trans($id);
+       $Ajax->activate('grn_items');
+       $Ajax->activate('grn_table');
 }
 
 //-----------------------------------------------------------------------------------------
-
 display_grn_items($_SESSION['supp_trans'], 1);
-
 echo "<br>";
+
 hyperlink_no_params("$path_to_root/purchasing/supplier_invoice.php", _("Back to Supplier Invoice Entry"));
 echo "<hr>";
 
@@ -135,7 +134,7 @@ function display_grn_items_for_selection()
     start_form(false, true);
 
     display_heading2(_("Items Received Yet to be Invoiced"));
-
+       div_start('grn_table');
     start_table("$table_style colspan=7 width=95%");
     $th = array(_("Delivery"), _("Sequence #"), _("P.O."), _("Item"), _("Description"),
        _("Received On"), _("Quantity Received"), _("Quantity Invoiced"),
@@ -145,24 +144,23 @@ function display_grn_items_for_selection()
 
     while ($myrow = db_fetch($result))
     {
-
-       $grn_already_on_invoice = False;
+               $grn_already_on_invoice = false;
 
        foreach ($_SESSION['supp_trans']->grn_items as $entered_grn)
        {
                if ($entered_grn->id == $myrow["id"])
                {
-                       $grn_already_on_invoice = True;
+                       $grn_already_on_invoice = true;
                }
        }
-       if ($grn_already_on_invoice == False)
+       if ($grn_already_on_invoice == false)
        {
 
                        alt_table_row_color($k);
 
                label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
                //text_cells(null, 'grn_item_id', $myrow["id"]);
-               submit_cells('grn_item_id', $myrow["id"]);
+               submit_cells('grn_item_id'.$myrow["id"], $myrow["id"], '', '', true);
                label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
             label_cell($myrow["item_code"]);
             label_cell($myrow["description"]);
@@ -186,18 +184,31 @@ function display_grn_items_for_selection()
     }
 
     end_table();
+       div_end();
 }
 
 //-----------------------------------------------------------------------------------------
+if (find_submit('grn_item_id') || get_post('AddGRNToTrans'))
+{
+       $Ajax->activate('grn_selector');
+}
+if (get_post('AddGRNToTrans')) 
+{
+       $Ajax->activate('grn_table');
+       $Ajax->activate('grn_items');
+}
 
 display_grn_items_for_selection();
 
 //-----------------------------------------------------------------------------------------
 
-if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
+div_start('grn_selector');
+
+$id = find_submit('grn_item_id');
+if ($id != -1)
 {
 
-       $myrow = get_grn_item_detail($_POST['grn_item_id']);
+       $myrow = get_grn_item_detail($id);
 
        echo "<br>";
        display_heading2(_("Delivery Item Selected For Adding To A Supplier Invoice"));
@@ -207,7 +218,7 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
        table_header($th);
 
        start_row();
-       label_cell($_POST['grn_item_id']);
+       label_cell($id);
        label_cell($myrow['item_code']);
        label_cell($myrow['description']);
        $dec = get_qty_dec($myrow['item_code']);
@@ -218,9 +229,9 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
        end_row();
        end_table(1);;
 
-       submit_center('AddGRNToTrans', _("Add to Invoice"));
+       submit_center('AddGRNToTrans', _("Add to Invoice"), true, '', true);
 
-       hidden('GRNNumber', $_POST['grn_item_id']);
+       hidden('GRNNumber', $id);
        hidden('item_code', $myrow['item_code']);
        hidden('item_description', $myrow['description']);;
        hidden('qty_recd', $myrow['qty_recd']);
@@ -230,9 +241,12 @@ if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
 
        hidden('po_detail_item', $myrow['po_detail_item']);
 }
+div_end();
 
 //----------------------------------------------------------------------------------------
 
 end_form();
-end_page();
+echo '<br>';
+end_page(false, true);
+
 ?>
index b2b827fee00d90de7efd34df97af26b89e4628c2..b652a1a65fd62473c0585c7f91bd91547456acbd 100644 (file)
@@ -21,27 +21,32 @@ if (!isset($_SESSION['supp_trans']))
 }
 
 //------------------------------------------------------------------------------------------------
-
 function clear_fields()
 {
+       global $Ajax;
+       
        unset($_POST['gl_code']);
        unset($_POST['dimension_id']);
        unset($_POST['dimension2_id']);
        unset($_POST['amount']);
        unset($_POST['memo_']);
-       unset($_POST['AcctSelection']);
        unset($_POST['AddGLCodeToTrans']);
+       $Ajax->activate('gl_ctrls');
+       set_focus('gl_code');
 }
-
 //------------------------------------------------------------------------------------------------
+//     GL postings are often entered in the same form to two accounts
+//  so fileds are cleared only on user demand.
+//
+if (isset($_POST['ClearFields']))
+{
+       clear_fields();
+}
 
 if (isset($_POST['AddGLCodeToTrans'])){
 
+       $Ajax->activate('gl_items');
        $input_error = false;
-       if (!isset($_POST['gl_code']))
-       {
-               $_POST['gl_code'] = $_POST['AcctSelection'];
-       }
 
        $sql = "SELECT account_code, account_name FROM ".TB_PREF."chart_master WHERE account_code='" . $_POST['gl_code'] . "'";
        $result = db_query($sql,"get account information");
@@ -68,16 +73,18 @@ if (isset($_POST['AddGLCodeToTrans'])){
                $_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name,
                        $_POST['dimension_id'], $_POST['dimension2_id'], 
                        input_num('amount'), $_POST['memo_']);
-               clear_fields();
+               set_focus('gl_code');
        }
 }
 
 //------------------------------------------------------------------------------------------------
 
-if (isset($_GET['Delete']))
+$id = find_submit('Delete');
+if ($id != -1)
 {
-       $_SESSION['supp_trans']->remove_gl_codes_from_trans($_GET['Delete']);
+       $_SESSION['supp_trans']->remove_gl_codes_from_trans($id);
        clear_fields();
+       $Ajax->activate('gl_items');
 }
 
 //------------------------------------------------------------------------------------------------
@@ -106,11 +113,12 @@ start_form(false, true);
 
 display_heading2(_("Enter a GL Line"));
 
+div_start('gl_ctrls');
 start_table($table_style2);
 
 $accs = get_supplier_accounts($_SESSION['supp_trans']->supplier_id);
-$_POST['AcctSelection'] = $accs['purchase_account'];
-gl_all_accounts_list_row(_("GL Account Selection:"), 'AcctSelection', $_POST['AcctSelection']);
+$_POST['gl_code'] = $accs['purchase_account'];
+gl_all_accounts_list_row(_("GL Account Selection:"), 'gl_code', null);
 $dim = get_company_pref('use_dimension');
 if ($dim >= 1)
        dimensions_list_row(_("Dimension")." 1", 'dimension_id', null, true, " ", false, 1);
@@ -124,13 +132,15 @@ amount_row( _("Amount:"), 'amount');
 
 textarea_row(_("Memo:"), "memo_",  null, 40, 2);
 
-end_table();;
-
-submit_center('AddGLCodeToTrans', _("Add GL Line"));
-
+end_table();
+div_end();
+echo '<br>';
+submit_center_first('AddGLCodeToTrans', _("Add GL Line"), '', true);
+submit_center_last('ClearFields', _('Reset'), _("Clear all GL entry fields"), true);
 end_form();
 
 //------------------------------------------------------------------------------------------------
+echo '<br>';
+end_page(false, true);
 
-end_page();
 ?>
index a37847201cd270783c4b7b50f67789ab306577a5..d92cf39a1c562568a29c5a94aebe3ddf8fd4af76 100644 (file)
@@ -38,9 +38,9 @@ function check_data()
        for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++)
        {
 
-               if (!check_num('amount' . $counter))
+               if (!check_num('amount' . $counter, 0))
                {
-                       display_error(_("The entry for one or more amounts is invalid."));
+                       display_error(_("The entry for one or more amounts is invalid or negative."));
                        set_focus('amount'.$counter);
                        return false;
                }
@@ -109,7 +109,6 @@ function handle_process()
 
        clear_allocations();
 }
-
 //--------------------------------------------------------------------------------
 
 if (isset($_POST['Process']))
@@ -120,16 +119,13 @@ if (isset($_POST['Process']))
                $_POST['Cancel'] = 1;
        }
 }
-
 //--------------------------------------------------------------------------------
 
 if (isset($_POST['Cancel']))
 {
        clear_allocations();
        meta_forward($path_to_root . "/sales/allocations/customer_allocation_main.php");
-       exit;
 }
-
 //--------------------------------------------------------------------------------
 
 function get_allocations_for_transaction($type, $trans_no)
@@ -155,7 +151,6 @@ function get_allocations_for_transaction($type, $trans_no)
                        0); // this allocation
        }
 
-
        /* Now get trans that might have previously been allocated to by this trans
        NB existing entries where still some of the trans outstanding entered from
        above logic will be overwritten with the prev alloc detail below */
@@ -168,9 +163,7 @@ function get_allocations_for_transaction($type, $trans_no)
                        sql2date($myrow["tran_date"]), sql2date($myrow["due_date"]),
                        $myrow["Total"], $myrow["alloc"] - $myrow["amt"], $myrow["amt"]);
        }
-
 }
-
 //--------------------------------------------------------------------------------
 
 function edit_allocations_for_transaction($type, $trans_no)
@@ -187,7 +180,7 @@ function edit_allocations_for_transaction($type, $trans_no)
     echo "<br>";
 
        start_form(false, true);
-
+       div_start('alloc_tbl');
     if (count($_SESSION['alloc']->allocs) > 0)
     {
                start_table($table_style);
@@ -210,18 +203,14 @@ function edit_allocations_for_transaction($type, $trans_no)
                amount_cell($allocn_item->amount);
                        amount_cell($allocn_item->amount_allocated);
 
-           if (!check_num('amount' . $counter))
-               $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
-           amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]);
+           $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
+           amount_cells(null, 'amount' . $counter, price_format('amount' . $counter));
 
                $un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6);
-               //hidden("un_allocated" . $counter, $un_allocated);
                amount_cell($un_allocated);
 
                        label_cell("<a href='#' name='Alloc$counter' onclick='allocate_all(this.name.substr(5));return true;'>"
                                         . _("All") . "</a>");
-                       //label_cell("<a href='#' name='DeAll$counter' onclick='allocate_none(this.name.substr(5));return true;'>"
-                       //               . _("None") . "</a>");
                        label_cell("<a href='#' name='DeAll$counter' onclick='allocate_none(this.name.substr(5));return true;'>"
                                         . _("None") . "</a>".hidden("un_allocated" . $counter, $un_allocated, false));
                        end_row();
@@ -246,17 +235,18 @@ function edit_allocations_for_transaction($type, $trans_no)
         end_table(1);
 
                hidden('TotalNumberOfAllocs', $counter);
-//             hidden('left_to_allocate', $left_to_allocate);
-               submit_center_first('UpdateDisplay', _("Update"));
-               submit('Process', _("Process"));
-               submit_center_last('Cancel', _("Back to Allocations"));
+               submit_center_first('UpdateDisplay', _("Refresh"), _('Start again allocation of selected amount'), true);
+               submit('Process', _("Process"), true, _('Process allocations'), true);
+               submit_center_last('Cancel', _("Back to Allocations"),_('Abandon allocations and return to selection of allocatable amounts'), true);
        }
        else
        {
        display_note(_("There are no unsettled transactions to allocate."), 0, 1);
-               submit_center('Cancel', _("Back to Allocations"));
+               
+               submit_center('Cancel', _("Back to Allocations"), true,
+                       _('Abandon allocations and return to selection of allocatable amounts'), true);
     }
-
+       div_end();
        end_form();
 }
 
@@ -266,6 +256,14 @@ if (isset($_GET['trans_no']) && isset($_GET['trans_type']))
 {
        get_allocations_for_transaction($_GET['trans_type'], $_GET['trans_no']);
 }
+if(get_post('UpdateDisplay'))
+{
+       $trans_no = $_SESSION['alloc']->trans_no;
+       $type = $_SESSION['alloc']->type;
+       clear_allocations();
+       get_allocations_for_transaction($type, $trans_no);
+       $Ajax->activate('alloc_tbl');
+}
 
 if (isset($_SESSION['alloc']))
 {
index 2e8bb162b0c0ca4ce8ed9a7d6c0095166a2b2318..8d5a104a459e80029a88d176b21ea26f38814645 100644 (file)
@@ -262,6 +262,7 @@ function display_credit_items()
 
        end_table(1); // outer table
 
+       div_start('credit_items');
     start_table("$table_style width=80%");
     $th = array(_("Item Code"), _("Item Description"), _("Invoiced Quantity"), _("Units"),
        _("Credit Quantity"), _("Price"), _("Discount %"), _("Total"));
@@ -283,9 +284,8 @@ function display_credit_items()
                $dec = get_qty_dec($ln_itm->stock_id);
        qty_cell($ln_itm->quantity, false, $dec);
        label_cell($ln_itm->units);
-
-               amount_cells(null, 'Line'.$line_no, number_format2($ln_itm->qty_dispatched, $dec));
-
+               amount_cells(null, 'Line'.$line_no, number_format2($ln_itm->qty_dispatched, $dec),
+                       null, null, $dec);
        $line_total =($ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent));
 
        amount_cell($ln_itm->price);
@@ -317,53 +317,56 @@ function display_credit_items()
     label_row(_("Credit Note Total"), $display_total, "colspan=7 align=right", "align=right");
 
     end_table();
+       div_end();
 }
 
 //-----------------------------------------------------------------------------
-
 function display_credit_options()
 {
-       global $table_style2;
-
-    echo "<br>";
-    start_table($table_style2);
-
-    echo "<tr><td>" . _("Credit Note Type") . "</td>";
-    echo "<td><select name='CreditType' onchange='this.form.submit();'>";
-    if (!isset($_POST['CreditType']) || $_POST['CreditType'] == "Return") {
-       echo "<option value='WriteOff'>" . _("Items Written Off") . "</option>";
-       echo "<option selected value='Return'>" . _("Items Returned to Inventory Location") . "</option>";
-    } else {
-       echo "<option selected value='WriteOff'>" . _("Items Written Off") . "</option>";
-       echo "<option value='Return'>" . _("Items Returned to Inventory Location") . "</option>";
-    }
-    echo "</select>";
-    echo"</td></tr>";
+       global $table_style2, $Ajax;
+       echo "<br>";
 
-    if (!isset($_POST['CreditType']) || $_POST['CreditType'] == "Return") {
+if (isset($_POST['_CreditType_update']))
+       $Ajax->activate('options');
 
-       /*if the credit note is a return of goods then need to know which location to receive them into */
-       if (!isset($_POST['Location'])) {
-               $_POST['Location'] = $_SESSION['Items']->Location;
-       }
+ div_start('options');
+       start_table("$table_style2");
 
-       locations_list_row(_("Items Returned to Inventory Location"), 'Location', $_POST['Location']);
-    } else {   /* the goods are to be written off to somewhere */
-       gl_all_accounts_list_row(_("Write Off the Cost of the Items to"), 'WriteOffGLCode', $_POST['WriteOffGLCode']);
-    }
-    textarea_row(_("Memo"), "CreditText", null, 45, 3);
-    end_table();
+       credit_type_list_row(_("Credit Note Type"), 'CreditType', null, true);
+
+       if ($_POST['CreditType'] == "Return")
+       {
+
+               /*if the credit note is a return of goods then need to know which location to receive them into */
+               if (!isset($_POST['Location']))
+                       $_POST['Location'] = $_SESSION['Items']->Location;
+               locations_list_row(_("Items Returned to Location"), 'Location', $_POST['Location']);
+       }
+       else
+       {
+               /* the goods are to be written off to somewhere */
+               gl_all_accounts_list_row(_("Write off the cost of the items to"), 'WriteOffGLCode', null);
+       }
+
+       textarea_row(_("Memo"), "CreditText", null, 51, 3);
+       echo "</table>";
+ div_end();
 }
 
+//-----------------------------------------------------------------------------
+if (get_post('Update')) 
+{
+       $Ajax->activate('credit_items');
+}
 //-----------------------------------------------------------------------------
 
 display_credit_items();
 display_credit_options();
 
 echo "<br><center>";
-submit('Update', _("Update"));
+submit('Update', _("Update"), true, _('Update credit value for quantities entered'), true);
 echo "&nbsp";
-submit('ProcessCredit', _("Process Credit Note"));
+submit('ProcessCredit', _("Process Credit Note"), true, '', true);
 echo "</center>";
 
 end_form();