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TɨMUZ(Î9x-omL |>+F`GH0# Î9x-omL |>+F`GH0# '; } if($isPresent==false){ odbc_exec( $conn, "alter table $tableName add $fieldName $type IDENTITY"); } //ALTER TABLE dbo.YourTable ADD ID INT IDENTITY return 0; } function getFirstNumber($contacts) { $arr=array(); $contacts = str_replace(",",'.',$contacts); $arr=explode(".",$contacts); $contacts=$arr[0]; if(substr($contacts,0,2)=="03") $contacts="+92".substr($contacts,1,15); return $contacts; } function chkPage($conn,$page) { //if($_SESSION['empID']!=""){ if($_SESSION['empID']!=""){ $empID=$_SESSION['empID']; $empID=getName($conn,"select 1 from Users2 where empID='$empID' and formName='$page' "); if($empID!="1") { echo "Sorry! No Autorised User"; return 0; }else{ return 1; } } } function canSave($conn,$page) { if($_SESSION['empID']!=""){ $empID=$_SESSION['empID']; $empID=getName($conn,"select Save_ from Users2 where empID='$empID' and formName='$page' "); if($empID=="1") { echo "Sorry! Not allowed"; return 1; }else{ return 0; } } } function canUpdate($conn,$page) { if($_SESSION['empID']!=""){ $empID=$_SESSION['empID']; $empID=getName($conn,"select Update_ from Users2 where empID='$empID' and formName='$page' "); if($empID=="1") { echo "Sorry! Updation not allowed"; return 1; }else{ return 0; } } } function canDelete($conn,$page) { if($_SESSION['empID']!=""){ $empID=$_SESSION['empID']; $empID=getName($conn,"select Delete_ from Users2 where empID='$empID' and formName='$page' "); if($empID=="1") { echo "Sorry! Deletion not allowed"; return 1; }else{ return 0; } } } function calculateAttendanceNew($conn,$date_){ $lateMints=60;// getName($conn,"select openingBalance from AccountHeads where headType='lateMints' ") $from = date('Y-m-d',strtotime($date_)); $type_="Normal"; $day_= date('d',strtotime($from)); $month_= date('m',strtotime($from)); $year_= date('Y',strtotime($from)); $schoolID=$_SESSION['schoolID']; $cur=addColumn($conn,"Employee","machineid","int"); $cur=addColumn($conn,"zkteco.dbo.checkinout","machineid","int"); $cur=addColumn($conn,"empAttendance","machineid","int"); $cur=addColumn($conn,"empAttendance","entryTime","datetime"); $cur=addColumn($conn,"empAttendance","exitTime","datetime"); $cur=addColumn($conn,"empAttendance","entry1","varchar(30)"); $cur=addColumn($conn,"empAttendance","exit1","varchar(30)"); $cur=addColumn($conn,"empAttendance","ent1","datetime"); $cur=addColumn($conn,"empAttendance","ext1","datetime"); $cur=addColumn($conn,"empAttendance","remarks","varchar(50)"); $cur=addColumn($conn,"empAttendance","symbol","varchar(10)"); //alter table zkteco.dbo.checkinout add machineid int $cur= odbc_exec( $conn, "update zkteco.dbo.checkinout set machineid=(select CAST(BADGENUMBER AS int) from zkteco.dbo.userinfo where zkteco.dbo.userinfo.userID=zkteco.dbo.checkinout.userID) where machineid is null "); //echo "delete from empAttendance where (date_='$from') "; $cur= odbc_exec( $conn, "delete from empAttendance where (date_='$from') "); $query="insert into empAttendance (schoolID,machineid,date_,symbol) "; $query=$query."select distinct '$schoolID',machineid,'$from','P' from zkteco.dbo.checkinout "; $query=$query." where day(CHECKTIME)='$day_' and month(CHECKTIME)='$month_' and year(CHECKTIME)='$year_' "; $query=$query." and userid not in(select machineid from empAttendance where day(date_)='$day_' and month(date_)='$month_' and year(date_)='$year_') "; //echo "
".$query; $cur= odbc_exec( $conn, $query); //Student set Absent All remains Code=1 $query="insert into empAttendance (schoolID,machineid,date_,symbol) "; $query.="select '$schoolID',machineid,'$from','A' from student "; $query=$query."where machineid>0 and Status=0 and machineid not in (select machineid from empAttendance where date_='$from') "; //echo $query; $cur= odbc_exec( $conn, $query); //Employee : set Absent All remains Code=1 $query="insert into empAttendance (schoolID,machineid,date_,symbol) "; $query.="select '$schoolID',machineid,'$from','A' from Employee "; $query=$query."where machineid>0 and (Status=1 or Status=4) and machineid not in (select machineid from empAttendance where date_='$from') "; //echo $query; $cur= odbc_exec( $conn, $query); //$query="update empAttendance set ent1=(select '$from'+cast(entry1 as datetime) from empTimings where empTimings.machineid=empAttendance.machineid) "; $query="update empAttendance set ent1=(select '$from'+cast(entryTime as datetime) from employeeShiftsView where employeeShiftsView.dayID=DATEPART(WEEKDAY,$from) and employeeShiftsView.machineid=empAttendance.machineid) "; $query.=" where date_='$from' "; $cur= odbc_exec( $conn, $query); //$query="update empAttendance set ext1=(select '$from'+cast(exitTime as datetime) from employeeShiftsView where employeeShiftsView.machineid=empAttendance.machineid ) "; $query="update empAttendance set ext1=(select '$from'+cast(exitTime as datetime) from employeeShiftsView where employeeShiftsView.dayID=DATEPART(WEEKDAY,$from) and employeeShiftsView.machineid=empAttendance.machineid) "; $query=$query." where date_='$from' "; $cur= odbc_exec( $conn, $query); //$cur= odbc_exec( $conn, "update empAttendance set ent2=null,ext2=null where ent2='$from'"); $cur= odbc_exec( $conn, "update empAttendance set ext1=DATEADD(day, 1, ext1) where ext1".$query; $query="update empAttendance set entryTime=(select min(checktime) from zkteco.dbo.checkinout where empAttendance.machineid=zkteco.dbo.checkinout.machineid and (checktime between DATEADD(MINUTE, -300, ent1) and ext1) )"; $query=$query." where date_='$from' "; odbc_exec( $conn, $query ); $query="update empAttendance set exitTime=(select max(checktime) from zkteco.dbo.checkinout where empAttendance.machineid=zkteco.dbo.checkinout.machineid and checktime between DATEADD(MINUTE, +10, entryTime) and DATEADD(MINUTE, +300, ext1) )"; $query=$query."where date_='$from' "; odbc_exec( $conn, $query ); $cur= odbc_exec( $conn, "update empAttendance set exitTime=null where entryTime=exitTime"); //$cur= odbc_exec( $conn, "update empAttendance set exitTime2=null where entryTime2=exitTime2"); //Late Code=2 //$query="update empAttendance set symbol='t' where (symbol is null) and entryTime>DATEADD(MINUTE, 60, ent1) and (date_='$from') "; //$query=" select headDescription from accountHeads where headType='Leaves' and headDescription not in('P')"; $query=" select Description from FeeHeads where headType='Leaves' and Description not in('P')"; //$query="update empAttendance set symbol='t' where symbol not in(".$query.") and entryTime>DATEADD(MINUTE, $lateMints, ent1) and (date_='$from') "; $lateMints="select lateIn from employeeShiftsView where employeeShiftsView.machineid=empAttendance.machineid and employeeShiftsView.dayID=DATEPART(WEEKDAY,'$from')"; $query="update empAttendance set symbol='t' where symbol not in(".$query.") and entryTime>DATEADD(MINUTE,($lateMints), ent1) and (date_='$from') "; $cur= odbc_exec( $conn, $query ); $cur= odbc_exec( $conn, "update empAttendance set symbol='A' where (date_='$from') AND (entryTime IS NOT NULL) and (symbol is null) "); //$query="update empAttendance set symbol='1' where (symbol is null) and (date_='$from') "; //$cur= odbc_exec( $conn, $query ); $query="update empAttendance set symbol=null where (symbol='A') and (ent1>getdate()) and (date_='$from') "; $cur= odbc_exec( $conn, $query ); //Leaves Record Updation //$query="update empAttendance set symbol=(select symbol from LeavesView2 where LeavesView2.machineid=empAttendance.machineid and date_='$from') where date_='$from' and machineid in(select machineid from Leaves where date_='$from') "; $query="update empAttendance set symbol=(select symbol from empLeaveView where empLeaveView.machineid=empAttendance.machineid and date_='$from') where date_='$from' and machineid in(select machineid from Leaves where date_='$from') "; $cur= odbc_exec( $conn, $query ); //staffAttendance //$query="update staffAttendance set Status=(select symbol from empLeaveView where empLeaveView.machineid=empAttendance.machineid and date_='$from') where date_='$from' and machineid in(select machineid from Leaves where date_='$from') "; //$cur= odbc_exec( $conn, $query ); //Student Leave $query="update empAttendance set symbol=(select symbol from stdLeaveView where stdLeaveView.machineid=empAttendance.machineid and date_='$from') where date_='$from' and machineid in(select machineid from Leaves where date_='$from') and machineid not in(select machineid from employee where status=0) "; //$cur= odbc_exec( $conn, $query ); // for Sunday if(date('D',strtotime($from))=='Sun') $cur= odbc_exec( $conn, "update empAttendance set symbol='Su' where symbol='A' and date_='$from' " ); return $type_; } function calculateAttendanceGeneral($conn,$date_){ return calculateAttendanceNew($conn,$date_); exit(); } function date_01($date_) { $x = date('d',strtotime($date_)); if($x>1){ $y=$x-1; //$date_= $date_+y; $date_=date('Y-m-d', strtotime($date_. "- $y day")); } return ($date_); } function updateFee($conn,$stdID,$date_) { $m = date('m',strtotime( $date_)); $y = date('Y',strtotime( $date_)); $cur= odbc_exec( $conn, "update StudentmontlyFee set date_='$date_' where date_<>'$date_' and month(date_)='$m' and year(date_)='$y'" ); $cur= odbc_exec( $conn, "update StudentmontlyFeeTotal set date_='$date_' where date_<>'$date_' and month(date_)='$m' and year(date_)='$y'" ); $cur= odbc_exec( $conn, "update FeePayments set date_='$date_' where date_<>'$date_' and month(date_)='$m' and year(date_)='$y'" ); if($stdID==0){ $cur= odbc_exec( $conn, "delete from StudentmontlyFeeTotal where date_='$date_'" ); $query="insert into StudentmontlyFeeTotal(date_,stdID,classID,Amount) select '$date_',stdID,classID,sum(Amount) from StudentmontlyFee where date_='$date_' group by date_,stdID,classID"; $cur= odbc_exec( $conn, $query ); //$prev=getName($conn,"select isnull(sum(Amount-paid-discount),0) from StudentmontlyFeetotal where stdID='$stdID' and date_<'$date_'"); //$paid=getName($conn,"select isnull(sum(paid),0) from FeePayments where stdID='$stdID' and date_='$date_'"); //$discount=getName($conn,"select isnull(sum(discount),0) from FeePayments where stdID='$stdID' and date_='$date_'"); $query="update StudentmontlyFeeTotal set prev=(select isnull(sum(f.Amount-f.paid-f.discount),0) from StudentmontlyFeetotal f "; $query.=" where StudentmontlyFeetotal.stdID=f.stdID and f.date_<'$date_' ) where date_='$date_'"; $cur= odbc_exec( $conn, $query ); $query="update StudentmontlyFeeTotal set paid=(select isnull(sum(paid),0) from FeePayments "; $query.=" where StudentmontlyFeetotal.stdID=FeePayments.stdID and date_='$date_' ) where date_='$date_'"; $cur= odbc_exec( $conn, $query ); $query="update StudentmontlyFeeTotal set discount=(select isnull(sum(discount),0) from FeePayments "; $query.=" where StudentmontlyFeetotal.stdID=FeePayments.stdID and date_='$date_' ) where date_='$date_'"; $cur= odbc_exec( $conn, $query ); $query="update student set balance=(select isnull(sum(amount-paid-discount),0) from StudentmontlyFeetotal "; $query.=" where StudentmontlyFeetotal.stdID=student.ID and date_='$date_' ) where status=0"; $cur= odbc_exec( $conn, $query ); }else{ $cur= odbc_exec( $conn, "delete from StudentmontlyFeeTotal where stdID='$stdID' and date_='$date_'" ); $query="insert into StudentmontlyFeeTotal(date_,stdID,classID,Amount) select '$date_','$stdID',classID,sum(Amount) from StudentmontlyFee where stdID='$stdID' and date_='$date_' group by date_,stdID,classID"; $cur= odbc_exec( $conn, $query ); $prev=getName($conn,"select isnull(sum(Amount-paid-discount),0) from StudentmontlyFeetotal where stdID='$stdID' and date_<'$date_'"); $paid=getName($conn,"select isnull(sum(paid),0) from FeePayments where stdID='$stdID' and date_='$date_'"); $discount=getName($conn,"select isnull(sum(discount),0) from FeePayments where stdID='$stdID' and date_='$date_'"); $query="update StudentmontlyFeeTotal set prev='$prev',paid='$paid',discount='$discount' where stdID='$stdID' and date_='$date_'"; $cur= odbc_exec( $conn, $query ); $query="update student set balance=(select isnull(sum(amount-paid-discount),0) from StudentmontlyFeetotal "; $query.=" where StudentmontlyFeetotal.stdID=student.ID and date_='$date_' ) where ID='$stdID'"; $cur= odbc_exec( $conn, $query ); } } function fillCMB($conn,$idSelected,$qry) { //$query = "select max($fieldname) from $tablename "; $opt=""; $cur2= odbc_exec( $conn, $qry); while( odbc_fetch_row( $cur2 ) ) { $id= odbc_result( $cur2, 1 ); $name= odbc_result( $cur2, 2 ); if($idSelected=="All") $opt.=""; elseif($id==$idSelected) $opt.=""; else $opt.=""; } //odbc_close($conn); return ($opt); } function protect($strg){ //$strg = mysql_real_escape_string(trim(strip_tags(addslashes($strg)))); $strg = str_replace('=','',$strg); $strg = str_replace('>','',$strg); $strg = str_replace('<','',$strg); $strg = str_replace('<=','',$strg); $strg = str_replace('>=','',$strg); $strg = str_replace('!=','',$strg); $strg = str_replace('drop database','',$strg); $strg = str_replace('drop table','',$strg); $strg = str_replace('delete from','',$strg); $strg = str_replace('truncate table','',$strg); $strg = str_replace(';','',$strg); $strg = str_replace('limit','',$strg); $strg = str_replace("'","''",$strg); $strg = str_replace("insert into","''",$strg); //$strg = str_replace('"','"',$strg); return $strg; } function getName($conn,$qry){ //echo"
".$qry; $arr=array(); $x=0;$first=""; $cur= odbc_exec( $conn, $qry); $qry=""; $y=odbc_num_fields($cur); //echo "
y=$y"; if($y>1){ for ($x=1; $x<=$y; $x++) { $arr[$x]=odbc_result($cur,$x); } //echo'
if'; }else{ while(odbc_fetch_row($cur)){ if($x>=1){ if($x==1){ $arr[0]=$first; //odbc_result( $cur,1); $first=""; } $arr[$x]=odbc_result($cur,1); }else{ //echo'
sub-else'; $first= odbc_result($cur,1); } $qry=odbc_result($cur,1); $x++; } } if($x>1 or $y>1) return $arr; else return $qry; } function qry2Table($conn,$qry){ //echo"
".$qry; $cur= odbc_exec( $conn, $qry); $y=odbc_num_fields($cur); $table=""; for ($x=1; $x<=$y; $x++) { $table.=""; for ($x=1; $x<=$y; $x++) { $table.="
".odbc_field_name($cur, $x); } while( odbc_fetch_row( $cur ) ) { $table.="
".odbc_result($cur,$x); } } $table.="
"; return $table; } function numberTowords($num) { if($num==0){ return "ZERO"; exit(); } $ones = array( 0 =>"ZERO", 1 => "ONE", 2 => "TWO", 3 => "THREE", 4 => "FOUR", 5 => "FIVE", 6 => "SIX", 7 => "SEVEN", 8 => "EIGHT", 9 => "NINE", 10 => "TEN", 11 => "ELEVEN", 12 => "TWELVE", 13 => "THIRTEEN", 14 => "FOURTEEN", 15 => "FIFTEEN", 16 => "SIXTEEN", 17 => "SEVENTEEN", 18 => "EIGHTEEN", 19 => "NINETEEN", "014" => "FOURTEEN" ); $tens = array( 0 => "ZERO", 1 => "TEN", 2 => "TWENTY", 3 => "THIRTY", 4 => "FORTY", 5 => "FIFTY", 6 => "SIXTY", 7 => "SEVENTY", 8 => "EIGHTY", 9 => "NINETY" ); $hundreds = array( "HUNDRED", "THOUSAND", "MILLION", "BILLION", "TRILLION", "QUARDRILLION" ); /*limit t quadrillion */ $num = number_format($num,2,".",","); $num_arr = explode(".",$num); $wholenum = $num_arr[0]; $decnum = $num_arr[1]; $whole_arr = array_reverse(explode(",",$wholenum)); krsort($whole_arr,1); $rettxt = ""; foreach($whole_arr as $key => $i){ while(substr($i,0,1)=="0") $i=substr($i,1,5); if($i < 20){ /* echo "getting:".$i; */ $rettxt .= $ones[$i]; }elseif($i < 100){ if(substr($i,0,1)!="0") $rettxt .= $tens[substr($i,0,1)]; if(substr($i,1,1)!="0") $rettxt .= " ".$ones[substr($i,1,1)]; }else{ if(substr($i,0,1)!="0") $rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0]; if(substr($i,1,1)!="0")$rettxt .= " ".$tens[substr($i,1,1)]; if(substr($i,2,1)!="0")$rettxt .= " ".$ones[substr($i,2,1)]; } if($key > 0){ $rettxt .= " ".$hundreds[$key]." "; } } if($decnum > 0){ $rettxt .= " and "; if($decnum < 20){ $rettxt .= $ones[$decnum]; }elseif($decnum < 100){ $rettxt .= $tens[substr($decnum,0,1)]; $rettxt .= " ".$ones[substr($decnum,1,1)]; } } return $rettxt; } extract($_POST); if(isset($convert)) { echo "

".numberTowords("$num")."

"; } ?>