";///////FORM
echo "Enter the username of the client to be booked in the space below, select who to bill and click submit: ";
echo " ";
echo " ";
echo " Province: ";
echo "";
echo "";
echo $_SESSION['userCLprov'];
echo " ";
?>
BC
AB
SK
MB
ON
QC
NL
NS
NB
PEI
YK
NWT
NV
";
echo "";
echo $_SESSION['CLthird_co_pro'];
echo " ";
}
third_co_list();
echo "";
/*echo " Case/claim no: ";
echo " ";
*/
}
echo " ";
//echo " ";
echo "Update this client's registration here . Add claim number here . ";
echo "";
}////////////////END FUNCTION
//////////////////FUNCTION REGISTER_CLIENT_USERNAME
function register_client_username($name_in_box, $clients_db, $userCLprov)
{
$link_id = db_connect('appointments_db');
if(!$link_id) die(sql_error());
$queryCLname = "SELECT CL_id, CLemail FROM $clients_db WHERE CL_id = '$name_in_box'";
$resultCLname = mysql_query($queryCLname);
$marknoname = mysql_num_rows($resultCLname);
if(!$resultCLname) error_message(sql_error());
if(!$marknoname) error_message("No such username, check the client username and province");
else
{
$query_dataCLname = mysql_fetch_array($resultCLname);
$_SESSION['userCLid']=$query_dataCLname["CL_id"];
$_SESSION['userCLprov']=$userCLprov;
}
}
///////////////END FUNCTION
/*function check_iv($CL_id)
{
global $clients_db;
$query="SELECT CL_iv from $clients_db WHERE CL_id='$CL_id'";
$result=mysql_query($query);
if(!$result){error_message("No result from query");}
$retrieved=mysql_fetch_array($result);
$CL_iv_fetched=$retrieved['CL_iv'];
if(is_null($CL_iv_fetched))
{
error_message("There is no CL_iv_fetched!");
}
else {$result_iv=base64_decode($CL_iv_fetched); return $result_iv;}
}*///////end function check_iv
//////////FUNCTION TO GET BOOKED ARRAY INTO DATABASE
function into_database($app_id)
{
global $todaytime2, $authdb;
$into_query="INSERT INTO $authdb VALUES(NULL, '$todaytime2', '$app_id', 0)";
$into_var=mysql_query($into_query);
if(!$into_var) error_message("Failed to put appt into auth database");
}
//////////END FUNCTION TO GET BOOKED ARRAY INTO DATABASE
/////////GET THIRD FROM CLIENT
/*function get_third_from_client($userCLid_3)
{
global $clients_db;
$link_id = db_connect("appointments_db");
$query = "SELECT CLthird_co1 FROM $clients_db WHERE CL_id = '$userCLid_3'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) {return 0;}
else
{
$query_data = mysql_fetch_row($result);
return $query_data[0];
}
}*/////END FUNC GET THIRD
/////////GET CLAIM FROM CLIENT
function get_claim_from_client($userCLid_3)
{
global $mcrypt_key, $clients_db;
$tempuserCLid=$userCLid_3;
if(!empty($_SESSION['CLclaim_no_selected'])){$_SESSION['selected_claims']=array("");
return $_SESSION['CLclaim_no_selected'];
}
else
{
$mcrypt_module = mcrypt_module_open('rijndael-256', '', 'cbc', '');
$link_id = db_connect("appointments_db");
$query = "SELECT CL_iv, CLthird_co1, CLclaim_no1, CLthird_co2, CLclaim_no2, CLthird_co3, CLclaim_no3, CLthird_co4, CLclaim_no4, CLthird_co5, CLclaim_no5 FROM $clients_db WHERE CL_id = '$userCLid_3'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) {return 0;}
else
{
$query_data = mysql_fetch_array($result);
$CL_iv_fetched=$query_data['CL_iv'];
$mcrypt_iv=base64_decode($CL_iv_fetched);
$CLthird_co1=$query_data['CLthird_co1'];
$mCLclaim_no1=$query_data['CLclaim_no1'];
$CLthird_co2=$query_data['CLthird_co2'];
$mCLclaim_no2=$query_data['CLclaim_no2'];
$CLthird_co3=$query_data['CLthird_co3'];
$mCLclaim_no3=$query_data['CLclaim_no3'];
$CLthird_co4=$query_data['CLthird_co4'];
$mCLclaim_no4=$query_data['CLclaim_no4'];
$CLthird_co5=$query_data['CLthird_co5'];
$mCLclaim_no5=$query_data['CLclaim_no5'];
if(empty($_SESSION['CLthird_co_pro'])){echo "no go";return 0;}
$selected_claims=array();
if($CLthird_co1==$_SESSION['CLthird_co_pro'])
{
$CLclaim_no1=rtrim($mCLclaim_no1, "\0");
mcrypt_generic_init($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$mCL_decrypted=mdecrypt_generic($mcrypt_module, base64_decode($CLclaim_no1));
$selected_claims[]=$mCL_decrypted;
}
if($CLthird_co2==$_SESSION['CLthird_co_pro'])
{
$CLclaim_no2=rtrim($mCLclaim_no2, "\0");
mcrypt_generic_init($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$mCL_decrypted=mdecrypt_generic($mcrypt_module, base64_decode($CLclaim_no2));
$selected_claims[]=$mCL_decrypted;
}
if($CLthird_co3==$_SESSION['CLthird_co_pro'])
{
$CLclaim_no3=rtrim($mCLclaim_no3, "\0");
mcrypt_generic_init($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$mCL_decrypted=mdecrypt_generic($mcrypt_module, base64_decode($CLclaim_no3));
$selected_claims[]=$mCL_decrypted;
}
if($CLthird_co4==$_SESSION['CLthird_co_pro'])
{
$CLclaim_no4=rtrim($mCLclaim_no4, "\0");
mcrypt_generic_init($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$mCL_decrypted=mdecrypt_generic($mcrypt_module, base64_decode($CLclaim_no4));
$selected_claims[]=$mCL_decrypted;
}
if($CLthird_co5==$_SESSION['CLthird_co_pro'])
{
$CLclaim_no5=rtrim($mCLclaim_no5, "\0");
mcrypt_generic_init($mcrypt_module, $mcrypt_key, $mcrypt_iv);
$mCL_decrypted=mdecrypt_generic($mcrypt_module, base64_decode($CLclaim_no5));
$selected_claims[]=$mCL_decrypted;
}
mcrypt_generic_deinit($mcrypt_module);
mcrypt_module_close ($mcrypt_module);
$count_selected=count($selected_claims);
if($count_selected==1){
$_SESSION['selected_claims']=array("");
return $selected_claims['0'];
echo $selected_claims['0']; echo "one selected";$_SESSION['CLclaim_no_selected']="";
echo $selected_claims['1'];
}////decrypt before returning
if($count_selected > 1){echo "There is more than one claim number for this client and third party. Please select which claim number to use. ";
$_SESSION['selected_claims']=$selected_claims;
return 1;
}
if($count_selected==0)
{
if($_SESSION['CLthird_co_pro'] != "SELF")
{
error_message("There is no case or claim number associated with this client and that third party!");$_SESSION['selected_claims']=array("");echo $selected_claims['0'];
echo $selected_claims['1'];return 0;$_SESSION['CLclaim_no_selected']="";}
else {$_SESSION['selected_claims']=array("");return 1;}
}
}
}///end else
}/////END FUNC GET CLAIM
///////////GET THIRD EMAIL
function get_third_email_from_client($client)
{
global $clients_db;
$link_id = db_connect("appointments_db");
$query = "SELECT CLthird_co1, third_party_email1, CLthird_co2, third_party_email2, CLthird_co3, third_party_email3, CLthird_co4, third_party_email4, CLthird_co5, third_party_email5 FROM $clients_db WHERE CL_id = '$client'"; ///query works here
$result = mysql_query($query);
if(!result){error_message(sql_error());}
if(mysql_num_rows($result)==0) {error_message("no rows returned from $clients_db");}
else
{
// $_SESSION['CLthird_co_pro'] is okay here
$query_data = mysql_fetch_array($result);
$CLthird_co1=$query_data['CLthird_co1'];
echo $CLthird_co1 . " is CLthird_co1 ";
$third_party_email1=$query_data['third_party_email1'];
$CLthird_co2=$query_data['CLthird_co2'];
$third_party_email2=$query_data['third_party_email2'];
$CLthird_co3=$query_data['CLthird_co3'];
$third_party_email3=$query_data['third_party_email3'];
$CLthird_co4=$query_data['CLthird_co4'];
$third_party_email4=$query_data['third_party_email4'];
$CLthird_co5=$query_data['CLthird_co5'];
$third_party_email5=$query_data['third_party_email5'];
if($CLthird_co1==$_SESSION['CLthird_co_pro']){$third_email=$third_party_email1; echo $CLthird_co1 . " is MATCHED ";}
if($CLthird_co2==$_SESSION['CLthird_co_pro']){$third_email=$third_party_email2;}
if($CLthird_co3==$_SESSION['CLthird_co_pro']){$third_email=$third_party_email3;}
if($CLthird_co4==$_SESSION['CLthird_co_pro']){$third_email=$third_party_email4;}
if($CLthird_co5==$_SESSION['CLthird_co_pro']){$third_email=$third_party_email5;}
return $third_email;
}
}////END FUNC GET THIRD EMAIL
///////////AUTH SEND EMAIL
function auth_send_email($to_hold_booked_auth, $client)
{
global $todaytime2, $pageforauth, $clients_db, $authdb;
$to_hold_3_email=get_third_email_from_client($client); echo "third email is " . $to_hold_3_email . " ";
$secure_mail_subject = "Authorization requested";
$secure_mail_body = "
";
$secure_mail_body .= "Claim or reference number: ";
if(!empty($_POST['CLclaim_no'])) {$secure_mail_body .= $_POST['CLclaim_no'];}/////check if this is ever entered
else {$secure_mail_body .= "not entered";}
$secure_mail_body .= "\n";
$secure_mail_body .= "Click on the link below to view and authorize sessions \n";
$secure_mail_body .= "or to deny authorization\r\n";
$secure_mail_body .= "";
$secure_mail_body .= "authorization request";
$secure_mail_body .= " ";
$secure_mail_header = "From: admin@psycorps.com\n";
$secure_mail_header .= "Reply-to: admin@psycorps.com\n";
$secure_mail_header .= "MIME-Version: 1.0\r\n";
$secure_mail_header .= "Content-type: text/html";
$secure_mail_header .= "\r\n\r\n";
array_walk($to_hold_booked_auth, 'into_database');
reset($to_hold_booked_appts);
mail($to_hold_3_email, $secure_mail_subject, $secure_mail_body, $secure_mail_header);
}////END AUTH SEND EMAIL
//////function show gif
function show_gif()
{
global $CL_login, $CL_logout_pro, $third_login, $logout_script, $Pro_login, $root_page;
echo "";
echo "";
echo "";
echo "";
echo " ";
echo " ";
echo " ";
echo "";
if (!empty($_SESSION['userProid']))
{echo "";
echo " ";
}
else {echo "";
echo " ";
}
echo " ";
echo "";
echo "CURRENT CLIENT: ";
echo $_SESSION['userCLid'];
echo " " . $_SESSION['CLclaim_no_selected'];
echo " ";
echo " ";
if (!empty($_SESSION['userCLid']))
{
echo "";
echo " ";
}
else {echo "";
echo " ";
}
echo " ";
echo "";
//echo "";
//echo " ";
//echo " ";
echo "";
echo "";
echo " ";
echo " ";
echo " ";
echo "
";
}
function table_head()
{
?>
day
time
book/cancel/block
multiple
client
bill to
auth?
location
"#99CCCC", "#BBBBC0", "#66BBBB");
$color_no = "0";
$link_id = db_connect();
if(!link_id) die(sql_error());
$query="SELECT appt_id, date_format(day, '%a %b %e %Y'), time, Assmt, Agent_id, client_id, location, bill_to, auth_by_3rd, lastaccess
FROM $apptdb WHERE Agent_id='$service_provider' AND ($begin <= day
AND day <= $end)
ORDER BY day, time";
$result=mysql_query($query);
if(!$result) error_message(sql_error());
echo "
";
echo "
";
echo " ";
}
///END function retrieve_all_appointments_plus()
////////function to get email addresses for third party or client or pro
function get_userid_email($email, $case_id, $the_id, $the_db_name)
{
$func_query = "SELECT " . $email . " from " . $the_db_name . " where " . $case_id . " = '$the_id'";
$result_get_query=mysql_query($func_query);
$result_get=mysql_result($result_get_query, 0, 0);
if(empty($result_get)) echo "failed to get user email from the db named " . $the_db_name;
echo $func_query . " ";
return $result_get;
}
////END function get_userid_email
//////////////////FUNCTION TO GET APPT DATE AND TIME FROM APPT_ID
function get_datime_fr_appt_id($appt_id)
{
global $apptdb;
$datime_result=mysql_query("SELECT day, time from $apptdb where appt_id='$appt_id'");
$datime1=mysql_result($datime_result, 0, 0);
$datime2=mysql_result($datime_result, 0, 1);
$translation= array(":00:00" => ":00", ":30:00" => ":30", ":15:00" => ":15");
$datime3=strtr($datime2,$translation);
$datime=$datime1 . " " . $datime3;
return $datime;
}//////////////////END FUNC TO GET APPT DATE AND TIME FROM APPT_ID
//////////////////FUNCTION TO EMAIL EVERYBODY
function email_everybody($to_hold_email, $to_hold_booked, $to_hold_canceled, $to_hold_blocked, $reply_to)
{
//global $email_addresses, $booked, $canceled;
$s_email_addresses = implode(",", $to_hold_email);
$s_booked = implode(", ", $to_hold_booked);
$s_canceled = implode(", ", $to_hold_canceled);
$s_blocked = implode(", ", $to_hold_blocked);
$s_email_message_body = "This is a message from psycorps.com.\n";
if($s_booked){$s_email_message_body .= "The following appts have been booked: ";
$s_email_message_body .= $s_booked;
$s_email_message_body .= ".\n";}
if($s_canceled){$s_email_message_body .= "The following appts have been canceled: " . $s_canceled . ".\n";}
if($s_blocked){$s_email_message_body .= "The following appts have been blocked: ";
$s_email_message_body .= $s_blocked;
$s_email_message_body .= ".\n";}
$s_email_message_body .= "You may wish to check the www.psycorps.com website ";
$s_email_message_body .= "for your updated schedule.\n";
$s_email_subject="Changed appts";
//echo "EMAIL ADDRESSES: " . $s_email_addresses;
//echo $s_email_message_body;
mail($s_email_addresses, $s_email_subject, $s_email_message_body, $reply_to);
}
//////////END FUNCTION TO EMAIL EVERYBODY
//////////body//////BODY////BODY/////BODY
session_start();
//session_register("user3id1");
//session_register("userCLid");
//session_register("userProid");
//session_register("pro_enter");
//$_SESSION['userProid']='zsaper';
//autoreload();
echo " ";
echo"";
echo "";
$temppro_enter=$_SESSION['userCLid'];
if($_SESSION['userProprov']=="BC"){$servProdb="service_providers";$apptdb="appointments";}
else if($_SESSION['userProprov']=="AB"){$servProdb="service_providers_ab";$apptdb="appointments_ab";$authdb="auth_by_3rd";}
else if($_SESSION['userProprov']=="SK"){$servProdb="service_providers_sk";$apptdb="appointments_sk";$authdb="auth_by_3rd_sk";}
else if($_SESSION['userProprov']=="MB"){$servProdb="service_providers_mb";$apptdb="appointments_mb";$authdb="auth_by_3rd_mb";}
else if($_SESSION['userProprov']=="ON"){$servProdb="service_providers_on";$apptdb="appointments_on";$authdb="auth_by_3rd_on";}
else if($_SESSION['userProprov']=="QC"){$servProdb="service_providers_qc";$apptdb="appointments_qc";$authdb="auth_by_3rd_qc";}
else if($_SESSION['userProprov']=="NS"){$servProdb="service_providers_ns";$apptdb="appointments_ns";$authdb="auth_by_3rd_ns";}
else if($_SESSION['userProprov']=="NB"){$servProdb="service_providers_nb";$apptdb="appointments_nb";$authdb="auth_by_3rd_nb";}
else if($_SESSION['userProprov']=="PE"){$servProdb="service_providers_pe";$apptdb="appointments_pe";$authdb="auth_by_3rd_pe";}
else if($_SESSION['userProprov']=="NL"){$servProdb="service_providers_nl";$apptdb="appointments_nl";$authdb="auth_by_3rd_nl";}
else if($_SESSION['userProprov']=="YK"){$servProdb="service_providers_yk";$apptdb="appointments_yk";$authdb="auth_by_3rd_yk";}
else if($_SESSION['userProprov']=="NW"){$servProdb="service_providers_nw";$apptdb="appointments_nw";$authdb="auth_by_3rd_nw";}
else if($_SESSION['userProprov']=="NV"){$servProdb="service_providers_nv";$apptdb="appointments_nv";$authdb="auth_by_3rd_nv";}
else {error_message("no user Pro province");}
$todaytime=time();
if($_POST['SUBMIT_CLIENT']=='1')
{
$userCLprov=$_POST['userCLprov'];
if($userCLprov=="BC"){$clients_db = "clients";}
else if($userCLprov=="AB"){$clients_db = "clients_ab";}
else if($userCLprov=="SK"){$clients_db = "clients_sk";}
else if($userCLprov=="MB"){$clients_db = "clients_mb";}
else if($userCLprov=="ON"){$clients_db = "clients_on";}
else if($userCLprov=="QC"){$clients_db = "clients_qc";}
else if($userCLprov=="NB"){$clients_db = "clients_nb";}
else if($userCLprov=="NS"){$clients_db = "clients_ns";}
else if($userCLprov=="PE"){$clients_db = "clients_pe";}
else if($userCLprov=="NL"){$clients_db = "clients_nl";}
else if($userCLprov=="YK"){$clients_db = "clients_yk";}
else if($userCLprov=="NW"){$clients_db = "clients_nw";}
else if($userCLprov=="NV"){$clients_db = "clients_nv";}
else {$clients_db = "clients";}
$name_in_box=$_POST['client_username'];
if($name_in_box=='')
{
unset($_SESSION['userCLid']);
unset($_SESSION['CLthird_co_pro']);
//unset($_SESSION['userCLprov']);
}
else
{
register_client_username($name_in_box, $clients_db, $userCLprov);
$_SESSION['CLthird_co_pro']=$_POST['CLthird_co'];
$_SESSION['CLclaim_no_selected']=$_POST['CLclaim_no_selected'];
$_SESSION['CLclaim_no']=get_claim_from_client($name_in_box);
}
}
else if($_POST)
{
$userCLprov=$_SESSION['userCLprov'];
if($userCLprov=="BC"){$clients_db = "clients";}
else if($userCLprov=="AB"){$clients_db = "clients_ab";}
else if($userCLprov=="SK"){$clients_db = "clients_sk";}
else if($userCLprov=="MB"){$clients_db = "clients_mb";}
else if($userCLprov=="ON"){$clients_db = "clients_on";}
else if($userCLprov=="QC"){$clients_db = "clients_qc";}
else if($userCLprov=="NB"){$clients_db = "clients_nb";}
else if($userCLprov=="NS"){$clients_db = "clients_ns";}
else if($userCLprov=="PE"){$clients_db = "clients_pe";}
else if($userCLprov=="NL"){$clients_db = "clients_nl";}
else if($userCLprov=="YK"){$clients_db = "clients_yk";}
else if($userCLprov=="NW"){$clients_db = "clients_nw";}
else if($userCLprov=="NV"){$clients_db = "clients_nv";}
if(isset($_POST['pro_enter_cl_id']))
{
$_SESSION['userCLid']=$_POST['pro_enter_cl_id'];
//echo "pro_enter is " . $_SESSION['userCLid'];
//check if it's in the database though and if not deregister it as a variable
$link_id_cl = db_connect();
if(!link_id_cl) die(sql_error());
$temppro_enter=$_SESSION['userCLid'];
$pro_enter_query="SELECT CLemail FROM $clients_db WHERE CL_id = '$temppro_enter'";
$pro_enter_resultset=mysql_query($pro_enter_query);
$pro_enter_result=mysql_num_rows($pro_enter_resultset);
if(!$pro_enter_result)
{
echo " Error, no such client! ";
$_SESSION['userCLid']="";
}
else
{
////////////////////////////retrieve CLemail and put into array? or as is!
}
if($_SESSION['userCLid'])
echo "Got the client's user id! Go ahead and book the appointments! ";
}
else
{
$link_id = db_connect();
if(!link_id) die(sql_error());
$dbnom=$servProdb;////service provider will be set by GET HTTP or login
$email="Proemail";
$case_id="Pro_id";
$to_hold_email_addresses[] = get_userid_email($email, $case_id, $_SESSION['userProid'], $servProdb);
$to_hold_email_addresses[] = "admin@psycorps.com";
while (list($lvar, $lvalue) = each($_POST))
{
////////BOOK////BOOK/////BOOK
if ($lvalue=="book")
{
if(!$_SESSION['userCLid'] && $timeround==0)
{
echo " Enter the user id of the client you want to book.";
echo " Note that you can only book appointments for one client at a time.";
echo " If the client you want to book is not yet registered, register them ";
echo "here .";
//error_reload("Enter the user id of the client you want to book. Note that you can only book appointments for one client at a time");
$stop_email = 1;
}
else if($_SESSION['userCLid'] && $timeround==0)
{
$dbnom=$clients_db; //okay here
$email="CLemail";
$case_id="CL_id";
$to_hold_email_addresses[] = get_userid_email($email, $case_id, $_SESSION['userCLid'], $clients_db);
$temppro_enter=$_SESSION['userCLid'];
$user3id_3=$_SESSION['CLthird_co_pro'];
if(empty($user3id_3)){$user3id_3='SELF';}
$bookquery="UPDATE $apptdb SET client_id='$temppro_enter', bill_to='$user3id_3', CLprov='$userCLprov' WHERE appt_id='$lvar' and client_id IS NULL";
$bookresult=mysql_query($bookquery);
$numrowsresult=mysql_affected_rows($link_id);
if(!$numrowsresult)
{error_message("Appt already booked. Reload page.");
}
if($user3id_3 != 'SELF')
{
$to_hold_booked_auth[]=$lvar;
}
}
else if($_SESSION['userCLid'] && $timeround != 0)
{
$temppro_enter=$_SESSION['userCLid'];
$bookquery="UPDATE $apptdb SET client_id='$temppro_enter', bill_to='$user3id_3', CLprov='$userCLprov' WHERE appt_id='$lvar' and client_id IS NULL";
$bookresult=mysql_query($bookquery);
$numrowsresult=mysql_affected_rows($link_id);
if(!$numrowsresult)
{error_message("Appt already booked. Reload page.");
}
if($user3id_3 != 'SELF')
{
$to_hold_booked_auth[]=$lvar;
}
}
else {}
$timeround=1;
$to_hold_booked_appts[]=get_datime_fr_appt_id($lvar);
}
//////CANCEL/////CANCEL////CANCEL
else if ($lvalue=="cancel")
{$cquery1="SELECT client_id FROM $apptdb WHERE appt_id='$lvar'";
$clresult1=mysql_query($cquery1);
if(!$clresult1) error_message(sql_error());
$clresult2=mysql_fetch_array($clresult1);
if (!$to_hold_canceled_array) ///initialize array
{
$to_hold_canceled_array = array ($lvar => $clresult2["client_id"]);//prob here
}
else
{
$to_hold_canceled_array[$lvar]=$clresult2["client_id"];//appt-client pairs
}
$cancelquery="UPDATE $apptdb SET client_id=NULL, bill_to=NULL, auth_by_3rd=0
WHERE appt_id='$lvar'";
$cancelresult=mysql_query($cancelquery);
if(!$cancelresult) error_message(sql_error());
}
/////BLOCK/////BLOCK////BLOCK
else if ($lvalue=="block")
{
$temppro_enter=$_SESSION['userCLid'];
$blockquery="UPDATE $apptdb SET client_id='BLOCKED', bill_to=NULL, CLprov=NULL WHERE appt_id='$lvar' and client_id IS NULL";
$blockresult=mysql_query($blockquery);
if(!$blockresult) error_message(sql_error());
$to_hold_blocked_appts[]=get_datime_fr_appt_id($lvar);
}
else
{
}
}
asort($to_hold_canceled_array);//appt-client pairs sorted by client
if ($to_hold_canceled_array)
{
$client_now = "nonsuch";
foreach ($to_hold_canceled_array as $apptc => $eclient)
{echo $eclient . " is client" . $apptc . " is apptc ";
if($client_now == "nonsuch")
{
$clientcancelarray = array ($eclient => array ($apptc));
$client_now = $eclient;
}
else if ($eclient != $client_now)
{
$clientcancelarray[$eclient] = array ($apptc);
$client_now = $eclient;
}
else {
array_push ($clientcancelarray[$eclient], $apptc);
}
}//end of foreach to_hold_canceled
foreach ($clientcancelarray as $clientname => $arrayofappts)
{
$dbnom=$clients_db;
$email="CLemail";
$case_id="CL_id";
$email_body2 = "This is a message from psycorps.com. ";
$email_body2 .= "The following appts have been canceled: \n";
foreach($arrayofappts as $key => $valueappt)
{
$email_body2 .= get_datime_fr_appt_id($valueappt);
$email_body2 .= " \n";
$valueapp=$valueappt;
}
$email_body2 .= "\n You may want to check www.psycorps.com for updated appts.";
if ($clientname != "BLOCKED")
{$clientemailgot=get_userid_email($email, $case_id, $clientname, $dbnom);
if(!empty($clientemailgot)){$email_addresses2[] = $clientemailgot;}
else {$equery="SELECT CLprov from $apptdb WHERE appt_id='$valueapp'";
$eresult=mysql_query($equery); echo $equery . " ";
$email_prov=mysql_result($eresult, 0, 0); echo $email_prov . " is email_prov ";
if($email_prov=="BC"){$dbnom_e="clients";}
else if($email_prov=="AB"){$dbnom_e="clients_ab";}
else if($email_prov=="SK"){$dbnom_e="clients_sk";}
else if($email_prov=="MB"){$dbnom_e="clients_mb";}
else if($email_prov=="ON"){$dbnom_e="clients_on";}
else if($email_prov=="QC"){$dbnom_e="clients_qc";}
else if($email_prov=="NB"){$dbnom_e="clients_nb";}
else if($email_prov=="NS"){$dbnom_e="clients_ns";}
else if($email_prov=="PE"){$dbnom_e="clients_pe";}
else if($email_prov=="NL"){$dbnom_e="clients_nl";}
else if($email_prov=="YK"){$dbnom_e="clients_yk";}
else if($email_prov=="NW"){$dbnom_e="clients_nw";}
else if($email_prov=="NV"){$dbnom_e="clients_nv";}
$clientemailgot2=get_userid_email($email, $case_id, $clientname, $dbnom_e);
if(!empty($clientemailgot2)){echo "Got the email on the 2nd try: " . $clientemailgot2;
$email_addresses2[] = $clientemailgot2;}
}////unfortunately by this time everything is null!
}
$dbnom=$servProdb;////service provider will be set by GET HTTP or login
$email="Proemail";
$case_id="Pro_id";
$email_addresses2[] = get_userid_email($email, $case_id, $_SESSION['userProid'], $dbnom);
$email_addresses2[] = "admin@psycorps.com";
$reply_to_fields2="From: admin@psycorps.com";
$email_addresses2i = implode(",", $email_addresses2);
$email_subject2 = "canceled appointment(s)";
mail($email_addresses2i, $email_subject2, $email_body2, $reply_to_fields2);
$email_addresses2 = array("");
}///end of foreach clientcancelarray
}//end of processing to_hold_canceled_array
$reply_to_fields="From: admin@psycorps.com";///\nReply-to: admin@psycorps.com";
if(!$email_addresses2 && !$stop_email)
{
email_everybody($to_hold_email_addresses, $to_hold_booked_appts, $to_hold_canceled_appts, $to_hold_blocked_appts, $reply_to_fields);
if(!empty($to_hold_booked_auth))
{
auth_send_email($to_hold_booked_auth, $temppro_enter);//temppro is okay here
}
}
else
{
}
//$_SESSION['userCLid']="";///empty pro_enter_cl_id variable after the http_post processed
autoreload();
$stop_email = 0;
$timeround=0;
//echo "session pro enter is ";
//echo $_SESSION['userCLid'];
}
}
if(isset($_SESSION['userProid']))
{
show_gif();
echo "Appointment booking method Patent Pending ";
echo "Add appointments one at a time ";
echo "Set your weekly schedule
";
if(empty($_GET['beginmark'])) {$_GET['beginmark']=0;}
$beginmark1=$_GET['beginmark'] + 1;
$beginmark_min1=$_GET['beginmark'] - 1;
if($_GET['beginmark'] > 0)
{
echo "To check the previous two weeks, click here . ";
}
echo "To check the next two weeks, click here . ";
$begintime=$todaytime + (1209600 * $_GET['beginmark']);
$beginplus2w=$begintime + 1209600;
$endtime1=date("Ymd", $beginplus2w); //1209600 is two weeks
$begintime1=date("Ymd",$begintime);
$begindate = date("d M Y",$begintime);
$enddate = date("d M Y",$beginplus2w);
echo " Showing period beginning " . $begindate;
echo " and ending " . $enddate;
echo " ";
input_client_username();
table_head();
retrieve_all_appointments_plus($_SESSION['userProid'], $begintime1, $endtime1);
}
else
{
echo " There is no service provider logged in. If you are a service provider, log in here .";
}
echo "Appointment booking method Patent Pending
";
?>