<?php
/*=================================================================
functionfile.php
Contains functions to execute php functions
===================================================================*/
class OOSFunction
{
var $USERTYPEARR = array('P'=>'Patient','D' =>'Doctor','S'=>'Staff','V'=>'Visitor');
var $TimeSlotArr = array('00'=>'12 AM','01'=>'1 AM','02'=>'2 AM','03'=>'3 AM','04'=>'4 AM','05'=>'5 AM','06'=>'6 AM','07'=>'7 AM','08'=>'8 AM','09'=>'9 AM','10'=>'10 AM','11'=>'11 AM','12'=>'12 PM','13'=>'1 PM','14'=>'2 PM','15'=>'3 PM','16'=>'4 PM','17'=>'5 PM','18'=>'6 PM','19'=>'7 PM','20'=>'8 PM','21'=>'9 PM','22'=>'10 PM','23'=>'11 PM');
var $VISITDAYARR = array('monday'=>'Monday','tuesday' =>'Tuesday','wed'=>'Wednesday','thurs'=>'Thursday','fri'=>'Friday','sat'=>'Saturday','sunday'=>'Sunday');
//========================================================
function GenerateSMSText($SMSFor, $RecordID)
{
}
//========================================================
//========================================================
//.......function to generate investor reg. number series..
//========================================================
function GenerateInvestRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(invest_reg_num,6,5) as InvNum,
invest_reg_num from member_master
where invest_reg_num IS NOT NULL AND invest_reg_num != ''
order by InvNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "I".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['invest_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "I".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate associate reg. number series..
//========================================================
function GenerateAssociateRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(assoc_reg_num,6,5) as AssocNum,
assoc_reg_num from member_master
where is_assoc ='Yes' order by AssocNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "A".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['assoc_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "A".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate Unit Reigstraion no. series..
//========================================================
function GenerateUnitRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(unit_regno,6,5) as RegUnitNum,
unit_regno from plan_member_registration
order by RegUnitNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "U".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['unit_regno'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "U".date('ym').$PadStr.$NextNum;
}//........end else..............
// echo $InvestorNo;
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate payment receipt number series..
//========================================================
function GenerateReceiptNo()
{
/* $InvRS = $this->SimpleRunQuery("select invest_reg_num from member_master
order by member_id DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "I".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['invest_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "I".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
*/}//..............end function.................
//========================================================
//================================================================================
//=function GenrateBarcodeImage to generate barcode...............................
//================================================================================
//$BCString - String to generate barcode..................
//================================================================================
function GenrateBarcodeImage($BCString, $FontSize=10)
{
if($BCString == '' or strlen($BCString) < 3)
return '';
require_once(DIRPATH.'/common/barcode/BCGFont.php');
require_once(DIRPATH.'/common/barcode/BCGColor.php');
require_once(DIRPATH.'/common/barcode/BCGDrawing.php');
// Including the barcode technology
include_once(DIRPATH.'/common/barcode/BCGcode39.barcode.php');
$font = new BCGFont(DIRPATH.'/common/barcode/font/Arial.ttf', $FontSize);
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$code = new BCGcode39();
$code->setScale(1); // Resolution
$code->setThickness(10); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse($BCString); // Text
$drawing = new BCGDrawing(DIRPATH.'adminpanel/invbarcodeimg.png', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
return file_get_contents(DIRPATH.'adminpanel/invbarcodeimg.png');
}
//================================================================================
//================================================================================
//.......function GetNextDueDate() to get next payment due date as per plan.......
//================================================================================
/*
@param -
$RegDate - date of plan registration
$PremPayDuration - Duration to pay premium
$DurationType - Duration type
$NoInstallment - total no. of installments to be paid
*/
//================================================================================
function GetNextDueDate($RegDate,$PremPayDuration,$DurationType, $PaidInstallment)
{
//........get no. of installments paid.....................
//echo $RegDate."::".$PremPayDuration."::".$DurationType."::".$PaidInstallment;
$RDArr = explode("-",$RegDate);
$RegTime = mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]);
$NextInst = ($PaidInstallment) * $PremPayDuration;
if($DurationType == 'Day')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2]+$NextInst,$RDArr[0]));
}
elseif($DurationType == 'Month')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1]+$NextInst,$RDArr[2],$RDArr[0]));
}
elseif($DurationType == 'Year')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]+$NextInst));
}
elseif($DurationType == 'Once')
{
$NextDueDate = "NA";
}
return $NextDueDate;
}
//================================================================================
//================================================================================
//.......function GetERVDate() to get ERV date as per plan.......
//================================================================================
/*
@param -
$RegDate - date of plan registration
$PremPayDuration - Duration to pay premium
$DurationType - Duration type
*/
//================================================================================
function GetERVDate($RegDate,$PremPayDuration,$DurationType)
{
//........get no. of installments paid.....................
//echo $RegDate."::".$PremPayDuration."::".$DurationType."::".$PaidInstallment;
$RDArr = explode("-",$RegDate);
$RegTime = mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]);
if($DurationType == 'Day')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2]+$PremPayDuration,$RDArr[0]));
}
elseif($DurationType == 'Month')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1]+$PremPayDuration,$RDArr[2],$RDArr[0]));
}
elseif($DurationType == 'Year')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]+$PremPayDuration));
}
elseif($DurationType == 'Once')
{
$NextDueDate = "NA";
}
return $NextDueDate;
}
//================================================================================
//================================================================================
//...........function StoreAssocIncentive() to store incentive of associate.....
/*
@param
- $MemberId -> Lower level investor or associte id
- $ReceiptNo -> Payment Receipt no...
*/
//================================================================================
//================================================================================
function StoreAssocIncentive($MemberId, $ReceiptNo)
{
if($MemberId == '' || $ReceiptNo == '')
return;
//............check if the member has any associate divide incentive ........
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount == 0)
return;
$MemInfo = $MemRS[0];
if($MemInfo['intro_asso_id'] == '0')
return;
//..........get required details to store associate incentive..........
$RecRS = $this->SelectQuery("payment_receipt_master",array('receipt_id'=>$ReceiptNo),$TotalRpCnt);
$RecInfo = $RecRS[0];
$PMemRS = $this->SelectQuery("plan_member_registration",array('plan_mem_regno'=>$RecInfo['plan_member_regno']),$TotalPMemCnt);
$PMemInfo = $PMemRS[0];
$AssocId = $MemInfo['intro_asso_id'];
$PlanCatId = $PMemInfo['plan_cat_id'];
$PlanId = $PMemInfo['plan_id'];
$SubPlanId = $PMemInfo['sub_plan_id'];
$PlanCode = $PMemInfo['plan_code'];
$RegDate = $PMemInfo['reg_date'];
$InvestMemId = $PMemInfo['member_id'];
$PremiumAmt = $RecInfo['inst_amount'];
$MemDesigId = $MemInfo['desig_id'];
$AssocDesigId = $this->GetValueById("member_master","member_id",$AssocId,"desig_id");
$InvestDesigId = $this->GetValueById("member_master","member_id",$InvestMemId,"desig_id");
//......................................................................
//......get plan details to get no. of years.....
$PlRS = $this->SelectQuery("plan_master",array('plan_id'=>$PlanId),$TotalPlCnt);
$PlRow = $PlRS[0];
$PlCatRS = $this->SelectQuery("plan_category_master",array('plan_cat_id'=>$PlanCatId),$TotalPlCatCnt);
$PlCatRow = $PlCatRS[0];
$PlCatIncType = $PlCatRow['cat_ret'];
/*
if($PlCatIncType == 'RD')
{
$DayDiff = $this->DateDifference(date('Y-m-d'),$RegDate);
if($DayDiff != '' && $DayDiff >= 365)
{
$YearNum = ceil($DayDiff/365);
}
else
$YearNum = 1;
}
else
{
$YearNum = $PlRow['plan_duration'] / 12;
}//....end else..............
*/
$YearNum = $PlRow['plan_duration'] / 12;
//echo $YearNum;
//==================================================================
if($InvestMemId == $MemberId && $InvestDesigId == 0)
$AssocDesigFromId = 1;
elseif($InvestMemId == $MemberId && $InvestDesigId > 0)
$AssocDesigFromId = $InvestDesigId+1;
elseif($InvestMemId != $MemberId && $MemDesigId != $AssocDesigId)
$AssocDesigFromId = $MemDesigId+1;
else
$AssocDesigFromId = $MemDesigId;
$IncSql = "SELECT SUM(incent_value) as TotalInc FROM designation_incentive_master
WHERE plan_year = '".$YearNum."' AND (desig_id BETWEEN
'".$AssocDesigFromId."' AND '".$AssocDesigId."')
AND plan_cat_id ='".$PlanCatId."' GROUP BY plan_cat_id";
$IncRS = $this->SimpleRunQuery($IncSql, $IncCnt);
$IncPer = $IncRS[0]['TotalInc'];
$IncAmt = round(($PremiumAmt * $IncPer)/100,2);
//.........store into database.....................
if($AssocId == $MemberId)
return;
if($AssocDesigId > 0)
{
$IncValueArr = array("receipt_id"=>$ReceiptNo,"plan_cat_id"=>$PlanCatId,"invest_mem_id"=>$InvestMemId,"assoc_mem_id"=>$AssocId,"mediat_mem_id"=>$MemberId,"plan_id"=>$PlanId,"sub_plan_id"=>$SubPlanId,"plan_code"=>$PlanCode,"assoc_desig_id"=>$AssocDesigId,"mediat_desig_id"=>$MemDesigId,'invest_desig_id'=>$InvestDesigId,"inc_per"=>$IncPer,"inc_amt"=>$IncAmt,"inc_date"=>date('Y-m-d'));
$this->InsertQuery("incentive_detail",$IncValueArr);
}
$this->StoreAssocIncentive($AssocId, $ReceiptNo);
//......................................................................
return;
}
//================================================================================
//================================================================================
//...........function StoreSelfIncentive() to store incentive of self incentive.....
/*
@param
- $MemberId -> investor id
- $ReceiptNo -> Payment Receipt no...
*/
//================================================================================
//================================================================================
function StoreSelfIncentive($MemberId, $ReceiptNo)
{
if($MemberId == '' || $ReceiptNo == '')
return;
//............check if the member has any associate divide incentive ........
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount == 0)
return;
$MemInfo = $MemRS[0];
if($MemInfo['intro_asso_id'] == '0')
return;
//..........get required details to store incentive..........
$RecRS = $this->SelectQuery("payment_receipt_master",array('receipt_id'=>$ReceiptNo),$TotalRpCnt);
$RecInfo = $RecRS[0];
$PMemRS = $this->SelectQuery("plan_member_registration",array('plan_mem_regno'=>$RecInfo['plan_member_regno']),$TotalPMemCnt);
$PMemInfo = $PMemRS[0];
$PlanCatId = $PMemInfo['plan_cat_id'];
$PlanId = $PMemInfo['plan_id'];
$SubPlanId = $PMemInfo['sub_plan_id'];
$PlanCode = $PMemInfo['plan_code'];
$RegDate = $PMemInfo['reg_date'];
$InvestMemId = $PMemInfo['member_id'];
$PremiumAmt = $RecInfo['inst_amount'];
$MemDesigId = $MemInfo['desig_id'];
$AssocDesigId = $this->GetValueById("member_master","member_id",$AssocId,"desig_id");
$InvestDesigId = $this->GetValueById("member_master","member_id",$InvestMemId,"desig_id");
//......................................................................
//......get plan details to get no. of years.....
$PlRS = $this->SelectQuery("plan_master",array('plan_id'=>$PlanId),$TotalPlCnt);
$PlRow = $PlRS[0];
$PlCatRS = $this->SelectQuery("plan_category_master",array('plan_cat_id'=>$PlanCatId),$TotalPlCatCnt);
$PlCatRow = $PlCatRS[0];
$PlCatIncType = $PlCatRow['cat_ret'];
/*
if($PlCatIncType == 'RD')
{
$DayDiff = $this->DateDifference(date('Y-m-d'),$RegDate);
if($DayDiff != '' && $DayDiff >= 365)
{
$YearNum = ceil($DayDiff/365);
}
else
$YearNum = 1;
}
else
{
$YearNum = $PlRow['plan_duration'] / 12;
}//....end else..............
*/
$YearNum = $PlRow['plan_duration'] / 12;
//echo $YearNum;
//==================================================================
if($InvestMemId == $MemberId)
$AssocDesigFromId = 1;
$AssocDesigId = $MemDesigId;
$IncSql = "SELECT SUM(incent_value) as TotalInc FROM designation_incentive_master
WHERE plan_year = '".$YearNum."' AND (desig_id BETWEEN
'".$AssocDesigFromId."' AND '".$AssocDesigId."')
AND plan_cat_id ='".$PlanCatId."' GROUP BY plan_cat_id";
$IncRS = $this->SimpleRunQuery($IncSql, $IncCnt);
$IncPer = $IncRS[0]['TotalInc'];
//echo $IncPer;
//exit();
$IncAmt = round(($PremiumAmt * $IncPer)/100,2);
//.........store into database.....................
// if($AssocId == $MemberId)
// return;
if($AssocDesigId > 0)
{
$IncValueArr = array("receipt_id"=>$ReceiptNo,"plan_cat_id"=>$PlanCatId,"invest_mem_id"=>$InvestMemId,"assoc_mem_id"=>$InvestMemId,"mediat_mem_id"=>$MemberId,"plan_id"=>$PlanId,"sub_plan_id"=>$SubPlanId,"plan_code"=>$PlanCode,"assoc_desig_id"=>$AssocDesigId,"mediat_desig_id"=>$MemDesigId,'invest_desig_id'=>$InvestDesigId,"inc_per"=>$IncPer,"inc_amt"=>$IncAmt,"inc_date"=>date('Y-m-d'));
$this->InsertQuery("incentive_detail",$IncValueArr);
}
//......................................................................
return;
}
//================================================================================
//================================================================================
//...........function GetInvestorUnderAssosiate() to get investors under given associate.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetInvestorUnderAssosiate($MemberId, $ParentTag = 'No')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
$MemName = $MemRow['title_name']." ".$MemRow['full_name'];
if($MemRow['desig_id'] != '' && $MemRow['desig_id'] != '0')
{
$Designation = $this->GetValueById("designation_master","desig_id",$MemRow['desig_id'],"desig_name");
$Designation = "(".$Designation.")";
}
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0' || $ParentTag=='Yes')
$AssosRegNum = '';
else
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
echo "[{v:'".$MemRegNum."', f:'".$MemRegNum."<br>".$MemName."<br>".$Designation."'}, '".$AssosRegNum."', ''],";
//echo "<br><br> ".$MemRegNum." --- ".$MemName." ( ".$Designation."') ::: '".$AssosRegNum."'";
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetInvestorUnderAssosiate($MemRow['member_id']);
}
}
}//.....end function.........
//================================================================================
//================================================================================
//...........function GetLevelInvestorUnderAssosiate() to get investors under given associate upto 2 level.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetLevelInvestorUnderAssosiate($MemberId, $ParentTag = 'No', $LevelNo, $GoHigher='Yes')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
$MemName = $MemRow['title_name']." ".$MemRow['full_name'];
if($MemRow['desig_id'] != '' && $MemRow['desig_id'] != '0')
{
$Designation = $this->GetValueById("designation_master","desig_id",$MemRow['desig_id'],"desig_name");
$Designation = "(".$Designation.")";
}
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0')
$AssosRegNum = '';
else
{
//.........check if further investors exists under this associate..............
$InvIntroRS = $this->SelectQuery("member_master",array("intro_asso_id" => $MemberId), $TtlIntroCnt);
}
if($LevelNo == '1')
{
if($AssosRegNum != '' && $GoHigher != 'No')
{
echo "<tr><td style='text-align:center;'>
<center><div style='width:150px;' class='level1' onclick='DisplayNewChart(\"".$AssosRegNum."\")'>".$MemRegNum."<br>".$MemName."<br>".$Designation."</div></center>
</td></tr>";
}
else
{
echo "<tr><td style='text-align:center;'>
<center><div style='width:150px;' class='level1'>".$MemRegNum."<br>".$MemName."<br>".$Designation."</div></center>
</td></tr>";
}
}
else
{
if($TtlIntroCnt > 0)
$ClassName = 'level2';
else
$ClassName = 'level5';
echo "<td style='width:100px; vertical-align:top; padding-left:10px; padding-right:10px;'>
<center><div style='width:100px;'>
<center>
<img src='../images/blue_top.png' border='0' align='absmiddle'/>
</center>
</div>";
if($MemRow['assoc_reg_num'] != '')
{
echo "<div style='width:100px;' class='".$ClassName."' onclick='DisplayNewChart(\"".$MemRegNum."\")'><b>".$MemRegNum."</b><br>".$MemName."<br>".$Designation."</div>";
}
else
{
echo "<div style='width:100px;' class='".$ClassName."'><b>".$MemRegNum."</b><br>".$MemName."<br>".$Designation."</div>";
}
echo "
</center>
</td>";
}
//=============================================================================
if($LevelNo < 2)
{
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
echo '<tr><td style="text-align:center;">
<img src="../images/blue_top.png" border="0" align="absmiddle"/>
</td></tr>
<tr><td style="text-align:center; vertical-align:top;">
<table cellpadding="0" cellspacing="0" border="0" class="leveltable" align=center>
<tr>';
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetLevelInvestorUnderAssosiate($MemRow['member_id'],'No',++$LevelNo);
}
echo '</tr>
</table>
</td>
</tr>';
}
}//......end if
//=============================================================================
//=============================================================================
}//.....end function.........
//================================================================================
//================================================================================
//...........function GetInvestorUnderAssosiate() to get investors under given associate.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetInvestorSummaryUnderAssosiate($MemberId, $ParentTag = 'No')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0' || $ParentTag=='Yes')
$AssosRegNum = '';
else
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
echo "['".$MemRegNum."', '".$AssosRegNum."', ''],";
//echo "<br><br> ".$MemRegNum." --- ".$MemName." ( ".$Designation."') ::: '".$AssosRegNum."'";
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetInvestorSummaryUnderAssosiate($MemRow['member_id']);
}
}
}//.....end function.........
//================================================================================
/*================================================================================
//========= function GetDesignationByDateRange() return designation of a member as per given date range...
@param -
$no - MemberID, $DateFrom, $DateTo
@return
- Desgination and Target amount array.........
=========================================================================================== */
function GetDesignationByDateRange($MemberID, $DateFrom, $DateTo)
{
if($MemberID == '' || $MemberID == '0')
return;
$Query = "SELECT new_desig_id, promote_date FROM associate_promote_master WHERE
(promote_date BETWEEN '".$DateFrom."' AND '".$DateTo."') AND
member_id = '".$MemberID."'
UNION ALL
SELECT new_desig_id, promote_date FROM associate_promote_master WHERE
promote_date <= ".$DateFrom." AND
member_id = '".$MemberID."' ORDER BY promote_date DESC limit 1
";
$MemRS = $this->SimpleRunQuery($Query, $TtlCnt);
if($TtlCnt > 0)
{
$MemRow = $MemRS[0];
$DesRS = $this->SelectQuery("designation_master",array('desig_id'=>$MemRow['new_desig_id']), $DesCnt);
$DesArr = array("TargetAmt" =>$DesRS[0]['target_amt'], "Designation" =>$DesRS[0]['desig_name']);
return $DesArr;
}
else
return;
//.....................
}//....end function
//================================================================================
//================================================================================
/*================================================================================
//========= function CurrencyToWord() convert indian currency from no to words
@param -
$no - amount
=========================================================================================== */
function CurrencyToWord($no)
{
$words = array('0'=> '' ,'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' => 'Fouteen','15' => 'Fifteen','16' => 'Sixteen','17' => 'Seventeen','18' => 'Eighteen','19' => 'Nineteen','20' => 'Twenty','30' => 'Thirty','40' => 'Fourty','50' => 'Fifty','60' => 'Sixty','70' => 'Seventy','80' => 'Eighty','90' => 'Ninty','100' => 'Hundred &','1000' => 'Thousand','100000' => 'Lakh','10000000' => 'Crore');
if($no == 0)
return ' ';
else {
$novalue='';
$highno=$no;
$remainno=0;
$value=100;
$value1=1000;
while($no>=100) {
if(($value <= $no) &&($no < $value1)) {
$novalue=$words["$value"];
$highno = (int)($no/$value);
$remainno = $no % $value;
break;
}
$value= $value1;
$value1 = $value * 100;
}
if(array_key_exists("$highno",$words))
return $words["$highno"]." ".$novalue." ".$this->CurrencyToWord($remainno);
else {
$unit=$highno%10;
$ten =(int)($highno/10)*10;
return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".$this->CurrencyToWord($remainno);
}
}
}
/*=======================================================================================
/*=======================================================================================
//========= function ShowAddLink() to include edit link .....
@param -
$TagName - Name of module
//=========================================================================================== */
function ShowAddLink($TagName = 'Record')
{
$LabelStr = "<label class='newrecord' onClick='AddRecord()' id='YKNRecordTdId' style='height:20px;'>Add New ".$TagName."</label>";
return $LabelStr;
}
/*=======================================================================================
/*=======================================================================================
/*=======================================================================================
//========= function ShowEditLink() to include edit link .....
@param -
$RecordId - Record id
//=========================================================================================== */
function ShowEditLink($RecordId = '0')
{
$LabelStr = "<center><label class='recedit_cls' onClick='EditRecord(\"$RecordId\")'>Edit</label></center>";
return $LabelStr;
}
/*=======================================================================================
//========= function ShowRecordListInfo() to display number of records in the listing .....
@param -
$FromRec - Starts from record no.
$RecInList - no. of records displayed in the list
$TotalRec - Total records for this resultset
//=========================================================================================== */
function ShowRecordListInfo($FromRec = '1',$RecInList = '1' ,$TotalRec = '1' )
{
$LabelStr = "<label class='tdreccountlist'>Record ".$FromRec.' to '.(($FromRec+$RecInList)-1)." | Total :".$TotalRec."</label>";
return $LabelStr;
}
/*=======================================================================================
/*=======================================================================================
//========= function ShowViewLink() to include view link .....
@param -
$RecordId - Record id
//=========================================================================================== */
function ShowViewLink($RecordId = '0')
{
$LabelStr = "<center><label class='recedit_cls' onClick='EditRecord(\"$RecordId\")'>View</label></center>";
return $LabelStr;
}
/*=======================================================================================
//========= function ShowRecordListInfo() to display number of records in the listing .....
@param -
$FromRec - Starts from record no.
$RecInList - no. of records displayed in the list
$TotalRec - Total records for this resultset
//=========================================================================================== */
/*=======================================================================================
//========= function SendAnEmail() sents mail according to the given parameters.....
@param -
$Subject - subject of the mail
$ToMail - To Email Id
$Message - Message to be send
$FromMail - From Email Id
//=========================================================================================== */
function SendAnEmail($Subject, $ToMail, $Message, $FromMail = 'admin@wealthproaf.com')
{
$Headers = 'MIME-Version: 1.0' . "\r\n";
$Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Headers .= 'From:'.$FromMail . "\r\n";
if(@mail($ToMail, $Subject, $Message, $Headers))
return true;
else
return false;
}
/*=======================================================================================
/*=======================================================================================
//===== function MultiDimArrSort() to sort multi-dimensional array on a key field. .......
@param -
$array - Name of array
$key - Key on which sorted...
======================================================================================= */
function MultiDimArrSort(&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
//=====================================================================================
/*=======================================================================================
//========= function MailonHotelBooking() sents mail according to the given parameters.....
@param -
$BookInfo
$Paymode - Payment method
//=========================================================================================== */
function MailonHotelBooking($BookInfo, $PayMode, $RegId, $FileName)
{
$MemDSrs = $this->SelectQuery("tbl_tgmember",array('MEMID' => $BookInfo['member_id']));
$rows = $MemDSrs[0];
$emailid = $rows['EMAILID'];
$sgender = $rows['GENDER'];
$scat = $rows['CATEGORY'];
$speciality = $rows['SPECIALITY'];
$stitle = $rows['TITLE'];
$sfname = $rows['FNAME'];
$slname = $rows['LNAME'];
$sorg = $rows['ORG'];
$saddr = $rows['ADDRESS'];
$saddr2 = $rows['ADDR2'];
$saddr3 = $rows['ADDR3'];
$saddr4 = $rows['ADDR4'];
$scountry = $rows['NCOUNTRY'];
$sstate = $rows['NSTATE'];
$scity = $rows['NCITY'];
$spin = $rows['PINCODE'];
$sstdcode = $rows['PHCODE'];
$sphno = $rows['PHONE'];
$scouncode = $rows['MCODE'];
$smobile = $rows['MOBILE'];
$sfaxcode = $rows['FCODE'];
$sfax = $rows['FAX'];
$htmlText = "<!Doctype html public .../ / W3c/dtd html>";
$htmlText = $htmlText."<html>";
$htmlText= $htmlText."<head>";
$htmlText= $htmlText."<title>Hotel Booking Request</title>";
$htmlText= $htmlText."</head>";
$htmlText = $htmlText."<body>";
$htmlText= $htmlText."<TABLE cellSpacing=1 cellPadding=4 width=100% border=0>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Hotel Booking : Online Booking Confirmation</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Hotel Name :".$BookInfo['hotel_name']."," .$BookInfo['hotel_city']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Room Type :".$BookInfo['room_type']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >No of Rooms :".$BookInfo['room_count']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Check-in Date :".$this->DateShifting($BookInfo['checkin_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Check-out Date :".$this->DateShifting($BookInfo['checkout_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Total Amount :".$BookInfo['total_amt_paid']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Payment Mode :".$PayMode."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Registered On :".$this->DateShifting($BookInfo['reg_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Registration id :".$RegId."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Email Id :".$emailid."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Gender :".$sgender."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Category :".$scat."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >speciality :".$speciality."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Name :".$stitle." ".$sfname." ".$slname."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Address :".$saddr." ".$saddr2." ".$saddr3." ".$saddr4."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >".$scity." ".$sstate." ".$scountry." ".$spin."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Phone No :".$sstdcode." ".$sphno."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Mobile No :".$scouncode." ".$smobile."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Fax No :".$sfaxcode." ".$sfax."</TD></TR>";
$htmlText= $htmlText."</TABLE>";
$htmlText= $htmlText."</body>";
$htmlText= $htmlText."</html>";
$adminmail = "cde@idrr.org";
//$adminmail = "tanisisoftware@gmail.com";
$Subject = "Online Hotel Booking";
$MailTO = $adminmail;
$Message = $htmlText;
$Headers = 'MIME-Version: 1.0' . "\r\n";
$Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Headers .= "'To: ".$emailid."'\r\n";
$Headers .= "'CC: ".$adminmail."'\r\n";
$Headers .= 'From: IDRR CDE <'.$adminmail."> ". "\r\n" ;
//......create pdf file.........
$this->CurlToGetDetails('htlbkid='.$RegId."&nodisp=Yes", '', 'Hotel');
//..........send mail with pdf attachment............
$this->SendMailWithAttachment(DIRPATH."IDRRreghotel.pdf",$emailid, $adminmail,"IDRR CDE", $adminmail, $Subject, $htmlText, $adminmail,'enquiry@thegrandmagrath.com');
//@mail($MailTO, $Subject, $Message, $Headers);
//return $PDFMessage;
}
/*=======================================================================================
//==== function SendMailWithAttachment() send mail with attachment.....
@param -
$BookInfo
$Paymode - Payment method
//=========================================================================================== */
function SendMailWithAttachment($FileName,$MailTo, $MailFrom, $FromName, $ReplyTo, $Subject, $Message, $BCC='', $CC='')
{
$file_size = filesize($FileName);
$handle = fopen($FileName, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($FileName);
$header = "From: ".$FromName." <".$MailFrom.">\r\n";
if($BCC != '')
{
$header .= "Bcc: ".$BCC."\r\n";
}
if($CC != '')
{
$header .= "Cc: ".$CC."\r\n";
}
$header .= "Reply-To: ".$ReplyTo."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $Message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$name."\"\r\n"; // use diff. tyoes here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$name."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if(mail($MailTo, $Subject, "", $header))
return true;
else
return false;
}
/*=======================================================================================
/*=======================================================================================
//*=======================================================================================
/========= function DisplaySelect() to create list box with provided information
@param -
$ComboName - Name of combo box / list box
$DataArr - Data to display
$SelectedValue - Value to display as selected
$MultipleState - If multiple or not
$Display - If 'Yes', echo the list box else return the string
$FunctionToCall - Function to call for list box
$AddHeading - If yes, the first option will be Please select, else not.
$ComboWidth - to fix combo width =========================================================================================== */
function DisplaySelect($ComboName,$DataArr,$SelectedValue='', $MultipleState='',$Display = 'Yes',$FunctionToCall = '', $AddHeading = 'Yes', $ComboWidth='', $ComboStyle='')
{
$ComboID = $ComboName;
$MultipleStr = '';
if($MultipleState == 'Multiple')
{
$ComboName.= "[]";
$MultipleStr = " multiple='multiple' size=5";
}
if($MultipleState == 'Array')
{
$ComboName.= "[]";
}
$WidthStyle = '';
if($ComboWidth != '')
{
$WidthStyle = "style='width:".$ComboWidth."px;".$ComboStyle."'";
}
elseif($ComboStyle != '')
{
$WidthStyle = "style='".$ComboStyle."'";
}
$DisplayStr = "<select name='".$ComboName."' id ='".$ComboID."' ".$FunctionToCall. $MultipleStr." ".$WidthStyle.">";
if($AddHeading == 'All')
$DisplayStr.="<option value=''>All</option>";
if($AddHeading == 'Yes')
$DisplayStr.="<option value=''>Please select</option>";
if($AddHeading == 'Dash')
$DisplayStr.="<option value=''> ---------------- </option>";
if($AddHeading == 'Blank')
$DisplayStr.="<option value=''> </option>";
//............add options..............
$Selected = '';
if(count($DataArr) > 0)
{
foreach($DataArr as $KeyVal => $DispVal)
{
if(is_array($SelectedValue))
{
if(array_key_exists($KeyVal, $SelectedValue))
$Selected = ' selected';
}
else
{
if($SelectedValue == $KeyVal)
$Selected = ' selected';
}
$DisplayStr.= "<option value='".$KeyVal."' ".$Selected.">".$DispVal."</option>";
$Selected = '';
}
}
$DisplayStr.="</select>";
if($Display == 'Yes')
echo $DisplayStr;
else
return $DisplayStr;
}
/*=======================================================================================
//========= function OrderByDisp() to display the image according to the order by
@param -
$CurField - Current field
$OrderedField - Field on which order by was applied
$CurOrderType - Order by type - ASC or DESC
=========================================================================================== */
function OrderByDisp($CurField,$OrderedField,$CurOrderType='ASC')
{
if($CurField != $OrderedField)
$CurOrderType='ASC';
if($CurOrderType=='ASC')
$ImagePath = ASCIMGPATH;
else
$ImagePath = DESCIMGPATH;
echo "<img src='".$ImagePath."' onClick = 'ChangeOrderField(\"".$CurField."\",\"".$CurOrderType."\")' align='absmiddle' style='cursor:pointer;'>";
}
//=====================================================================================
//======================================================================================
//==================================================================================
/*========= function CurlToGetDetails() to receive desired info
@param -
$FieldStr - post string
$FileName - file url
*///==================================================================================
//==================================================================================
function CurlToGetDetails($FieldStr, $FileName='index.php', $TicketType='')
{
$StrCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
// session_write_close();
if($TicketType == 'VIP')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/vippass.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/vippass.php");
}
elseif($TicketType == 'ALL')
{
//$CurlCon = curl_init("http://localhost/web-2012/newidrr/website/idrr/allorderpdf.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/allorderpdf.php");
}
elseif($TicketType == 'Hotel')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/hotelpdf.php");
}
elseif($TicketType == 'Booth')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/boothpdf.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/boothpdf.php");
}
else
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/printticket.php");
}
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
//$CurlCon = curl_init("http://cdecentre.com/idrr/printticket.php");
//set options
curl_setopt($CurlCon, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($CurlCon, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($CurlCon, CURLOPT_RETURNTRANSFER, true);
curl_setopt($CurlCon, CURLOPT_COOKIE, $StrCookie);
curl_setopt($CurlCon, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($CurlCon, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($CurlCon, CURLOPT_POSTFIELDS, $FieldStr);
//perform our request
$ResponseText = curl_exec($CurlCon);
//show information regarding the request
//close the connection
curl_close($CurlCon);
//echo $ResponseText;
}
//=====================================================================================
//======================================================================================
//==================================================================================
function tep_validate_password($plain, $encrypted,$type='O') {
$valid_password=false;
if ($plain != '' && $encrypted != '')
{
// split apart the hash / salt
$stack = explode(':', $encrypted);
if (sizeof($stack) != 2) return false;
if ($type=="V"){
if (md5(md5($plain) . $stack[1]) == $stack[0]) {
$valid_password=true;
}
} else {
if (md5($stack[1] . $plain) == $stack[0]){
$valid_password=true;
}
}
}
return $valid_password;
}
//=====================================================================================
//======================================================================================
//==================================================================================
// This function makes a new password from a plaintext password.
function tep_encrypt_password($plain,$type='O') {
$password = '';
for ($i=0; $i<10; $i++) {
$password .= $this->tep_rand();
}
$salt = substr(md5($password), 0, 2);
if ($type=="V"){
$password = md5(md5($plain) . $salt) . ':' . $salt;
} else {
$password = md5($salt . $plain) . ':' . $salt;
}
return $password;
}
//=====================================================================================
//=====================================================================================
function tep_rand($min = null, $max = null) {
static $seeded;
if (!$seeded) {
mt_srand((double)microtime()*1000000);
$seeded = true;
}
if (isset($min) && isset($max)) {
if ($min >= $max) {
return $min;
} else {
return mt_rand($min, $max);
}
} else {
return mt_rand();
}
}
//======================================================================================
//==================================================================================
/*=======================================================================================
//========= function TimeTo12Hour() to convert 24 hr time to 12 hr time........
@param -
$Time - Time value
=========================================================================================== */
function TimeTo12Hour($Time)
{
if($Time == '')
return "";
else
{
$TimeArr = explode(":",$Time);
if($TimeArr[0] > 12)
{
$Hours = $TimeArr[0] - 12;
$TimeString = str_pad($Hours, 2, "0", STR_PAD_LEFT).":".$TimeArr[1]." PM";
}
else
{
$TimeString = substr($Time,0,5)." AM";
}
return $TimeString;
}
}//...end function
//=======================================================================================
/*=======================================================================================
//========= function TimeTo24Hour() to convert 12 hr time to 24 hr time........
@param -
$Time - Time value
=========================================================================================== */
function TimeTo24Hour($Time)
{
if($Time == '')
return "";
else
{
$SlotArr = explode(" ",$Time);
$TimeArr = explode(":",$SlotArr[0]);
// print_r($SlotArr);
if($SlotArr[1] == 'PM')
{
$Hours = $TimeArr[0] + 12;
$TimeString = $Hours.":".$TimeArr[1].":00";
}
else
{
$TimeString = $SlotArr[0].":00";
}
return $TimeString;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function DateShifting() to change date format like from dd-mm-yyyy to yyyy-mm-dd.......
@param -
$DateVal - Date value
=========================================================================================== */
function DateShifting($DateVal)
{
if($DateVal == '')
return "";
else
{
if(stripos($DateVal,"-") > 0)
$Divider = "-";
elseif(stripos($DateVal,"/") > 0)
$Divider = "/";
$DateArr = @explode($Divider,$DateVal);
$DateStr = $DateArr[2]."-".$DateArr[1]."-".$DateArr[0];
return $DateStr;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function DateByTime() to get date by arrival and departure time from journey date.......
@param -
$DateVal - Date value
$Departure - Departure time value
$Arrival - Arrival time value
=========================================================================================== */
function DateByTime($DateVal, $Departure, $Arrival)
{
if($DateVal == '')
return "";
else
{
$DateArr = explode("-",$DateVal);
$DepartDateStamp = mktime(0, 0, 0, $DateArr[1], $DateArr[0], $DateArr[2]);
$ReturnDate[0] = date("D M j",$DepartDateStamp);
//....get difference between depart time and arrival time, if arrival time is less than depart time...................
$IncDay = 0;
$DepartArr = explode(":",$Departure);
$ArriveArr = explode(":",$Arrival);
if($DepartArr[0] > $ArriveArr[0])
{
$IncDay = 1;
}
$ArriveDateStamp = mktime(0, 0, 0, $DateArr[1], $DateArr[0]+$IncDay, $DateArr[2]);
$ReturnDate[1] = date("D M j",$ArriveDateStamp);
return $ReturnDate;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function UploadImage() to store any image to provided folder .......
- all parameters must to be provided
@param -
$ImageName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadImage($ImageName, $TmpName, $ImageSize,$ImageHW, $ImageType, $TargetName, &$ErrorInUpload = '')
{
//echo $ImageName." : ".$TmpName." : ".$ImageSize." : ".$ImageHW." : ".$ImageType." : ".$TargetName;
//.....validate image (check image type, image size, image height and width)
$ImgFile = $_FILES[$ImageName];
$ImageTypeArr = array('image/gif','image/pjpeg','image/jpeg','image/jpg','image/png');
if(in_array($ImageType,$ImageTypeArr)) //check image type
{
//....check size.....
if($ImageSize > (UPLOADIMGSIZE * 1024))
$ErrorInUpload = "Image size must be upto ".UPLOADIMGSIZE." KB";
else //...check height and width...
{
$ImageSize = @getimagesize($ImgFile);
if($ImageHW[0] > UPLOADIMGWIDTH || $ImageHW[1] > UPLOADIMGHEIGHT)
$ErrorInUpload = "Image width and height should be Maximum ".UPLOADIMGWIDTH." x ".UPLOADIMGHEIGHT.".";
}
}
else
$ErrorInUpload = "Only .gif, .png and .jpeg images can be uploaded.";
//echo $ErrorInUpload."asdf";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
//...upload image
$ImgExtension = substr($ImageName, @strripos($ImageName,"."), (strlen($ImageName) - @strripos(".")));
//echo IMGFOLDERPATH.$TargetName.$ImgExtension;
if(! move_uploaded_file($TmpName, IMGFOLDERPATH.$TargetName.$ImgExtension))
{
$ErrorInUpload = "Due to some errors could not upload image";
}
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
/*=======================================================================================
//========= function UploadSingleImage() to store any image to provided folder .......
@param -
$ImageName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadSingleImage($ImageName, $TargetName, $MaxHeight, $MaxWidth, &$ErrorInUpload = '', $DeleteExisting='No', $ImageFolder = '',$MaxAdImgSize = '')
{
$ImgFile = $_FILES[$ImageName];
//.....validate image (check image type, image size, image height and width)
$ImageTypeArr = array('image/gif','image/pjpeg','image/jpeg','image/png');
if(in_array($ImgFile['type'],$ImageTypeArr)) //check image type
{
if($MaxAdImgSize == '')
$MaxAdImgSize = UPLOADIMGSIZE;
//....check size.....
if($ImgFile['size'] > ($MaxAdImgSize * 1024))
$ErrorInUpload = "Image size must be upto ".$MaxAdImgSize." KB";
else //...check height and width...
{
$ImageSize = getimagesize($ImgFile);
if($ImageSize[0] > $MaxWidth || $ImageSize[1] > $MaxHeight)
$ErrorInUpload = "Image width and height should be ". $MaxWidth." x ". $MaxHeight.".";
}
}
else
$ErrorInUpload = "Only .gif, .png and .jpeg images can be uploaded.";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
if($DeleteExisting == 'Yes')
unlink(IMGFOLDERPATH.$ExistingName);
//...upload image
$ImgExtension = substr($ImgFile['name'], strripos($ImgFile['name'],"."), (strlen($ImgFile['name']) - strripos(".")));
if($ImageFolder == '')
$ImageFolder = IMGFOLDERPATH;
if(! move_uploaded_file($ImgFile['tmp_name'], $ImageFolder.$TargetName.$ImgExtension))
$ErrorInUpload = "Due to some errors could not upload image";
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
/*=======================================================================================
//========= function UploadSingleFile() to store any image to provided folder .......
@param -
$DocName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadSingleFile($DocName, $TargetName,&$ErrorInUpload = '', $DeleteExisting='No', $DocFolder = '',$MaxFileSize = '')
{
$ImgFile = $_FILES[$DocName];
//.....validate image (check file type, file size)
$DocTypeArr = array('application/msword','application/pdf','application/doc','application/vnd.msword','image/gif','image/pjpeg','image/jpeg','image/png');
if(in_array($ImgFile['type'],$DocTypeArr)) //check image type
{
if($MaxFileSize == '')
$MaxFileSize = UPLOADFILESIZE;
//....check size.....
if($ImgFile['size'] > ($MaxFileSize * 1024))
$ErrorInUpload = "Doc size must be upto ".$MaxFileSize." KB";
}
else
$ErrorInUpload = "Only Images with .gif, .png and .jpeg can be uploaded.";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
if($DeleteExisting == 'Yes')
unlink(IMGFOLDERPATH.$ExistingName);
//...upload image
$ImgExtension = substr($ImgFile['name'], strripos($ImgFile['name'],"."), (strlen($ImgFile['name']) - strripos(".")));
if($DocFolder == '')
$DocFolder = IMGFOLDERPATH;
//echo $DocFolder.$TargetName.$ImgExtension;
if(! move_uploaded_file($ImgFile['tmp_name'], $DocFolder.$TargetName.$ImgExtension))
$ErrorInUpload = "Due to some errors could not upload File";
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function ImageWidthHeight() to get reduce image height and width as required.......
@param -
$ImagePath - Path of image
$MaxWidth - Maximum image width
$MaxHeight - Maximum height of the image which is allowed to display
=========================================================================================== */
function ImageWidthHeight($ImagePath, $MaxWidth, $MaxHeight)
{
if(! file_exists($ImagePath))
{
return '';
}
$Size=getimagesize($ImagePath);
$ImageHeight=$Size[1];
$ImageWidth=$Size[0];
if($ImageWidth < $MaxWidth)
$DisplayWidth = $ImageWidth;
else
$DisplayWidth = $MaxWidth;
$DisplayHeight = $DisplayWidth*$ImageHeight/$ImageWidth;
$SizeArr = array("width"=>$DisplayWidth,"height"=>$DisplayHeight);
return $SizeArr;
}//...end function
//===================================================================================================
/*=======================================================================================
//========= function ImageWidthHeight() to get reduce image height and width as required.......
@param -
$ImagePath - Path of image
$MaxWidth - Maximum image width
$MaxHeight - Maximum height of the image which is allowed to display
=========================================================================================== */
function ImageHeightWidth($ImagePath, $MaxWidth, $MaxHeight)
{
if(! file_exists($ImagePath))
{
return '';
}
$Size=getimagesize($ImagePath);
$ImageHeight=$Size[1];
$ImageWidth=$Size[0];
if($ImageHeight < $MaxHeight)
$DisplayHeight = $ImageHeight;
else
$DisplayHeight = $MaxHeight;
$DisplayWidth = $DisplayHeight*$ImageWidth/$ImageHeight;
if($DisplayWidth > $MaxWidth)
{
$DisplayWidth = $MaxWidth;
$DisplayHeight = $DisplayWidth*$ImageHeight/$ImageWidth;
}
$SizeArr = array("width"=>$DisplayWidth,"height"=>$DisplayHeight);
return $SizeArr;
}//...end function
//===================================================================================================
//===================================================================================================
//===================================================================================================
//===================================================================================================
//function to encrypt the string
function encode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=strrev(base64_encode($str)); //apply base64 first and then reverse the string
}
return $str;
}
//===================================================================================================
//function to decrypt the string
function decode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=base64_decode(strrev($str)); //apply base64 first and then reverse the string
}
return $str;
}
//===================================================================================================
/*=======================================================================================
//========= function RandomStringGenerator() to genrerate random string .......
@param -
$CurrencyVal - Digit to convert value
=========================================================================================== */
function RandomStringGenerator($length=8)
{
$characters = '123456789ABCDEFGHIJKLMNPQRSTUVWXYZ';
$string = '';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
//=====================================================================================
/*=======================================================================================
//========= function NumberToCurrency() to convert number from integer format to money format.......
@param -
$CurrencyVal - Digit to convert value
=========================================================================================== */
function NumberToCurrency($CurrencyVal)
{
return number_format($CurrencyVal, 2, '.', ',');
}//...end function
//=====================================================================================
//=====================================================================================
/*=======================================================================================
//===== function DateDifference() to get difference between to dates .......
@param -
$Date1 - Date Bigger
$Date2 - Date Smaller
======================================================================================= */
function DateDifference($Date1, $Date2)
{
if($Date1 != '' && $Date2 != '')
return round((strtotime($Date1)-strtotime($Date2))/86400);
else
return '';
}//...end function
//=======================================================================================
/*=======================================================================================
//===== function TimeDifferenceInHour() to get difference between two times .......
@param -
$Time1 - Time 1 //..format is HH:MM AM/PM
$Time2 - Time 2 //..format is HH:MM AM/PM
======================================================================================= */
function TimeDifferenceInHour($Time1, $Time2)
{
//echo $Time1.":::".$Time2;
if($Time1 != '' && $Time2 != '')
{
$TimeAr1 = explode(" ",$Time1);
$TimeHMAr1 = explode(":",$TimeAr1);
$TimeAr2 = explode(" ",$Time2);
$TimeHMAr2 = explode(":",$TimeAr2);
if($TimeAr1 == 'PM')
$TimeHMAr1[0] = $TimeHMAr1[0] + 12;
if($TimeAr2 == 'PM')
$TimeHMAr2[0] = $TimeHMAr2[0] + 12;
$HrDiff = $TimeHMAr2[0] - $TimeHMAr1[0];
return $HrDiff;
}
else
return '';
}//...end function
//=======================================================================================
/*=======================================================================================
//===== function GetIPAddress() to get visitors IP address .......
======================================================================================= */
function GetIPAddress()
{
if(getenv(HTTP_X_FORWARDED_FOR))
{
$IPAddress = getenv(HTTP_X_FORWARDED_FOR);
//$ipaddress = getenv(REMOTE_ADDR);
}
else
{
$IPAddress = getenv(REMOTE_ADDR);
}
return $IPAddress;
}//...end function
/*=======================================================================================
//=======================================================================================
/*===== function MergeTwoArrays() to merger two array keeping their indexes and return unique values.. .......
@param -
$ValueArr1 - array 1
$ValueArr2 - array 2
@return -
$NewValueArr
======================================================================================= */
function MergeTwoArrays($ValueArr1,$ValueArr2)
{
if(count($ValueArr1) == 0)
return $ValueArr2;
if(count($ValueArr2) == 0)
return $ValueArr1;
//=======================================================
$KeyArr = array_merge(array_keys($ValueArr1), array_keys($ValueArr2));
$ValArr = array_merge($ValueArr1, $ValueArr2);
$NewValueArr = array_combine($KeyArr, $ValArr);
//........................
return $NewValueArr;
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextInfoEncoding($NormalText) to encode text to enter into database and display properly....................
@param -
$NormalText - normal text
@return -
$EncodedText
======================================================================================= */
function TextInfoEncoding($NormalText)
{
//....replace all " with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
return urlencode($NormalText);
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextQuoteHandle($NormalText) to handle double and single quotes....................
@param -
$NormalText - normal text
@return -
$NormalText - after quote handling
======================================================================================= */
function TextQuoteHandle($NormalText)
{
//....replace all other types of quotes with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace('”','`',$NormalText);
$NormalText = str_replace('“','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
$NormalText = str_replace("’","`",$NormalText);
return $NormalText;
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextInfoEntityEncode($NormalText) to encode text to enter into database using function htmlentities and display properly....................
@param -
$NormalText - normal text
@return -
$EncodedText
======================================================================================= */
function TextInfoEntityEncode($NormalText)
{
//....replace all " with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
return htmlentities($NormalText);
}//...end function
//=======================================================================================
///=======================================================================================
//=-========================================================================================
//---=======-------- array containing value for hours --------------------------------------
var $HRSValArr = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06',
'07'=>'07','08'=>'08','09'=>'09','10'=>'10','11'=>'11','12'=>'12');
//------------------ array containing values for passengers ---------------------------------
var $MonthStringArr = array('01'=>'January','02'=>'February','03'=>'March','04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August','09'=>'September','10'=>'October','11'=>'November','12'=>'December');
var $MDayStringArr = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'09','10'=>'10','11'=>'11','12'=>'12','13'=>'13','14'=>'14','15'=>'15','16'=>'16','17'=>'17','18'=>'18','19'=>'19','20'=>'20','21'=>'21','22'=>'22','23'=>'23','24'=>'24','25'=>'25','26'=>'26','27'=>'27','28'=>'28','29'=>'29','30'=>'30','31'=>'31');
var $DaysOfWeekArr = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
//=-========================================================================================
var $RECORDSPERPAGEARR = array('10'=>'10','20'=>'20','40'=>'40','80'=>'80');
//=======================================================================================
//=======================================================================================
}// end class
?>
/*=================================================================
functionfile.php
Contains functions to execute php functions
===================================================================*/
class OOSFunction
{
var $USERTYPEARR = array('P'=>'Patient','D' =>'Doctor','S'=>'Staff','V'=>'Visitor');
var $TimeSlotArr = array('00'=>'12 AM','01'=>'1 AM','02'=>'2 AM','03'=>'3 AM','04'=>'4 AM','05'=>'5 AM','06'=>'6 AM','07'=>'7 AM','08'=>'8 AM','09'=>'9 AM','10'=>'10 AM','11'=>'11 AM','12'=>'12 PM','13'=>'1 PM','14'=>'2 PM','15'=>'3 PM','16'=>'4 PM','17'=>'5 PM','18'=>'6 PM','19'=>'7 PM','20'=>'8 PM','21'=>'9 PM','22'=>'10 PM','23'=>'11 PM');
var $VISITDAYARR = array('monday'=>'Monday','tuesday' =>'Tuesday','wed'=>'Wednesday','thurs'=>'Thursday','fri'=>'Friday','sat'=>'Saturday','sunday'=>'Sunday');
//========================================================
function GenerateSMSText($SMSFor, $RecordID)
{
}
//========================================================
//========================================================
//.......function to generate investor reg. number series..
//========================================================
function GenerateInvestRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(invest_reg_num,6,5) as InvNum,
invest_reg_num from member_master
where invest_reg_num IS NOT NULL AND invest_reg_num != ''
order by InvNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "I".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['invest_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "I".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate associate reg. number series..
//========================================================
function GenerateAssociateRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(assoc_reg_num,6,5) as AssocNum,
assoc_reg_num from member_master
where is_assoc ='Yes' order by AssocNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "A".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['assoc_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "A".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate Unit Reigstraion no. series..
//========================================================
function GenerateUnitRegNo()
{
$InvRS = $this->SimpleRunQuery("select substring(unit_regno,6,5) as RegUnitNum,
unit_regno from plan_member_registration
order by RegUnitNum DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "U".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['unit_regno'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "U".date('ym').$PadStr.$NextNum;
}//........end else..............
// echo $InvestorNo;
return $InvestorNo;
}//..............end function.................
//========================================================
//========================================================
//.......function to generate payment receipt number series..
//========================================================
function GenerateReceiptNo()
{
/* $InvRS = $this->SimpleRunQuery("select invest_reg_num from member_master
order by member_id DESC LIMIT 1", $TtlInvCnt);
if($TtlInvCnt == 0)
{
$InvestorNo = "I".date('ym').'00001';
}
else
{
$LastInvNo = $InvRS[0]['invest_reg_num'];
$NumVal = substr($LastInvNo,5,5);
$NextNum = $NumVal+1;
if(strlen($NextNum) < 5)
{
$StrLen = strlen($NextNum);
$PadLen = 5 - $StrLen;
for($ZCtr = 1; $ZCtr <= $PadLen; $ZCtr++)
$PadStr.= "0";
}
$InvestorNo = "I".date('ym').$PadStr.$NextNum;
}//........end else..............
return $InvestorNo;
*/}//..............end function.................
//========================================================
//================================================================================
//=function GenrateBarcodeImage to generate barcode...............................
//================================================================================
//$BCString - String to generate barcode..................
//================================================================================
function GenrateBarcodeImage($BCString, $FontSize=10)
{
if($BCString == '' or strlen($BCString) < 3)
return '';
require_once(DIRPATH.'/common/barcode/BCGFont.php');
require_once(DIRPATH.'/common/barcode/BCGColor.php');
require_once(DIRPATH.'/common/barcode/BCGDrawing.php');
// Including the barcode technology
include_once(DIRPATH.'/common/barcode/BCGcode39.barcode.php');
$font = new BCGFont(DIRPATH.'/common/barcode/font/Arial.ttf', $FontSize);
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$code = new BCGcode39();
$code->setScale(1); // Resolution
$code->setThickness(10); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse($BCString); // Text
$drawing = new BCGDrawing(DIRPATH.'adminpanel/invbarcodeimg.png', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
return file_get_contents(DIRPATH.'adminpanel/invbarcodeimg.png');
}
//================================================================================
//================================================================================
//.......function GetNextDueDate() to get next payment due date as per plan.......
//================================================================================
/*
@param -
$RegDate - date of plan registration
$PremPayDuration - Duration to pay premium
$DurationType - Duration type
$NoInstallment - total no. of installments to be paid
*/
//================================================================================
function GetNextDueDate($RegDate,$PremPayDuration,$DurationType, $PaidInstallment)
{
//........get no. of installments paid.....................
//echo $RegDate."::".$PremPayDuration."::".$DurationType."::".$PaidInstallment;
$RDArr = explode("-",$RegDate);
$RegTime = mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]);
$NextInst = ($PaidInstallment) * $PremPayDuration;
if($DurationType == 'Day')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2]+$NextInst,$RDArr[0]));
}
elseif($DurationType == 'Month')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1]+$NextInst,$RDArr[2],$RDArr[0]));
}
elseif($DurationType == 'Year')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]+$NextInst));
}
elseif($DurationType == 'Once')
{
$NextDueDate = "NA";
}
return $NextDueDate;
}
//================================================================================
//================================================================================
//.......function GetERVDate() to get ERV date as per plan.......
//================================================================================
/*
@param -
$RegDate - date of plan registration
$PremPayDuration - Duration to pay premium
$DurationType - Duration type
*/
//================================================================================
function GetERVDate($RegDate,$PremPayDuration,$DurationType)
{
//........get no. of installments paid.....................
//echo $RegDate."::".$PremPayDuration."::".$DurationType."::".$PaidInstallment;
$RDArr = explode("-",$RegDate);
$RegTime = mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]);
if($DurationType == 'Day')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2]+$PremPayDuration,$RDArr[0]));
}
elseif($DurationType == 'Month')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1]+$PremPayDuration,$RDArr[2],$RDArr[0]));
}
elseif($DurationType == 'Year')
{
$NextDueDate = date("d-m-Y",mktime(0,0,0,$RDArr[1],$RDArr[2],$RDArr[0]+$PremPayDuration));
}
elseif($DurationType == 'Once')
{
$NextDueDate = "NA";
}
return $NextDueDate;
}
//================================================================================
//================================================================================
//...........function StoreAssocIncentive() to store incentive of associate.....
/*
@param
- $MemberId -> Lower level investor or associte id
- $ReceiptNo -> Payment Receipt no...
*/
//================================================================================
//================================================================================
function StoreAssocIncentive($MemberId, $ReceiptNo)
{
if($MemberId == '' || $ReceiptNo == '')
return;
//............check if the member has any associate divide incentive ........
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount == 0)
return;
$MemInfo = $MemRS[0];
if($MemInfo['intro_asso_id'] == '0')
return;
//..........get required details to store associate incentive..........
$RecRS = $this->SelectQuery("payment_receipt_master",array('receipt_id'=>$ReceiptNo),$TotalRpCnt);
$RecInfo = $RecRS[0];
$PMemRS = $this->SelectQuery("plan_member_registration",array('plan_mem_regno'=>$RecInfo['plan_member_regno']),$TotalPMemCnt);
$PMemInfo = $PMemRS[0];
$AssocId = $MemInfo['intro_asso_id'];
$PlanCatId = $PMemInfo['plan_cat_id'];
$PlanId = $PMemInfo['plan_id'];
$SubPlanId = $PMemInfo['sub_plan_id'];
$PlanCode = $PMemInfo['plan_code'];
$RegDate = $PMemInfo['reg_date'];
$InvestMemId = $PMemInfo['member_id'];
$PremiumAmt = $RecInfo['inst_amount'];
$MemDesigId = $MemInfo['desig_id'];
$AssocDesigId = $this->GetValueById("member_master","member_id",$AssocId,"desig_id");
$InvestDesigId = $this->GetValueById("member_master","member_id",$InvestMemId,"desig_id");
//......................................................................
//......get plan details to get no. of years.....
$PlRS = $this->SelectQuery("plan_master",array('plan_id'=>$PlanId),$TotalPlCnt);
$PlRow = $PlRS[0];
$PlCatRS = $this->SelectQuery("plan_category_master",array('plan_cat_id'=>$PlanCatId),$TotalPlCatCnt);
$PlCatRow = $PlCatRS[0];
$PlCatIncType = $PlCatRow['cat_ret'];
/*
if($PlCatIncType == 'RD')
{
$DayDiff = $this->DateDifference(date('Y-m-d'),$RegDate);
if($DayDiff != '' && $DayDiff >= 365)
{
$YearNum = ceil($DayDiff/365);
}
else
$YearNum = 1;
}
else
{
$YearNum = $PlRow['plan_duration'] / 12;
}//....end else..............
*/
$YearNum = $PlRow['plan_duration'] / 12;
//echo $YearNum;
//==================================================================
if($InvestMemId == $MemberId && $InvestDesigId == 0)
$AssocDesigFromId = 1;
elseif($InvestMemId == $MemberId && $InvestDesigId > 0)
$AssocDesigFromId = $InvestDesigId+1;
elseif($InvestMemId != $MemberId && $MemDesigId != $AssocDesigId)
$AssocDesigFromId = $MemDesigId+1;
else
$AssocDesigFromId = $MemDesigId;
$IncSql = "SELECT SUM(incent_value) as TotalInc FROM designation_incentive_master
WHERE plan_year = '".$YearNum."' AND (desig_id BETWEEN
'".$AssocDesigFromId."' AND '".$AssocDesigId."')
AND plan_cat_id ='".$PlanCatId."' GROUP BY plan_cat_id";
$IncRS = $this->SimpleRunQuery($IncSql, $IncCnt);
$IncPer = $IncRS[0]['TotalInc'];
$IncAmt = round(($PremiumAmt * $IncPer)/100,2);
//.........store into database.....................
if($AssocId == $MemberId)
return;
if($AssocDesigId > 0)
{
$IncValueArr = array("receipt_id"=>$ReceiptNo,"plan_cat_id"=>$PlanCatId,"invest_mem_id"=>$InvestMemId,"assoc_mem_id"=>$AssocId,"mediat_mem_id"=>$MemberId,"plan_id"=>$PlanId,"sub_plan_id"=>$SubPlanId,"plan_code"=>$PlanCode,"assoc_desig_id"=>$AssocDesigId,"mediat_desig_id"=>$MemDesigId,'invest_desig_id'=>$InvestDesigId,"inc_per"=>$IncPer,"inc_amt"=>$IncAmt,"inc_date"=>date('Y-m-d'));
$this->InsertQuery("incentive_detail",$IncValueArr);
}
$this->StoreAssocIncentive($AssocId, $ReceiptNo);
//......................................................................
return;
}
//================================================================================
//================================================================================
//...........function StoreSelfIncentive() to store incentive of self incentive.....
/*
@param
- $MemberId -> investor id
- $ReceiptNo -> Payment Receipt no...
*/
//================================================================================
//================================================================================
function StoreSelfIncentive($MemberId, $ReceiptNo)
{
if($MemberId == '' || $ReceiptNo == '')
return;
//............check if the member has any associate divide incentive ........
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount == 0)
return;
$MemInfo = $MemRS[0];
if($MemInfo['intro_asso_id'] == '0')
return;
//..........get required details to store incentive..........
$RecRS = $this->SelectQuery("payment_receipt_master",array('receipt_id'=>$ReceiptNo),$TotalRpCnt);
$RecInfo = $RecRS[0];
$PMemRS = $this->SelectQuery("plan_member_registration",array('plan_mem_regno'=>$RecInfo['plan_member_regno']),$TotalPMemCnt);
$PMemInfo = $PMemRS[0];
$PlanCatId = $PMemInfo['plan_cat_id'];
$PlanId = $PMemInfo['plan_id'];
$SubPlanId = $PMemInfo['sub_plan_id'];
$PlanCode = $PMemInfo['plan_code'];
$RegDate = $PMemInfo['reg_date'];
$InvestMemId = $PMemInfo['member_id'];
$PremiumAmt = $RecInfo['inst_amount'];
$MemDesigId = $MemInfo['desig_id'];
$AssocDesigId = $this->GetValueById("member_master","member_id",$AssocId,"desig_id");
$InvestDesigId = $this->GetValueById("member_master","member_id",$InvestMemId,"desig_id");
//......................................................................
//......get plan details to get no. of years.....
$PlRS = $this->SelectQuery("plan_master",array('plan_id'=>$PlanId),$TotalPlCnt);
$PlRow = $PlRS[0];
$PlCatRS = $this->SelectQuery("plan_category_master",array('plan_cat_id'=>$PlanCatId),$TotalPlCatCnt);
$PlCatRow = $PlCatRS[0];
$PlCatIncType = $PlCatRow['cat_ret'];
/*
if($PlCatIncType == 'RD')
{
$DayDiff = $this->DateDifference(date('Y-m-d'),$RegDate);
if($DayDiff != '' && $DayDiff >= 365)
{
$YearNum = ceil($DayDiff/365);
}
else
$YearNum = 1;
}
else
{
$YearNum = $PlRow['plan_duration'] / 12;
}//....end else..............
*/
$YearNum = $PlRow['plan_duration'] / 12;
//echo $YearNum;
//==================================================================
if($InvestMemId == $MemberId)
$AssocDesigFromId = 1;
$AssocDesigId = $MemDesigId;
$IncSql = "SELECT SUM(incent_value) as TotalInc FROM designation_incentive_master
WHERE plan_year = '".$YearNum."' AND (desig_id BETWEEN
'".$AssocDesigFromId."' AND '".$AssocDesigId."')
AND plan_cat_id ='".$PlanCatId."' GROUP BY plan_cat_id";
$IncRS = $this->SimpleRunQuery($IncSql, $IncCnt);
$IncPer = $IncRS[0]['TotalInc'];
//echo $IncPer;
//exit();
$IncAmt = round(($PremiumAmt * $IncPer)/100,2);
//.........store into database.....................
// if($AssocId == $MemberId)
// return;
if($AssocDesigId > 0)
{
$IncValueArr = array("receipt_id"=>$ReceiptNo,"plan_cat_id"=>$PlanCatId,"invest_mem_id"=>$InvestMemId,"assoc_mem_id"=>$InvestMemId,"mediat_mem_id"=>$MemberId,"plan_id"=>$PlanId,"sub_plan_id"=>$SubPlanId,"plan_code"=>$PlanCode,"assoc_desig_id"=>$AssocDesigId,"mediat_desig_id"=>$MemDesigId,'invest_desig_id'=>$InvestDesigId,"inc_per"=>$IncPer,"inc_amt"=>$IncAmt,"inc_date"=>date('Y-m-d'));
$this->InsertQuery("incentive_detail",$IncValueArr);
}
//......................................................................
return;
}
//================================================================================
//================================================================================
//...........function GetInvestorUnderAssosiate() to get investors under given associate.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetInvestorUnderAssosiate($MemberId, $ParentTag = 'No')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
$MemName = $MemRow['title_name']." ".$MemRow['full_name'];
if($MemRow['desig_id'] != '' && $MemRow['desig_id'] != '0')
{
$Designation = $this->GetValueById("designation_master","desig_id",$MemRow['desig_id'],"desig_name");
$Designation = "(".$Designation.")";
}
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0' || $ParentTag=='Yes')
$AssosRegNum = '';
else
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
echo "[{v:'".$MemRegNum."', f:'".$MemRegNum."<br>".$MemName."<br>".$Designation."'}, '".$AssosRegNum."', ''],";
//echo "<br><br> ".$MemRegNum." --- ".$MemName." ( ".$Designation."') ::: '".$AssosRegNum."'";
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetInvestorUnderAssosiate($MemRow['member_id']);
}
}
}//.....end function.........
//================================================================================
//================================================================================
//...........function GetLevelInvestorUnderAssosiate() to get investors under given associate upto 2 level.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetLevelInvestorUnderAssosiate($MemberId, $ParentTag = 'No', $LevelNo, $GoHigher='Yes')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
$MemName = $MemRow['title_name']." ".$MemRow['full_name'];
if($MemRow['desig_id'] != '' && $MemRow['desig_id'] != '0')
{
$Designation = $this->GetValueById("designation_master","desig_id",$MemRow['desig_id'],"desig_name");
$Designation = "(".$Designation.")";
}
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0')
$AssosRegNum = '';
else
{
//.........check if further investors exists under this associate..............
$InvIntroRS = $this->SelectQuery("member_master",array("intro_asso_id" => $MemberId), $TtlIntroCnt);
}
if($LevelNo == '1')
{
if($AssosRegNum != '' && $GoHigher != 'No')
{
echo "<tr><td style='text-align:center;'>
<center><div style='width:150px;' class='level1' onclick='DisplayNewChart(\"".$AssosRegNum."\")'>".$MemRegNum."<br>".$MemName."<br>".$Designation."</div></center>
</td></tr>";
}
else
{
echo "<tr><td style='text-align:center;'>
<center><div style='width:150px;' class='level1'>".$MemRegNum."<br>".$MemName."<br>".$Designation."</div></center>
</td></tr>";
}
}
else
{
if($TtlIntroCnt > 0)
$ClassName = 'level2';
else
$ClassName = 'level5';
echo "<td style='width:100px; vertical-align:top; padding-left:10px; padding-right:10px;'>
<center><div style='width:100px;'>
<center>
<img src='../images/blue_top.png' border='0' align='absmiddle'/>
</center>
</div>";
if($MemRow['assoc_reg_num'] != '')
{
echo "<div style='width:100px;' class='".$ClassName."' onclick='DisplayNewChart(\"".$MemRegNum."\")'><b>".$MemRegNum."</b><br>".$MemName."<br>".$Designation."</div>";
}
else
{
echo "<div style='width:100px;' class='".$ClassName."'><b>".$MemRegNum."</b><br>".$MemName."<br>".$Designation."</div>";
}
echo "
</center>
</td>";
}
//=============================================================================
if($LevelNo < 2)
{
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
echo '<tr><td style="text-align:center;">
<img src="../images/blue_top.png" border="0" align="absmiddle"/>
</td></tr>
<tr><td style="text-align:center; vertical-align:top;">
<table cellpadding="0" cellspacing="0" border="0" class="leveltable" align=center>
<tr>';
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetLevelInvestorUnderAssosiate($MemRow['member_id'],'No',++$LevelNo);
}
echo '</tr>
</table>
</td>
</tr>';
}
}//......end if
//=============================================================================
//=============================================================================
}//.....end function.........
//================================================================================
//================================================================================
//...........function GetInvestorUnderAssosiate() to get investors under given associate.....
/*
@param
- $MemberId -> Associate member id
*/
//================================================================================
//================================================================================
function GetInvestorSummaryUnderAssosiate($MemberId, $ParentTag = 'No')
{
if($MemberId == '')
return;
$MemRS = $this->SelectQuery("member_master",array('member_id'=>$MemberId),$TotalRecCount);
$MemRow = $MemRS[0];
//print_r($MemRow);
if($MemRow['assoc_reg_num'] == '')
$MemRegNum = $MemRow['invest_reg_num'];
else
$MemRegNum = $MemRow['assoc_reg_num'];
// print_r($MemRow);
if($MemRow['intro_asso_id'] == '' || $MemRow['intro_asso_id'] == '0' || $ParentTag=='Yes')
$AssosRegNum = '';
else
$AssosRegNum = $this->GetValueById("member_master","member_id",$MemRow['intro_asso_id'],"assoc_reg_num");
echo "['".$MemRegNum."', '".$AssosRegNum."', ''],";
//echo "<br><br> ".$MemRegNum." --- ".$MemName." ( ".$Designation."') ::: '".$AssosRegNum."'";
$AssocRS = $this->SelectQuery("member_master",array('intro_asso_id'=>$MemberId),$TotalRecCount);
if($TotalRecCount > 0)
{
foreach($AssocRS as $MemRow)
{
//$InvArr[$MemRow['member_id']] = $MemRow['member_id'];
if($MemRow['member_id'] == $MemberId || $MemRow['invest_reg_num'] == '')
continue;
$this->GetInvestorSummaryUnderAssosiate($MemRow['member_id']);
}
}
}//.....end function.........
//================================================================================
/*================================================================================
//========= function GetDesignationByDateRange() return designation of a member as per given date range...
@param -
$no - MemberID, $DateFrom, $DateTo
@return
- Desgination and Target amount array.........
=========================================================================================== */
function GetDesignationByDateRange($MemberID, $DateFrom, $DateTo)
{
if($MemberID == '' || $MemberID == '0')
return;
$Query = "SELECT new_desig_id, promote_date FROM associate_promote_master WHERE
(promote_date BETWEEN '".$DateFrom."' AND '".$DateTo."') AND
member_id = '".$MemberID."'
UNION ALL
SELECT new_desig_id, promote_date FROM associate_promote_master WHERE
promote_date <= ".$DateFrom." AND
member_id = '".$MemberID."' ORDER BY promote_date DESC limit 1
";
$MemRS = $this->SimpleRunQuery($Query, $TtlCnt);
if($TtlCnt > 0)
{
$MemRow = $MemRS[0];
$DesRS = $this->SelectQuery("designation_master",array('desig_id'=>$MemRow['new_desig_id']), $DesCnt);
$DesArr = array("TargetAmt" =>$DesRS[0]['target_amt'], "Designation" =>$DesRS[0]['desig_name']);
return $DesArr;
}
else
return;
//.....................
}//....end function
//================================================================================
//================================================================================
/*================================================================================
//========= function CurrencyToWord() convert indian currency from no to words
@param -
$no - amount
=========================================================================================== */
function CurrencyToWord($no)
{
$words = array('0'=> '' ,'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' => 'Fouteen','15' => 'Fifteen','16' => 'Sixteen','17' => 'Seventeen','18' => 'Eighteen','19' => 'Nineteen','20' => 'Twenty','30' => 'Thirty','40' => 'Fourty','50' => 'Fifty','60' => 'Sixty','70' => 'Seventy','80' => 'Eighty','90' => 'Ninty','100' => 'Hundred &','1000' => 'Thousand','100000' => 'Lakh','10000000' => 'Crore');
if($no == 0)
return ' ';
else {
$novalue='';
$highno=$no;
$remainno=0;
$value=100;
$value1=1000;
while($no>=100) {
if(($value <= $no) &&($no < $value1)) {
$novalue=$words["$value"];
$highno = (int)($no/$value);
$remainno = $no % $value;
break;
}
$value= $value1;
$value1 = $value * 100;
}
if(array_key_exists("$highno",$words))
return $words["$highno"]." ".$novalue." ".$this->CurrencyToWord($remainno);
else {
$unit=$highno%10;
$ten =(int)($highno/10)*10;
return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".$this->CurrencyToWord($remainno);
}
}
}
/*=======================================================================================
/*=======================================================================================
//========= function ShowAddLink() to include edit link .....
@param -
$TagName - Name of module
//=========================================================================================== */
function ShowAddLink($TagName = 'Record')
{
$LabelStr = "<label class='newrecord' onClick='AddRecord()' id='YKNRecordTdId' style='height:20px;'>Add New ".$TagName."</label>";
return $LabelStr;
}
/*=======================================================================================
/*=======================================================================================
/*=======================================================================================
//========= function ShowEditLink() to include edit link .....
@param -
$RecordId - Record id
//=========================================================================================== */
function ShowEditLink($RecordId = '0')
{
$LabelStr = "<center><label class='recedit_cls' onClick='EditRecord(\"$RecordId\")'>Edit</label></center>";
return $LabelStr;
}
/*=======================================================================================
//========= function ShowRecordListInfo() to display number of records in the listing .....
@param -
$FromRec - Starts from record no.
$RecInList - no. of records displayed in the list
$TotalRec - Total records for this resultset
//=========================================================================================== */
function ShowRecordListInfo($FromRec = '1',$RecInList = '1' ,$TotalRec = '1' )
{
$LabelStr = "<label class='tdreccountlist'>Record ".$FromRec.' to '.(($FromRec+$RecInList)-1)." | Total :".$TotalRec."</label>";
return $LabelStr;
}
/*=======================================================================================
/*=======================================================================================
//========= function ShowViewLink() to include view link .....
@param -
$RecordId - Record id
//=========================================================================================== */
function ShowViewLink($RecordId = '0')
{
$LabelStr = "<center><label class='recedit_cls' onClick='EditRecord(\"$RecordId\")'>View</label></center>";
return $LabelStr;
}
/*=======================================================================================
//========= function ShowRecordListInfo() to display number of records in the listing .....
@param -
$FromRec - Starts from record no.
$RecInList - no. of records displayed in the list
$TotalRec - Total records for this resultset
//=========================================================================================== */
/*=======================================================================================
//========= function SendAnEmail() sents mail according to the given parameters.....
@param -
$Subject - subject of the mail
$ToMail - To Email Id
$Message - Message to be send
$FromMail - From Email Id
//=========================================================================================== */
function SendAnEmail($Subject, $ToMail, $Message, $FromMail = 'admin@wealthproaf.com')
{
$Headers = 'MIME-Version: 1.0' . "\r\n";
$Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Headers .= 'From:'.$FromMail . "\r\n";
if(@mail($ToMail, $Subject, $Message, $Headers))
return true;
else
return false;
}
/*=======================================================================================
/*=======================================================================================
//===== function MultiDimArrSort() to sort multi-dimensional array on a key field. .......
@param -
$array - Name of array
$key - Key on which sorted...
======================================================================================= */
function MultiDimArrSort(&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
//=====================================================================================
/*=======================================================================================
//========= function MailonHotelBooking() sents mail according to the given parameters.....
@param -
$BookInfo
$Paymode - Payment method
//=========================================================================================== */
function MailonHotelBooking($BookInfo, $PayMode, $RegId, $FileName)
{
$MemDSrs = $this->SelectQuery("tbl_tgmember",array('MEMID' => $BookInfo['member_id']));
$rows = $MemDSrs[0];
$emailid = $rows['EMAILID'];
$sgender = $rows['GENDER'];
$scat = $rows['CATEGORY'];
$speciality = $rows['SPECIALITY'];
$stitle = $rows['TITLE'];
$sfname = $rows['FNAME'];
$slname = $rows['LNAME'];
$sorg = $rows['ORG'];
$saddr = $rows['ADDRESS'];
$saddr2 = $rows['ADDR2'];
$saddr3 = $rows['ADDR3'];
$saddr4 = $rows['ADDR4'];
$scountry = $rows['NCOUNTRY'];
$sstate = $rows['NSTATE'];
$scity = $rows['NCITY'];
$spin = $rows['PINCODE'];
$sstdcode = $rows['PHCODE'];
$sphno = $rows['PHONE'];
$scouncode = $rows['MCODE'];
$smobile = $rows['MOBILE'];
$sfaxcode = $rows['FCODE'];
$sfax = $rows['FAX'];
$htmlText = "<!Doctype html public .../ / W3c/dtd html>";
$htmlText = $htmlText."<html>";
$htmlText= $htmlText."<head>";
$htmlText= $htmlText."<title>Hotel Booking Request</title>";
$htmlText= $htmlText."</head>";
$htmlText = $htmlText."<body>";
$htmlText= $htmlText."<TABLE cellSpacing=1 cellPadding=4 width=100% border=0>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Hotel Booking : Online Booking Confirmation</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Hotel Name :".$BookInfo['hotel_name']."," .$BookInfo['hotel_city']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Room Type :".$BookInfo['room_type']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >No of Rooms :".$BookInfo['room_count']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Check-in Date :".$this->DateShifting($BookInfo['checkin_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Check-out Date :".$this->DateShifting($BookInfo['checkout_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Total Amount :".$BookInfo['total_amt_paid']."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Payment Mode :".$PayMode."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Registered On :".$this->DateShifting($BookInfo['reg_date'])."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Registration id :".$RegId."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Email Id :".$emailid."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Gender :".$sgender."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Category :".$scat."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >speciality :".$speciality."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Name :".$stitle." ".$sfname." ".$slname."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Address :".$saddr." ".$saddr2." ".$saddr3." ".$saddr4."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >".$scity." ".$sstate." ".$scountry." ".$spin."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Phone No :".$sstdcode." ".$sphno."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Mobile No :".$scouncode." ".$smobile."</TD></TR>";
$htmlText= $htmlText."<TR bgColor=#ffffff>";
$htmlText= $htmlText."<TD >Fax No :".$sfaxcode." ".$sfax."</TD></TR>";
$htmlText= $htmlText."</TABLE>";
$htmlText= $htmlText."</body>";
$htmlText= $htmlText."</html>";
$adminmail = "cde@idrr.org";
//$adminmail = "tanisisoftware@gmail.com";
$Subject = "Online Hotel Booking";
$MailTO = $adminmail;
$Message = $htmlText;
$Headers = 'MIME-Version: 1.0' . "\r\n";
$Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Headers .= "'To: ".$emailid."'\r\n";
$Headers .= "'CC: ".$adminmail."'\r\n";
$Headers .= 'From: IDRR CDE <'.$adminmail."> ". "\r\n" ;
//......create pdf file.........
$this->CurlToGetDetails('htlbkid='.$RegId."&nodisp=Yes", '', 'Hotel');
//..........send mail with pdf attachment............
$this->SendMailWithAttachment(DIRPATH."IDRRreghotel.pdf",$emailid, $adminmail,"IDRR CDE", $adminmail, $Subject, $htmlText, $adminmail,'enquiry@thegrandmagrath.com');
//@mail($MailTO, $Subject, $Message, $Headers);
//return $PDFMessage;
}
/*=======================================================================================
//==== function SendMailWithAttachment() send mail with attachment.....
@param -
$BookInfo
$Paymode - Payment method
//=========================================================================================== */
function SendMailWithAttachment($FileName,$MailTo, $MailFrom, $FromName, $ReplyTo, $Subject, $Message, $BCC='', $CC='')
{
$file_size = filesize($FileName);
$handle = fopen($FileName, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($FileName);
$header = "From: ".$FromName." <".$MailFrom.">\r\n";
if($BCC != '')
{
$header .= "Bcc: ".$BCC."\r\n";
}
if($CC != '')
{
$header .= "Cc: ".$CC."\r\n";
}
$header .= "Reply-To: ".$ReplyTo."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $Message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$name."\"\r\n"; // use diff. tyoes here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$name."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if(mail($MailTo, $Subject, "", $header))
return true;
else
return false;
}
/*=======================================================================================
/*=======================================================================================
//*=======================================================================================
/========= function DisplaySelect() to create list box with provided information
@param -
$ComboName - Name of combo box / list box
$DataArr - Data to display
$SelectedValue - Value to display as selected
$MultipleState - If multiple or not
$Display - If 'Yes', echo the list box else return the string
$FunctionToCall - Function to call for list box
$AddHeading - If yes, the first option will be Please select, else not.
$ComboWidth - to fix combo width =========================================================================================== */
function DisplaySelect($ComboName,$DataArr,$SelectedValue='', $MultipleState='',$Display = 'Yes',$FunctionToCall = '', $AddHeading = 'Yes', $ComboWidth='', $ComboStyle='')
{
$ComboID = $ComboName;
$MultipleStr = '';
if($MultipleState == 'Multiple')
{
$ComboName.= "[]";
$MultipleStr = " multiple='multiple' size=5";
}
if($MultipleState == 'Array')
{
$ComboName.= "[]";
}
$WidthStyle = '';
if($ComboWidth != '')
{
$WidthStyle = "style='width:".$ComboWidth."px;".$ComboStyle."'";
}
elseif($ComboStyle != '')
{
$WidthStyle = "style='".$ComboStyle."'";
}
$DisplayStr = "<select name='".$ComboName."' id ='".$ComboID."' ".$FunctionToCall. $MultipleStr." ".$WidthStyle.">";
if($AddHeading == 'All')
$DisplayStr.="<option value=''>All</option>";
if($AddHeading == 'Yes')
$DisplayStr.="<option value=''>Please select</option>";
if($AddHeading == 'Dash')
$DisplayStr.="<option value=''> ---------------- </option>";
if($AddHeading == 'Blank')
$DisplayStr.="<option value=''> </option>";
//............add options..............
$Selected = '';
if(count($DataArr) > 0)
{
foreach($DataArr as $KeyVal => $DispVal)
{
if(is_array($SelectedValue))
{
if(array_key_exists($KeyVal, $SelectedValue))
$Selected = ' selected';
}
else
{
if($SelectedValue == $KeyVal)
$Selected = ' selected';
}
$DisplayStr.= "<option value='".$KeyVal."' ".$Selected.">".$DispVal."</option>";
$Selected = '';
}
}
$DisplayStr.="</select>";
if($Display == 'Yes')
echo $DisplayStr;
else
return $DisplayStr;
}
/*=======================================================================================
//========= function OrderByDisp() to display the image according to the order by
@param -
$CurField - Current field
$OrderedField - Field on which order by was applied
$CurOrderType - Order by type - ASC or DESC
=========================================================================================== */
function OrderByDisp($CurField,$OrderedField,$CurOrderType='ASC')
{
if($CurField != $OrderedField)
$CurOrderType='ASC';
if($CurOrderType=='ASC')
$ImagePath = ASCIMGPATH;
else
$ImagePath = DESCIMGPATH;
echo "<img src='".$ImagePath."' onClick = 'ChangeOrderField(\"".$CurField."\",\"".$CurOrderType."\")' align='absmiddle' style='cursor:pointer;'>";
}
//=====================================================================================
//======================================================================================
//==================================================================================
/*========= function CurlToGetDetails() to receive desired info
@param -
$FieldStr - post string
$FileName - file url
*///==================================================================================
//==================================================================================
function CurlToGetDetails($FieldStr, $FileName='index.php', $TicketType='')
{
$StrCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
// session_write_close();
if($TicketType == 'VIP')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/vippass.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/vippass.php");
}
elseif($TicketType == 'ALL')
{
//$CurlCon = curl_init("http://localhost/web-2012/newidrr/website/idrr/allorderpdf.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/allorderpdf.php");
}
elseif($TicketType == 'Hotel')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/hotelpdf.php");
}
elseif($TicketType == 'Booth')
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/boothpdf.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/boothpdf.php");
}
else
{
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
$CurlCon = curl_init("http://cdecentre.com/idrr/printticket.php");
}
//$CurlCon = curl_init("http://localhost/web-2012/cdecentre/website/idrr/printticket.php");
//$CurlCon = curl_init("http://cdecentre.com/idrr/printticket.php");
//set options
curl_setopt($CurlCon, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($CurlCon, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($CurlCon, CURLOPT_RETURNTRANSFER, true);
curl_setopt($CurlCon, CURLOPT_COOKIE, $StrCookie);
curl_setopt($CurlCon, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($CurlCon, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($CurlCon, CURLOPT_POSTFIELDS, $FieldStr);
//perform our request
$ResponseText = curl_exec($CurlCon);
//show information regarding the request
//close the connection
curl_close($CurlCon);
//echo $ResponseText;
}
//=====================================================================================
//======================================================================================
//==================================================================================
function tep_validate_password($plain, $encrypted,$type='O') {
$valid_password=false;
if ($plain != '' && $encrypted != '')
{
// split apart the hash / salt
$stack = explode(':', $encrypted);
if (sizeof($stack) != 2) return false;
if ($type=="V"){
if (md5(md5($plain) . $stack[1]) == $stack[0]) {
$valid_password=true;
}
} else {
if (md5($stack[1] . $plain) == $stack[0]){
$valid_password=true;
}
}
}
return $valid_password;
}
//=====================================================================================
//======================================================================================
//==================================================================================
// This function makes a new password from a plaintext password.
function tep_encrypt_password($plain,$type='O') {
$password = '';
for ($i=0; $i<10; $i++) {
$password .= $this->tep_rand();
}
$salt = substr(md5($password), 0, 2);
if ($type=="V"){
$password = md5(md5($plain) . $salt) . ':' . $salt;
} else {
$password = md5($salt . $plain) . ':' . $salt;
}
return $password;
}
//=====================================================================================
//=====================================================================================
function tep_rand($min = null, $max = null) {
static $seeded;
if (!$seeded) {
mt_srand((double)microtime()*1000000);
$seeded = true;
}
if (isset($min) && isset($max)) {
if ($min >= $max) {
return $min;
} else {
return mt_rand($min, $max);
}
} else {
return mt_rand();
}
}
//======================================================================================
//==================================================================================
/*=======================================================================================
//========= function TimeTo12Hour() to convert 24 hr time to 12 hr time........
@param -
$Time - Time value
=========================================================================================== */
function TimeTo12Hour($Time)
{
if($Time == '')
return "";
else
{
$TimeArr = explode(":",$Time);
if($TimeArr[0] > 12)
{
$Hours = $TimeArr[0] - 12;
$TimeString = str_pad($Hours, 2, "0", STR_PAD_LEFT).":".$TimeArr[1]." PM";
}
else
{
$TimeString = substr($Time,0,5)." AM";
}
return $TimeString;
}
}//...end function
//=======================================================================================
/*=======================================================================================
//========= function TimeTo24Hour() to convert 12 hr time to 24 hr time........
@param -
$Time - Time value
=========================================================================================== */
function TimeTo24Hour($Time)
{
if($Time == '')
return "";
else
{
$SlotArr = explode(" ",$Time);
$TimeArr = explode(":",$SlotArr[0]);
// print_r($SlotArr);
if($SlotArr[1] == 'PM')
{
$Hours = $TimeArr[0] + 12;
$TimeString = $Hours.":".$TimeArr[1].":00";
}
else
{
$TimeString = $SlotArr[0].":00";
}
return $TimeString;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function DateShifting() to change date format like from dd-mm-yyyy to yyyy-mm-dd.......
@param -
$DateVal - Date value
=========================================================================================== */
function DateShifting($DateVal)
{
if($DateVal == '')
return "";
else
{
if(stripos($DateVal,"-") > 0)
$Divider = "-";
elseif(stripos($DateVal,"/") > 0)
$Divider = "/";
$DateArr = @explode($Divider,$DateVal);
$DateStr = $DateArr[2]."-".$DateArr[1]."-".$DateArr[0];
return $DateStr;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function DateByTime() to get date by arrival and departure time from journey date.......
@param -
$DateVal - Date value
$Departure - Departure time value
$Arrival - Arrival time value
=========================================================================================== */
function DateByTime($DateVal, $Departure, $Arrival)
{
if($DateVal == '')
return "";
else
{
$DateArr = explode("-",$DateVal);
$DepartDateStamp = mktime(0, 0, 0, $DateArr[1], $DateArr[0], $DateArr[2]);
$ReturnDate[0] = date("D M j",$DepartDateStamp);
//....get difference between depart time and arrival time, if arrival time is less than depart time...................
$IncDay = 0;
$DepartArr = explode(":",$Departure);
$ArriveArr = explode(":",$Arrival);
if($DepartArr[0] > $ArriveArr[0])
{
$IncDay = 1;
}
$ArriveDateStamp = mktime(0, 0, 0, $DateArr[1], $DateArr[0]+$IncDay, $DateArr[2]);
$ReturnDate[1] = date("D M j",$ArriveDateStamp);
return $ReturnDate;
}
}//...end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function UploadImage() to store any image to provided folder .......
- all parameters must to be provided
@param -
$ImageName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadImage($ImageName, $TmpName, $ImageSize,$ImageHW, $ImageType, $TargetName, &$ErrorInUpload = '')
{
//echo $ImageName." : ".$TmpName." : ".$ImageSize." : ".$ImageHW." : ".$ImageType." : ".$TargetName;
//.....validate image (check image type, image size, image height and width)
$ImgFile = $_FILES[$ImageName];
$ImageTypeArr = array('image/gif','image/pjpeg','image/jpeg','image/jpg','image/png');
if(in_array($ImageType,$ImageTypeArr)) //check image type
{
//....check size.....
if($ImageSize > (UPLOADIMGSIZE * 1024))
$ErrorInUpload = "Image size must be upto ".UPLOADIMGSIZE." KB";
else //...check height and width...
{
$ImageSize = @getimagesize($ImgFile);
if($ImageHW[0] > UPLOADIMGWIDTH || $ImageHW[1] > UPLOADIMGHEIGHT)
$ErrorInUpload = "Image width and height should be Maximum ".UPLOADIMGWIDTH." x ".UPLOADIMGHEIGHT.".";
}
}
else
$ErrorInUpload = "Only .gif, .png and .jpeg images can be uploaded.";
//echo $ErrorInUpload."asdf";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
//...upload image
$ImgExtension = substr($ImageName, @strripos($ImageName,"."), (strlen($ImageName) - @strripos(".")));
//echo IMGFOLDERPATH.$TargetName.$ImgExtension;
if(! move_uploaded_file($TmpName, IMGFOLDERPATH.$TargetName.$ImgExtension))
{
$ErrorInUpload = "Due to some errors could not upload image";
}
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
/*=======================================================================================
//========= function UploadSingleImage() to store any image to provided folder .......
@param -
$ImageName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadSingleImage($ImageName, $TargetName, $MaxHeight, $MaxWidth, &$ErrorInUpload = '', $DeleteExisting='No', $ImageFolder = '',$MaxAdImgSize = '')
{
$ImgFile = $_FILES[$ImageName];
//.....validate image (check image type, image size, image height and width)
$ImageTypeArr = array('image/gif','image/pjpeg','image/jpeg','image/png');
if(in_array($ImgFile['type'],$ImageTypeArr)) //check image type
{
if($MaxAdImgSize == '')
$MaxAdImgSize = UPLOADIMGSIZE;
//....check size.....
if($ImgFile['size'] > ($MaxAdImgSize * 1024))
$ErrorInUpload = "Image size must be upto ".$MaxAdImgSize." KB";
else //...check height and width...
{
$ImageSize = getimagesize($ImgFile);
if($ImageSize[0] > $MaxWidth || $ImageSize[1] > $MaxHeight)
$ErrorInUpload = "Image width and height should be ". $MaxWidth." x ". $MaxHeight.".";
}
}
else
$ErrorInUpload = "Only .gif, .png and .jpeg images can be uploaded.";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
if($DeleteExisting == 'Yes')
unlink(IMGFOLDERPATH.$ExistingName);
//...upload image
$ImgExtension = substr($ImgFile['name'], strripos($ImgFile['name'],"."), (strlen($ImgFile['name']) - strripos(".")));
if($ImageFolder == '')
$ImageFolder = IMGFOLDERPATH;
if(! move_uploaded_file($ImgFile['tmp_name'], $ImageFolder.$TargetName.$ImgExtension))
$ErrorInUpload = "Due to some errors could not upload image";
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
/*=======================================================================================
//========= function UploadSingleFile() to store any image to provided folder .......
@param -
$DocName - Name of image to upload
$TargetName - Name os image to be upload as
$ErrorInUpload - Contains error message, if any problem occurs
=========================================================================================== */
function UploadSingleFile($DocName, $TargetName,&$ErrorInUpload = '', $DeleteExisting='No', $DocFolder = '',$MaxFileSize = '')
{
$ImgFile = $_FILES[$DocName];
//.....validate image (check file type, file size)
$DocTypeArr = array('application/msword','application/pdf','application/doc','application/vnd.msword','image/gif','image/pjpeg','image/jpeg','image/png');
if(in_array($ImgFile['type'],$DocTypeArr)) //check image type
{
if($MaxFileSize == '')
$MaxFileSize = UPLOADFILESIZE;
//....check size.....
if($ImgFile['size'] > ($MaxFileSize * 1024))
$ErrorInUpload = "Doc size must be upto ".$MaxFileSize." KB";
}
else
$ErrorInUpload = "Only Images with .gif, .png and .jpeg can be uploaded.";
//.......if all validations of image are approved then, upload the image....
if($ErrorInUpload == '')
{
if($DeleteExisting == 'Yes')
unlink(IMGFOLDERPATH.$ExistingName);
//...upload image
$ImgExtension = substr($ImgFile['name'], strripos($ImgFile['name'],"."), (strlen($ImgFile['name']) - strripos(".")));
if($DocFolder == '')
$DocFolder = IMGFOLDERPATH;
//echo $DocFolder.$TargetName.$ImgExtension;
if(! move_uploaded_file($ImgFile['tmp_name'], $DocFolder.$TargetName.$ImgExtension))
$ErrorInUpload = "Due to some errors could not upload File";
else
return $TargetName.$ImgExtension;
}
}//end function
//===================================================================================================
//===================================================================================================
/*=======================================================================================
//========= function ImageWidthHeight() to get reduce image height and width as required.......
@param -
$ImagePath - Path of image
$MaxWidth - Maximum image width
$MaxHeight - Maximum height of the image which is allowed to display
=========================================================================================== */
function ImageWidthHeight($ImagePath, $MaxWidth, $MaxHeight)
{
if(! file_exists($ImagePath))
{
return '';
}
$Size=getimagesize($ImagePath);
$ImageHeight=$Size[1];
$ImageWidth=$Size[0];
if($ImageWidth < $MaxWidth)
$DisplayWidth = $ImageWidth;
else
$DisplayWidth = $MaxWidth;
$DisplayHeight = $DisplayWidth*$ImageHeight/$ImageWidth;
$SizeArr = array("width"=>$DisplayWidth,"height"=>$DisplayHeight);
return $SizeArr;
}//...end function
//===================================================================================================
/*=======================================================================================
//========= function ImageWidthHeight() to get reduce image height and width as required.......
@param -
$ImagePath - Path of image
$MaxWidth - Maximum image width
$MaxHeight - Maximum height of the image which is allowed to display
=========================================================================================== */
function ImageHeightWidth($ImagePath, $MaxWidth, $MaxHeight)
{
if(! file_exists($ImagePath))
{
return '';
}
$Size=getimagesize($ImagePath);
$ImageHeight=$Size[1];
$ImageWidth=$Size[0];
if($ImageHeight < $MaxHeight)
$DisplayHeight = $ImageHeight;
else
$DisplayHeight = $MaxHeight;
$DisplayWidth = $DisplayHeight*$ImageWidth/$ImageHeight;
if($DisplayWidth > $MaxWidth)
{
$DisplayWidth = $MaxWidth;
$DisplayHeight = $DisplayWidth*$ImageHeight/$ImageWidth;
}
$SizeArr = array("width"=>$DisplayWidth,"height"=>$DisplayHeight);
return $SizeArr;
}//...end function
//===================================================================================================
//===================================================================================================
//===================================================================================================
//===================================================================================================
//function to encrypt the string
function encode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=strrev(base64_encode($str)); //apply base64 first and then reverse the string
}
return $str;
}
//===================================================================================================
//function to decrypt the string
function decode5t($str)
{
for($i=0; $i<5;$i++)
{
$str=base64_decode(strrev($str)); //apply base64 first and then reverse the string
}
return $str;
}
//===================================================================================================
/*=======================================================================================
//========= function RandomStringGenerator() to genrerate random string .......
@param -
$CurrencyVal - Digit to convert value
=========================================================================================== */
function RandomStringGenerator($length=8)
{
$characters = '123456789ABCDEFGHIJKLMNPQRSTUVWXYZ';
$string = '';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
//=====================================================================================
/*=======================================================================================
//========= function NumberToCurrency() to convert number from integer format to money format.......
@param -
$CurrencyVal - Digit to convert value
=========================================================================================== */
function NumberToCurrency($CurrencyVal)
{
return number_format($CurrencyVal, 2, '.', ',');
}//...end function
//=====================================================================================
//=====================================================================================
/*=======================================================================================
//===== function DateDifference() to get difference between to dates .......
@param -
$Date1 - Date Bigger
$Date2 - Date Smaller
======================================================================================= */
function DateDifference($Date1, $Date2)
{
if($Date1 != '' && $Date2 != '')
return round((strtotime($Date1)-strtotime($Date2))/86400);
else
return '';
}//...end function
//=======================================================================================
/*=======================================================================================
//===== function TimeDifferenceInHour() to get difference between two times .......
@param -
$Time1 - Time 1 //..format is HH:MM AM/PM
$Time2 - Time 2 //..format is HH:MM AM/PM
======================================================================================= */
function TimeDifferenceInHour($Time1, $Time2)
{
//echo $Time1.":::".$Time2;
if($Time1 != '' && $Time2 != '')
{
$TimeAr1 = explode(" ",$Time1);
$TimeHMAr1 = explode(":",$TimeAr1);
$TimeAr2 = explode(" ",$Time2);
$TimeHMAr2 = explode(":",$TimeAr2);
if($TimeAr1 == 'PM')
$TimeHMAr1[0] = $TimeHMAr1[0] + 12;
if($TimeAr2 == 'PM')
$TimeHMAr2[0] = $TimeHMAr2[0] + 12;
$HrDiff = $TimeHMAr2[0] - $TimeHMAr1[0];
return $HrDiff;
}
else
return '';
}//...end function
//=======================================================================================
/*=======================================================================================
//===== function GetIPAddress() to get visitors IP address .......
======================================================================================= */
function GetIPAddress()
{
if(getenv(HTTP_X_FORWARDED_FOR))
{
$IPAddress = getenv(HTTP_X_FORWARDED_FOR);
//$ipaddress = getenv(REMOTE_ADDR);
}
else
{
$IPAddress = getenv(REMOTE_ADDR);
}
return $IPAddress;
}//...end function
/*=======================================================================================
//=======================================================================================
/*===== function MergeTwoArrays() to merger two array keeping their indexes and return unique values.. .......
@param -
$ValueArr1 - array 1
$ValueArr2 - array 2
@return -
$NewValueArr
======================================================================================= */
function MergeTwoArrays($ValueArr1,$ValueArr2)
{
if(count($ValueArr1) == 0)
return $ValueArr2;
if(count($ValueArr2) == 0)
return $ValueArr1;
//=======================================================
$KeyArr = array_merge(array_keys($ValueArr1), array_keys($ValueArr2));
$ValArr = array_merge($ValueArr1, $ValueArr2);
$NewValueArr = array_combine($KeyArr, $ValArr);
//........................
return $NewValueArr;
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextInfoEncoding($NormalText) to encode text to enter into database and display properly....................
@param -
$NormalText - normal text
@return -
$EncodedText
======================================================================================= */
function TextInfoEncoding($NormalText)
{
//....replace all " with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
return urlencode($NormalText);
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextQuoteHandle($NormalText) to handle double and single quotes....................
@param -
$NormalText - normal text
@return -
$NormalText - after quote handling
======================================================================================= */
function TextQuoteHandle($NormalText)
{
//....replace all other types of quotes with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace('”','`',$NormalText);
$NormalText = str_replace('“','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
$NormalText = str_replace("’","`",$NormalText);
return $NormalText;
}//...end function
//=======================================================================================
//=======================================================================================
/*===== function TextInfoEntityEncode($NormalText) to encode text to enter into database using function htmlentities and display properly....................
@param -
$NormalText - normal text
@return -
$EncodedText
======================================================================================= */
function TextInfoEntityEncode($NormalText)
{
//....replace all " with `
$NormalText = str_replace('"','`',$NormalText);
$NormalText = str_replace("'","`",$NormalText);
return htmlentities($NormalText);
}//...end function
//=======================================================================================
///=======================================================================================
//=-========================================================================================
//---=======-------- array containing value for hours --------------------------------------
var $HRSValArr = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06',
'07'=>'07','08'=>'08','09'=>'09','10'=>'10','11'=>'11','12'=>'12');
//------------------ array containing values for passengers ---------------------------------
var $MonthStringArr = array('01'=>'January','02'=>'February','03'=>'March','04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August','09'=>'September','10'=>'October','11'=>'November','12'=>'December');
var $MDayStringArr = array('01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07','08'=>'08','09'=>'09','10'=>'10','11'=>'11','12'=>'12','13'=>'13','14'=>'14','15'=>'15','16'=>'16','17'=>'17','18'=>'18','19'=>'19','20'=>'20','21'=>'21','22'=>'22','23'=>'23','24'=>'24','25'=>'25','26'=>'26','27'=>'27','28'=>'28','29'=>'29','30'=>'30','31'=>'31');
var $DaysOfWeekArr = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
//=-========================================================================================
var $RECORDSPERPAGEARR = array('10'=>'10','20'=>'20','40'=>'40','80'=>'80');
//=======================================================================================
//=======================================================================================
}// end class
?>
No comments:
Post a Comment