Clone record/short names added
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 3 Aug 2009 21:23:49 +0000 (21:23 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 3 Aug 2009 21:23:49 +0000 (21:23 +0000)
inventory/manage/item_categories.php
inventory/manage/items.php
purchasing/manage/suppliers.php
sales/manage/customer_branches.php
sales/manage/customers.php

index cff22f4739f0f94b0699e1d19fe39e67f62ec8b1..076de0c59cfef2c8f47a77ca4837cd3cce3001f0 100644 (file)
@@ -160,7 +160,7 @@ if ($selected_id != -1)
        } 
        hidden('selected_id', $selected_id);
        hidden('category_id');
-} else {
+} else if ($Mode != 'CLONE') {
                $_POST['long_description'] = '';
                $_POST['description'] = '';
                $_POST['no_sale']  = 0;
@@ -194,7 +194,7 @@ stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, true);
 
 stock_units_list_row(_("Units of Measure:"), 'units', null);
 
-check_row(_("Exclude from sales:"), 'no_sale', $_POST['no_sale']);
+check_row(_("Exclude from sales:"), 'no_sale');
 
 gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
 
@@ -231,7 +231,7 @@ if ($dim < 2)
 
 end_table(1);
 div_end();
-submit_add_or_update_center($selected_id == -1, '', 'both');
+submit_add_or_update_center($selected_id == -1, '', 'both', true);
 
 end_form();
 
index d7f806149222d1a82b9c84cca54e84aea9c1175b..b5f6534bd5373e1bdaddf5f384ece812b1c8b3ee 100644 (file)
@@ -22,7 +22,7 @@ include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
 $user_comp = user_company();
-$new_item = get_post('stock_id')=='' || get_post('cancel'); 
+$new_item = get_post('stock_id')=='' || get_post('cancel') || get_post('clone')
 //------------------------------------------------------------------------------------
 
 if (isset($_GET['stock_id']))
@@ -97,7 +97,6 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
  /* EOF Add Image upload for New Item  - by Ori */
 }
 
-
 check_db_has_stock_categories(_("There are no item categories defined in the system. At least one item category is required to add a item."));
 
 check_db_has_item_tax_types(_("There are no item tax types defined in the system. At least one item tax type is required to add a item."));
@@ -200,6 +199,13 @@ if (isset($_POST['addupdate']))
        }
 }
 
+if (get_post('clone')) {
+       unset($_POST['stock_id']);
+       unset($_POST['inactive']);
+       set_focus('NewStockID');
+       $Ajax->activate('_page_body');
+}
+
 //------------------------------------------------------------------------------------
 
 function check_usage($stock_id, $dispmsg=true)
@@ -285,7 +291,7 @@ if (db_has_stock_items())
        start_row();
     stock_items_list_cells(_("Select an item:"), 'stock_id', null,
          _('New item'), true, check_value('show_inactive'));
-       $new_item = get_post('stock_id')==''; 
+       $new_item = get_post('stock_id')=='';
        check_cells(_("Show inactive:"), 'show_inactive', null, true);
        end_row();
        end_table();
@@ -304,7 +310,6 @@ table_section(1);
 table_section_title(_("Item"));
 
 //------------------------------------------------------------------------------------
-
 if ($new_item) 
 {
        text_row(_("Item Code:"), 'NewStockID', null, 21, 20);
@@ -432,9 +437,9 @@ else
 
 label_row("&nbsp;", $stock_img_link);
 if ($check_remove_image)
-       check_row(_("Delete Image:"), 'del_image', $_POST['del_image']);
+       check_row(_("Delete Image:"), 'del_image');
        
-check_row(_("Exclude from sales:"), 'no_sale', $_POST['no_sale']);
+check_row(_("Exclude from sales:"), 'no_sale');
 
 record_status_list_row(_("Item status:"), 'inactive');
 end_outer_table(1);
@@ -450,6 +455,7 @@ else
                @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', get_post('stock_id'), 
                _("Select this items and return to document entry."), 'default');
