get_row("select * from ".EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE." where registration_id = '$registration_id' "); if ( $check !== NULL ) { $registration_id = $check->primary_registration_id; $registration_ids = $wpdb->get_results("select * from ".EVENTS_MULTI_EVENT_REGISTRATION_ID_GROUP_TABLE." where primary_registration_id = '$registration_id' ", ARRAY_A); $multi_reg = true; } switch ( $_REQUEST[ 'form_action' ] ) { //Add payment info case 'payment': if ( isset($_REQUEST[ 'attendee_action' ]) && $_REQUEST[ 'attendee_action' ] == 'post_payment' ){ //Added by Imon $primary_row = $wpdb->get_row("select id from ".EVENTS_ATTENDEE_TABLE." where registration_id = '$registration_id' order by id limit 0,1 "); $primary_attendee_id = $primary_row->id; // GET the primary attendee id because amount paid info is kept with the primary attendee $payment_status = isset($_REQUEST[ 'payment_status' ]) ? $_REQUEST[ 'payment_status' ]:''; $txn_type = isset($_REQUEST[ 'txn_type' ]) ? $_REQUEST[ 'txn_type' ]:''; $txn_id = isset($_REQUEST[ 'txn_id' ]) ? $_REQUEST[ 'txn_id' ]:''; //$quantity = isset($_REQUEST[ 'quantity' ]) ? $_REQUEST[ 'quantity' ]:''; $amount_pd = isset($_REQUEST[ 'amount_pd' ]) ? $_REQUEST[ 'amount_pd' ]:''; $payment_date = isset($_REQUEST[ 'payment_date' ]) ? $_REQUEST[ 'payment_date' ]:''; $coupon_code = isset($_REQUEST[ 'coupon_code' ]) ? $_REQUEST[ 'coupon_code' ]:''; //Added/updated by Imon //Update payment status information for primary attendee $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '$payment_status', txn_type = '$txn_type', txn_id = '$txn_id', amount_pd = '$amount_pd', payment_date ='$payment_date', coupon_code ='$coupon_code' WHERE registration_id ='" . $registration_id . "' and id = $primary_attendee_id "; $wpdb->query( $sql ); if ( count($registration_ids) > 0 ) { foreach($registration_ids as $reg_id) { // Update payment status information for all attendees $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '$payment_status', txn_type = '$txn_type', txn_id = '$txn_id', payment_date ='$payment_date', coupon_code ='$coupon_code' WHERE registration_id ='" . $reg_id['registration_id']. "' "; $wpdb->query( $sql ); } } else { // Update payment status information for all attendees $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET payment_status = '$payment_status', txn_type = '$txn_type', txn_id = '$txn_id', payment_date ='$payment_date', coupon_code ='$coupon_code' WHERE registration_id ='" . $registration_id . "' "; $wpdb->query( $sql ); } //Send Payment Recieved Email if ( $_REQUEST[ 'send_payment_rec' ] == "send_message" ) { /* * @todo Do we send an email to each attendee in a group or just the main? */ //event_espresso_send_payment_notification( $id ); //Added by Imon if ( count($registration_ids) > 0 ) { $reg_attendees = array(); foreach($registration_ids as $reg_id) { $SQL = 'SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE registration_id =%s'; $more_reg_attendees = $wpdb->get_results( $wpdb->prepare( $SQL, $reg_id['registration_id'] ), 'OBJECT_K' ); foreach ( $more_reg_attendees as $another_reg_attendee ) { $reg_attendees[ $another_reg_attendee->email ] = $another_reg_attendee; } } foreach ( $reg_attendees as $reg_attendee ){ event_espresso_send_payment_notification( array( 'registration_id'=>$reg_attendee->registration_id )); } } else { event_espresso_send_payment_notification(array('registration_id'=>$registration_id)); } } } break; //Send Invoice case 'send_invoice': //Added by Imon if ( $org_options["use_attendee_pre_approval"] == "Y" ) { $pre_approve = $_REQUEST['pre_approve']; if ( count($registration_ids) > 0 ) { foreach($registration_ids as $reg_id) { $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = '$pre_approve' WHERE registration_id ='" . $reg_id['registration_id'] . "'"; $wpdb->query( $sql ); } } else { $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET pre_approve = '$pre_approve' WHERE registration_id ='" . $registration_id . "'"; $wpdb->query( $sql ); } } else { $pre_approve = 0; } if ( $pre_approve == "0" ) { if ( count($registration_ids) > 0 ) { $reg_attendees = array(); foreach($registration_ids as $reg_id) { $SQL = 'SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE registration_id =%s'; $more_reg_attendees = $wpdb->get_results( $wpdb->prepare( $SQL, $reg_id['registration_id'] ), 'OBJECT_K' ); foreach ( $more_reg_attendees as $another_reg_attendee ) { $reg_attendees[ $another_reg_attendee->email ] = $another_reg_attendee; } } foreach ( $reg_attendees as $reg_attendee ){ event_espresso_send_invoice( $reg_attendee->registration_id, $_REQUEST[ 'invoice_subject' ], $_REQUEST[ 'invoice_message' ] ); } } else { event_espresso_send_invoice( $registration_id , $_REQUEST[ 'invoice_subject' ], $_REQUEST[ 'invoice_message' ] ); } echo '
'.__('Invoice Sent', 'event_espresso').'
.