$rsmaxcode = fatch_branch_maxcode($bank); $rowmaxcode = getRows($rsmaxcode); if ($rowmaxcode['branch_cd'] == null) { $branch_code = "001"; } else { $branch_code = sprintf("%03d", $rowmaxcode['branch_cd'] + 1); } } $usercd = $user_cd; $c_branch = duplicate_branch($bank, $branch_code, $branch_name); if ($c_branch == 0) { if (isset($_REQUEST['branch_cd'])) { $branch_code = decode($_REQUEST['branch_cd']); $dt = new DateTime(); $posted_date = $dt->format('Y-m-d H:i:s'); $ret = update_branch($branch_code, $bank, $branch_name, $branch_address, $ifsc, $usercd, $posted_date); if ($ret == 1) { redirect("branch-master.php?msg=success"); } } else { $ret = save_branch($branch_code, $bank, $branch_name, $branch_address, $ifsc, $usercd); } if ($ret == 1) { $msg = "<div class='alert-success'>Record saved successfully</div>"; } } else { $msg = "<div class='alert-error'>Branch already exists</div>"; } //unset($ret,$posted_date,$c_branch,$branch_code,$branch_name,$bank,$ifsc); } ?>
//initialise no input errors assumed initially before we test $input_error = 0; if (strlen($_POST['br_name']) == 0) { $input_error = 1; display_error(_("The Branch name cannot be empty.")); 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) { begin_transaction(); if ($selected_id != -1) { update_branch($_POST['customer_id'], $_POST['branch_code'], $_POST['br_name'], $_POST['br_ref'], $_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'], $_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'], $_POST['default_location'], $_POST['br_post_address'], $_POST['disable_trans'], $_POST['group_no'], $_POST['default_ship_via'], $_POST['notes']); // update_record_status($_POST['supplier_id'], $_POST['inactive'], // 'cust_branch', 'branch_code'); $note = _('Selected customer branch has been updated'); } else { add_branch($_POST['customer_id'], $_POST['br_name'], $_POST['br_ref'], $_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'], $_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'], $_POST['default_location'], $_POST['br_post_address'], 0, $_POST['group_no'], $_POST['default_ship_via'], $_POST['notes']); $selected_id = db_insert_id(); add_crm_person($_POST['contact_name'], $_POST['contact_name'], '', $_POST['br_post_address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['rep_lang'], ''); add_crm_contact('cust_branch', 'general', $selected_id, db_insert_id()); $note = _('New customer branch has been added'); } commit_transaction(); display_notification($note); // $Mode = 'RESET'; if (@$_REQUEST['popup']) { set_focus("Select" . ($_POST['branch_code'] == -1 ? $selected_id : $_POST['branch_code']));