}
hidden('selected_id', $selected_id);
hidden('category_id');
-} else {
+} else if ($Mode != 'CLONE') {
$_POST['long_description'] = '';
$_POST['description'] = '';
$_POST['no_sale'] = 0;
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']);
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();
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']))
/* 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."));
}
}
+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)
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();
table_section_title(_("Item"));
//------------------------------------------------------------------------------------
-
if ($new_item)
{
text_row(_("Item Code:"), 'NewStockID', null, 21, 20);
label_row(" ", $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);
@$_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');
}
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 )
{
{
$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']) . ",
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']). ", "
$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"];
}
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;
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);
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);
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)
{
/*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']).",
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']) . ","
$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']));
+ }
}
}
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[] = '';
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"]);
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"];
$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'];
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);
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))
{
{
$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']) . ",
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']) . ",
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;
$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"];
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);
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);