now able to add Person records to your own
This commit is contained in:
		@ -61,6 +61,12 @@ function fulcrm_shoppingcart_menu() {
 | 
				
			|||||||
                                                     'access callback' => 'user_access',
 | 
					                                                     'access callback' => 'user_access',
 | 
				
			||||||
                                                     'access arguments' => array('access content'),
 | 
					                                                     'access arguments' => array('access content'),
 | 
				
			||||||
                                                     );
 | 
					                                                     );
 | 
				
			||||||
 | 
					    $items[ 'fulcrm/cart/person/add/%/%' ] = array( 'page callback' => 'fulcrm_shoppingcart_person_add',
 | 
				
			||||||
 | 
					                                                    'page arguments' => array(4,5),
 | 
				
			||||||
 | 
					                                                    'type' => MENU_CALLBACK,
 | 
				
			||||||
 | 
					                                                    'access callback' => 'user_access',
 | 
				
			||||||
 | 
					                                                    'access arguments' => array('access content'),
 | 
				
			||||||
 | 
					                                                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return $items;
 | 
					    return $items;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -146,12 +152,52 @@ function fulcrm_shoppingcart_remove_url( $shoppingitem_id ) {
 | 
				
			|||||||
    return url( 'fulcrm/cart/remove/' . $shoppingitem_id . '/' . $hmac );
 | 
					    return url( 'fulcrm/cart/remove/' . $shoppingitem_id . '/' . $hmac );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function fulcrm_shoppingcart_buy_eventobokingtype_person_form_submit( $form, &$form_state ) {
 | 
					function fulcrm_shoppingcart_person_add_form_submit( $form, &$form_state ) {
 | 
				
			||||||
 | 
					    $person_d = fulcrm_collection_form_values_to_d( 'person', $form_state[ 'values' ] );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $person_data = array( 'd' => $person_d );
 | 
				
			||||||
 | 
					    if ( array_key_exists( 'name', $person_d ) ) {
 | 
				
			||||||
 | 
					        if ( is_array( $person_d[ 'name' ] ) )
 | 
				
			||||||
 | 
					            $person_data[ 'name' ] = $person_d[ 'name' ][ 0 ];
 | 
				
			||||||
 | 
					        elseif ( is_string( $person_d[ 'name' ] ) )
 | 
				
			||||||
 | 
					            $person_data[ 'name' ] = $person_d[ 'name' ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function fulcrm_shoppingcart_buy_eventobokingtype_person_form( $form, &$form_state ) {
 | 
					    $person_data[ 'uuid' ] = fulcrm_uuid_uuid4();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $api_data = fulcrm_apiv2_POST( 'person/', $person_data, $query = array( 'expand' => 'd' ) );
 | 
				
			||||||
 | 
					    if ( $api_data[ 'success' ] ) {
 | 
				
			||||||
 | 
					        module_invoke_all( 'fulcrm_shoppingcart_person_add', $api_data[ 'data' ] );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function fulcrm_shoppingcart_person_add_form( $form, &$form_state, $collection, $destination ) {
 | 
				
			||||||
 | 
					    $form_state[ 'fulcrm_shoppingcart' ][ 'collection' ] = $collection;
 | 
				
			||||||
 | 
					    $form[ 'title_event' ] = array( '#type' => 'markup',
 | 
				
			||||||
 | 
					                                    '#markup' => '<h1>Add a Person</h1>',
 | 
				
			||||||
 | 
					                                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $form[ 'person' ] = fulcrm_collection_to_form( 'person', $collection, array() );
 | 
				
			||||||
 | 
					    $form[ 'destination' ] = array( '#type' => 'hidden',
 | 
				
			||||||
 | 
					                                    '#default_value' => $destination,
 | 
				
			||||||
 | 
					                                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $form[ 'actions' ] = array( '#type' => 'actions' );
 | 
				
			||||||
 | 
					    $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
 | 
				
			||||||
 | 
					                                          '#value' => t('Add Person'),
 | 
				
			||||||
 | 
					                                          '#submit' => array( 'fulcrm_shoppingcart_person_add_form_submit' ),
 | 
				
			||||||
 | 
					                                          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return $form;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function fulcrm_shoppingcart_person_add( $collection_id, $hmac ) {
 | 
				
			||||||
 | 
					    if ( fulcrm_crypto_check_object_id_hmac( 'collection', $collection_id, $hmac ) ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $collection_data = fulcrm_apiv2_GET( 'ddatacollection/' . $collection_id . '/' );
 | 
				
			||||||
 | 
					        if ( $collection_data[ 'success' ] ) 
 | 
				
			||||||
 | 
					            return drupal_get_form( 'fulcrm_shoppingcart_person_add_form', $collection_data[ 'data' ], array_key_exists( 'destination', $_GET ) ? $_GET[ 'destination' ] : variable_get( 'fulcrm_shoppingcart_proceed_url', url('<front>') ) );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_state ) {
 | 
					function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_state ) {
 | 
				
			||||||
@ -278,20 +324,10 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes',
 | 
					    $form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes',
 | 
				
			||||||
                                           '#title' => 'Who is coming to the event?',
 | 
					                                           '#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' ] ), $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,
 | 
				
			||||||
                                           );
 | 
					                                           );
 | 
				
			||||||
    $form[ 'tickets_for_others' ] = array( '#type' => 'select',
 | 
					 | 
				
			||||||
                                           '#title' => 'Do you need extra tickets for any other people?',
 | 
					 | 
				
			||||||
                                           '#description' => 'Choose how many tickets you are getting for other people. You\'ll be asked their details in the next step.',
 | 
					 | 
				
			||||||
                                           '#options' => array( 0 => 'No thanks, just the people I\'ve chosen above.',
 | 
					 | 
				
			||||||
                                                                1 => 'Yes, 1 more!',
 | 
					 | 
				
			||||||
                                                                2 => 'Yes, 2 more!',
 | 
					 | 
				
			||||||
                                                                3 => 'Yes, 3 more!',
 | 
					 | 
				
			||||||
                                                                4 => 'Yes, 4 more!',
 | 
					 | 
				
			||||||
                                                                ),
 | 
					 | 
				
			||||||
                                           );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $form[ 'actions' ] = array( '#type' => 'actions' );
 | 
					    $form[ 'actions' ] = array( '#type' => 'actions' );
 | 
				
			||||||
    $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
 | 
					    $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user