From 6521e09079933072ff2d473bb781578e7116c692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20G=C3=A5rdenberg?= Date: Thu, 19 Jan 2017 15:59:26 +0100 Subject: [PATCH] It is now possible to book a single participant. --- CHANGELOG.md | 14 +- .../__bookMultipleParticipants.php | 2 +- .../__bookSingleParticipant.php | 130 +++--------------- .../bookingTemplate/createBooking.php | 29 +--- .../bookingTemplate/singlePersonBooking.php | 53 +++++-- .../listTemplate/template_A_listCourses.php | 7 +- 6 files changed, 86 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb9ff331..00a2e9c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,21 @@ ## [Unreleased] ### Added + + +## [0.9.15] +### Added - Added `singlePersonBooking.php` to handle when the participant is customer, contact and participant. - Added `__bookSingleParticipant.php` and `__bookMultipleParticipants.php` to handle different settings. - Fixing `frontend.js` to work with single participant-settings. - +- Switched to openssl_encrypt/decrypt since mcrypt is deprecated +- Added class name to dates, so you can style them yourself +- Added span around venue name, so you can style it, if you want to - Adding support to load existing attribute data to customer and contact, when loading the booking form. (Would be bad if we emptied it..) +### Removed +- `getallheaders` is now gone, forever. + ## [0.9.14] ### Added - Attributes can now be saved on customers, contacts and participants (person) (Only multiple participants currently) @@ -101,7 +110,8 @@ - Added inquiry support in course -[Unreleased]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.14...HEAD +[Unreleased]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.15...HEAD +[0.9.15]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.14...v0.9.15 [0.9.14]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.13...v0.9.14 [0.9.13]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.12...v0.9.13 [0.9.12]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.11...v0.9.12 diff --git a/content/template/bookingTemplate/__bookMultipleParticipants.php b/content/template/bookingTemplate/__bookMultipleParticipants.php index b556d0eb..9a273c5a 100644 --- a/content/template/bookingTemplate/__bookMultipleParticipants.php +++ b/content/template/bookingTemplate/__bookMultipleParticipants.php @@ -590,7 +590,7 @@ $eduapi->SetEventCustomerAnswerV2($edutoken, $sanswers); } - $ai = $eduapi->GetAccountInfo($edutoken); + $ai = $eduapi->GetAccountInfo($edutoken)[0]; $senderEmail = $ai->Email; if(empty($senderEmail)) { diff --git a/content/template/bookingTemplate/__bookSingleParticipant.php b/content/template/bookingTemplate/__bookSingleParticipant.php index b556d0eb..ac905a51 100644 --- a/content/template/bookingTemplate/__bookSingleParticipant.php +++ b/content/template/bookingTemplate/__bookSingleParticipant.php @@ -1,22 +1,22 @@ CustomerName = trim($_POST['customerName']); +$customer->CustomerName = trim($_POST['contactFirstName'] . " " . $_POST["contactLastName"]); $customer->CustomerGroupID = get_option('eduadmin-customerGroupId', NULL); -$customer->InvoiceOrgnr = trim($_POST['customerVatNo']); +if(isset($_POST['contactCivRegNr'])) + $customer->InvoiceOrgnr = trim($_POST['contactCivRegNr']); $customer->Address1 = trim($_POST['customerAddress1']); $customer->Address2 = trim($_POST['customerAddress2']); $customer->Zip = trim($_POST['customerPostalCode']); $customer->City = trim($_POST['customerPostalCity']); -$customer->Email = trim($_POST['customerEmail']); -$customer->CustomerReference = trim($_POST['invoiceReference']); - -$purchaseOrderNumber = trim($_POST['purchaseOrderNumber']); +$customer->Phone = trim($_POST['contactPhone']); +$customer->Mobile = trim($_POST['contactMobile']); +$customer->Email = trim($_POST['contactEmail']); $customerInvoiceEmailAddress = trim($_POST['invoiceEmail']); if(!isset($_POST['alsoInvoiceCustomer'])) { - $customer->InvoiceName = trim($_POST['customerName']); + $customer->InvoiceName = trim($_POST['contactFirstName'] . " " . $_POST["contactLastName"]); $customer->InvoiceAddress1 = trim($_POST['customerAddress1']); $customer->InvoiceAddress2 = trim($_POST['customerAddress2']); $customer->InvoiceZip = trim($_POST['customerPostalCode']); @@ -340,107 +340,7 @@ $fo->AddItem($f); $personAttributes = $eduapi->GetAttribute($edutoken, $so->ToString(), $fo->ToString()); -foreach($_POST['participantFirstName'] as $key => $value) -{ - if($key == "0") - { - continue; - } - - if(!empty($_POST['participantFirstName'][$key])) - { - $person = new SubEventPerson(); - $person->CustomerID = $customer->CustomerID; - $person->PersonName = trim($_POST['participantFirstName'][$key]) . ";" . trim($_POST['participantLastName'][$key]); - $person->PersonEmail = trim($_POST['participantEmail'][$key]); - $person->PersonPhone = trim($_POST['participantPhone'][$key]); - $person->PersonMobile = trim($_POST['participantMobile'][$key]); - - $ft = new XFiltering(); - $f = new XFilter('CustomerID', '=', $customer->CustomerID); - $ft->AddItem($f); - $f = new XFilter('PersonName', '=', trim(str_replace(';', ' ', $person->PersonName))); - $ft->AddItem($f); - $f = new XFilter('PersonEmail', '=', $person->PersonEmail); - $ft->AddItem($f); - $matchingPersons = $eduapi->GetPerson($edutoken, '', $ft->ToString(), false); - if(!empty($matchingPersons)) - { - $person = $matchingPersons[0]; - } - - $cmpArr = array(); - - foreach($personAttributes as $attr) - { - $fieldId = "edu-attr_" . $attr->AttributeID; - if(isset($_POST[$fieldId][$key])) - { - $at = new Attribute(); - $at->AttributeID = $attr->AttributeID; - - switch($attr->AttributeTypeID) - { - case 1: - //$at->AttributeChecked = true; - break; - case 5: - $alt = new AttributeAlternative(); - $alt->AttributeAlternativeID = $_POST[$fieldId][$key]; - $at->AttributeAlternative[] = $alt; - break; - default: - $at->AttributeValue = $_POST[$fieldId][$key]; - break; - } - - $cmpArr[] = $at; - } - } - - $person->Attribute = $cmpArr; - - $person->PersonEmail = trim($_POST['participantEmail'][$key]); - $person->PersonPhone = trim($_POST['participantPhone'][$key]); - $person->PersonMobile = trim($_POST['participantMobile'][$key]); - - if(isset($_POST['participantCivReg'][$key])) - { - $person->PersonCivicRegistrationNumber = trim($_POST['participantCivReg'][$key]); - } - - if(isset($_POST['participantPriceName'][$key])) - { - $person->OccasionPriceNameLnkID = trim($_POST['participantPriceName'][$key]); - } - - foreach($subEvents as $subEvent) - { - $fieldName = "participantSubEvent_" . $subEvent->EventID; - if(isset($_POST[$fieldName][$key])) - { - $fieldValue = $_POST[$fieldName][$key]; - $subEventInfo = new SubEventInfo(); - $subEventInfo->EventID = $fieldValue; - $person->SubEvents[] = $subEventInfo; - } - else if($subEvent->MandatoryParticipation) { - $subEventInfo = new SubEventInfo(); - $subEventInfo->EventID = $subEvent->EventID; - $person->SubEvents[] = $subEventInfo; - } - } - - $pArr[] = $person; - - if(!empty($person->PersonEmail) && !in_array($person->PersonEmail, $personEmail)) - { - $personEmail[] = $person->PersonEmail; - } - } -} - -if(isset($_POST['contactIsAlsoParticipant']) && $contact->CustomerContactID > 0) +if($contact->CustomerContactID > 0) { $person = new SubEventPerson(); $person->CustomerID = $customer->CustomerID; @@ -529,7 +429,8 @@ $bi->CustomerID = $customer->CustomerID; $bi->CustomerContactID = $contact->CustomerContactID; $bi->SubEventPersons = $pArr; - $bi->PurchaseOrderNumber = $purchaseOrderNumber; + if(isset($purchaseOrderNumber)) + $bi->PurchaseOrderNumber = $purchaseOrderNumber; if(isset($_POST['edu-pricename'])) { $bi->OccasionPriceNameLnkID = $_POST['edu-pricename']; @@ -590,7 +491,8 @@ $eduapi->SetEventCustomerAnswerV2($edutoken, $sanswers); } - $ai = $eduapi->GetAccountInfo($edutoken); + $ai = $eduapi->GetAccountInfo($edutoken)[0]; + //print_r($ai); $senderEmail = $ai->Email; if(empty($senderEmail)) { @@ -603,14 +505,18 @@ $_SESSION['eduadmin-printJS'] = true; - $user = $_SESSION['eduadmin-loginUser']; + if(isset($_SESSION['eduadmin-loginUser'])) + $user = $_SESSION['eduadmin-loginUser']; + else + $user = new stdClass; + $jsEncContact = json_encode($contact); @$user->Contact = json_decode($jsEncContact); $jsEncCustomer = json_encode($customer); @$user->Customer = json_decode($jsEncCustomer); $_SESSION['eduadmin-loginUser'] = $user; - + //die(); die(""); } ?> \ No newline at end of file diff --git a/content/template/bookingTemplate/createBooking.php b/content/template/bookingTemplate/createBooking.php index 3796ca15..34651c17 100644 --- a/content/template/bookingTemplate/createBooking.php +++ b/content/template/bookingTemplate/createBooking.php @@ -1,30 +1,11 @@ \ No newline at end of file diff --git a/content/template/bookingTemplate/singlePersonBooking.php b/content/template/bookingTemplate/singlePersonBooking.php index 7da51d97..0e30268a 100644 --- a/content/template/bookingTemplate/singlePersonBooking.php +++ b/content/template/bookingTemplate/singlePersonBooking.php @@ -93,13 +93,7 @@ - +
+ + +
+
+ 0) { + echo "

" . edu__("Sub events") . "

\n"; + foreach($subEvents as $subEvent) + { + if(count($sePrice[$subEvent->OccasionID]) > 0) { + $s = current($sePrice[$subEvent->OccasionID])->Price; + } else { + $s = 0; + } + // PriceNameVat + echo "\n"; + } + echo "
"; + } + ?> +

\ No newline at end of file diff --git a/content/template/listTemplate/template_A_listCourses.php b/content/template/listTemplate/template_A_listCourses.php index 84d2e7a5..f99eb5f7 100644 --- a/content/template/listTemplate/template_A_listCourses.php +++ b/content/template/listTemplate/template_A_listCourses.php @@ -358,9 +358,12 @@ foreach($pricenames as $pr) { - if($object->ObjectID == $pr->ObjectID) + if(isset($object->ObjectID) && isset($pr->ObjectID)) { - $prices[$pr->Price] = $pr; + if($object->ObjectID == $pr->ObjectID) + { + $prices[$pr->Price] = $pr; + } } }