hii...
in my code,the alert() function is not getting triggered. below is the code:
<?php
$this->load->helper("check");
$data = array("arrDt", "dptDt");
foreach($data as $val){
$$val = (isset($$val) && $$val!=0)? date("d/m/Y h:i A",$$val) : "";
}
$data = array("type", "name", "address", "dayTot","pt1","pt2","pt3","pt4","noofroom1","roomno1","cost1", "stax1", "ltax1","total1","noofroom2","roomno2","cost2", "stax2", "ltax2","total2" ,"noofroom3","roomno3","cost3", "stax3", "ltax3","total3","noofroom4","roomno4","cost4", "stax4", "ltax4","total4","sTaxno","lTaxno","vatno", "less", "advance","date","rno", "lTax", "sTax", "vat", "aCharge","eno","erate","dayTot","eST","eLT","amount","aNet","aPending","exNo","exST","exLT","exCharge","num_adult","num_child");
foreach($data as $val){
$$val = (isset($$val))? $$val : "";
}
$dayTot =($dayTot=="")? 1:$dayTot;
$frmAction = (isset($id))? "editPayment":"addPayment";
?>
<?php
function package($k){
$sql="SELECT * FROM package WHERE id=".$k;
$rs=mysql_query($sql);
$rw=mysql_fetch_array($rs);
$package=$rw['package'];
return $package;
}
?>
<html>
<head>
<title>Resort Payment Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Copyright" content="arirusmanto.com">
<meta name="description" content="Admin MOS Template">
<meta name="keywords" content="Admin Page">
<meta name="author" content="Ari Rusmanto">
<meta name="language" content="Bahasa Indonesia">
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css'); ?>/mos-style.css">
<script type="text/javascript" src="<?php echo base_url("js/jquery.min.js"); ?>"></script>
<script type="text/javascript" src="<?php echo base_url("js/common.js"); ?>"></script>
<script type="text/javascript">
function makeBlank(a) {
for(i in a) {
$("#"+a[i]).html("");
}
}
function doCalculation()
{
var dayTot = $("#dayTot").val();
// For Option 1
var cost1 = ($("#cost1").val()!="")? Number($("#cost1").val()):0;
var ltax1 = ($("#ltax1").val()!="")? Number($("#ltax1").val()):0;
var stax1 = ($("#stax1").val()!="")? Number($("#stax1").val()):0;
var noofroom1 = ($("#noofroom1").val()!="")? Number($("#noofroom1").val()):0;
var eST = ($("#eST").val()!="")? Number($("#eST").val()):0;
var eLT = ($("#eLT").val()!="")? Number($("#eLT").val()):0;
var num_adult = ($("#num_adult").val()!="")? Number($("#num_adult").val()):0;
var num_child = ($("#num_child").val()!="")? Number($("#num_child").val()):0;
//var aCharge=($("#aCharge").val()!="")? Number($("#aCharge").val()):0;
var aCharge=0;
var t1 = cost1 * dayTot * noofroom1;
aCharge=aCharge+t1;
t1 = t1 + t1*((ltax1+stax1)/100);
$("#total1").val(t1);
//doExtraCalculate();
// For Option 2
var cost2 = ($("#cost2").val()!="")? Number($("#cost2").val()):0;
var ltax2 = ($("#ltax2").val()!="")? Number($("#ltax2").val()):0;
var stax2 = ($("#stax2").val()!="")? Number($("#stax2").val()):0;
var noofroom2 = ($("#noofroom2").val()!="")? Number($("#noofroom2").val()):0;
var t2 = cost2 * dayTot * noofroom2;
aCharge=aCharge+t2;
t2 = t2 + t2*((ltax2+stax2)/100);
$("#total2").val(t2);
// For Option 3
var cost3 = ($("#cost3").val()!="")? Number($("#cost3").val()):0;
var ltax3 = ($("#ltax3").val()!="")? Number($("#ltax3").val()):0;
var stax3 = ($("#stax3").val()!="")? Number($("#stax3").val()):0;
var noofroom3 = ($("#noofroom3").val()!="")? Number($("#noofroom3").val()):0;
var t3 = cost3 * dayTot * noofroom3;
aCharge=aCharge+t3;
t3 = t3 + t3*((ltax3+stax3)/100);
$("#total3").val(t3);
// For Option 4
var cost4 = ($("#cost4").val()!="")? Number($("#cost4").val()):0;
var ltax4 = ($("#ltax4").val()!="")? Number($("#ltax4").val()):0;
var stax4 = ($("#stax4").val()!="")? Number($("#stax4").val()):0;
var noofroom4 = ($("#noofroom4").val()!="")? Number($("#noofroom4").val()):0;
var t4 = cost4 * dayTot * noofroom4;
aCharge=aCharge+t4;
t4 = t4 + t4*((ltax4+stax4)/100);
$("#total4").val(t4);
// For Option 4
var eno = ($("#eno").val()!="")? Number($("#eno").val()):0;
var erate = ($("#erate").val()!="")? Number($("#erate").val()):0;
var exCharge=($("#exCharge").val()!="")? Number($("#exCharge").val()):0;
exCharge=eno*erate*dayTot;
exCharge=exCharge+(exCharge*(eST+eLT)/100);
//var ex_ch = eno * erate;
var t = t1 + t2 + t3 + t4 + exCharge;
$("#aCharge").val(aCharge); //aCharge amount goes to database-->
//$("#amount").html(t);
$("#amount").val(t);
var less = ($("#less").val()!="")? Number($("#less").val()):0;
var less1 = (t - less); //working on this currently
$("#aNet").html(less1);
var advance = ($("#advance").val()!="")? Number($("#advance").val()):0;
var advance1 = less1 - advance;
$("#aPending").html(advance1);
}
function numOnly(evt,input) {
var z = evt.charCode ? evt.charCode : evt.keyCode;
if(z==190 || z==110) {
var arr = (input.val()).split(".");
if(arr.length==1) {
setTimeout("doCalculation();",5);
return;
} else {
return evt.preventDefault ? evt.preventDefault():false;
}
}
if(!(z == 35 || z == 36 || z == 8 || z == 9 || z == 46 || (z>= 37 && z<=40) || (z>= 48 && z<=57) || (z>= 96 && z<=105))) {
return evt.preventDefault ? evt.preventDefault():false;
}
setTimeout("doCalculation();",5);
}
function percentOnly(evt,input) {
var z = evt.charCode ? evt.charCode : evt.keyCode;
if(input.val()>9) {
if(input.val()==10 && (z==48 || z==96)) return;
if(z == 35 || z == 36 || z == 8 || z == 9 || z == 46) return;
var arr = (input.val()).split(".");
if(arr[0]==100) return evt.preventDefault ? evt.preventDefault():false;
if(z==190 || z==110) {
if(arr.length==1) return;
else return evt.preventDefault ? evt.preventDefault():false;
}
if(arr.length==1) return evt.preventDefault ? evt.preventDefault():false;
else return;
}
}
$(document).ready(function() {
doCalculation();
$(".numberOnly").keydown(function(evt) {
numOnly(evt,$(this));
});
$(".percentOnly").keydown(function(evt) {
numOnly(evt,$(this));
percentOnly(evt,$(this));
});
$("input[name=status]").click(function(evt) {
doCalculation();
});
$("#pform").submit(function(evt) {
evt.preventDefault();
var url = $(this).attr("action");
var data = $(this).serialize();
$("#sbmTab").attr("disabled",true);
$.ajax({
url: url,
type: "POST",
data: data,
cache: false,
success: function(html) {
$("#sbmTab").attr("disabled",false);
eval("var status = "+html+";");
alert(status);
if(status.error==1) {
alert(status.msg);
} else if(status.error==3) {
if(confirm("A bill with same room number and time comflict exist.\nDo You want to check it?")) {
window.location = "<?php echo base_url("resort/editPaymentform/"); ?>"+status.msg;
return;
}
} else {
if($("#id").length==0) {
alert("Payment inserted successfully in database!");
$("#pform").attr("action","<?php ?>/"+status.msg);
$("#frmhead").html("Edit invoice number "+status.msg);
$("#pform").append("<input type='hidden' name='id' id='id' value='"+status.msg+"'>");
$("#frnBtn").append("<a href='<?php //echo base_url("resort/viewBill"); ?>/"+status.msg+"' id='viewBill' class='button'>View Bill</a>");
window.location = "<?php echo base_url("resort/listpayment/"); ?>";
} else {
alert("Payment updated successfully in database!");
}
}
},
error: function() {
$("#sbmTab").attr("disabled",false);
alert("Connectivity Issue fd!");
}
});
});
});
</script>
<script type="text/javascript" src="<?php echo base_url("js");?>/jquery.datetimeentry.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.datetimeEntry.setDefaults({spinnerImage: '<?php echo base_url("img");?>/spinnerDefault.png'});
$('#date').datetimeEntry({datetimeFormat: 'D-O-Y'});
$('#arrDt').datetimeEntry({datetimeFormat: 'D-O-Y H:M a'});
$('#dptDt').datetimeEntry({datetimeFormat: 'D-O-Y H:M a'});
//$('#month1').datetimeEntry({datetimeformat: ['January','February','March','April','May','June','July','August','September','October','November','December']});
// $('#year1').datetimeEntry({datetimeformat: 'Y'});
$("#type").change(function(){
var a = ["pt1","pt2","pt3","pt4","noofroom1","roomno1","cost1", "stax1", "ltax1","total1","noofroom2","roomno2","cost2", "stax2", "ltax2","total2" ,"noofroom3","roomno3","cost3", "stax3", "ltax3","total3","noofroom4","roomno4","cost4", "stax4", "ltax4","total4","sTaxno","lTaxno","vatno", "less", "advance","eST","eLT","amount","aNet","aPending","eno","exNo","dayTot","exST","exLT","exCharge","num_adult","num_child"];
for(i in a){
$("#"+a[i]).hide();
}
switch($(this).val()) {
case "accomodation":
var a = ["pt1","pt2","pt3","pt4","noofroom1","roomno1","cost1", "stax1", "ltax1","total1","noofroom2","roomno2","cost2", "stax2", "ltax2","total2" ,"noofroom3","roomno3","cost3", "stax3", "ltax3","total3","noofroom4","roomno4","cost4", "stax4", "ltax4","total4","sTaxno","lTaxno","vatno", "less", "advance","eST","eLT","amount","aNet","aPending","eno","exNo","dayTot","exST","exLT","exCharge","num_adult","num_child"];
for(i in a) {
$("#"+a[i]).show();
}
break;
default:
alert("Please select invoce type!");
break;
}
doCalculation();
});
});
</script>
</head>
<body>
<?php $this->load->view("common/header"); ?>
<div id="wrapper">
<?php $this->load->view("common/sidebar"); ?>
<div id="rightContent">
<ul class="TabGroup">
<li><a href="<?php echo base_url("resort/addPaymentForm"); ?>">Generate Invoice</a></li>
<li class="Tablink">Generate Accmodation Invoices</a></li>
<li><a href="<?php echo base_url("resort/listPayment"); ?>">View Invoices</a></li>
</ul>
<form action="<?php echo base_url("resort/".$frmAction);?>" method="POST" id="pform" class="tabContent">
<h3 id="frmhead"><?php echo (isset($id))? "Edit invoice number ".$id:"Fill this form to generate invoice number ".$ivno; ?></h3>
<table width="95%">
<tr>
<td height="38">Invoice Type:</td>
<td><select name="type" id="type">
<option value="accomodation" <?php echo isSelected($type,"accomodation"); ?>>Accomodation</option>
</select>
<input type="hidden" class="pendek" name="rno" value="<?php echo $rno; ?>">
<input type="hidden" class="percentOnly pendek" name="lTax" value="<?php echo $lTax; ?>" id="lTax">
<input type="hidden" class="pendek" name="sTax" value="<?php echo $sTax; ?>" id="sTax">
<input type="hidden" class="percentOnly pendek" name="vat" value="<?php echo $vat; ?>" id="vat">
<input type="hidden" class="numberOnly pendek" name="aCharge" value="<?php echo $aCharge; ?>" id="aCharge"></td>
</tr>
<tr>
<td width="217">Name:</td>
<td width="952"><input type="text" class="sedang" name="name" value="<?php echo $name; ?>"></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" class="panjang" name="address" value="<?php echo $address; ?>"></td>
</tr>
<tr>
<td>Arrival Date & time:</td>
<td><input type="text" class="dateTime pendek" style="width:200px;" name="arrDt" value="<?php echo $arrDt; ?>" id="arrDt"></td>
</tr>
<tr>
<td>Departure Date & time:</td>
<td><input type="text" class="dateTime pendek" style="width:200px;" name="dptDt" value="<?php echo $dptDt; ?>" id="dptDt"></td>
</tr>
<tr id="dayTotr2">
<td>Total Days:</td>
<td><input type="text" class="numberOnly pendek" name="dayTot" value="<?php echo $dayTot; ?>" id="dayTot"></td>
</tr>
<tr class="top row" >
<td height="144" colspan="2">Option 1
<p>
Select Package Type
<select name="pt1" id="pt1" onChange="showUser1(this.value)" >
<option value="">Select</option>
<?php $sql2 = "SELECT * FROM package";
$result2 = mysql_query($sql2);
if(isset($id)){
?>
<option value="<?php echo $pt1; ?>" selected><?php echo package($pt1); ?></option>
<?php
}
while ($row2 = mysql_fetch_array($result2))
{
$package = $row2["package"];
$id1 = $row2["id"];
?>
<option value="<?php echo $id1; ?>"><?php echo $package; ?></option>
<?php
}
?>
</select>
</p>
<p id="op1" > No of rooms
<input type="text" class="numberOnly pendek1" name="noofroom1" id="noofroom1" value="<?php echo $noofroom1; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">
Room No
<input type="text" class="numberOnly pendek1" name="roomno1" value="<?php echo $roomno1; ?>" >
Cost
<input type="text" class="numberOnly pendek1" name="cost1" id="cost1" value="<?php echo $cost1; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">Per Day
<br><br>No of Adults:<input type="text" class="numberOnly pendek1" name="num_adult" id="num_adult" value="<?php echo $num_adult; ?>">
No of Child:<input type="text" class="numberOnly pendek1" name="num_child" id="num_child" value="<?php echo $num_child; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">
<br><br> Service Tax
<input type="text" class="numberOnly pendek1" name="stax1" id="stax1" value="<?php echo $stax1; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Luxury Tax
<input type="text" class="numberOnly pendek1" name="ltax1" id="ltax1" value="<?php echo $ltax1; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Total
<input type="text" class="numberOnly pendek1" name="total1" id="total1" value="<?php echo $total1; ?>" readonly >
</p></td>
</tr>
</table>
<?php
if(isset($id) && $total2!== '0' )
{
?>
<table width="95%" style="" id="example" >
<tr class="top row" >
<?
}
else
{
?>
<table width="95%" style="display:none;" id="example" >
<tr class="top row" >
<?
}
?>
<td >
<p>Option2 </p>
<p> Select Package Type
<select name="pt2" id="pt2" onChange="showUser2(this.value)" >
<option value="">Select</option>
<?php $sql2 = "SELECT * FROM package";
$result2 = mysql_query($sql2);
if(isset($id)){
?>
<option value="<?php echo $pt2; ?>" selected><?php echo package($pt2); ?></option>
<?php
}
while ($row2 = mysql_fetch_array($result2))
{
$package = $row2["package"];
$id1 = $row2["id"];
?>
<option value="<?php echo $id1; ?>"><?php echo $package; ?></option>
<?php
}
?>
</select></p>
<p id="op2" > No of rooms
<input type="text" class="numberOnly pendek1" name="noofroom2" id="noofroom2" value="<?php echo $noofroom2; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Room No
<input type="text" class="numberOnly pendek1" name="roomno2" value="<?php echo $roomno2; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Cost
<input type="text" class="numberOnly pendek1" name="cost2" id="cost2" value="<?php echo $cost2; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">Per Day
<br /><br />Service Tax
<input type="text" class="numberOnly pendek1" name="stax2" id="stax2" value="<?php echo $stax2; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Luxury Tax
<input type="text" class="numberOnly pendek1" name="ltax2" id="ltax2" value="<?php echo $ltax2; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Total
<input type="text" class="numberOnly pendek1" name="total2" id="total2" value="<?php echo $total2; ?>" readonly onKeyDown="doCalculation()" onChange="doCalculation()" ></p>
</td>
</tr>
</table>
<?php
if(isset($id) && $total3!== '0' )
{
?>
<table width="95%" style="" id="example1" >
<?
}
else
{
?>
<table width="95%" style="display:none;" id="example1" >
<?
}
?>
<tr class="top row" >
<td >
<p>Option3 </p>
<p> Select Package Type
<select name="pt3" id="pt3" onChange="showUser3(this.value)" >
<option value="">Select</option>
<?php $sql2 = "SELECT * FROM package";
$result2 = mysql_query($sql2);
if(isset($id)){
?>
<option value="<?php echo $pt3; ?>" selected><?php echo package($pt3); ?></option>
<?php
}
while ($row2 = mysql_fetch_array($result2))
{
$package = $row2["package"];
$id1 = $row2["id"];
?>
<option value="<?php echo $id1; ?>"><?php echo $package; ?></option>
<?php
}
?>
</select></p>
<p id="op3" > No of rooms
<input type="text" class="numberOnly pendek1" name="noofroom3" id="noofroom3" value="<?php echo $noofroom3; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Room No
<input type="text" class="numberOnly pendek1" name="roomno3" value="<?php echo $roomno3; ?>" >
Cost
<input type="text" class="numberOnly pendek1" name="cost3" id="cost3" value="<?php echo $cost3; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">Per Day
<br /><br />
Service Tax
<input type="text" class="numberOnly pendek1" name="stax3" id="stax3" value="<?php echo $stax3; ?>" onkeydown="doCalculation()" onChange="doCalculation()" >
Luxury Tax
<input type="text" class="numberOnly pendek1" name="ltax3" id="ltax3" value="<?php echo $ltax3; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Total
<input type="text" class="numberOnly pendek1" name="total3" id="total3" value="<?php echo $total3; ?>" readonly onKeyDown="doCalculation()" onChange="doCalculation()" >
</p>
</td>
</tr>
</table>
<?php
if(isset($id) && $total4!== '0' )
{
?>
<table width="95%" style="" id="example2" >
<?
}
else
{
?>
<table width="95%" style="display:none;" id="example2" > <?
}
?>
<tr class="top row" >
<td >
<p>Option4 </p>
<p> Select Package Type
<select name="pt4" id="pt4" onChange="showUser4(this.value)" >
<option value="">Select</option>
<?php $sql2 = "SELECT * FROM package";
$result2 = mysql_query($sql2);
if(isset($id)){
?>
<option value="<?php echo $pt4; ?>" selected><?php echo package($pt4); ?></option>
<?php
}
while ($row2 = mysql_fetch_array($result2))
{
$package = $row2["package"];
$id1 = $row2["id"];
?>
<option value="<?php echo $id1; ?>"><?php echo $package; ?></option>
<?php
}
?>
</select></p>
<p id="op4" > No of rooms
<input type="text" class="numberOnly pendek1" name="noofroom4" id="noofroom4" value="<?php echo $noofroom4; ?>" onKeyDown="doCalculation()" onChange="doCalculation()" >
Room No
<input type="text" class="numberOnly pendek1" name="roomno4" value="<?php echo $roomno4; ?>" >
Cost
<input type="text" class="numberOnly pendek1" name="cost4" id="cost4" value="<?php echo $cost4; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">Per Day
<br /><br />
Service Tax
<input type="text" class="numberOnly pendek1" name="stax4" id="stax4" value="<?php echo $stax4; ?>" onChange="doCalculation()" onKeyDown="doCalculation()" >
Luxury Tax
<input type="text" class="numberOnly pendek1" name="ltax4" id="ltax4" value="<?php echo $ltax4; ?>" onChange="doCalculation()" onKeyDown="doCalculation()" >
Total
<input type="text" class="numberOnly pendek1" name="total4" id="total4" value="<?php echo $total4; ?>" readonly onKeyDown="doCalculation()" onChange="doCalculation()" >
</p>
</td>
</tr>
</table>
<table width="95%" >
<tr id="exchr" >
<td>Extra Person Charges:</td>
<td style="line-height:35px;">
No. of Person : <input type="text" style="width:50px;" class="numberOnly pendek" id="eno" name="eno" value="<?php echo $eno; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">
Rate : <input type="text" style="width:50px;" class="numberOnly pendek" id="erate" name="erate" value="<?php echo $erate; ?>" onKeyDown="doCalculation()" onChange="doCalculation()"> Rs./Per Person ST : <input type="text" style="width:50px;" class="numberOnly pendek" id="eST" name="eST" value="<?php echo $eST; ?>" onKeyDown="doCalculation()" onChange="doCalculation()"> LT : <input type="text" style="width:50px;" class="numberOnly pendek" id="eLT" name="eLT" value="<?php echo $eLT; ?>" onKeyDown="doCalculation()" onChange="doCalculation()">
<div id="exCharge"><?php //echo $exCharge; ?></div>
</td>
</tr>
<tr id="stnor" ><td width="23%">Service Tax No:</td><td width="77%"><input type="text" class="pendek" name="sTaxno" value="AAECD5999CSD001" id="sTaxno" ></td></tr>
<tr id="vnr" ><td>Vat No:</td><td><input type="text" class="pendek" name="vatno" value="27745260530V" id="vatno"></td></tr>
<tr id="ltnor" ><td>Luxary Tax No:</td><td><input type="text" class="pendek" name="lTaxno" value="27745260530L" id="lTaxno"></td></tr>
<tr id="amtr"><td>Total Amount:</td><td><input type="text" class="numberOnly pendek" name="amount" value="<?php echo $amount; ?>" id="amount"></td></tr>
<tr><td>Less/Discount:</td><td><input type="text" class="numberOnly pendek" name="less" value="<?php echo $less; ?>" id="less"> Rs.</td></tr>
<tr><td>Net Amount:</td><td><span id="aNet"><?php echo $aNet; ?></span></td></tr>
<tr><td>Advance:</td><td><input type="text" class="numberOnly" name="advance" value="<?php echo $advance; ?>" id="advance"> Rs.</td></tr>
<tr><td>Balance Amount Pending:</td><td><span id="aPending"><?php echo $aPending; ?></span></td></tr>
<tr>
<td>Status</td>
<td>Amount Paid On <input type="text" class="pendek" name="date" value="<?php echo $date; ?>" id="date"> at resort</td>
</tr>
<tr>
<td></td>
<td id="frnBtn">
<input type="submit" class="button" value="Submit">
<?php if(isset($id)) echo "<a href=".base_url("resort/viewBill/".$id)." class='button' id='viewBill'>View Bill</a>"; ?>
</td>
</tr>
</table>
<?php if(isset($id)) echo "<input type='hidden' name='id' id='id' value='".$id."'>"; ?>
</form>
</div>
<div class="clear"></div>
<?php $this->load->view("common/footer"); ?>
</div>
</body>
</html><script >
function showUser1(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("op1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("post","<?php echo base_url(""); ?>/getpackage.php?q="+str,true);
xmlhttp.send();
}
function showUser2(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("op2").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("post","<?php echo base_url(""); ?>/getpackage2.php?q="+str,true);
xmlhttp.send();
}
function showUser3(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("op3").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("post","<?php echo base_url(""); ?>/getpackage3.php?q="+str,true);
xmlhttp.send();
}
function showUser4(str)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("op4").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("post","<?php echo base_url(""); ?>/getpackage4.php?q="+str,true);
xmlhttp.send();
}
</script>
<script language="javascript" type="text/javascript">
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
<script language="javascript" type="text/javascript">
function showHide1(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
<script language="javascript" type="text/javascript">
function showHide2(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
and the php file which is used for inserting updationg and deleting the data from mysql database is as follows:
resortmodel.php
<?php
class Resortmodel extends CI_Model {
function addPayment($input) {
$db = array();
$data = array("arrDt", "dptDt");
foreach($data as $val) {
$db[$val] = (strtotime($input[$val])!=false)? strtotime($input[$val]):0;
}
$data = array("type", "vatno", "sTaxno", "lTaxno", "rno", "name", "address", "date");
foreach($data as $val) {
$db[$val] = $input[$val];
}
$data = array("less", "lTax", "sTax", "vat", "advance", "aCharge","eST","eLT","exCharge","num_adult","num_child");
foreach($data as $val) {
$db[$val] = (is_numeric($input[$val]))? $input[$val] : 0;
}
switch($input["type"]) {
case "accomodation":
$data = array("pt1","noofroom1","roomno1","cost1", "stax1", "ltax1","total1","pt2","noofroom2","roomno2","cost2", "stax2", "ltax2","total2" ,"pt3","noofroom3","roomno3","cost3", "stax3", "ltax3","total3","pt4","noofroom4","roomno4","cost4", "stax4", "ltax4","total4","eno","erate","dayTot","eST","eLT","exCharge","aNet","amount","num_adult","num_child","date");
foreach($data as $val) {
$db[$val] = $input[$val];
}
$total1 = (is_numeric($input["total1"]))? $input["total1"] : 0;
$total2 = (is_numeric($input["total2"]))? $input["total2"] : 0;
$total3 = (is_numeric($input["total3"]))? $input["total3"] : 0;
$total4 = (is_numeric($input["total4"]))? $input["total4"] : 0;
$num_child = (is_numeric($input["num_child"]))? $input["num_child"] : 0;
$num_adult = (is_numeric($input["num_adult"]))? $input["num_adult"] : 0;
$eLT=(is_numeric($input["eLT"]))? $input["eLT"]:0;
$eST=(is_numeric($input["eST"]))? $input["eST"]:0;
$eno = (is_numeric($input["eno"]))? $input["eno"] : 0;
$erate = (is_numeric($input["erate"]))? $input["erate"] : 0;
$exCharge=(is_numeric($input["exCharge"]))? $input["exCharge"]:0;
$db["exCharge"] = $exCharge;
$less = (is_numeric($input["less"]))? $input["less"] : 0;
$advance = (is_numeric($input["advance"]))? $input["advance"] : 0;
$exAllTax=($eST+$eLT)*$exCharge/100;
$db["aNet"]=$db["amount"]-$less;
$db["aPending"] = $db["aNet"] - $db["advance"];
break;
case "oneday":
$afno = (is_numeric($input["afno"]))? $input["afno"] : 0;
$afrate = (is_numeric($input["afrate"]))? $input["afrate"] : 0;
$cfno = (is_numeric($input["cfno"]))? $input["cfno"] : 0;
$cfrate = (is_numeric($input["cfrate"]))? $input["cfrate"] : 0;
$efrate = (is_numeric($input["efrate"]))? $input["efrate"] : 0;
$db["fCharge"] = json_encode(array($afno,$afrate,$cfno,$cfrate,$efrate));
$fcharge = $afno * $afrate + $cfno * $cfrate + $efrate;
$fcharge = $fcharge + ($fcharge)*($db["vat"]/100);
$ano = (is_numeric($input["ano"]))? $input["ano"] : 0;
$arate = (is_numeric($input["arate"]))? $input["arate"] : 0;
$cno = (is_numeric($input["cno"]))? $input["cno"] : 0;
$crate = (is_numeric($input["crate"]))? $input["crate"] : 0;
$db["oCharge"] = json_encode(array($ano,$arate,$cno,$crate));
$charge = $ano * $arate + $cno * $crate;
$charge = $charge + ($charge)*($db["sTax"]/100);
$db["amount"] = $charge + $fcharge;
$db["aNet"] = $db["amount"] - $db["less"];
$db["aPending"] = $db["aNet"] - $db["advance"];
break;
case "food":
$afno = (is_numeric($input["afno"]))? $input["afno"] : 0;
$afrate = (is_numeric($input["afrate"]))? $input["afrate"] : 0;
$cfno = (is_numeric($input["cfno"]))? $input["cfno"] : 0;
$cfrate = (is_numeric($input["cfrate"]))? $input["cfrate"] : 0;
$efrate = (is_numeric($input["efrate"]))? $input["efrate"] : 0;
$dayTot = (is_numeric($input["dayTot"]))? $input["dayTot"] : 1;
$db["fCharge"] = json_encode(array($afno,$afrate,$cfno,$cfrate,$efrate,$dayTot));
$fcharge = ($afno * $afrate + $cfno * $cfrate + $efrate) * $dayTot;
$db["amount"] = $fcharge + ($fcharge)*($db["vat"]/100);
$db["aNet"] = $db["amount"] - $db["less"];$db["aPending"] = $db["aNet"] - $db["advance"];
break;
}
$this->db->insert("rpayment",$db);
return true;
}
function checkRTcomflict($rno, $arrDt, $dptDt, $id=null) {
$this->db->select("id");
$this->db->where("`rno` = '".$rno."' and (
(`arrDt` <= '".$arrDt."' and `dptDt` >= '".$arrDt."') or
(`arrDt` <= '".$dptDt."' and `dptDt` >= '".$dptDt."')
)");
if($id!=null) $this->db->where("id !=", $id);
$result = $this->db->get("rpayment")->result_array();
return (count($result)==0)? 0:$result[0]["id"];
}
function updatePayment($input) {
$db = array();
$data = array("arrDt", "dptDt");
foreach($data as $val) {
$db[$val] = (strtotime($input[$val])!=false)? strtotime($input[$val]):0;
}
$data = array("type", "vatno", "sTaxno", "lTaxno", "rno", "name", "address", "date");
foreach($data as $val) {
$db[$val] = $input[$val];
}
$data = array("less", "lTax", "sTax", "vat", "advance", "aCharge","eST","eLT","num_adult","num_child");
foreach($data as $val) {
$db[$val] = (is_numeric($input[$val]))? $input[$val] : 0;
}
switch($input["type"]) {
case "accomodation":
if($input["type"] == 'accomodation' && $input["id"] < 882)
{
$eLT=(is_numeric($input["eLT"]))? $input["eLT"]:0;
$eST=(is_numeric($input["eST"]))? $input["eST"]:0;
$num_child = (is_numeric($input["num_child"]))? $input["num_child"] : 0;
$num_adult = (is_numeric($input["num_adult"]))? $input["num_adult"] : 0;
$eno = (is_numeric($input["eno"]))? $input["eno"] : 0;
$erate = (is_numeric($input["erate"]))? $input["erate"] : 0;
$exCharge=(is_numeric($input["exCharge"]))? $input["exCharge"]:0;
$db["exCharge"] = $exCharge;
$less = (is_numeric($input["less"]))? $input["less"] : 0;
$advance = (is_numeric($input["advance"]))? $input["advance"] : 0;
$exAllTax=($eST+$eLT)*$exCharge/100;
$db["aNet"]=$db["amount"]-$less;
$db["aPending"] = $db["aNet"] - $db["advance"];
$db["aNet"] = $db["amount"] - $db["less"];
}
else
{
$data = array("pt1","noofroom1","roomno1","cost1", "stax1", "ltax1","total1","pt2","noofroom2","roomno2","cost2", "stax2", "ltax2","total2" ,"pt3","noofroom3","roomno3","cost3", "stax3", "ltax3","total3","pt4","noofroom4","roomno4","cost4", "stax4", "ltax4","total4","eno","erate","dayTot","eST","eLT","exCharge","amount","date");
foreach($data as $val) {
$db[$val] = $input[$val];
}
$total1 = (is_numeric($input["total1"]))? $input["total1"] : 0;
$total2 = (is_numeric($input["total2"]))? $input["total2"] : 0;
$total3 = (is_numeric($input["total3"]))? $input["total3"] : 0;
$total4 = (is_numeric($input["total4"]))? $input["total4"] : 0;
$num_child = (is_numeric($input["num_child"]))? $input["num_child"] : 0;
$num_adult = (is_numeric($input["num_adult"]))? $input["num_adult"] : 0;
$eLT=(is_numeric($input["eLT"]))? $input["eLT"]:0;
$eST=(is_numeric($input["eST"]))? $input["eST"]:0;
$eno = (is_numeric($input["eno"]))? $input["eno"] : 0;
$erate = (is_numeric($input["erate"]))? $input["erate"] : 0;
$exCharge=(is_numeric($input["exCharge"]))? $input["exCharge"]:0;
$db["exCharge"] = $exCharge;
$less = (is_numeric($input["less"]))? $input["less"] : 0;
$advance = (is_numeric($input["advance"]))? $input["advance"] : 0;
$exAllTax=($eST+$eLT)*$exCharge/100;
$db["aNet"]=$db["amount"]-$less;
$db["aPending"] = $db["aNet"] - $db["advance"];
$month1=(is_numeric($input["month1"]))? $input["month1"]:0;
$year1=(is_numeric($input["year1"]))? $input["year1"]:0;
$db["month1"]=$month1;
$db["year1"]=$year1;
}
break;
case "oneday":
$afno = (is_numeric($input["afno"]))? $input["afno"] : 0;
$afrate = (is_numeric($input["afrate"]))? $input["afrate"] : 0;
$cfno = (is_numeric($input["cfno"]))? $input["cfno"] : 0;
$cfrate = (is_numeric($input["cfrate"]))? $input["cfrate"] : 0;
$efrate = (is_numeric($input["efrate"]))? $input["efrate"] : 0;
$db["fCharge"] = json_encode(array($afno,$afrate,$cfno,$cfrate,$efrate));
$fcharge = $afno * $afrate + $cfno * $cfrate + $efrate;
$fcharge = $fcharge + ($fcharge)*($db["vat"]/100);
$ano = (is_numeric($input["ano"]))? $input["ano"] : 0;
$arate = (is_numeric($input["arate"]))? $input["arate"] : 0;
$cno = (is_numeric($input["cno"]))? $input["cno"] : 0;
$crate = (is_numeric($input["crate"]))? $input["crate"] : 0;
$db["oCharge"] = json_encode(array($ano,$arate,$cno,$crate));
$charge = $ano * $arate + $cno * $crate;
$charge = $charge + ($charge)*($db["sTax"]/100);
$db["amount"] = $charge + $fcharge;
$db["aNet"] = $db["amount"] - $db["less"];
$db["aPending"] = $db["aNet"] - $db["advance"];
break;
case "food":
$afno = (is_numeric($input["afno"]))? $input["afno"] : 0;
$afrate = (is_numeric($input["afrate"]))? $input["afrate"] : 0;
$cfno = (is_numeric($input["cfno"]))? $input["cfno"] : 0;
$cfrate = (is_numeric($input["cfrate"]))? $input["cfrate"] : 0;
$efrate = (is_numeric($input["efrate"]))? $input["efrate"] : 0;
$dayTot = (is_numeric($input["dayTot"]))? $input["dayTot"] : 1;
$db["fCharge"] = json_encode(array($afno,$afrate,$cfno,$cfrate,$efrate,$dayTot));
$fcharge = ($afno * $afrate + $cfno * $cfrate + $efrate) * $dayTot;
$db["amount"] = $fcharge + ($fcharge)*($db["vat"]/100);
$db["aNet"] = $db["amount"] - $db["less"]; $db["aPending"] = $db["aNet"] - $db["advance"];
break;
}
$this->db->where("id",$input["id"]);
$this->db->update("rpayment",$db);
return true;
}
function getPaymentList($where=array(),$like=array(),$per_page=null) {
$this->db->like($like);
$this->db->where($where);
if($per_page==null) {
return $this->db->get("rpayment")->num_rows();
} else {
$this->db->order_by("id","desc");
return $this->db->get("rpayment",$per_page,$this->uri->segment(3));
}
}
}
previously this was working but after I added some fields in my page since then it is not working.