|
|
@ -500,35 +500,6 @@ function fulcrm_shoppingcart_event_has_capacity( $event_id ) {
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_eventslot_has_capacity( $eventslot_id ) {
|
|
|
|
|
|
|
|
$capacity = null;
|
|
|
|
|
|
|
|
$count = null;
|
|
|
|
|
|
|
|
$api_data = fulcrm_apiv2_GET( 'eventslot/' . $event_id . '/',
|
|
|
|
|
|
|
|
$query = array( 'expand' => 'eventpart,eventpart.event' ) );
|
|
|
|
|
|
|
|
if ( $api_data[ 'success' ] ) {
|
|
|
|
|
|
|
|
$capacities = array( $api_data[ 'data' ][ 'eventpart' ][ 'event' ][ 'capacity' ],
|
|
|
|
|
|
|
|
$api_data[ 'data' ][ 'eventpart' ][ 'capacity' ],
|
|
|
|
|
|
|
|
$api_data[ 'data' ][ 'capacity' ] );
|
|
|
|
|
|
|
|
foreach ( $capacities as $cap ) {
|
|
|
|
|
|
|
|
if ( !is_null( $cap ) )
|
|
|
|
|
|
|
|
$capacity = $cap;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$api_data = fulcrm_apiv2_GET( 'eventslotbooking/', $query = array( 'eventslot' => $eventslot_id,
|
|
|
|
|
|
|
|
'eventbooking__confirmed__isnull' => 'False',
|
|
|
|
|
|
|
|
'eventbooking__cancelled__isnull' => 'True',
|
|
|
|
|
|
|
|
) );
|
|
|
|
|
|
|
|
if ( $api_data[ 'success' ] )
|
|
|
|
|
|
|
|
$count = $api_data[ 'data' ][ 'count' ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !is_null( $capacity ) && !is_null( $count ) ) {
|
|
|
|
|
|
|
|
if ( $count >= $capacity )
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
|
|
|
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
|
|
|
$form = array();
|
|
|
|
$form = array();
|
|
|
|
|
|
|
|
|
|
|
@ -613,6 +584,8 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
|
|
|
'#options' => array(),
|
|
|
|
'#options' => array(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
$eventslot_id = fulcrm_crypto_object_id_form_value( 'eventslot.id', $eventslot[ 'id' ] );
|
|
|
|
$eventslot_id = fulcrm_crypto_object_id_form_value( 'eventslot.id', $eventslot[ 'id' ] );
|
|
|
|
|
|
|
|
$remaining_capacity = $eventslot[ '_remaining_capacity' ];
|
|
|
|
|
|
|
|
if ( is_null( $remaining_capacity ) || ( $remaining_capacity > 0 ) )
|
|
|
|
$form[ 'eventslots' ][ $eventpart_key ][ '#options' ][ $eventslot_id ] = $eventslot[ 'name' ];
|
|
|
|
$form[ 'eventslots' ][ $eventpart_key ][ '#options' ][ $eventslot_id ] = $eventslot[ 'name' ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -623,12 +596,6 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
|
|
|
$eventpart[ '#default_value' ] = $option_key;
|
|
|
|
$eventpart[ '#default_value' ] = $option_key;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$choices = true;
|
|
|
|
$choices = true;
|
|
|
|
foreach ( $eventpart[ '#options' ] as $option_key => $option_value ) {
|
|
|
|
|
|
|
|
$eventslot_id = fulcrm_crypto_get_object_id_form_value( 'eventslot.id', $option_key );
|
|
|
|
|
|
|
|
if ( $eventslot_id && !fulcrm_shoppingcart_eventslot_has_capacity( $eventslot_id ) ) {
|
|
|
|
|
|
|
|
unset( $eventpart[ '#options' ][ $option_key ] );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|