|
|
|
@ -499,6 +499,35 @@ function fulcrm_shoppingcart_event_has_capacity( $event_id ) {
|
|
|
|
|
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 ) {
|
|
|
|
|
$form = array();
|
|
|
|
|
|
|
|
|
|