Merge pull request #287 from totten/givi
[civicrm-core.git] / CRM / Batch / Form / Entry.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35
36 /**
37 * This class provides the functionality for batch entry for contributions/memeberships
38 */
39 class CRM_Batch_Form_Entry extends CRM_Core_Form {
40
41 /**
42 * maximum profile fields that will be displayed
43 *
44 */
45 protected $_rowCount = 1;
46
47 /**
48 * Batch id
49 */
50 protected $_batchId;
51
52 /**
53 * Batch informtaion
54 */
55 protected $_batchInfo = array();
56
57 /**
58 * store the profile id associated with the batch type
59 */
60 protected $_profileId;
61
62 public $_action;
63
64 public $_mode;
65
66 public $_params;
67
68 public $_membershipId = null;
69 /**
70 * when not to reset sort_name
71 */
72 protected $_preserveDefault = TRUE;
73
74 /**
75 * Contact fields
76 */
77 protected $_contactFields = array();
78
79 /**
80 * build all the data structures needed to build the form
81 *
82 * @return void
83 * @access public
84 */
85 function preProcess() {
86 $this->_batchId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
87
88 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
89
90 if (empty($this->_batchInfo)) {
91 $params = array('id' => $this->_batchId);
92 CRM_Batch_BAO_Batch::retrieve($params, $this->_batchInfo);
93
94 $this->assign('batchTotal', $this->_batchInfo['total']);
95 $this->assign('batchType', $this->_batchInfo['type_id']);
96
97 // get the profile id associted with this batch type
98 $this->_profileId = CRM_Batch_BAO_Batch::getProfileId($this->_batchInfo['type_id']);
99 }
100 }
101
102 /**
103 * Build the form
104 *
105 * @access public
106 *
107 * @return void
108 */
109 function buildQuickForm() {
110 if (!$this->_profileId) {
111 CRM_Core_Error::fatal(ts('Profile for bulk data entry is missing.'));
112 }
113
114 $this->addElement('hidden', 'batch_id', $this->_batchId);
115
116 // get the profile information
117 if ($this->_batchInfo['type_id'] == 1) {
118 CRM_Utils_System::setTitle(ts('Batch Data Entry for Contributions'));
119 $customFields = CRM_Core_BAO_CustomField::getFields('Contribution');
120 }
121 else {
122 CRM_Utils_System::setTitle(ts('Batch Data Entry for Memberships'));
123 $customFields = CRM_Core_BAO_CustomField::getFields('Membership');
124 }
125
126 $this->_fields = array();
127 $this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, CRM_Core_Action::VIEW);
128
129 // remove file type field and then limit fields
130 $suppressFields = FALSE;
131 $removehtmlTypes = array('File', 'Autocomplete-Select');
132 foreach ($this->_fields as $name => $field) {
133 if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
134 in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
135 ) {
136 $suppressFields = TRUE;
137 unset($this->_fields[$name]);
138 }
139
140 //fix to reduce size as we are using this field in grid
141 if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
142 //shrink class to "form-text-medium"
143 $this->_fields[$name]['attributes']['size'] = 19;
144 }
145 }
146
147 $this->addFormRule(array('CRM_Batch_Form_Entry', 'formRule'), $this);
148
149 // add the force save button
150 $forceSave = $this->getButtonName('upload', 'force');
151
152 $this->addElement('submit',
153 $forceSave,
154 ts('Ignore Mismatch & Process the Batch?')
155 );
156
157 $this->addButtons(array(
158 array(
159 'type' => 'upload',
160 'name' => ts('Validate & Process the Batch'),
161 'isDefault' => TRUE
162 ),
163 array(
164 'type' => 'cancel',
165 'name' => ts('Save & Continue Later'),
166 )
167 )
168 );
169
170 $this->assign('rowCount', $this->_batchInfo['item_count'] + 1);
171
172 $fileFieldExists = FALSE;
173 $preserveDefaultsArray = array(
174 'first_name', 'last_name', 'middle_name',
175 'organization_name',
176 'household_name',
177 );
178
179 $contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
180 for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
181 CRM_Contact_Form_NewContact::buildQuickForm($this, $rowNumber, NULL, TRUE, 'primary_');
182
183 // special field specific to membership batch udpate
184 if ($this->_batchInfo['type_id'] == 2) {
185 $options = array(
186 1 => ts('Add Membership'),
187 2 => ts('Renew Membership'),
188 );
189 $this->add('select', "member_option[$rowNumber]", '', $options);
190 }
191
192 foreach ($this->_fields as $name => $field) {
193 if (in_array($field['field_type'], $contactTypes)) {
194 $this->_contactFields[$field['name']] = 1;
195 }
196 CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, NULL, FALSE, FALSE, $rowNumber);
197
198 if (in_array($field['name'], $preserveDefaultsArray)) {
199 $this->_preserveDefault = FALSE;
200 }
201 }
202 }
203
204 $this->assign('fields', $this->_fields);
205 $this->assign('contactFields', $this->_contactFields);
206
207 // don't set the status message when form is submitted.
208 $buttonName = $this->controller->getButtonName('submit');
209
210 if ($suppressFields && $buttonName != '_qf_Entry_next') {
211 CRM_Core_Session::setStatus(ts("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update."), ts("Some fields have been excluded."), "info");
212 }
213 }
214
215 /**
216 * form validations
217 *
218 * @param array $params posted values of the form
219 * @param array $files list of errors to be posted back to the form
220 * @param array $self form object
221 *
222 * @return array list of errors to be posted back to the form
223 * @static
224 * @access public
225 */
226 static function formRule($params, $files, $self) {
227 $errors = array();
228
229 if (CRM_Utils_Array::value('_qf_Entry_upload_force', $params)) {
230 return TRUE;
231 }
232
233 $batchTotal = 0;
234 foreach ($params['field'] as $key => $value) {
235 $batchTotal += $value['total_amount'];
236
237 //membership type is required for membership batch entry
238 if ( $self->_batchInfo['type_id'] == 2 ) {
239 if ( !CRM_Utils_Array::value( 1, $value['membership_type'] ) ) {
240 $errors["field[$key][membership_type]"] = ts('Membership type is a required field.');
241 }
242 }
243 }
244
245 if ($batchTotal != $self->_batchInfo['total']) {
246 $self->assign('batchAmountMismatch', TRUE);
247 $errors['_qf_defaults'] = ts('Total for amounts entered below does not match the expected batch total.');
248 }
249
250 if (!empty($errors)) {
251 return $errors;
252 }
253
254 $self->assign('batchAmountMismatch', FALSE);
255 return TRUE;
256 }
257
258 /**
259 * Override default cancel action
260 */
261 function cancelAction() {
262 // redirect to batch listing
263 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/batch', 'reset=1'));
264 CRM_Utils_System::civiExit();
265 }
266
267 /**
268 * This function sets the default values for the form.
269 *
270 * @access public
271 *
272 * @return None
273 */
274 function setDefaultValues() {
275 if (empty($this->_fields)) {
276 return;
277 }
278
279 // for add mode set smart defaults
280 if ( $this->_action & CRM_Core_Action::ADD ) {
281 list( $currentDate, $currentTime ) = CRM_Utils_Date::setDateDefaults( NULL, 'activityDateTime' );
282
283 //get all status
284 $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
285 $completeStatus = array_search( 'Completed', $allStatus );
286 $specialFields = array(
287 'join_date' => $currentDate,
288 'receive_date' => $currentDate,
289 'receive_date_time' => $currentTime,
290 'contribution_status_id' => $completeStatus
291 );
292
293 for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
294 foreach ($specialFields as $key => $value ) {
295 $defaults['field'][$rowNumber][$key] = $value;
296 }
297 }
298 }
299 else {
300 // get the existing batch values from cache table
301 $cacheKeyString = CRM_Batch_BAO_Batch::getCacheKeyForBatch($this->_batchId);
302 $defaults = CRM_Core_BAO_Cache::getItem('batch entry', $cacheKeyString);
303 }
304 return $defaults;
305 }
306
307 /**
308 * process the form after the input has been submitted and validated
309 *
310 * @access public
311 *
312 * @return None
313 */
314 public function postProcess() {
315 $params = $this->controller->exportValues($this->_name);
316
317 $params['actualBatchTotal'] = 0;
318
319 // get the profile information
320 if ($this->_batchInfo['type_id'] == 1) {
321 $this->processContribution($params);
322 }
323 else {
324 $this->processMembership($params);
325 }
326
327 // update batch to close status
328 $paramValues = array(
329 'id' => $this->_batchId,
330 // close status
331 'status_id' => 2,
332 'total' => $params['actualBatchTotal'],
333 );
334
335 CRM_Batch_BAO_Batch::create($paramValues);
336
337 // delete from cache table
338 $cacheKeyString = CRM_Batch_BAO_Batch::getCacheKeyForBatch($this->_batchId);
339 CRM_Core_BAO_Cache::deleteGroup('batch entry', $cacheKeyString, FALSE);
340
341 // set success status
342 CRM_Core_Session::setStatus("", ts("Batch Processed."), "success");
343
344 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/batch', 'reset=1'));
345 }
346
347 /**
348 * process contribution records
349 *
350 * @param array $params associated array of submitted values
351 *
352 * @access public
353 *
354 * @return None
355 */
356 private function processContribution(&$params) {
357 $dates = array(
358 'receive_date',
359 'receipt_date',
360 'thankyou_date',
361 'cancel_date',
362 );
363
364 // get the price set associated with offline contribution record.
365 $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
366 $this->_priceSet = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
367 $fieldID = key($this->_priceSet['fields']);
368
369 $assetRelation = key(CRM_CORE_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
370
371 if (isset($params['field'])) {
372 foreach ($params['field'] as $key => $value) {
373 // if contact is not selected we should skip the row
374 if (!CRM_Utils_Array::value($key, $params['primary_contact_select_id'])) {
375 continue;
376 }
377
378 $value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_select_id']);
379
380 // update contact information
381 $this->updateContactInfo($value);
382
383 // handle soft credit
384 if (CRM_Utils_Array::value('soft_credit_contact_select_id', $params) && CRM_Utils_Array::value($key, $params['soft_credit_contact_select_id'])) {
385 $value['soft_credit_to'] = $params['soft_credit_contact_select_id'][$key];
386 }
387
388 $value['custom'] = CRM_Core_BAO_CustomField::postProcess($value,
389 CRM_Core_DAO::$_nullObject,
390 NULL,
391 'Contribution'
392 );
393
394 foreach ($dates as $val) {
395 if ( CRM_Utils_Array::value( $val, $value ) ) {
396 $value[$val] = CRM_Utils_Date::processDate( $value[$val], $value[$val . '_time'], TRUE );
397 }
398 }
399
400 if (CRM_Utils_Array::value('send_receipt', $value)) {
401 $value['receipt_date'] = date('Y-m-d His');
402 }
403
404 if ($value['financial_type']) {
405 $value['financial_type_id'] = $value['financial_type'];
406 }
407
408 if (CRM_Utils_Array::value('payment_instrument', $value)) {
409 $value['payment_instrument_id'] = $value['payment_instrument'];
410 }
411
412 if (CRM_Utils_Array::value('contribution_source', $value)) {
413 $value['source'] = $value['contribution_source'];
414 }
415
416 if (CRM_Utils_Array::value('contribution_note', $value)) {
417 $value['note'] = $value['contribution_note'];
418 }
419
420 $params['actualBatchTotal'] += $value['total_amount'];
421
422 unset($value['contribution_note']);
423 unset($value['financial_type']);
424 unset($value['contribution_source']);
425
426 $value['batch_id'] = $this->_batchId;
427 $value['skipRecentView'] = TRUE;
428
429 // build line item params
430 $this->_priceSet['fields'][$fieldID]['options'][$fieldID]['amount'] = $value['total_amount'];
431 $value['price_'.$fieldID] = 1;
432
433 $lineItem = array();
434 CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
435
436 //unset amount level since we always use quick config price set
437 unset($value['amount_level']);
438
439 //CRM-11529 for backoffice transactions
440 //when financial_type_id is passed in form, update the
441 //lineitems with the financial type selected in form
442 if (CRM_Utils_Array::value('financial_type_id', $value) && CRM_Utils_Array::value($priceSetId, $lineItem)) {
443 foreach ($lineItem[$priceSetId] as &$values) {
444 $values['financial_type_id'] = $value['financial_type_id'];
445 }
446 }
447 $value['line_item'] = $lineItem;
448
449 //finally call contribution create for all the magic
450 $contribution = CRM_Contribute_BAO_Contribution::create($value, CRM_Core_DAO::$_nullArray);
451
452 //process premiums
453 if (CRM_Utils_Array::value('product_name', $value)) {
454 if ($value['product_name'][0] > 0) {
455 list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
456
457 $value['hidden_Premium'] = 1;
458 $value['product_option'] = CRM_Utils_Array::value(
459 $value['product_name'][1],
460 $options[$value['product_name'][0]]
461 );
462
463 $premiumParams = array(
464 'product_id' => $value['product_name'][0],
465 'contribution_id' => $contribution->id,
466 'product_option' => $value['product_option'],
467 'quantity' => 1,
468 );
469 CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
470 }
471 }
472 // end of premium
473
474 //send receipt mail.
475 if ( $contribution->id &&
476 CRM_Utils_Array::value( 'send_receipt', $value ) ) {
477 // add the domain email id
478 $domainEmail = CRM_Core_BAO_Domain::getNameAndEmail();
479 $domainEmail = "$domainEmail[0] <$domainEmail[1]>";
480
481 $value['from_email_address'] = $domainEmail;
482 $value['contribution_id'] = $contribution->id;
483 CRM_Contribute_Form_AdditionalInfo::emailReceipt( $this, $value );
484 }
485 }
486 }
487 }
488 //end of function
489
490 /**
491 * process membership records
492 *
493 * @param array $params associated array of submitted values
494 *
495 * @access public
496 *
497 * @return None
498 */
499 private function processMembership(&$params) {
500 $dateTypes = array(
501 'join_date' => 'joinDate',
502 'membership_start_date' => 'startDate',
503 'membership_end_date' => 'endDate'
504 );
505
506 $dates = array(
507 'join_date',
508 'start_date',
509 'end_date',
510 'reminder_date'
511 );
512
513 // get the price set associated with offline memebership
514 $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_membership_type_amount', 'id', 'name');
515 $this->_priceSet = $priceSets = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
516
517 if (isset($params['field'])) {
518 $customFields = array();
519 foreach ($params['field'] as $key => $value) {
520 // if contact is not selected we should skip the row
521 if (!CRM_Utils_Array::value($key, $params['primary_contact_select_id'])) {
522 continue;
523 }
524
525 $value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_select_id']);
526
527 // update contact information
528 $this->updateContactInfo($value);
529
530 $membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
531
532 foreach ($dateTypes as $dateField => $dateVariable) {
533 $$dateVariable = CRM_Utils_Date::processDate($value[$dateField]);
534 }
535
536 $calcDates = array();
537 $calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId,
538 $joinDate, $startDate, $endDate
539 );
540
541 foreach ($calcDates as $memType => $calcDate) {
542 foreach ($dates as $d) {
543 //first give priority to form values then calDates.
544 $date = CRM_Utils_Array::value($d, $value);
545 if (!$date) {
546 $date = CRM_Utils_Array::value($d, $calcDate);
547 }
548
549 $value[$d] = CRM_Utils_Date::processDate($date);
550 }
551 }
552
553 if (CRM_Utils_Array::value('send_receipt', $value)) {
554 $value['receipt_date'] = date('Y-m-d His');
555 }
556
557 if (CRM_Utils_Array::value('membership_source', $value)) {
558 $value['source'] = $value['membership_source'];
559 }
560
561 unset($value['membership_source']);
562
563 //Get the membership status
564 if ( CRM_Utils_Array::value('membership_status', $value) ) {
565 $value['status_id'] = $value['membership_status'];
566 unset($value['membership_status']);
567 }
568
569 if (empty($customFields)) {
570 // membership type custom data
571 $customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
572
573 $customFields = CRM_Utils_Array::crmArrayMerge($customFields,
574 CRM_Core_BAO_CustomField::getFields('Membership',
575 FALSE, FALSE, NULL, NULL, TRUE
576 )
577 );
578 }
579
580 //check for custom data
581 $value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key],
582 $customFields,
583 $key,
584 'Membership',
585 $membershipTypeId
586 );
587
588 if (CRM_Utils_Array::value('financial_type', $value)) {
589 $value['financial_type_id'] = $value['financial_type'];
590 }
591
592 if (CRM_Utils_Array::value('payment_instrument', $value)) {
593 $value['payment_instrument_id'] = $value['payment_instrument'];
594 }
595
596 // handle soft credit
597 if (CRM_Utils_Array::value('soft_credit_contact_select_id', $params) && CRM_Utils_Array::value($key, $params['soft_credit_contact_select_id'])) {
598 $value['soft_credit_to'] = $params['soft_credit_contact_select_id'][$key];
599 }
600
601 if ( CRM_Utils_Array::value('receive_date', $value) ) {
602 $value['receive_date'] = CRM_Utils_Date::processDate( $value['receive_date'], $value['receive_date_time'] , TRUE );
603 }
604
605 $params['actualBatchTotal'] += $value['total_amount'];
606
607 unset($value['financial_type']);
608 unset($value['payment_instrument']);
609
610 $value['batch_id'] = $this->_batchId;
611 $value['skipRecentView'] = TRUE;
612
613 // make entry in line item for contribution
614
615 $editedFieldParams = array(
616 'price_set_id' => $priceSetId,
617 'name' => $value['membership_type'][0]
618 );
619
620 $editedResults = array();
621 CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
622
623 if (!empty($editedResults)) {
624 unset($this->_priceSet['fields']);
625 $this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
626 unset($this->_priceSet['fields'][$editedResults['id']]['options']);
627 $fid = $editedResults['id'];
628 $editedFieldParams = array(
629 'price_field_id' => $editedResults['id'],
630 'membership_type_id' => $value['membership_type_id']
631 );
632
633 $editedResults = array();
634 CRM_Price_BAO_FieldValue::retrieve($editedFieldParams, $editedResults);
635 $this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
636 if (CRM_Utils_Array::value('total_amount', $value)) {
637 $this->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $value['total_amount'];
638 }
639
640 $fieldID = key($this->_priceSet['fields']);
641 $value['price_' . $fieldID] = $editedResults['id'];
642
643 $lineItem = array();
644 CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'],
645 $value, $lineItem[$priceSetId]
646 );
647
648 //CRM-11529 for backoffice transactions
649 //when financial_type_id is passed in form, update the
650 //lineitems with the financial type selected in form
651 if (CRM_Utils_Array::value('financial_type_id', $value) && CRM_Utils_Array::value($priceSetId, $lineItem)) {
652 foreach ($lineItem[$priceSetId] as &$values) {
653 $values['financial_type_id'] = $value['financial_type_id'];
654 }
655 }
656
657 $value['lineItems'] = $lineItem;
658 $value['processPriceSet'] = TRUE;
659 }
660 // end of contribution related section
661
662 unset($value['membership_type']);
663 unset($value['membership_start_date']);
664 unset($value['membership_end_date']);
665
666 $value['is_renew'] = false;
667 if ( CRM_Utils_Array::value('member_option', $params) && CRM_Utils_Array::value( $key, $params['member_option'] ) == 2 ) {
668 $this->_params = $params;
669 $value['is_renew'] = true;
670 $membership = CRM_Member_BAO_Membership::renewMembership(
671 $value['contact_id'],
672 $value['membership_type_id'],
673 FALSE, $this, NULL, NULL,
674 $value['custom']
675 );
676
677 // make contribution entry
678 CRM_Member_BAO_Membership::recordMembershipContribution( $value, CRM_Core_DAO::$_nullArray, $membership->id );
679 }
680 else {
681 $membership = CRM_Member_BAO_Membership::create($value, CRM_Core_DAO::$_nullArray);
682 }
683
684 //process premiums
685 if (CRM_Utils_Array::value('product_name', $value)) {
686 if ($value['product_name'][0] > 0) {
687 list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
688
689 $value['hidden_Premium'] = 1;
690 $value['product_option'] = CRM_Utils_Array::value(
691 $value['product_name'][1],
692 $options[$value['product_name'][0]]
693 );
694
695 $premiumParams = array(
696 'product_id' => $value['product_name'][0],
697 'contribution_id' => $value['contribution_id'],
698 'product_option' => $value['product_option'],
699 'quantity' => 1,
700 );
701 CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
702 }
703 }
704 // end of premium
705
706 //send receipt mail.
707 if ( $membership->id &&
708 CRM_Utils_Array::value( 'send_receipt', $value ) ) {
709
710 // add the domain email id
711 $domainEmail = CRM_Core_BAO_Domain::getNameAndEmail();
712 $domainEmail = "$domainEmail[0] <$domainEmail[1]>";
713
714 $value['from_email_address'] = $domainEmail;
715 $value['membership_id'] = $membership->id;
716 CRM_Member_Form_Membership::emailReceipt( $this, $value, $membership );
717 }
718 }
719 }
720 }
721
722 /**
723 * update contact information
724 *
725 * @param array $value associated array of submitted values
726 *
727 * @access public
728 *
729 * @return None
730 */
731 private function updateContactInfo(&$value) {
732 $value['preserveDBName'] = $this->_preserveDefault;
733
734 //parse street address, CRM-7768
735 CRM_Contact_Form_Task_Batch::parseStreetAddress($value, $this);
736
737 CRM_Contact_BAO_Contact::createProfileContact($value, $this->_fields,
738 $value['contact_id']
739 );
740 }
741 }
742