File: /home/imensosw/www/imenso.co/demo/mcm/ajax.php
<?php
function olddb()
{
$conn=mysql_connect("localhost","mcm123","mcm@123") or die(mysql_error());
$db=mysql_select_db("school_mcm",$conn) or die(mysql_error());
}
//;
if(isset($_POST['month']))
{
$month=$_POST['month'];
$year=$_POST['year'];
//$m = strtotime('01-'.$_POST['month'].'-2017');
$weekf_date=0;
$totald=cal_days_in_month(CAL_GREGORIAN,$month,$year);
$m = strtotime('01-'.$month.'-'.$year);
$today = date('l', $m);
$custom_date = strtotime( date('d-m-Y', $m) );
if ($today == 'Monday') {
$week_start = date("d-m-Y", $m);
$weekf_date=date('d', $m);
$week_end = date('d-M,Y', strtotime($weekf_date."-".$month."-".$year));
} else {
$week_start = date('d-M,Y', strtotime('this week first monday', $custom_date));
$weekf_date=date('d', strtotime('this week first monday', $custom_date));
$week_end=6+$weekf_date;
$week_end = date('d-M,Y', strtotime($week_end."-".$month."-".$year));
}
$data="";
$k=1;
$checkflag=0;
$checked_id=0;
for($i=$weekf_date;$i<=$totald;$i++)
{
$checked="";
if($totald>=$i+7 )
{
if($weekf_date!=1 && $weekf_date==$i)
{
$week_start = date('dS-M, Y', strtotime('last monday of previous month', $custom_date));
$weekf_date=date('d', strtotime('last monday of previous month', $custom_date));
$after7 = strtotime("+4 days", strtotime($week_start));
$week_end = date('dS-M, Y', $after7);
if(date("Y-m-d",strtotime(date('Y-m-d')))>=date("Y-m-d",strtotime('last monday of previous month', $custom_date)))
{
$disable = "disable";
}
else
{
$disable = "";
if($checkflag==0)
{
$checked='checked="checked"';
$checked_id='radio0'.$k;
$checkflag++;
}
}
$j=$i+6;
$data.='
<div class="bdr_bt padd_lr_10">
<input id="radio0'.$k.'" '.$checked.' start_date="'.$week_start.'" end_date="'.$week_end.'" value="'.$week_start.' To '.$week_end.'" name="radio2" type="radio" clas="cldate">
<label class="'.$disable.'" for="radio0'.$k.'"><span></span>'.$week_start.' - '.$week_end.'</label>
</div>';
$k++;
}
$checked="";
$week_start=date('dS-M, Y', strtotime($i."-".$month."-".$year));
$j=$i+4;
$week_end = date('dS-M, Y', strtotime($j."-".$month."-".$year));
if(date("Y-m-d",strtotime(date('Y-m-d')))>=date("Y-m-d",strtotime($j."-".$month."-".$year)))
{
$disable = "disable";
}
else
{
$disable = "";
if($checkflag==0)
{
$checked='checked="checked"';
$checked_id='radio0'.$k;
$checkflag++;
}
}
$data.='
<div class="bdr_bt padd_lr_10">
<input id="radio0'.$k.'" '.$checked.' start_date="'.$week_start.'" end_date="'.$week_end.'" value="'.$week_start.' To '.$week_end.'" name="radio2" class="cldate" type="radio">
<label class="'.$disable.'" for="radio0'.$k.'"><span></span>'.$week_start.' - '.$week_end.'</label>
</div>';
}
$i=$i+6;
$k++;
}
$data.='<span class="radio_error boder-none"></span>';
echo json_encode(array('week'=>$data,'monthyear'=>date('F Y',$m),'checkid'=>$checked_id));
}
elseif(isset($_POST['Daniel']))
{
olddb();
$create_date = date('d-m-y');
// $sql="insert into SaveContactForm7_3(created_on,Daniel,Week,Appelbee,email,Tittle,FirstName,LastName,UnitedKingdom,Housenumber,ZipCode, country)values('".$create_date."','".$_POST['Daniel']."','".$_POST['Week']."','".$_POST['Appelbee']."','".$_POST['email']."','".$_POST['Tittle']."','".$_POST['FirstName']."','".$_POST['LastName']."','".$_POST['UnitedKingdom']."','".$_POST['Housenumber']."','".$_POST['ZipCode']."','".$_POST['country']."')";
//print_r($_POST);
//die();
$sql="insert into SaveContactForm7_3(created_on,Daniel,Week,Appelbee,email)values('".$create_date."','".$_POST['Daniel']."','".$_POST['week']."','".$_POST['surname']."','".$_POST['email']."')";
$q=mysql_query($sql) or die(mysql_error());
$newid=mysql_insert_id();
// echo json_encode(array('id'=>$newid));
?>
<html>
<head>
</head>
<body onload="document.getElementById('sub').submit();">
<form class="paypal" action="paypal/payments.php" method="post" id="paypal_form" >
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="UK" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="Customer's First Name" />
<input type="hidden" name="last_name" value="Customer's Last Name" />
<input type="hidden" name="payer_email" value="customer@example.com" />
<input type="hidden" name="item_number" value="<?php echo $newid; ?>" / >
<input type="hidden" name="item_id" value="<?php echo $newid; ?>" / >
<INPUT TYPE="image" NAME="submit" BORDER="0" SRC="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" ALT="PayPal - The safer, easier way to pay online">
<img alt="" border="" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#paypal_form').submit();
});
</script>
</body>
</html>
<?php
}
?>