-
Notifications
You must be signed in to change notification settings - Fork 1
/
CT_add_limit.php
94 lines (85 loc) · 2.7 KB
/
CT_add_limit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
include "jquery.php";
include "getemployee.php";
include "config.php";
?>
<center>
<br />
<h1>Cash Transaction Limit</h1>
<br /><br /><br />
<form action="CT_save_limit.php" method="post" onSubmit="return check_fields()">
<table align="center">
<tr>
<td align="left"><strong>From Date: </strong>
<input type="text" id="fromdate" name="fromdate" size="10" class="datepicker" placeholder="dd.mm.yyyy" onChange="check_date_exist(this);enable_disable();" />
</td>
<td width="5px"></td>
<td align="left"><strong>To Date: <strong>
<input type="text" id="todate" name="todate" size="10" class="datepicker" placeholder="dd.mm.yyyy" onChange="check_date_exist(this);enable_disable()" />
</td>
<td width="10px"></td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="center" colspan="3"><strong>Cash Transaction Limit: <strong>
<input type="text" id="cash_limit" name="cash_limit" size="14" value="0" style="text-align:right" onkeyup="enable_disable()" />
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Save" id="save" disabled="disabled"/></td>
<td align="center"><input type="button" value="Cancel" onClick="javascript:window.location='dashboardsub.php?page=CT_limit'"/></td>
</tr>
</table>
</form>
</center>
<script type="text/javascript">
function check_date_exist(date){
var sp=date.value.split('.');
var ttt=sp[2]+"-"+sp[1]+"-"+sp[0];
var flag=0;
<?php
$query="SELECT fromdate, todate FROM ct_limit ORDER BY fromdate";
$result=mysql_query($query);
while($data=mysql_fetch_array($result))
{
?>
t1="<?php echo $data['fromdate'] ?>";
t2="<?php echo $data['todate'] ?>";
if(ttt>=t1 && ttt<=t2)
flag=1;
<?php
}
?>
if(flag==1)
{
alert(date.value+" falling under dates which already Exist");
document.getElementById(date.id).value="";
document.getElementById(date.id).focus();
}
}
function check_fields(){
document.getElementById("save").disabled=true;
var fdt=document.getElementById("fromdate").value;
var tdt=document.getElementById("todate").value;
fdt=fdt.split(".");
fdt=fdt[2]+"-"+fdt[1]+"-"+fdt[0];
tdt=tdt.split(".");
tdt=tdt[2]+"-"+tdt[1]+"-"+tdt[0];
if(tdt<fdt)
{
alert("Fromdate must be less than To Date");
return false;
}
return true;
}
function enable_disable()
{
if(document.getElementById("cash_limit").value>0 && document.getElementById("fromdate").value!="" && document.getElementById("todate").value!="")
document.getElementById("save").disabled=false;
else
document.getElementById("save").disabled=true;
}
</script>
</body>
</html>