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!");}
else {$_SESSION['selected_claims']=array("");return 1;}
}
}
}///end else
}/////END FUNC GET CLAIM
/////////GET CLAIM FROM CLIENT2
function get_claim_from_client2($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();
$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);
$selected_string=implode(" ", $selected_claims);
//$selected_claims[0] . " " . $selected_claims[1] . " " . $selected_claims[2] . " " . $selected_claims[3] . " " . $selected_claims[4];
$selected_string=trim($selected_string, "\0");
return $selected_string;
}
}///end else
}/////END FUNC GET CLAIM
/////////GET CLAIM FROM PAYOR CLIENT and province
function get_claim_from_payor_client($payor, $userCLid_3, $userCLprov)
{
global $mcrypt_key;
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";}
$tempuserCLid=$userCLid_3;
$mcrypt_module = mcrypt_module_open('rijndael-256', '', 'cbc', '');
$link_id = db_connect();
$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($payor)){echo "no go";return 0;}
$selected_claims=array();
if($CLthird_co1==$payor)
{
$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==$payor)
{
$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==$payor)
{
$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==$payor)
{
$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==$payor)
{
$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){$returnMo=implode(",",$selected_claims);
//$_SESSION['selected_claims']=$selected_claims;
return $returnMo;
}
if($count_selected==0)
{
if($payor != "SELF")
{
error_message("There is no case or claim number associated with this client and " . $payor);$_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 FUNC GET CLAIM from payor and client
function get_third_email_from_payor_client($payor, $client, $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";}
$link_id = db_connect();
$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 $DBname");}
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==$payor){$third_email=$third_party_email1;}
if($CLthird_co2==$payor){$third_email=$third_party_email2;}
if($CLthird_co3==$payor){$third_email=$third_party_email3;}
if($CLthird_co4==$payor){$third_email=$third_party_email4;}
if($CLthird_co5==$payor){$third_email=$third_party_email5;}
return $third_email;
}
}////END FUNC GET THIRD EMAIL From payor and client
///////////////////FUNCTION INPUT_CLIENT_USERNAME
function input_client_username()
{
global $servpro_id, $start_appt, $number_appts, $claim_add, $update_CL, $PHP_SELF;
echo "
";
}////////////////END FUNCTION
//////////////////FUNCTION REGISTER_CLIENT_USERNAME
function register_client_username($name_in_box, $clients_db, $userCLprov, $permdb)
{
$link_id = db_connect();
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;
add_perm($link_id, $permdb);
}
}
///////////////END FUNCTION
/////////////////FUNCTION GET_MULT
function get_mult($servpro_id, $number_appts, $start_appt)
{
global $dbhost, $apptdb, $block_info, $servProdb;
$link_id = db_connect();
if(!$link_id) die(sql_error());
$tempuserCL = $_SESSION['userCLid'];
$querymult = "SELECT appt_id, date_format(day, '%a %b %e %Y'), time, Assmt, Agent_id, client_id, bill_to, auth_by_3rd, location FROM $apptdb WHERE (Agent_id='$servpro_id' AND appt_id='$start_appt')";
$resultmult = mysql_query($querymult);
if(!$resultmult) error_message(sql_error());
echo "";
}
/////////////////END FUNCTION GET MULTIPLE APPOINTMENTS
//////////FUNCTION TO GET BOOKED ARRAY INTO DATABASE
function into_database($app_id)
{
global $todaytime2, $authdb;
if($_SESSION['userProprov']=="BC"){$authdb="auth_by_3rd";}
else if($_SESSION['userProprov']=="AB"){$authdb="auth_by_3rd_ab";}
else if($_SESSION['userProprov']=="SK"){$authdb="auth_by_3rd_sk";}
else if($_SESSION['userProprov']=="MB"){$authdb="auth_by_3rd_mb";}
else if($_SESSION['userProprov']=="ON"){$authdb="auth_by_3rd_on";}
else if($_SESSION['userProprov']=="QC"){$authdb="auth_by_3rd_qc";}
else if($_SESSION['userProprov']=="NB"){$authdb="auth_by_3rd_nb";}
else if($_SESSION['userProprov']=="NS"){$authdb="auth_by_3rd_ns";}
else if($_SESSION['userProprov']=="PE"){$authdb="auth_by_3rd_pe";}
else if($_SESSION['userProprov']=="NL"){$authdb="auth_by_3rd_nl";}
else if($_SESSION['userProprov']=="YK"){$authdb="auth_by_3rd_yk";}
else if($_SESSION['userProprov']=="NW"){$authdb="auth_by_3rd_nw";}
else if($_SESSION['userProprov']=="NV"){$authdb="auth_by_3rd_nv";}
$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 EMAIL
///////////GET THIRD EMAIL
function get_third_email_from_client($client)
{
global $clients_db;
$link_id = db_connect();
$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'";
$result = mysql_query($query);
if(!mysql_num_rows($result)) {echo "no rows returned at get third email";}
else
{
$query_data = mysql_fetch_array($result);
$CLthird_co1=$query_data['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'];
$tempcopro=$_SESSION['CLthird_co_pro'];
if($CLthird_co1==$tempcopro){$third_email=$third_party_email1;}
if($CLthird_co2==$tempcopro){$third_email=$third_party_email2;}
if($CLthird_co3==$tempcopro){$third_email=$third_party_email3;}
if($CLthird_co4==$tempcopro){$third_email=$third_party_email4;}
if($CLthird_co5==$tempcopro){$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);
$to_hold_3_email=trim($to_hold_3_email, "\0");
$secure_mail_subject = "Authorization requested";
$secure_mail_body = "--01fedcb871d3f012e43680250ba5ca3f\n";
$secure_mail_body .= "Content-type:text/html; charset=\"iso-8859-1\"\n";
$secure_mail_body .= "Content-transfer-encoding:7bit\n\n";
$secure_mail_body .= "\n";
$secure_mail_body .= "\n";
$secure_mail_body .= "";
$secure_mail_body .= "
";
$secure_mail_body .= "Authorization has been requested for an appointments or appointments for claim or reference number: ";
$claimnogot=get_claim_from_client2($client);
if(empty($claimnogot)) {$secure_mail_body .= "not entered";}
else {$secure_mail_body .= $claimnogot;}
$secure_mail_body .= ". Click on the link below to view and authorize sessions \r\n";
$secure_mail_body .= "or to deny authorization:\r\n";
$secure_mail_body .= "";
$secure_mail_body .= "Reply to authorization request here";
$secure_mail_body .= "
";
$secure_mail_body .= "";
$secure_mail_body .= "\n\n--01fedcb871d3f012e43680250ba5ca3f--\n";
$secure_mail_header = "From: admin@zappointments.com\n";
$secure_mail_header .= "Reply-to: admin@zappointments.com\n";
$secure_mail_header .= "MIME-Version: 1.0\n";
$secure_mail_header .= "Content-type: multipart/mixed";
$secure_mail_header .= ";";
$secure_mail_header .= " ";
$secure_mail_header .= "boundary=\"01fedcb871d3f012e43680250ba5ca3f\"\n";
$secure_mail_header .= "Content-type:text/html; charset=\"iso-8859-1\"\n";
$secure_mail_header .= "Content-transfer-encoding:7bit\n\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, $CL_logout_pro_mult;
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
|
client
|
bill to
|
auth?
|
location
|
":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_client_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 zappointments.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.zappointments.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);
mail($to_hold_client_email, $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 "";
echo "";
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";}
$todaytime=time();
global $Pro_login, $add_appointment;
if($_POST['SUBMIT_CLIENT']=='1')
{
$userCLprov=$_POST['userCLprov'];
if($userCLprov=="BC"){$clients_db = "clients";$permdb="cl_perm";}
else if($userCLprov=="AB"){$clients_db = "clients_ab";$permdb="cl_perm_ab";}
else if($userCLprov=="SK"){$clients_db = "clients_sk";$permdb="cl_perm_sk";}
else if($userCLprov=="MB"){$clients_db = "clients_mb";$permdb="cl_perm_mb";}
else if($userCLprov=="ON"){$clients_db = "clients_on";$permdb="cl_perm_on";}
else if($userCLprov=="QC"){$clients_db = "clients_qc";$permdb="cl_perm_qc";}
else if($userCLprov=="NB"){$clients_db = "clients_nb";$permdb="cl_perm_nb";}
else if($userCLprov=="NS"){$clients_db = "clients_ns";$permdb="cl_perm_ns";}
else if($userCLprov=="PE"){$clients_db = "clients_pe";$permdb="cl_perm_pe";}
else if($userCLprov=="NL"){$clients_db = "clients_nl";$permdb="cl_perm_nl";}
else if($userCLprov=="YK"){$clients_db = "clients_yk";$permdb="cl_perm_yk";}
else if($userCLprov=="NW"){$clients_db = "clients_nw";$permdb="cl_perm_nw";}
else if($userCLprov=="NV"){$clients_db = "clients_nv";$permdb="cl_perm_nv";}
else {$clients_db = "clients";$permdb="cl_perm";}
$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, $permdb);
$_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";}
$link_id = db_connect();
if(!$link_id) die(sql_error());
$dbnom=$servProdb;
$email="Proemail";
$case_id="Pro_id";
$to_hold_email_addresses[] = get_userid_email($email, $case_id, $_SESSION['userProid'], $dbnom);
$to_hold_email_addresses[] = "admin@zappointments.com";
while (list($lvar, $lvalue) = each($_POST))
{
////////BOOK////BOOK/////BOOK
if ($lvalue=="book")
{
if(!$_SESSION['userCLid'] && $timeround==0)
{
echo "
If the client you want to book is not yet registered, register them ";
echo "here.";
$stop_email = 1;
}
else if($_SESSION['userCLid'] && $timeround==0)
{
$dbnom=$clients_db;
$email="CLemail";
$case_id="CL_id";
$to_hold_client_email = get_userid_email($email, $case_id, $_SESSION['userCLid'], $dbnom);
$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, bill_to, CLprov FROM $apptdb WHERE appt_id='$lvar'";///Here should get payor, put in ary payor-ar(clt)
$clresult1=mysql_query($cquery1);
if(!$clresult1) error_message(sql_error());
$clresult2=mysql_fetch_array($clresult1);
if($clresult2)
{
$payor=$clresult2['bill_to'];
$province=$clresult2['CLprov'];
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
}
if(!empty($payor))
{
$client_id=$clresult2['client_id'];
$payorclaim=get_claim_from_payor_client($payor, $client_id, $province);
$payoremail=get_third_email_from_payor_client($payor, $client_id, $province);
if(!$to_hold_payor_client)///initialize payor-client multi array
{
$to_hold_payor_client= array ($payoremail => array($payorclaim));
}
else {
$to_hold_payor_client2= array ($payoremail => array($payorclaim));
$to_hold_payor_client = array_merge_recursive($to_hold_payor_client,$to_hold_payor_client2);
}
}
}
}
/////BLOCK/////BLOCK////BLOCK
else if ($lvalue=="block")
{
$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
{
}
}///end of while
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)
{
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 zappointments.com. ";
$email_body2 .= "The following appts have been canceled: \n";
$goRound=0;
foreach($arrayofappts as $key => $valueappt)
{
if($goRound==0)
{
if ($clientname != "BLOCKED")
{$clientemailgot=get_userid_email($email, $case_id, $clientname, $dbnom);
if(!empty($clientemailgot))
{$to_hold_client_email2 = $clientemailgot;}
else {$equery="SELECT CLprov from $apptdb WHERE appt_id='$valueappt'";
$eresult=mysql_query($equery);
$email_prov=mysql_result($eresult, 0, 0);
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";}
else {}
$clientemailgot2=get_userid_email($email, $case_id, $clientname, $dbnom_e);
if(!empty($clientemailgot2)){
$to_hold_client_email2 = $clientemailgot2;}
}//endof else
$goRound=1;
}///end of if not blocked get email
}////end of if go round 0 get email
$email_body2 .= get_datime_fr_appt_id($valueappt);
$email_body2 .= " \n";
$cancelquery="UPDATE $apptdb SET client_id=NULL, bill_to=NULL, auth_by_3rd=0, CLprov=NULL WHERE appt_id='$valueappt'";
$cancelresult=mysql_query($cancelquery);
if(!$cancelresult) error_message(sql_error());
}///end of foreach
$email_body2 .= "\n You may want to check www.zappointments.com for updated appts.";
$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@zappointments.com";
$reply_to_fields2="From: admin@zappointments.com";
$email_addresses2i = implode(",", $email_addresses2);
$email_subject2 = "canceled appointment(s)";
$anythingdone=mysql_affected_rows($link_id);
if($anythingdone){mail($email_addresses2i, $email_subject2, $email_body2, $reply_to_fields2); mail($to_hold_client_email2, $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@zappointments.com";///\nReply-to: admin@zappointments.com";
$anythingdone=mysql_affected_rows($link_id);
if(!$email_addresses2 && !$stop_email)
{if($anythingdone)
{
email_everybody($to_hold_email_addresses, $to_hold_client_email, $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);
}
}
}
else
{
}
if(!empty($to_hold_payor_client))
{
while(list($payoremailary) = each($to_hold_payor_client))
{
$clientwas='nonesuchclient';$no_appts_for_3_email=0;
while(list(,$eaclmno) = each($to_hold_payor_client[$payoremailary]))
{$no_appts_for_3_email++;
if($clientwas == 'nonesuchclient'){$gotthirdemail=$payoremailary; $clientwas=$eaclmno;}
else if($eaclmno != $clientwas)
{
$eProid=$_SESSION['userProid'];
$querygetSP="SELECT Proftitle, Profname, Prolname from $servProdb WHERE Pro_id='$eProid'";
$resultgetSP=mysql_query($querygetSP);
$Pronameary=mysql_fetch_array($resultgetSP);
$Profullname = $Pronameary['Proftitle'] . " " . $Pronameary['Profname'] . " " . $Pronameary['Prolname'];
$clientclaimnumber=$eaclmno;
$bodyof3mail = $Profullname . " has canceled " . $no_appts_for_3_email . " appointment(s) for a client identified by case/claim number " . $clientclaimnumber;
$subj_field="Service Provider canceled appts";
mail($gotthirdemail, $subj_field, $bodyof3mail, $reply_to_fields2);
$gotthirdemail=$payoremailary;
$no_appts_for_3_email=1;
}
else {$clientclaimnumber=$eaclmno;}
}
$eProid=$_SESSION['userProid'];
$querygetSP="SELECT Proftitle, Profname, Prolname from $servProdb WHERE Pro_id='$eProid'";
$resultgetSP=mysql_query($querygetSP); if(!$resultgetSP) echo "no result got from SP";
$Pronameary=mysql_fetch_array($resultgetSP);
$Profullname = $Pronameary['Proftitle'] . " " . $Pronameary['Profname'] . " " . $Pronameary['Prolname'];
$bodyof3mail = $Profullname . " has canceled " . $no_appts_for_3_email . " appointment(s) for a client identified by case/claim number " . $clientclaimnumber;
$subj_field="Service Provider canceled appts";
mail($gotthirdemail, $subj_field, $bodyof3mail, $reply_to_fields2);
}
}
$_SESSION['pro_enter2']=$_SESSION['userCLid'];
//$_SESSION['userCLid']="";///empty pro_enter_cl_id variable after the http_post processed
autoreload();
$stop_email = 0;
$timeround=0;
}
// }
if(isset($_SESSION['userProid']))
{
show_gif();
echo "Appointment booking method Patent Pending";
echo "
";
input_client_username();
get_mult($_SESSION['userProid'], $_GET['no_appts'], $_GET['first_appt']);
}
else
{
echo "
There is no service provider logged in. If you are a service provider, log in here";
}
echo "Appointment booking method Patent Pending
";
?>