117 lines
6.6 KiB
PHP
117 lines
6.6 KiB
PHP
|
<?php
|
||
|
add_action('mep_add_to_cart','mep_get_event_reg_btn');
|
||
|
|
||
|
// Get Event Registration Button
|
||
|
function mep_get_event_reg_btn(){
|
||
|
global $post,$event_meta;
|
||
|
$post_id = $post->ID;
|
||
|
// $event_meta = get_post_meta($post_id, 'mep_event_meta',true);
|
||
|
$event_meta = get_post_custom($post_id);
|
||
|
$event_expire_date = $event_meta['mep_event_start_date'][0];
|
||
|
$event_sqi = $event_meta['mep_sqi'][0];
|
||
|
|
||
|
$mep_full_name = strip_tags($event_meta['mep_full_name'][0]);
|
||
|
$mep_reg_email = strip_tags($event_meta['mep_reg_email'][0]);
|
||
|
$mep_reg_phone = strip_tags($event_meta['mep_reg_phone'][0]);
|
||
|
$mep_reg_address = strip_tags($event_meta['mep_reg_address'][0]);
|
||
|
$mep_reg_designation = strip_tags($event_meta['mep_reg_designation'][0]);
|
||
|
$mep_reg_website = strip_tags($event_meta['mep_reg_website'][0]);
|
||
|
$mep_reg_veg = strip_tags($event_meta['mep_reg_veg'][0]);
|
||
|
$mep_reg_company = strip_tags($event_meta['mep_reg_company'][0]);
|
||
|
$mep_reg_gender = strip_tags($event_meta['mep_reg_gender'][0]);
|
||
|
$mep_reg_tshirtsize = strip_tags($event_meta['mep_reg_tshirtsize'][0]);
|
||
|
$event_ecternal_link = '';
|
||
|
$book_count = get_post_meta($post_id,'total_booking', true);
|
||
|
|
||
|
if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
|
||
|
|
||
|
$seat_left = ($event_meta['mep_total_seat'][0]- $total_book);
|
||
|
$time = strtotime($event_expire_date);
|
||
|
$newformat = date('Y-m-d H:i:s',$time);
|
||
|
$datetime1 = new DateTime();
|
||
|
$datetime2 = new DateTime($newformat);
|
||
|
$interval = $datetime1->diff($datetime2);
|
||
|
$mep_event_ticket_type = get_post_meta($post_id, 'mep_event_ticket_type', true);
|
||
|
|
||
|
$stc = 0;
|
||
|
$leftt = 0;
|
||
|
foreach ( $mep_event_ticket_type as $field ) {
|
||
|
$qm = $field['option_name_t'];
|
||
|
$tesqn = $post_id.str_replace(' ', '', $qm);
|
||
|
$tesq = get_post_meta($post_id,"mep_xtra_$tesqn",true);
|
||
|
$stc = $stc+$field['option_qty_t'];
|
||
|
$llft = ($field['option_qty_t'] - $tesq);
|
||
|
$leftt = $leftt+$llft;
|
||
|
}
|
||
|
|
||
|
if($mep_event_ticket_type){
|
||
|
$seat_left = $leftt;
|
||
|
}else{
|
||
|
$seat_left = $seat_left;
|
||
|
}
|
||
|
|
||
|
if(time() > strtotime($newformat)){
|
||
|
echo "<span class=event-expire-btn>Event Expired</span>";
|
||
|
}
|
||
|
elseif($seat_left<=0){
|
||
|
echo "<span class=event-expire-btn>No Seat Available</span>";
|
||
|
}
|
||
|
else{
|
||
|
$days = $interval->d;
|
||
|
$hours = $interval->h;
|
||
|
$minutes = $interval->i;
|
||
|
if($days>0){ $dd = $days." days "; }else{ $dd=""; }
|
||
|
if($hours>0){ $hh = $hours." hours "; }else{ $hh=""; }
|
||
|
if($minutes>0){ $mm = $minutes." minutes "; }else{ $mm=""; }
|
||
|
$qty_typec = $event_meta['qty_box_type'][0];
|
||
|
|
||
|
?>
|
||
|
<form action="" method='post'>
|
||
|
<?php do_action('mep_event_ticket_type_extra_service'); ?>
|
||
|
<input type='hidden' id='rowtotal' value="<?php echo get_post_meta($post_id,"_price",true); ?>"/>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align="left"><?php _e('Total'); ?></td>
|
||
|
<td><?php if($event_sqi==1){
|
||
|
$mep_event_ticket_type = get_post_meta($post_id, 'mep_event_ticket_type', true);
|
||
|
if($mep_event_ticket_type){
|
||
|
?>
|
||
|
<input id="quantity_5a7abbd1bff73" class="input-text qty text extra-qty-box" step="1" min="1" max="<?php echo ($event_meta['mep_total_seat'][0]- $total_book); ?>" name="quantity" value="1" title="Qty" size="4" pattern="[0-9]*" inputmode="numeric" type="hidden">
|
||
|
<p id="ttyttl"></p>
|
||
|
<?php
|
||
|
}else{
|
||
|
?>
|
||
|
|
||
|
|
||
|
<?php
|
||
|
$qmx = ($event_meta['mep_total_seat'][0]- $total_book);
|
||
|
if($qty_typec=='dropdown'){ ?>
|
||
|
<select name="quantity" id="quantity_5a7abbd1bff73" class='input-text qty text extra-qty-box'>
|
||
|
<?php for ($i = 1; $i <= $qmx; $i++) { ?>
|
||
|
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
|
||
|
<?php } ?>
|
||
|
</select>
|
||
|
<?php }else{ ?>
|
||
|
<input id="quantity_5a7abbd1bff73" class="input-text qty text extra-qty-box" step="1" min="1" max="<?php echo ($event_meta['mep_total_seat'][0]- $total_book); ?>" name="quantity" value="1" title="Qty" size="4" pattern="[0-9]*" inputmode="numeric" type="number">
|
||
|
<?php } } } ?></td>
|
||
|
|
||
|
<td align="right"><span id="usertotal"></span></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<?php
|
||
|
$mep_event_ticket_type = get_post_meta($post->ID, 'mep_event_ticket_type', true);
|
||
|
if(!$mep_event_ticket_type){
|
||
|
?>
|
||
|
<div class="user-info-sec">
|
||
|
<div id="divParent"><div class='mep-user-info-sec'><h5><?php echo $qm; ?> Attendee info:1</h5><input type='<?php if($mep_full_name){ echo 'text'; }else{ echo 'hidden'; } ?>' <?php if($mep_full_name){ ?> required='required' <?php } ?> name='user_name[]' class='mep_input' placeholder='Enter Your Name'/><input type='<?php if($mep_reg_email){ echo 'email'; }else{ echo 'hidden'; } ?>' <?php if($mep_reg_email){ ?> required='required' <?php } ?> name='user_email[]' class='mep_input' placeholder='Enter Your Email'/><input type='<?php if($mep_reg_phone){ echo 'text'; }else{ echo 'hidden'; } ?>' <?php if($mep_reg_phone){ ?> required='required' <?php } ?> name='user_phone[]' class='mep_input' placeholder='Enter Your Phone'/><textarea name='user_address[]' class='mep_input <?php if($mep_reg_address){ echo 'mep-show'; }else{ echo 'mep-hidden'; } ?>' rows='3' <?php if($mep_reg_address){ ?> required='required' <?php } ?> placeholder='Enter you address'></textarea><label class='<?php if($mep_reg_tshirtsize){ echo "mep-show"; }else{ echo "mep-hidden"; } ?>' for='gen' style='text-align: left;'>T-Shirt Size<select name='tshirtsize[]' id='gen'><option value=''>Please Select</option><?php echo mep_get_tshirts_sizes($post->ID); ?></select></label><label class='<?php if($mep_reg_gender){ echo 'mep-show'; }else{ echo 'mep-hidden'; } ?>' for='gen' style='text-align: left;'>Gender<select name='gender[]' id='gen'><option value=''>Please Select</option><option value='Male'>Male</option><option value='Female'>Female</option></select></label><input type='<?php if($mep_reg_company){ echo 'text'; }else{ echo 'hidden'; } ?>' name='user_company[]' class='mep_input' placeholder='Company'/><input type='<?php if($mep_reg_designation){ echo 'text'; }else{ echo 'hidden'; } ?>' name='user_designation[]' class='mep_input' placeholder='Designation'/><input type='<?php if($mep_reg_website){ echo 'text'; }else{ echo 'hidden'; } ?>' name='user_website[]' class='mep_input' placeholder='Website'/><label class='<?php if($mep_reg_veg){ echo 'mep-show'; }else{ echo 'mep-hidden'; } ?>' for='veg' style='text-align: left;'>Vegetarian<select name='vegetarian[]' id='veg'><option value=''>Please Select</option><option value='Yes'>Yes</option><option value='No'>No</option></select></label><input type='hidden' name='ticket_type[]' class='mep_input' value='<?php echo $qm; ?>' /></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
|
||
|
<button type="submit" name="add-to-cart" value="<?php echo esc_attr($post_id); ?>" class="single_add_to_cart_button button alt btn-mep-event-cart"><?php _e('Register This Event'); ?> </button>
|
||
|
</form>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
}
|
||
|
}
|