fetch ddatacollection information and use fulcrm_collection to show it

master
Marek Isalski 9 years ago
parent 0292445e5e
commit 41984d4926

@ -117,35 +117,44 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_sta
if ( is_array( $cart ) ) {
if ( $person_uuid ) {
$api_data = fulcrm_apiv2_PATCH( $cart[ 'url' ], array( 'd' => array( 'fulcrm' => array( 'transaction' => array( 'person' => $person_uuid,
),
),
),
) );
$api_data = fulcrm_apiv2_PATCH( $cart[ 'url' ],
array( 'd' => array( 'fulcrm' => array( 'transaction' => array( 'person' => $person_uuid,
),
'person' => array( $person_uuid => array() ),
),
),
),
$query = array( 'expand' => 'd' ) );
}
// $cart[ 'd' ][ 'fulcrm' ][ 'person' ] = array( $uuid => array() );
// $cart[ 'd' ][ 'fulcrm' ][ 'transaction' ][ 'person' ] = $uuid;
$item = array( 'shoppingcart' => $cart[ 'url' ],
'product' => fulcrm_apiv2_make_url( 'product', $product_id ),
'quantity' => 1.0,
'd' => array( 'fulcrm' => array( 'eventbooking' => array( 'eventbooking' => array( 'foo' => 'bar',
),
// 'eventslotbookings' => array( $part => $slot )
// 'person' => $uuid,
),
),
'name' => $form_state[ 'values' ][ 'shoppingitem_name' ],
),
);
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
if ( $api_data[ 'success' ] ) {
drupal_set_message( t('Added to shopping cart.'), 'status' );
$form_state[ 'redirect' ] = 'fulcrm/cart';
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
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 ( $person_uuid ) {
$item = array( 'shoppingcart' => $cart[ 'url' ],
'product' => fulcrm_apiv2_make_url( 'product', $product_id ),
'quantity' => 1.0,
'd' => array( 'fulcrm' => array( 'eventbooking' => array( 'eventbooking' => array( 'foo' => 'bar',
),
// 'eventslotbookings' => array( $part => $slot )
'person' => $person_uuid,
),
),
'name' => $form_state[ 'values' ][ 'shoppingitem_name' ],
),
);
$api_data = fulcrm_apiv2_POST( 'shoppingitem/', $item, $query = array( 'expand' => 'd' ) );
if ( $api_data[ 'success' ] ) {
drupal_set_message( t('Added to shopping cart.'), 'status' );
$form_state[ 'redirect' ] = 'fulcrm/cart';
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
}
}
}
} else {
drupal_set_message( t('There was a problem adding your item to the shopping cart.'), 'error' );
@ -180,6 +189,8 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
'#value' => fulcrm_crypto_object_id_form_value( 'person.uuid', $person[ 'uuid' ] ) );
}
$form[ 'test' ] = fulcrm_collection_to_form( $eventbookingtype[ 'person_ddatacollection' ] );
if ( array_key_exists( 'id', $person ) )
$persons = array( fulcrm_crypto_object_id_hmac( 'person', $person[ 'id' ] ) => 'myself' );
else
@ -187,12 +198,12 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
if ( array_key_exists( 'related_from_person2persons', $person ) ) {
foreach ( $person[ 'related_from_person2persons' ] as $p2p ) {
$persons[ fulcrm_crypto_object_id_hmac( 'person', $p2p[ 'related_from' ][ 'id' ] ) ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ fulcrm_crypto_object_id_hmac( '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', $p2p[ 'related_to' ][ 'id' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ fulcrm_crypto_object_id_hmac( 'person.uuid', $p2p[ 'related_to' ][ 'uuid' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
}
}
@ -259,7 +270,9 @@ function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
switch ( fulcrm_apiv2_url_to_type( $product_data[ 'data' ][ 'content_object' ][ 'url' ] ) ) {
case 'eventbookingtype':
$eventbookingtype_data = fulcrm_apiv2_GET( $product_data[ 'data' ][ 'content_object' ][ 'url' ],
$query = array( 'expand' => implode( ',', array( 'event' ) ) ) );
$query = array( 'expand' => implode( ',', array( 'event',
'person_ddatacollection',
'eventbooking_ddatacollection' ) ) ) );
if ( $eventbookingtype_data[ 'success' ] ) {
return drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person_data[ 'data' ], $eventbookingtype_data[ 'data' ], $product_data[ 'data' ] );
}

@ -1,5 +1,5 @@
<tr>
<td><?php if ( array_key_exists( 'name', $item[ 'd' ] ) ) print nl2br( check_plain( $item[ 'd' ][ 'name' ] ) ); else print check_plain( $item[ 'product' ][ 'name' ] ); ?></td>
<td><?php print check_plain( $item[ 'product' ][ '_price' ][ 'format_total_net' ] ); ?></td>
<td><?php print check_plain( $item[ 'quantity' ] ); ?></td>
<td><span class="pull-right"><a class="btn btn-xs btn-danger" title="Remove from cart" href=""><span class="glyphicon glyphicon-trash"></span></a></span><?php if ( array_key_exists( 'name', $item[ 'd' ] ) ) print nl2br( check_plain( $item[ 'd' ][ 'name' ] ) ); else print check_plain( $item[ 'product' ][ 'name' ] ); ?></td>
<td class="text-right"><?php print check_plain( $item[ 'product' ][ '_price' ][ 'format_total_net' ] ); ?></td>
<td class="text-right"><?php print check_plain( $item[ 'quantity' ] ); ?></td>
</tr>

Loading…
Cancel
Save