+       submit('clone', _("Clone This Item"), true, '', true);
        submit('delete', _("Delete This Item"), true, '', true);
        submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel');
 }
index 809ebb3cab29ecedf8d35e120f12f54b0e410501..be2f1a7dc749f6e9ccfdf7908130e8429bbd22b8 100644 (file)
@@ -45,6 +45,13 @@ if (isset($_POST['submit']))
                set_focus('supp_name');
        }
 
+       if (strlen($_POST['supp_ref']) == 0 || $_POST['supp_ref'] == "") 
+       {
+               $input_error = 1;
+               display_error(_("The supplier short name must be entered."));
+               set_focus('supp_ref');
+       }
+
        if ($input_error !=1 )
        {
 
@@ -52,6 +59,7 @@ if (isset($_POST['submit']))
                {
 
                        $sql = "UPDATE ".TB_PREF."suppliers SET supp_name=".db_escape($_POST['supp_name']) . ",
+                               supp_ref=".db_escape($_POST['supp_ref']) . ",
                 address=".db_escape($_POST['address']) . ",
                 supp_address=".db_escape($_POST['supp_address']) . ",
                 phone=".db_escape($_POST['phone']) . ",
@@ -83,10 +91,11 @@ if (isset($_POST['submit']))
                else 
                {
 
-                       $sql = "INSERT INTO ".TB_PREF."suppliers (supp_name, address, supp_address, phone, fax, gst_no, email, website,
+                       $sql = "INSERT INTO ".TB_PREF."suppliers (supp_name, supp_ref, address, supp_address, phone, fax, gst_no, email, website,
                                contact, supp_account_no, bank_account, credit_limit, dimension_id, dimension2_id, curr_code,
                                payment_terms, payable_account, purchase_account, payment_discount_account, notes, tax_group_id)
                                VALUES (".db_escape($_POST['supp_name']). ", "
+                               .db_escape($_POST['supp_ref']). ", "
                                .db_escape($_POST['address']) . ", "
                                .db_escape($_POST['supp_address']) . ", "
                                .db_escape($_POST['phone']). ", "
@@ -189,6 +198,7 @@ if (!$new_supplier)
        $myrow = get_supplier($_POST['supplier_id']);
 
        $_POST['supp_name'] = $myrow["supp_name"];
+       $_POST['supp_ref'] = $myrow["supp_ref"];
        $_POST['address']  = $myrow["address"];
        $_POST['supp_address']  = $myrow["supp_address"];
        $_POST['phone']  = $myrow["phone"];
@@ -213,7 +223,7 @@ if (!$new_supplier)
 } 
 else 
 {
-       $_POST['supp_name'] = $_POST['address'] = $_POST['supp_address'] = $_POST['tax_group_id']  = 
+       $_POST['supp_name'] = $_POST['supp_ref'] = $_POST['address'] = $_POST['supp_address'] = $_POST['tax_group_id']  = 
                $_POST['website'] = $_POST['supp_account_no'] = $_POST['notes'] = '';
        $_POST['dimension_id'] = 0;
        $_POST['dimension2_id'] = 0;
@@ -233,6 +243,7 @@ else
 table_section_title(_("Name and Contact"));
 
 text_row(_("Supplier Name:"), 'supp_name', null, 42, 40);
+text_row(_("Supplier Short Name:"), 'supp_ref', null, 30, 30);
 text_row(_("Contact Person:"), 'contact', null, 42, 40);
 
 text_row(_("Phone Number:"), 'phone', null, 42, 40);
@@ -297,7 +308,7 @@ div_start('controls');
 if (!$new_supplier) 
 {
        submit_center_first('submit', _("Update Supplier"), 
-         _('Update supplier data'), true);
+         _('Update supplier data'), @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry."));
        submit_center_last('delete', _("Delete Supplier"), 
          _('Delete supplier data if have been never used'), true);
index e2a73af9007a1fd00426206f04598b0eade9b065..1147dcf36fdcb40d14b9600ad30ed59557a7d932 100644 (file)
@@ -62,6 +62,13 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                set_focus('br_name');
        }
 
+       if (strlen($_POST['br_ref']) == 0)
+       {
+               $input_error = 1;
+               display_error(_("The Branch short name cannot be empty."));
+               set_focus('br_ref');
+       }
+
        if ($input_error != 1)
        {
 
@@ -70,6 +77,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                        /*SelectedBranch could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the     delete code below*/
 
                        $sql = "UPDATE ".TB_PREF."cust_branch SET br_name = " . db_escape($_POST['br_name']) . ",
+                               branch_ref = " . db_escape($_POST['br_ref']) . ",
                                br_address = ".db_escape($_POST['br_address']). ",
                phone=".db_escape($_POST['phone']). ",
                fax=".db_escape($_POST['fax']).",
@@ -95,11 +103,12 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                else
                {
                        /*Selected branch is null cos no item selected on first time round so must be adding a  record must be submitting new entries in the new Customer Branches form */
-                       $sql = "INSERT INTO ".TB_PREF."cust_branch (debtor_no, br_name, br_address,
+                       $sql = "INSERT INTO ".TB_PREF."cust_branch (debtor_no, br_name, branch_ref, br_address,
                                salesman, phone, fax,
                                contact_name, area, email, tax_group_id, sales_account, receivables_account, payment_discount_account, sales_discount_account, default_location,
                                br_post_address, disable_trans, group_no, default_ship_via)
                                VALUES (".db_escape($_POST['customer_id']). ",".db_escape($_POST['br_name']) . ", "
+                                       .db_escape($_POST['br_ref']) . ", "
                                        .db_escape($_POST['br_address']) . ", ".db_escape($_POST['salesman']) . ", "
                                        .db_escape($_POST['phone']) . ", ".db_escape($_POST['fax']) . ","
                                        .db_escape($_POST['contact_name']) . ", ".db_escape($_POST['area']) . ","
@@ -116,11 +125,14 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
 
                        $note = _('New customer branch has been added');
                }
-
                //run the sql from either of the above possibilites
                db_query($sql,"The branch record could not be inserted or updated");
                display_notification($note);
                $Mode = 'RESET';
+               if (@$_REQUEST['popup']) {
+                       set_focus("Select".($_POST['branch_code'] == -1 
+                               ? db_insert_id(): $_POST['branch_code']));
+               }
        }
 
 }
@@ -193,7 +205,7 @@ if ($num_branches)
 
        start_table("$table_style width=60%");
 
-       $th = array(_("Name"), _("Contact"), _("Sales Person"), _("Area"),
+       $th = array(_("Short Name"), _("Name"), _("Contact"), _("Sales Person"), _("Area"),
                _("Phone No"), _("Fax No"), _("E-mail"), _("Tax Group"), "", "");
        inactive_control_column($th);
        if (@$_REQUEST['popup']) $th[] = '';
@@ -203,6 +215,7 @@ if ($num_branches)
        while ($myrow = db_fetch($result))
        {
                start_row();
+               label_cell($myrow["branch_ref"]);
                label_cell($myrow["br_name"]);
                label_cell($myrow["contact_name"]);
                label_cell($myrow["salesman_name"]);
@@ -244,6 +257,7 @@ if ($selected_id != -1)
                set_focus('br_name');
        $_POST['branch_code'] = $myrow["branch_code"];
            $_POST['br_name']  = $myrow["br_name"];
+           $_POST['br_ref']  = $myrow["branch_ref"];
            $_POST['br_address']  = $myrow["br_address"];
            $_POST['br_post_address']  = $myrow["br_post_address"];
            $_POST['contact_name'] = $myrow["contact_name"];
@@ -271,6 +285,7 @@ elseif ($Mode != 'ADD_ITEM')
                $result = db_query($sql,"check failed");
                $myrow = db_fetch($result);
                $_POST['br_name'] = $myrow["name"];
+               $_POST['br_ref'] = $myrow["cust_ref"];
                $_POST['contact_name'] = _('Main Branch');
                $_POST['br_address'] = $_POST['br_post_address'] = $myrow["address"];
                $_POST['email'] = $myrow['email'];
@@ -297,6 +312,7 @@ hidden('popup', @$_REQUEST['popup']);
 table_section_title(_("Name and Contact"));
 
 text_row(_("Branch Name:"), 'br_name', null, 35, 40);
+text_row(_("Branch Short Name:"), 'br_ref', null, 30, 30);
 text_row(_("Contact Person:"), 'contact_name', null, 35, 40);
 
 text_row(_("Phone Number:"), 'phone', null, 20, 20);
index e5ea837ab7228c08f75c2ca6d5efe089d31f4017..d98a21f0560c237174723910265ef442d2f3ae2f 100644 (file)
@@ -34,6 +34,13 @@ function can_process()
                set_focus('CustName');
                return false;
        } 
+
+       if (strlen($_POST['cust_ref']) == 0) 
+       {
+               display_error(_("The customer short name cannot be empty."));
+               set_focus('cust_ref');
+               return false;
+       } 
        
        if (!check_num('credit_limit', 0))
        {
@@ -72,6 +79,7 @@ function handle_submit()
        {
 
                $sql = "UPDATE ".TB_PREF."debtors_master SET name=" . db_escape($_POST['CustName']) . ", 
+                       debtor_ref=" . db_escape($_POST['cust_ref']) . ",
                        address=".db_escape($_POST['address']) . ", 
                        tax_id=".db_escape($_POST['tax_id']) . ", 
                        curr_code=".db_escape($_POST['curr_code']) . ", 
@@ -99,9 +107,9 @@ function handle_submit()
 
                begin_transaction();
 
-               $sql = "INSERT INTO ".TB_PREF."debtors_master (name, address, tax_id, email, dimension_id, dimension2_id,  
+               $sql = "INSERT INTO ".TB_PREF."debtors_master (name, debtor_ref, address, tax_id, email, dimension_id, dimension2_id,  
                        curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit,  
-                       sales_type) VALUES (".db_escape($_POST['CustName']) .", " 
+                       sales_type) VALUES (".db_escape($_POST['CustName']) .", " .db_escape($_POST['cust_ref']) .", "
                        .db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . ","
                        .db_escape($_POST['email']) . ", ".db_escape($_POST['dimension_id']) . ", " 
                        .db_escape($_POST['dimension2_id']) . ", ".db_escape($_POST['curr_code']) . ", 
@@ -205,7 +213,7 @@ else
 
 if ($new_customer) 
 {
-       $_POST['CustName'] = $_POST['address'] = $_POST['tax_id']  = '';
+       $_POST['CustName'] = $_POST['cust_ref'] = $_POST['address'] = $_POST['tax_id']  = '';
        $_POST['dimension_id'] = 0;
        $_POST['dimension2_id'] = 0;
        $_POST['sales_type'] = -1;
@@ -226,6 +234,7 @@ else
        $myrow = db_fetch($result);
 
        $_POST['CustName'] = $myrow["name"];
+       $_POST['cust_ref'] = $myrow["debtor_ref"];
        $_POST['address']  = $myrow["address"];
        $_POST['tax_id']  = $myrow["tax_id"];
        $_POST['email']  = $myrow["email"];
@@ -246,6 +255,7 @@ table_section(1);
 table_section_title(_("Name and Address"));
 
 text_row(_("Customer Name:"), 'CustName', $_POST['CustName'], 40, 80);
+text_row(_("Customer Short Name:"), 'cust_ref', null, 30, 30);
 textarea_row(_("Address:"), 'address', $_POST['address'], 35, 5);
 
 email_row(_("E-mail:"), 'email', null, 40, 40);
@@ -304,7 +314,7 @@ if ($new_customer)
 else 
 {
        submit_center_first('submit', _("Update Customer"), 
-         _('Update customer data'), true);
+         _('Update customer data'), @$_REQUEST['popup'] ? true : 'default');
        submit_return('select', get_post('customer_id'), _("Select this customer and return to document entry."));
        submit_center_last('delete', _("Delete Customer"), 
          _('Delete customer data if have been never used'), true);