$remarks = $_POST[$varname]; $varname = "dept_" . $i; $dept = $POST[$varname]; if ($dept == -1) { $dept = ""; } $varname = "amount_" . $i; $amount = $_POST[$varname]; # Would that not be much more easier ? You can make sums very easily ?! # Because I don't know about all the implications, I let it like that # $amount = -$amount; $result = mysql_query("INSERT INTO TRANS (VR_NO, VR_DT, VR_TP, AC_ID1, AC_ID2, AC_ID3, AC_ID4, AC_ID5, DR_CR, CHQ_NO, AMOUNT, PARTY, REMARKS, T_DT, DEPT) VALUES ('{$max_vr_no}','{$vr_dt}','{$vr_tp}','{$ac_id1}','{$ac_id2}','{$ac_id3}','{$ac_id4}','{$ac_name}','{$dr_cr}','{$chq_no}','{$amount}','{$party}','{$remarks}','{$t_dt}','{$dept}')", $db); checkMySQLError(); } $result = mysql_query("UNLOCK TABLES", $db); mysqlReport($result, "Transaction sucessfully added, Voucher Number is {$max_vr_no}", "print_money_receipt.php?vr_no={$max_vr_no}", "printmoneyReceipt"); } else { if ($vr_tp == "DB") { $type_of_voucher = "Debit "; $dr_cr = "C"; $ac_array = get_ac5_sc_array("5(1)", "B"); } elseif ($vr_tp == "CR") { $type_of_voucher = "Credit "; $dr_cr = "D"; $ac_array = get_ac5_sc_array("5(1)", "B"); } elseif ($vr_tp == "JV") { $type_of_voucher = "Journal "; $dr_cr = "C"; $ac_array = get_ac5_sc_array("5(1)", "B"); } else { die("Unknown Voucher-type: ({$vr_tp})");
} else { $join_dt = conv_to_srd($join_dt); } if ($emp_id3) { $query = "UPDATE PERSONAL SET EMP_NAME='{$emp_name}', DESIG_ID={$desig_id}, STATUS='{$status}', AC_NO='{$ac_no}', CONF_DT='{$conf_dt}', JOIN_DT='{$join_dt}' WHERE EMP_ID3={$emp_id3}"; echo $query; $result = mysql_query($query, $db); checkMySQLError(); mysqlReport($result, "Employer sucessfully updated", "main.php", "Home"); mysql_close($db); } else { $query = "INSERT INTO PERSONAL (EMP_NAME, DESIG_ID, STATUS, AC_NO, CONF_DT,JOIN_DT) VALUES ('{$emp_name}','{$desig_id}','{$status}', '{$ac_no}', '{$conf_dt}','{$join_dt}')"; echo $query; $result = mysql_query($query, $db); checkMySQLError(); mysqlReport($result, "Employer sucessfully added", "main.php", "Home"); mysql_close($db); } } else { $db = getDBConnection(); if ($EMP_ID3) { $result = mysql_query("select * from PERSONAL where EMP_ID3 = {$EMP_ID3}"); checkMySQLError(); $edit = mysql_fetch_array($result); } $desig_array = get_designation_array(); ?> <table cellpadding=5 cellspacing=0 border=0 width='100%'> <tr> <td valign=top width='15%'>
<?php # enter_desig.php displays a form that allows the entry of a designation and # handles the submission session_start(); require "accrp.php"; require "security/secure.php"; beginDocument("Enter Designation", $sess_user); if ($desig_desc) { $db = getDBConnection(); $result = mysql_query("INSERT INTO DESIG (DESIG_DESC) VALUES ('{$desig_desc}')", $db); checkMySQLError(); mysqlReport($result, $lCustomerAddition, "main.php", "Home"); mysql_close($db); } else { ?> <table cellpadding=5 cellspacing=0 border=0 width='100%'> <tr> <td valign=top width='15%'> <?php beginPrettyTable("1"); ?> <tr> <?php echo "<td><a href='list_desig.php'>show List</a></td>"; ?> </tr> <tr> <td><hr color='black'></td>
if ($type == "PF") { $loan_table = "PF_LOAN"; } else { if ($type == "CUF") { $loan_table = "CUF_LOAN"; } else { die("Loantype unspecified !"); } } $loan_dt = conv_to_srd($loan_dt); $loan_start = conv_to_srd($loan_start); $loan_end = conv_to_srd($loan_end); $query = "INSERT INTO {$loan_table} (EMP_ID3,LOAN_DT,LOAN_START,LOAN_END,LOAN_AMT,INT_AMT,TOT_AMT,INST_NO,INT_RATE) VALUES ('{$emp_name}','{$loan_dt}','{$loan_start}','{$loan_end}','{$loan_amt}','{$int_amt}','{$tot_amt}', '{$inst_no}', '{$int_rate}' )"; $result = mysql_query($query, $db); checkMySQLError(); mysqlReport($result, "Loan sucessfully added", "main.php", "Home"); mysql_close($db); } else { if ($type == "PF") { $loan_type = "PF-Loan"; $interest_rate = 10; } else { if ($type = "CUF") { $loan_type = "CUF-Loan"; $interest_rate = 12; # is that true ???? } else { die("Loantype unspecified !"); } } ?>
<?php # enter_salary_element.php displays a form that allows the entry of a new salary element and # handles the submission require "accrp.php"; session_start(); require "security/secure.php"; pt_register('POST', 'sal_desc', 'id_tp'); beginDocument("Enter Salary Element", $sess_user); if ($sal_desc) { $db = getDBConnection(); $result = mysql_query("INSERT INTO SAL_ID (SAL_DESC,ID_TP) VALUES ('{$sal_desc}','{$id_tp}')", $db); checkMySQLError(); mysqlReport($result, "Salary Element sucessfully added!", "main.php", "Home"); mysql_close($db); } else { ?> <table cellpadding=5 cellspacing=0 border=0 width='100%'> <tr> <td valign=top width='15%'> <?php beginPrettyTable("1"); ?> <tr> <?php echo "<td><a href='list_salary_elements.php'>show List</a></td>"; ?> </tr> <tr>
<?php # enter_salary_element.php displays a form that allows the entry of a new salary element and # handles the submission session_start(); require "accrp.php"; require "security/secure.php"; beginDocument("Enter Salary Element", $sess_user); if ($remove_confirm == 1) { $db = getDBConnection(); $result = mysql_query("DELETE FROM TRANS WHERE VR_NO={$vr_no}", $db); if (!checkMySQLError()) { mysqlReport($result, "VoucherNo {$vr_no} sucessfully removed", "main.php", "Home"); } mysql_close($db); } else { if ($vr_no) { $db = getDBConnection(); $result = mysql_query("SELECT AC_ID1, AC_ID2, AC_ID3, AC_ID4, AC_ID5, VR_TP, VR_NO, VR_DT, PARTY, REMARKS, AMOUNT FROM TRANS WHERE VR_NO={$vr_no} AND DR_CR='D'", $db); checkMySQLError(); $row = mysql_fetch_array($result, MYSQL_ASSOC); if (!$row) { die("No Voucher with this Number found!"); } else { if ($row["VR_TP"] == "CR") { die("Requested Voucher is a Credit-Voucher. Credit-Vouchers can't get deleted. Instead, make a Debit-Voucher and correct the mistake!"); } else { if (mysql_fetch_array($result, MYSQL_ASSOC)) { die("more than one Voucher found! Database-integrity is in Danger! Call your System-maintainer!"); } }
require "security/secure.php"; # Prints all that HTML-stuff, we don't want to deal with beginDocument("Enter Department", $sess_user); # This PHP-File (and nearly all the others) have two parts. One is showing # the Form, the other one is doing database-stuff with the data, typed # in the form if ($dept_name) { # means nearly the same than "if user already typed in data" # get a connection to the database $db = getDBConnection(); # insert the new department $result = mysql_query("INSERT INTO DEPT (DEPT_NAME) VALUES ('{$dept_name}')", $db); # check if anything went wrong checkMySQLError(); # Give the user a report mysqlReport($result, "Department sucessfully added", "main.php", "Home"); # close connection to database mysql_close($db); } else { ## the following code is ignored. perhaps, we will use it sometimes ## later, when we make the possibility to edit a department #if ($EMP_ID3) { # $result = mysql_query("select * from DEPT where DEPT_ID = $dept_id"); # checkMySQLError(); # $edit = mysql_fetch_array($result); #} # With [Questionmark]> we will leave the PHP-mode. # Everything after this, will # get directly to the html-page ?>
# Enter customer displays a form that allows the entry of a customer, and # handles the submission require "accrp.php"; session_start(); require "security/secure.php"; pt_register('POST', 'ac', 'ac_desc'); beginDocument($lEnterCustomer, $sess_user); if ($ac_desc) { # the variable $ac determines, which AC_CODE_Table to alter if (!$ac) { $ac = 1; } $db = getDBConnection(); $result = mysql_query("INSERT INTO AC_CODE{$ac} (AC{$ac}_DESC) VALUES ('{$ac_desc}')", $db); mysqlReport($result, "show list", "list_acs?showac={$ac}", "show list"); mysql_close($db); } else { if (!$ac) { die("Error: I don't know, which Table to alter !"); } ?> <table cellpadding=5 cellspacing=0 border=0 width='100%'> <tr> <td valign=top width='15%'> <?php beginPrettyTable("1"); ?> <tr>
<?php # enter_desig.php displays a form that allows the entry of a designation and # handles the submission require "accrp.php"; session_start(); require "security/secure.php"; pt_register('POST', 'desig_desc'); beginDocument("Enter Designation", $sess_user); if ($desig_desc) { $db = getDBConnection(); $result = mysql_query("INSERT INTO DESIG (DESIG_DESC) VALUES ('{$desig_desc}')", $db); checkMySQLError(); mysqlReport($result, "Designation added", "main.php", "Home"); mysql_close($db); } else { ?> <table cellpadding=5 cellspacing=0 border=0 width='100%'> <tr> <td valign=top width='15%'> <?php beginPrettyTable("1"); ?> <tr> <?php echo "<td><a href='list_desig.php'>show List</a></td>"; ?> </tr> <tr>