|
|
|
@ -105,17 +105,20 @@ function fulcrm_shoppingcart_buy_url( $product_id ) {
|
|
|
|
|
function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_state ) {
|
|
|
|
|
// $person_d = fulcrm_collection_form_values_to_d( 'person', $form_state[ 'values' ] );
|
|
|
|
|
|
|
|
|
|
$product_id = fulcrm_crypto_get_object_id_form_value( 'product', $form_state[ 'values' ][ 'product_id_hmac' ] );
|
|
|
|
|
$eventbookingtype_id = fulcrm_crypto_get_object_id_form_value( 'eventbookingtype', $form_state[ 'values' ][ 'eventbookingtype_id_hmac' ] );
|
|
|
|
|
$product_id = $form_state[ 'fulcrm_shoppingcart' ][ 'product' ][ 'id' ];
|
|
|
|
|
$eventbookingtype_id = $form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'id' ];
|
|
|
|
|
|
|
|
|
|
$person_id = NULL;
|
|
|
|
|
$person_uuid = NULL;
|
|
|
|
|
if ( array_key_exists( 'person_id_hmac', $form_state[ 'values' ] ) )
|
|
|
|
|
$person_id = fulcrm_crypto_get_object_id_form_value( 'person', $form_state[ 'values' ][ 'person_id_hmac' ] );
|
|
|
|
|
if ( array_key_exists( 'person_uuid_hmac', $form_state[ 'values' ] ) )
|
|
|
|
|
$person_uuid = fulcrm_crypto_get_object_id_form_value( 'person.uuid', $form_state[ 'values' ][ 'person_uuid_hmac' ] );
|
|
|
|
|
if ( array_key_exists( 'id', $form_state[ 'fulcrm_shoppingcart' ] ) )
|
|
|
|
|
$person_id = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'id' ];
|
|
|
|
|
if ( array_key_exists( 'uuid', $form_state[ 'fulcrm_shoppingcart' ] ) )
|
|
|
|
|
$person_uuid = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'uuid' ];
|
|
|
|
|
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart();
|
|
|
|
|
if ( array_key_exists( 'shoppingcart', $form_state[ 'fulcrm_shoppingcart' ] ) )
|
|
|
|
|
$cart = $form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ];
|
|
|
|
|
else
|
|
|
|
|
$cart = fulcrm_shoppingcart_get_session_cart();
|
|
|
|
|
|
|
|
|
|
if ( is_array( $cart ) ) {
|
|
|
|
|
if ( $person_uuid ) {
|
|
|
|
@ -133,7 +136,19 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
|
|
|
|
// $cart[ 'd' ][ 'fulcrm' ][ 'transaction' ][ 'person' ] = $uuid;
|
|
|
|
|
|
|
|
|
|
foreach ( $form_state[ 'values' ][ 'ticket_for_persons' ] as $ticket_for_person ) {
|
|
|
|
|
$person_uuid = fulcrm_crypto_get_object_id_form_value( 'person.uuid', $ticket_for_person );
|
|
|
|
|
if ( $ticket_for_person === 'myself' ) {
|
|
|
|
|
$person_uuid = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'uuid' ];
|
|
|
|
|
$person_name = $form_state[ 'fulcrm_shoppingcart' ][ 'person' ][ 'name' ];
|
|
|
|
|
} else {
|
|
|
|
|
$person_uuid = fulcrm_crypto_get_object_id_form_value( 'person.uuid', $ticket_for_person );
|
|
|
|
|
if ( $person_uuid )
|
|
|
|
|
$person_name = $form_state[ 'fulcrm_shoppingcart' ][ 'persons' ][ $person_uuid ][ 'name' ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$shoppingitem_name = ( $form_state[ 'fulcrm_shoppingcart' ][ 'product' ][ 'name' ] . ', ' . $person_name . "\r\n" .
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'name' ] . "\r\n" .
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ][ 'event' ][ 'name' ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( $person_uuid ) {
|
|
|
|
|
$item = array( 'shoppingcart' => $cart[ 'url' ],
|
|
|
|
@ -145,7 +160,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
|
|
|
|
'person' => $person_uuid,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
'name' => $form_state[ 'values' ][ 'shoppingitem_name' ],
|
|
|
|
|
'name' => $shoppingitem_name,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -161,9 +176,15 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
|
|
|
|
|
} else {
|
|
|
|
|
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'shoppingcart' ] = $cart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'person' ] = $person;
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'eventbookingtype' ] = $eventbookingtype;
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'product' ] = $product;
|
|
|
|
|
|
|
|
|
|
$form = array();
|
|
|
|
|
|
|
|
|
|
$form[ 'title_event' ] = array( '#type' => 'markup',
|
|
|
|
@ -176,39 +197,25 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
|
|
|
|
|
'#markup' => '<h3>' . check_plain( $product[ 'name' ] ) . '</h3>',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$form[ 'shoppingitem_name' ] = array( '#type' => 'hidden',
|
|
|
|
|
'#value' => $product[ 'name' ] . "\r\n" . $eventbookingtype[ 'name' ] . "\r\n" . $eventbookingtype[ 'event' ][ 'name' ] );
|
|
|
|
|
|
|
|
|
|
$form[ 'product_id_hmac' ] = array( '#type' => 'hidden',
|
|
|
|
|
'#value' => fulcrm_crypto_object_id_form_value( 'product', $product[ 'id' ] ) );
|
|
|
|
|
$form[ 'eventbookingtype_id_hmac' ] = array( '#type' => 'hidden',
|
|
|
|
|
'#value' => fulcrm_crypto_object_id_form_value( 'eventbookingtype', $eventbookingtype[ 'id' ] ) );
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( 'id', $person ) ) {
|
|
|
|
|
$form[ 'person_id_hmac' ] = array( '#type' => 'hidden',
|
|
|
|
|
'#value' => fulcrm_crypto_object_id_form_value( 'person', $person[ 'id' ] ) );
|
|
|
|
|
$form[ 'person_uuid_hmac' ] = array( '#type' => 'hidden',
|
|
|
|
|
'#value' => fulcrm_crypto_object_id_form_value( 'person.uuid', $person[ 'uuid' ] ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] );
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( 'id', $person ) )
|
|
|
|
|
$persons = array( fulcrm_crypto_object_id_hmac( 'person', $person[ 'id' ] ) => 'myself' );
|
|
|
|
|
else
|
|
|
|
|
$persons = array( 'myself' => 'myself' );
|
|
|
|
|
$persons = array();
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( 'related_from_person2persons', $person ) ) {
|
|
|
|
|
foreach ( $person[ 'related_from_person2persons' ] as $p2p ) {
|
|
|
|
|
$persons[ fulcrm_crypto_object_id_hmac( 'person.uuid', $p2p[ 'related_from' ][ 'uuid' ] ) ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'persons' ][ $p2p[ 'related_from' ][ 'uuid' ] ] = $p2p[ 'related_from' ];
|
|
|
|
|
$persons[ fulcrm_crypto_object_id_form_value( 'person.uuid', $p2p[ 'related_from' ][ 'uuid' ] ) ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( array_key_exists( 'related_to_person2persons', $person ) ) {
|
|
|
|
|
foreach ( $person[ 'related_to_person2persons' ] as $p2p ) {
|
|
|
|
|
$persons[ fulcrm_crypto_object_id_hmac( 'person.uuid', $p2p[ 'related_to' ][ 'uuid' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
|
|
|
|
|
$form_state[ 'fulcrm_shoppingcart' ][ 'persons' ][ $p2p[ 'related_to' ][ 'uuid' ] ] = $p2p[ 'related_to' ];
|
|
|
|
|
$persons[ fulcrm_crypto_object_id_form_value( 'person.uuid', $p2p[ 'related_to' ][ 'uuid' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$persons[ 'myself' ] = 'myself';
|
|
|
|
|
|
|
|
|
|
$form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes',
|
|
|
|
|
'#title' => 'Who is coming to the event?',
|
|
|
|
|
'#description' => 'Tick the box next to each person for whom you want to buy a ticket.',
|
|
|
|
|