Skip to content

Commit

Permalink
It is now possible to book a single participant.
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimple committed Jan 19, 2017
1 parent 2607c0c commit 6521e09
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 149 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
$eduapi->SetEventCustomerAnswerV2($edutoken, $sanswers);
}

$ai = $eduapi->GetAccountInfo($edutoken);
$ai = $eduapi->GetAccountInfo($edutoken)[0];
$senderEmail = $ai->Email;
if(empty($senderEmail))
{
Expand Down
130 changes: 18 additions & 112 deletions content/template/bookingTemplate/__bookSingleParticipant.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
$customer = new CustomerV2();
$customer->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']);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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))
{
Expand All @@ -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("<script type=\"text/javascript\">location.href = '" . get_page_link(get_option('eduadmin-thankYouPage','/')) . "?edu-thankyou=" . $eventCustomerLnkID . "';</script>");
}
?>
29 changes: 5 additions & 24 deletions content/template/bookingTemplate/createBooking.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
<?php
$eventId = $_REQUEST['eid'];
$requiredFields = array();
$requiredFields[] = 'customerName';

$missingFields = false;
foreach($requiredFields as $field)
{
if(empty($_REQUEST[$field]))
{
$missingFields = true;
}
$singlePersonBooking = get_option('eduadmin-singlePersonBooking', false);
if($singlePersonBooking) {
include_once("__bookSingleParticipant.php");
} else {
include_once("__bookMultipleParticipants.php");
}

if($missingFields)
{
// TODO: Show an error message that some fields are missing
// Should not be able to happen, since we should validate the fields first
// And then we'd have to go through the trouble to recreate all participants.
}
else
{
$singlePersonBooking = get_option('eduadmin-singlePersonBooking', false);
if($singlePersonBooking) {
include_once("__bookSingleParticipant.php");
} else {
include_once("__bookMultipleParticipants.php");
}
}
?>
53 changes: 45 additions & 8 deletions content/template/bookingTemplate/singlePersonBooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@
</div>
</label>

<label>
<div class="inputHolder alsoInvoiceCustomer">
<input type="checkbox" id="alsoInvoiceCustomer" name="alsoInvoiceCustomer" value="true" onchange="eduBookingView.UpdateInvoiceCustomer();" />
<label class="inline-checkbox" for="alsoInvoiceCustomer"></label>
<?php edu_e("Use other information for invoicing"); ?>
</div>
</label>

</div>
<div id="invoiceView" class="invoiceView" style="display: none;">
<h2><?php edu_e("Invoice information"); ?></h2>
Expand Down Expand Up @@ -145,6 +139,22 @@
</label>
</div>
<br />
<label>
<div class="inputLabel">
<?php edu_e("Invoice e-mail address"); ?>
</div>
<div class="inputHolder">
<input type="text" name="invoiceEmail" placeholder="<?php edu_e("Invoice e-mail address"); ?>" value="<?php echo @esc_attr($customerInvoiceEmail); ?>" />
</div>
</label>
<label>
<div class="inputHolder alsoInvoiceCustomer">
<input type="checkbox" id="alsoInvoiceCustomer" name="alsoInvoiceCustomer" value="true" onchange="eduBookingView.UpdateInvoiceCustomer();" />
<label class="inline-checkbox" for="alsoInvoiceCustomer"></label>
<?php edu_e("Use other information for invoicing"); ?>
</div>
</label>
<br />
<div class="attributeView">
<?php
$so = new XSorting();
Expand Down Expand Up @@ -272,7 +282,34 @@
}
renderAttribute($attr, false, "contact", $data);
}

?>
<div class="participantItem contactPerson">
<?php
if(count($subEvents) > 0) {
echo "<h4>" . edu__("Sub events") . "</h4>\n";
foreach($subEvents as $subEvent)
{
if(count($sePrice[$subEvent->OccasionID]) > 0) {
$s = current($sePrice[$subEvent->OccasionID])->Price;
} else {
$s = 0;
}
// PriceNameVat
echo "<label>".
"<input class=\"subEventCheckBox\" data-price=\"" . $s . "\" onchange=\"eduBookingView.UpdatePrice();\" " .
"name=\"contactSubEvent_" . $subEvent->EventID . "\" " .
"type=\"checkbox\"" .
($subEvent->SelectedByDefault == true || $subEvent->MandatoryParticipation == true ? " checked=\"checked\"" : "") .
($subEvent->MandatoryParticipation == true ? " disabled=\"disabled\"" : "") .
" value=\"" . $subEvent->EventID . "\"> " .
$subEvent->Description .
($hideSubEventDateInfo ? "" : " (" . date("d/m H:i", strtotime($subEvent->StartDate)) . " - " . date("d/m H:i", strtotime($subEvent->EndDate)) . ") ") .
($s > 0 ? " <i class=\"priceLabel\">" . convertToMoney($s) . "</i>" : "") .
"</label>\n";
}
echo "<br />";
}
?>
</div>
</div>
<br />
7 changes: 5 additions & 2 deletions content/template/listTemplate/template_A_listCourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 6521e09

Please sign in to comment.