now showing both login form and add-new-person form side-by-side

master
Marek Isalski 7 years ago
parent 16974ef4c0
commit 64ec097b4c

@ -466,10 +466,14 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
// $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] ); // $form[ 'person' ] = fulcrm_collection_to_form( 'person', $eventbookingtype[ 'person_ddatacollection' ], $person[ 'd' ] );
if ( array_key_exists( 'url', $person ) ) {
if ( array_key_exists( 'name', $person ) ) if ( array_key_exists( 'name', $person ) )
$persons = array( 'myself' => $person[ 'name' ] . ' (myself)' ); $persons = array( 'myself' => $person[ 'name' ] . ' (myself)' );
else else
$persons = array( 'myself' => '(myself)' ); $persons = array( 'myself' => '(myself)' );
} else {
$persons = array();
}
if ( array_key_exists( 'related_from_person2persons', $person ) ) { if ( array_key_exists( 'related_from_person2persons', $person ) ) {
foreach ( $person[ 'related_from_person2persons' ] as $p2p ) { foreach ( $person[ 'related_from_person2persons' ] as $p2p ) {
@ -484,11 +488,21 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
} }
} }
if ( $persons ) {
$form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes', $form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes',
'#title' => 'Who is coming to the event? (<a href="' . url( 'fulcrm/cart/person/add/' . $eventbookingtype[ 'person_ddatacollection' ][ 'id' ] . '/' . fulcrm_crypto_object_id_hmac( 'collection', $eventbookingtype[ 'person_ddatacollection' ][ 'id' ] ), $options = array( 'query' => array( 'destination' => fulcrm_shoppingcart_buy_url( $product[ 'id' ] ) ) ) ) . '">add a new person to this list</a>)', '#title' => 'Who is coming to the event? (<a href="' . url( 'fulcrm/cart/person/add/' . $eventbookingtype[ 'person_ddatacollection' ][ 'id' ] . '/' . fulcrm_crypto_object_id_hmac( 'collection', $eventbookingtype[ 'person_ddatacollection' ][ 'id' ] ), $options = array( 'query' => array( 'destination' => fulcrm_shoppingcart_buy_url( $product[ 'id' ] ) ) ) ) . '">add a new person to this list</a>)',
'#description' => 'Tick the box next to each person for whom you want to buy a ticket.', '#description' => 'Tick the box next to each person for whom you want to buy a ticket.',
'#options' => $persons, '#options' => $persons,
); );
} else {
if ( $eventbookingtype[ 'person_ddatacollection' ] ) {
$collection_id = $eventbookingtype[ 'person_ddatacollection' ][ 'id' ];
$collection_data = fulcrm_apiv2_GET( 'ddatacollection/' . $collection_id . '/' );
if ( $collection_data[ 'success' ] ) {
$form[ 'new_person' ] = fulcrm_collection_to_form( 'person', $collection_data[ 'data' ], array() );
}
}
}
$form[ 'actions' ] = array( '#type' => 'actions' ); $form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'submit' ] = array( '#type' => 'submit', $form[ 'actions' ][ 'submit' ] = array( '#type' => 'submit',
@ -514,28 +528,24 @@ function fulcrm_shoppingcart_buy_eventbookingtype( $person, $eventbookingtype, $
$fulcrm_shoppingcart_buy_eventbookingtype_form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product ); $fulcrm_shoppingcart_buy_eventbookingtype_form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product );
return theme( 'fulcrm_shoppingcart_buy_eventbookingtype', array( 'fulcrm_shoppingcart_buy_eventbookingtype_form' => $fulcrm_shoppingcart_buy_eventbookingtype_form, 'user_login_form' => $user_login_form ) ); return theme( 'fulcrm_shoppingcart_buy_eventbookingtype', array( 'fulcrm_shoppingcart_buy_eventbookingtype_form' => $fulcrm_shoppingcart_buy_eventbookingtype_form, 'user_login_form' => $user_login_form ) );
} else {
return 'ZZZ'; // drupal_render( something );
} }
break; break;
case 'force': case 'force':
if ( user_is_anonymous() ) { if ( user_is_anonymous() ) {
drupal_set_message( t('You need to be logged in to continue shopping.'), 'error' ); // XXX change to be on form drupal_set_message( t('<strong>Sorry</strong>, but you need to be logged in to continue shopping.'), 'error' ); // XXX change to be on form
$form = user_login( $form, $form_state ); $form = user_login( $form, $form_state );
$form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] = $product[ 'id' ]; $form_state[ 'fulcrm_shoppingcart' ][ 'redirect_buy_product_id' ] = $product[ 'id' ];
$form[ '#submit' ][] = 'fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit'; $form[ '#submit' ][] = 'fulcrm_shoppingcart_buy_eventbookingtype_login_form_submit';
return 'XXX'; // drupal_render( $form ); return drupal_render( $form );
} else { } else {
drupal_set_message( t('Sorry! There was a problem looking up your record, and this means we cannot complete this order.'), 'error' ); drupal_set_message( t('Sorry! There was a problem looking up your record, and this means we cannot complete this order.'), 'error' );
return 'YYY'; // drupal_render( $form );
} }
break; break;
} }
} }
$form = drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person, $eventbookingtype, $product );
return druapl_render( $form );
return drupal_get_form( 'fulcrm_shoppingcart_buy_eventbookingtype_form', $person_data[ 'data' ], $eventbookingtype_data[ 'data' ], $product_data[ 'data' ] );
} }
function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_state ) { function fulcrm_shoppingcart_buy_generic_product_form_submit( $form, &$form_state ) {

@ -15,7 +15,7 @@
</div> </div>
<div class="col hide-xs col-md-1"></div> <div class="col hide-xs col-md-1"></div>
<div class="col col-xs-12 col-md-7"> <div class="col col-xs-12 col-md-7">
<div class="panel panel-default"> <div class="panel panel-info">
<div class="panel-heading"><h3 class="panel-title">Or continue your order by providing some details&hellip;</h3></div> <div class="panel-heading"><h3 class="panel-title">Or continue your order by providing some details&hellip;</h3></div>
<div class="panel-body"> <div class="panel-body">
<?php print drupal_render( $fulcrm_shoppingcart_buy_eventbookingtype_form ); ?> <?php print drupal_render( $fulcrm_shoppingcart_buy_eventbookingtype_form ); ?>

Loading…
Cancel
Save