| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/vx_testing/usa/professional-grant-services/ |
Upload File : |
<?
/**
* This framework has been created for a multitude of grant research websites.
*
* @copyright 2016-2021 Synergy Pro Marketing
* @author Aaron Campbell <aaron@synergymentoring.com>
* @license None, All Rights Reserved
* @package Business
*/
include_once($_SERVER['DOCUMENT_ROOT']."/vx/lib/inc.php");
if(!empty($_GET['username'])) {
header("Location: appointment.php");
exit(0);
}
track_member_action('Page Visit','Professional Grant Services Appointment');
$_SESSION['visited_professional_services'] = '1';
$client_res = $db->query("SELECT * FROM lc2{$siteCode}_lc.lc_reseller
WHERE id='".clean($user)."'");
if(!empty($client_res)) {
$client_info = $client_res[0];
$client_info['address'] = $client_info['address1'];
$client_info['cell_phone'] = phone_number($client_info['phone_1']);
$client_info['work_phone'] = phone_number($client_info['phone_1']);
$client_profile_res = $db->query("SELECT p.money,p.description FROM lc2{$siteCode}_lc.lead_profile p
LEFT JOIN lc2{$siteCode}_lc.lc_leads l ON l.id=p.lead_id
WHERE l.customerID='".clean($user)."'");
if(!empty($client_profile_res)) {
$client_info['description'] = $client_profile_res[0]['description'];
$client_info['money'] = $client_profile_res[0]['money'];
}
if($client_info['visited_professional_services_page']=='0') {
$db->query("UPDATE lc2{$siteCode}_lc.lc_reseller SET visited_professional_services_page=1 WHERE id='".clean($user)."'");
}
} else {
$client_info = array();
}
$marketer_res = $db->query("SELECT marketer FROM coaching_allocator.leads
WHERE leaddb='".clean($siteCode)."'
AND leadid='".clean($user)."'");
if(!empty($marketer_res[0]['marketer'])) {
$marketer_res = $db->query("SELECT e.username as 'marketer',e.first_name,e.work_email,s.extension
FROM surfcrm.employees e
LEFT JOIN surfcrm.softphone_logins s ON s.id=e.softphone_id
WHERE e.username='".clean($marketer_res[0]['marketer'])."'");
}
$timezone_offset = 0;
if(!empty($client_info['zip'])) {
$timezone_res = $db->query("SELECT timezone FROM geo.zip_codes WHERE zip='".clean($client_info['zip'])."'");
if(!empty($timezone_res)) {
$timezone_offset = ($timezone_res[0]['timezone'] - (-7));
}
}
$timezone_offset_pretty = array(
'0' => 'Mountain Time'
,'-1' => 'Pacific Time'
,'-2' => 'Alaska Time'
,'-4' => 'Hawaii Time'
,'1' => 'Central Time'
,'2' => 'Eastern Time'
);
if(empty($timezone_offset_pretty[$timezone_offset])) {
$timezone_offset = 0;
}
$dates = array();
$appointment_dates = array();
$first_date = date('Y-m-d');
$bus_days = 0;
while($bus_days<3) {
$first_date = date('Y-m-d',strtotime('+1 day',strtotime($first_date)));
if(date('w',strtotime($first_date))=='0' || date('w',strtotime($first_date))=='6') {
continue;
}
$appointment_count = rand(6,10);
$appointment_data = array();
$date = $first_date;
if($bus_days==0) {
$start_time = $date.' 09:00:00';
} else {
$start_time = $date.' 09:00:00';
}
$end_time = $date.' 18:00:00';
$usernames = array('bonniek','chriss','davidc');
if(date('w',strtotime($start_time))=='5') { //Bonnie isn't working Fridays
$usernames = array('chriss','davidc');
}
/*if(date('w',strtotime($start_time))=='6') {
$usernames = array('jasons');
$start_time = $date.' 06:00:00';
$end_time = $date.' 09:00:00';
}*/
if(date('Y-m-d',strtotime($start_time))==date('Y-m-d')) {
$start_time = date('Y-m-d H',strtotime('+2 hour')).':00:00';
$now = date('Y-m-d H:i:s',strtotime('+2 hour'));
while(strtotime($start_time)<=strtotime($now)) {
$start_time = date('Y-m-d H:i:s',strtotime('+45 minute',strtotime($start_time)));
}
}
$res = $db->query("SELECT username, start_date_time, end_date_time
FROM surfcrm.calendar
WHERE username IN ('".implode("','",$usernames)."')
AND '".clean($date)."' BETWEEN DATE(start_date_time) AND DATE(end_date_time)");
$emp_times = array();
foreach($res as $r) {
$emp_times[strtolower($r['username'])][] = $r;
}
while(strtotime($start_time) < strtotime($end_time)) {
$can_do = true;
$emp_blocked = 0;
$emps_cant_do = array();
$current_end_time = date('Y-m-d H:i:s',strtotime('+45 minute',strtotime($start_time)));
foreach($emp_times as $emp=>$emp_data) {
$ignore_me = false;
if(in_array($emp,array('bonniek','chriss','davidc'))) {
if(strtotime($start_time) < strtotime(date('Y-m-d',strtotime($start_time)).' 09:00:00') ||
strtotime($start_time) > strtotime(date('Y-m-d',strtotime($start_time)).' 16:30:00')) {
$emp_blocked++;
$emps_cant_do[] = $emp;
$ignore_me = true;
}
}
if(!$ignore_me) {
foreach($emp_data as $r) {
$in_appointment = false;
if(strtotime($start_time) >= strtotime($r['start_date_time']) && strtotime($start_time) < strtotime($r['end_date_time'])) {
//start date inside of current appointment
$in_appointment = true;
} elseif(strtotime($current_end_time) > strtotime($r['start_date_time']) && strtotime($current_end_time) <= strtotime($r['end_date_time'])) {
//end date inside of current appointment
$in_appointment = true;
} elseif(strtotime($start_time) < strtotime($r['start_date_time']) && strtotime($current_end_time) > strtotime($r['end_date_time'])) {
//appointment inside of the time
$in_appointment = true;
} elseif(strtotime($start_time) >= strtotime($r['start_date_time']) && strtotime($current_end_time) <= strtotime($r['end_date_time'])) {
$in_appointment = true;
}
if($in_appointment) {
$emp_blocked++;
$emps_cant_do[] = $emp;
break;
}
}
}
if($emp_blocked==count($usernames)) {
$can_do = false;
break;
}
}
if($can_do) {
$emps_can_do = array();
foreach($usernames as $emp) {
if(!in_array($emp,$emps_cant_do)) {
$emps_can_do[] = $emp;
}
}
$pretty_start_time = '';
$pretty_end_time = '';
if($timezone_offset=='0') {
$pretty_start_time = date('g:i',strtotime($start_time));
$pretty_end_time = date('g:i a',strtotime('+45 minute',strtotime($start_time)));
} elseif($timezone_offset*1 < 0) {
$timezone_offset_minus = $timezone_offset*-1;
$pretty_start_time = date('g:i',strtotime('-'.$timezone_offset_minus.' hour',strtotime($start_time)));
$pretty_end_time = date('g:i a',strtotime('-'.$timezone_offset_minus.' hour',strtotime('+45 minute',strtotime($start_time))));
} else {
$pretty_start_time = date('g:i',strtotime('+'.$timezone_offset.' hour',strtotime($start_time)));
$pretty_end_time = date('g:i a',strtotime('+'.$timezone_offset.' hour',strtotime('+45 minute',strtotime($start_time))));
}
$appointment_key = $start_time.'|||'.implode('|',$emps_can_do);
$appointment_data[$appointment_key] = date('g:i',strtotime($pretty_start_time)).' - '.date('g:i a',strtotime($pretty_end_time));
}
$start_time = date('Y-m-d H:i:s',strtotime('+45 minute',strtotime($start_time)));
}
if(count($appointment_data)<6) {
continue;
}
if(count($appointment_data)<$appointment_count) {
$appointment_count = count($appointment_data);
}
$nums = array();
for($i=0;$i<$appointment_count;$i++) {
$found = false;
while(!$found) {
$rand = rand(0,count($appointment_data)-1);
if(!in_array($rand,$nums)) {
$nums[] = $rand;
$found = true;
}
}
}
sort($nums);
foreach($nums as $num) {
$j=0;
foreach($appointment_data as $k=>$v) {
if($j==$num) {
$appointment_dates[$date][] = array('key'=>$k,'value'=>$v);
break;
}
$j++;
}
}
$dates[] = $first_date;
$bus_days++;
}
?>
<style>
#application_info {
padding:10px 0px 20px 0px;
position:relative;
margin-top:10px;
}
.datepicker_box,.datepicker_time_box {
width:90%;
background: #c9f1fd;
border: 1px solid #00a4d3;
border-radius: 10px;
text-align:center;
padding:10px;
}
.datepicker_date, .datepicker_time {
display:inline-block;
padding: 5px 10px;
border:2px solid black;
border-radius: 10px;
background:white;
width:90%;
margin: 5px auto;
cursor:pointer;
}
.datepicker_date.datepicker_selected, .datepicker_time.datepicker_selected {
border:2px solid #008db1;
background: #4dd7fa;
}
.vamiddle, .vamiddle input {
vertical-align:middle;
font-size:20px;
}
.vamiddle input {
margin:0px 10px;
}
.schedule_appointment {
background: #91e4fb;
border:2px solid #00a4d3;
font-size:24px;
font-style:italic;
cursor:pointer;
padding:10px 20px;
border-radius:10px;
margin-top:10px;
}
</style>
<script>
var current_appointment_date = '<?= $dates[0];?>';
var current_appointment_time = '';
function select_appointment_date(me,dt,pretty_dt) {
$('#appointment_time_label').html(pretty_dt);
$('.datepicker_date.datepicker_selected').removeClass('datepicker_selected');
$(me).addClass('datepicker_selected');
current_appointment_date = dt;
$('.appointment_times').hide();
$('#appointment_times_' + dt).show();
}
function select_appointment_time(me,dt) {
$('.datepicker_time.datepicker_selected').removeClass('datepicker_selected');
$(me).addClass('datepicker_selected');
current_appointment_time = dt;
}
function schedule_appointment(me) {
var errors = '';
if(current_appointment_time=='') {
alert("You need to select an appointment time");
} else {
$(me).hide();
$(me).removeAttr('onclick');
var str = '';
str += 'appointment_time=' + encodeURIComponent(current_appointment_time);
str += '&send_reminder_text=' + (($('#send_text_reminder').is(':checked')) ? '1' : '0');
str += '&send_reminder_email=' + (($('#send_email_reminder').is(':checked')) ? '1' : '0');
$.ajax({
method: "POST",
url: "/vx/usa/professional-grant-services/set_appointment.php",
data: str
}).done(function( msg ) {
$('#application_info').html(msg);
});
}
}
</script>
<div class="relative block" ng-controller="Members" style="height:100%; min-height:400px; margin:0px auto; max-width:1000px; background: white;">
<div style="padding:0px 10px;">
<center><h1>Appointment for Professional Grant Services</h1></center>
<?php if(!empty($marketer_res[0]['marketer'])) { ?>
<div class="video">
<div class="row">
<div class="company_info_label">
You are currently working with <?= $marketer_res[0]['first_name'];?>.<br />
If you have any questions you can call them at 800-858-1052 ext. <?= $marketer_res[0]['extension'];?>,<br />
or email them at <?= $marketer_res[0]['work_email'];?>.
</div>
</div>
</div>
<?php } else { ?>
<div id="application_info">
<h2>Select a Time To Meet with an Admissions Director</h2>
<div>
<div class="row" style="padding:20px 0px;">
<div class="col-sm-4">
<h3>Select a Date</h3>
<div class="datepicker_box">
<?php $i=0; foreach($dates as $date) { $i++; ?>
<div class="datepicker_date <?= ($i==1) ? 'datepicker_selected' : '';?>" onclick="select_appointment_date(this,'<?= $date;?>','<?= date('l, F jS',strtotime($date));?>'); return false;"><?= date('l, M j',strtotime($date));?></div>
<?php } ?>
</div>
</div>
<div class="col-sm-8">
<h3>Select an Available Time on <span id="appointment_time_label"><?= date('l, F jS',strtotime($dates[0]));?></span></h3>
<div class="datepicker_time_box">
<?php $i=0; foreach($appointment_dates as $date=>$date_data) { $i++; ?>
<div class="appointment_times" id="appointment_times_<?= $date;?>" style="<?= ($i==1) ? 'display:block;' : 'display:none;';?>">
<div class="row">
<?php $j=0; foreach($date_data as $k=>$v) { $j++; ?>
<?= ($j%2==1) ? '</div><div class="row">' : '';?>
<div class="col-sm-6">
<div class="datepicker_time" onclick="select_appointment_time(this,'<?= $v['key'];?>'); return false;"><?= $v['value'];?></div>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="row">
<label class="vamiddle"><input type="checkbox" id="send_text_reminder" checked name="send_text_reminder" />Yes, please send me a text message reminder about my appointment.</label>
</div>
<div class="row">
<label class="vamiddle"><input type="checkbox" id="send_email_reminder" checked name="send_email_reminder" />Yes, please also send me an email reminder as well.</label>
</div>
<div class="row">
<center>
<button class="schedule_appointment" onclick="schedule_appointment(this); return false;">Schedule Appointment</button>
</center>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<?
$title = "Professional Grant Services : ".$siteName;
include_once($_SERVER['DOCUMENT_ROOT']."/vx/usa/layout/body.php");
?>