function dt_delete_reservation() { $options = array(); if (get_option($_REQUEST['option'])) { $options = get_option($_REQUEST['option']); } else { $options = get_option($_REQUEST['option'] . '_agenda'); } if (!delete_option($_REQUEST['option'])) { delete_option($_REQUEST['option'] . '_agenda'); } if (!empty($options)) { $client_name = $client_phone = $client_email = ""; #Staff $staff_name = get_the_title($_REQUEST['memberid']); $service_name = get_the_title($_REQUEST['service']); $info = get_post_meta($_REQUEST['memberid'], "_info", true); $info = is_array($info) ? $info : array(); #Client $client = array_key_exists('user', $options) ? $options['user'] : ''; if (!empty($client)) { $client_name = get_the_title($client); $cinfo = get_post_meta($client, "_info", true); $cinfo = is_array($cinfo) ? $cinfo : array(); $client_email = array_key_exists('emailid', $cinfo) ? $cinfo['emailid'] : ""; $client_phone = array_key_exists('phone', $cinfo) ? $cinfo['phone'] : ""; } $array = array('staff_name' => $staff_name, 'service_name' => $service_name, 'appointment_id' => $options['id'], 'appointment_time' => $_REQUEST['time'], 'appointment_date' => $_REQUEST['date'], 'appointment_title' => $options['title'], 'appointment_body' => $options['body'], 'client_name' => $client_name, 'client_phone' => $client_phone, 'client_email' => $client_email, 'company_logo' => 'Company Logo', 'company_name' => 'Company Name', 'company_phone' => 'Company Phone', 'company_address' => 'Company Address', 'company_website' => 'Company Website'); $subject = dttheme_option('company', 'deleted_appointment_notification_to_staff_subject'); $subject = dt_replace($subject, $array); $message = dttheme_option('company', 'deleted_appointment_notification_to_staff_message'); $message = dt_replace($message, $array); dt_send_mail($info["emailid"], $subject, $message); if (!empty($client_email)) { $subject = dttheme_option('company', 'deleted_appointment_notification_to_client_subject'); $subject = dt_replace($subject, $array); $message = dttheme_option('company', 'deleted_appointment_notification_to_client_message'); $message = dt_replace($message, $array); dt_send_mail($client_email, $subject, $message); } } }
$end = $reservation['end']; $end = explode("(", $end); $end = $end[0]; $end = new DateTime($end); $end = $end->format('h:i A'); $time = $stime . ' - ' . $end; $mseeage .= '<td>' . $time . '</td>'; $mseeage .= '</tr>'; } $mseeage .= "</table>"; #Mailing $tomorrow_agenda = $mseeage; $replace['staff_name'] = $staff_name; $replace['tomorrow_agenda'] = $tomorrow_agenda; $subject = dttheme_option('company', 'agenda_to_staff_subject'); $subject = dt_replace_agenda($subject, $replace); $message = dttheme_option('company', 'agenda_to_staff_message'); $message = dt_replace_agenda($message, $replace); if (dt_send_mail($info["emailid"], $subject, $message)) { $update_wp_options = true; } #Mailing } } if ($update_wp_options) { foreach ($wp_options as $wp_option) { $wpdb->query("UPDATE {$wpdb->options} SET option_name = '{$wp_option}_agenda' WHERE option_name = '{$wp_option}'"); } } } }
function dt_paypal_listener() { if( isset( $_GET['action'] ) ) { switch ( $_GET['action'] ) { case 'dt_paypal_cancel': $arg = array('action','res'); delete_option($_GET['res']); #$url = remove_query_arg( $args ,home_url() ); $url = dt_get_page_permalink_by_its_template('tpl-reservation.php'); $url = remove_query_arg( $args ,$url ); $url = add_query_arg( array( 'action' => 'error' ) , $url ); wp_safe_redirect($url); exit; break; case 'dt_paypal_retrun': $reservation = get_option($_REQUEST['res']); $staff = explode("_",$_REQUEST['res']); $staff_name = get_the_title($staff[4]); $service_name = get_the_title($reservation['service']); $start = new DateTime($reservation['start']); $end = new DateTime($reservation['end']); $date = date_format($start, "Y/m/d"); $time = date_format($start,"g:i a").' - '.date_format($end,"g:i a"); $client_name = get_the_title($reservation['user']); $cinfo = get_post_meta( $reservation['user'], "_info",true); $cinfo = is_array($cinfo) ? $cinfo : array(); $client_email = array_key_exists('emailid', $cinfo) ? $cinfo['emailid'] : ""; $client_phone = array_key_exists('phone', $cinfo) ? $cinfo['phone'] : ""; #Staff Price $sinfo = get_post_meta( $staff[4] , "_info",true); $sinfo = is_array($sinfo) ? $sinfo : array(); $staff_price = array_key_exists("price", $sinfo) ? $sinfo['price'] : 0; $staff_price = floatval($staff_price); #Service Price $serviceinfo = get_post_meta($reservation['service'],'_info',true ); $serviceinfo = is_array( $serviceinfo ) ? $serviceinfo : array(); $service_price = array_key_exists("price", $serviceinfo) ? $serviceinfo['price'] : 0; $service_price = floatval($service_price); $amount = ( ($staff_price+$service_price) > 0 ) ? ( $staff_price+$service_price ) : ""; $pdata = '&TOKEN='.$_REQUEST['token'] .'&PAYERID='.$_REQUEST['PayerID'] .'&PAYMENTACTION='.urlencode( "SALE" ) .'&AMT='.urlencode($amount); //We need to execute the "DoExpressCheckoutPayment" at this point to Receive payment from user. $response = sendPaypalRequest('DoExpressCheckoutPayment', $pdata); if ( "SUCCESS" == strtoupper( $response["ACK"] ) || "SUCCESSWITHWARNING" == strtoupper( $response["ACK"] ) ) { // we can retrieve transaction details using either GetTransactionDetails or GetExpressCheckoutDetails // GetTransactionDetails requires a Transaction ID, and GetExpressCheckoutDetails requires Token returned by SetExpressCheckOut $response = sendPaypalRequest( 'GetTransactionDetails', "&TRANSACTIONID=" . urlencode( $response["TRANSACTIONID"] ) ); if ( "SUCCESS" == strtoupper( $response["ACK"] ) || "SUCCESSWITHWARNING" == strtoupper( $response["ACK"] ) ) { $array = array( 'staff_name' => $staff_name, 'service_name' => $service_name, 'appointment_id' => $reservation['id'], 'appointment_time' => $time, 'appointment_date' => $date, 'appointment_title' => $reservation['title'], 'appointment_body' => $reservation['body'], 'client_name' => $client_name, 'client_phone' => $client_phone, 'client_email' => $client_email, 'amount' => $amount, 'company_logo' => 'Company Logo', 'company_name' => 'Company Name', 'company_phone' => 'Company Phone', 'company_address' => 'Company Address', 'company_website' => 'Company Website'); #Staff Mail $subject = dttheme_option('company', 'appointment_notification_to_staff_subject'); $subject = dt_replace( $subject, $array); $message = dttheme_option('company', 'appointment_notification_to_staff_message' ); $message = dt_replace( $message, $array); dt_send_mail( $sinfo["emailid"], $subject, $message); #Customer Mail $subject = dttheme_option('company', 'appointment_notification_to_client_subject'); $subject = dt_replace( $subject, $array); $message = dttheme_option('company', 'appointment_notification_to_client_message' ); $message = dt_replace( $message, $array); dt_send_mail( $client_email, $subject, $message); #Add Payment Details to options table $payment_id = str_replace('_dt_reservation_',"_dt_payment_",$_REQUEST['res']); $payment_data = array( 'date' => date('Y-m-d H:i:s'), 'service' => get_the_title($reservation['service']), 'type' => 'paypal', 'customer_id' =>$reservation['user'], 'token' => $_REQUEST['token'], 'status' => $response['PAYMENTSTATUS'], 'transaction_id'=> $response['TRANSACTIONID'], 'total'=> urldecode( $response['AMT'])); update_option($payment_id,$payment_data); $arg = array('action','res'); # $url = remove_query_arg( $args ,home_url() ); $url = dt_get_page_permalink_by_its_template('tpl-reservation.php'); $url = remove_query_arg( $args ,$url ); $url = add_query_arg( array( 'action' => 'success' ) , $url ); wp_safe_redirect($url); exit; } else { throw new Exception( urldecode( $response["L_LONGMESSAGE0"] ) ); } } else { throw new Exception( urldecode( $response["L_LONGMESSAGE0"] ) ); } break; } } }?>