function dt_services_columns_display($columns, $id) { global $post; switch ($columns) { case 'details': $info = get_post_meta($post->ID, "_info", true); $info = is_array($info) ? $info : array(); $price = array_key_exists('price', $info) ? $info['price'] : ""; $price = !empty($price) ? dt_currency_symbol(dttheme_option('company', 'currency')) . ' ' . $price : ""; $price = !empty($price) ? '<p>' . __("Price", "dt_themes") . ' - ' . $price . '</p>' : ""; echo $price; $duration = array_key_exists('duration', $info) ? $info['duration'] : ""; $duration = !empty($duration) ? '<p>' . __("Duration", 'dt_themes') . ' - ' . durationToString($duration) . '</p>' : ""; echo $duration; break; } }
<div class="column one-sixth"><?php _e('Price', 'dt_themes'); ?> </div> <div class="column five-sixth last"><?php $price = array_key_exists('price', $info) ? $info['price'] : ""; ?> <input type="text" name="_info[price]" class='small-text' value="<?php echo $price; ?> " placeholder="<?php _e('Price', 'dt_themes'); ?> "> <?php echo dt_currency_symbol(dttheme_option('company', 'currency')); ?> </div> </div> <div class="custom-box"> <div class="column one-sixth"><?php _e('Duration', 'dt_themes'); ?> </div> <div class="column five-sixth last"> <select name="_info[duration]"> <option value=""><?php _e('Select', 'dt_themes'); ?> </option><?php
</div> </div><!-- #my-company end --> <!-- #my-payment start --> <div id="my-payment"> <div class="bpanel-box"><?php if( dttheme_is_plugin_active('designthemes-core-features/designthemes-core-features.php') ) : ?> <div class="box-title"><h3><?php _e('Payments','dt_themes');?></h3></div> <div class="box-content"> <h6><?php _e('Currency','dt_themes');?></h6> <select name="mytheme[company][currency]"><?php $selected = dttheme_option('company', 'currency'); $currency_code_options = dt_currencies(); foreach ( $currency_code_options as $code => $name ) { $symbol = dt_currency_symbol( $code ); $s = ( $code === $selected ) ? ' selected="selected" ' : ""; echo "<option value='{$code}' {$s}>{$name}( {$symbol} )</option>"; }?> </select> <div class="hr"></div> <h6><?php _e('Enable Pay At Arrival','dt_themes');?></h6> <div class="column one-fifth"> <?php dttheme_switch("",'company','enable-pay-at-arrival');?> </div> <div class="column four-fifth last"> <p class="note no-margin"><?php _e('You can enable pay at arrival option to pay locally','dt_themes');?></p> </div> <div class="hr"></div>
function dt_update_reservation() { $now = new DateTime("now"); $start = new DateTime($_REQUEST['c_start']); $readOnly = $now < $start ? true : false; $data = array('id' => $_REQUEST['id'], 'title' => $_REQUEST['title'], 'body' => $_REQUEST['body'], 'start' => $_REQUEST['start'], 'end' => $_REQUEST['end'], 'user' => $_REQUEST['user'], 'service' => $_REQUEST['service'], 'readOnly' => $readOnly); if (!get_option($_REQUEST['option'] . '_agenda')) { update_option($_REQUEST['option'], $data); } else { update_option($_REQUEST['option'] . '_agenda', $data); } #Send Mail To 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(); if (array_key_exists("emailid", $info)) { #Calculating Price $amount = ""; $staff_price = array_key_exists("price", $info) ? $info['price'] : 0; if (!empty($_REQUEST['service'])) { $sinfo = get_post_meta($_REQUEST['service'], "_info", true); $sinfo = is_array($sinfo) ? $sinfo : array(); $service_price = array_key_exists("price", $sinfo) ? $sinfo['price'] : 0; } $price = floatval($staff_price) + floatval($service_price); $currency = dt_currency_symbol(dttheme_option('company', 'currency')); $amount = $currency . ' ' . $price; #Calculating Price $client_name = $client_phone = $client_email = ""; $client = $data['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' => $data['id'], 'appointment_time' => $_REQUEST['time'], 'appointment_date' => $_REQUEST['date'], 'appointment_title' => $data['title'], 'appointment_body' => $data['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'); $subject = dttheme_option('company', 'modified_appointment_notification_to_staff_subject'); $subject = dt_replace($subject, $array); $message = dttheme_option('company', 'modified_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', 'modified_appointment_notification_to_client_subject'); $subject = dt_replace($subject, $array); $message = dttheme_option('company', 'modified_appointment_notification_to_client_message'); $message = dt_replace($message, $array); dt_send_mail($client_email, $subject, $message); } } #Send Mail die(''); }
function dt_new_reservation(){ global $wpdb; #New Customer $name = $_REQUEST['name']; $email = $_REQUEST['email']; $phone = $_REQUEST['phone']; $customer = dt_customer($name,$email,$phone); #New Customer $id = $wpdb->get_var("SELECT max(option_id) FROM $wpdb->options"); $title = __("New Reservation By ",'dt_themes').$name; $body = $_REQUEST['body']; $staff = $_REQUEST['staff']; $service = $_REQUEST['service']; $start = $_REQUEST['start']; $end = $_REQUEST['end']; $option = "_dt_reservation_mid_{$staff}_id_{$id}"; $data = array( 'id' => $id, 'title' => $title, 'body' => $body, 'start'=> $start, 'end'=>$end, 'service'=>$service, 'user'=>$customer, readOnly=>true ); # Sending Mail $client_name = $client_phone = $client_email = $amount = ""; #Staff $staff_name = get_the_title($staff); $service_name = get_the_title($service); $sinfo = get_post_meta( $staff , "_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 if( !empty( $data['service']) ){ $serviceinfo = get_post_meta($data['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 ) ? dt_currency_symbol( dttheme_option('company', 'currency') ).' '.( $staff_price+$service_price ) : $amount; #Client if( !empty($data['user']) ){ $client_name = get_the_title($data['user']); $cinfo = get_post_meta( $data['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'] : "";; } $array = array( 'staff_name' => $staff_name, 'service_name' => $service_name, 'appointment_id' => $data['id'], 'appointment_time' => $_POST['time'], 'appointment_date' => $_POST['date'], 'appointment_title' => $data['title'], 'appointment_body' => $data['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'); $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); #Staff Mail dt_send_mail( $sinfo["emailid"], $subject, $message); #Client Mail if( !empty($client_email) ) { $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); } # Sending Mail if( update_option( $option, $data ) ){ #echo "Added"; #Add Payment Details to options table $payment_id = str_replace('_dt_reservation_',"_dt_payment_",$option); #$amount = trim(str_replace(dt_currency_symbol( get_option("dt_currency") ),"",$amount)); $amount = $staff_price+$service_price; $payment_data = array( 'date' => date('Y-m-d H:i:s'), 'service' => get_the_title($data['service']), 'type' => 'local', 'customer_id' =>$data['user'], 'total'=> $amount); update_option($payment_id,$payment_data); # $result['url'] = home_url(); $url = dt_get_page_permalink_by_its_template('tpl-reservation.php'); $url = add_query_arg( array('action'=>'success'), $url ); $result['url'] = $url; echo json_encode( $result ); }else{ echo "FAiled"; } die(''); }