Skip to content

Commit 3e1edb1

Browse files
author
Chris Gårdenberg
committed
New version
1 parent 490b241 commit 3e1edb1

5 files changed

Lines changed: 114 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- Added `__bookSingleParticipant.php` and `__bookMultipleParticipants.php` to handle different settings.
77
- Fixing `frontend.js` to work with single participant-settings.
88

9+
## [0.9.14]
10+
### Added
11+
- Attributes can now be saved on customers, contacts and participants (person) (Only multiple participants currently)
912

1013
## [0.9.13]
1114
### Added
@@ -96,7 +99,8 @@
9699
- Added inquiry support in course
97100

98101

99-
[Unreleased]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.13...HEAD
102+
[Unreleased]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.14...HEAD
103+
[0.9.14]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.13...v0.9.14
100104
[0.9.13]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.12...v0.9.13
101105
[0.9.12]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.11...v0.9.12
102106
[0.9.11]: https://github.com/MultinetInteractive/EduAdmin-WordPress/compare/v0.9.10...v0.9.11

content/template/bookingTemplate/__bookMultipleParticipants.php

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
{
173173
$at = new CustomerAttribute();
174174
$at->CustomerID = $customer->CustomerID;
175-
//$at->CustomerAttributeID = $attr->AttributeID;
176175
$at->AttributeID = $attr->AttributeID;
177176

178177
switch($attr->AttributeTypeID)
@@ -181,7 +180,9 @@
181180
$at->AttributeChecked = true;
182181
break;
183182
case 5:
184-
$at->AttributeAlternative = $_POST[$fieldId];
183+
$alt = new AttributeAlternative();
184+
$alt->AttributeAlternativeID = $_POST[$fieldId];
185+
$at->AttributeAlternative[] = $alt;
185186
break;
186187
default:
187188
$at->AttributeValue = $_POST[$fieldId];
@@ -283,8 +284,7 @@
283284
if(isset($_POST[$fieldId]))
284285
{
285286
$at = new CustomerContactAttribute();
286-
$at->CustomerID = $customer->CustomerID;
287-
//$at->CustomerAttributeID = $attr->AttributeID;
287+
$at->CustomerContactID = $contact->CustomerContactID;
288288
$at->AttributeID = $attr->AttributeID;
289289

290290
switch($attr->AttributeTypeID)
@@ -293,7 +293,9 @@
293293
$at->AttributeChecked = true;
294294
break;
295295
case 5:
296-
$at->AttributeAlternative = $_POST[$fieldId];
296+
$alt = new AttributeAlternative();
297+
$alt->AttributeAlternativeID = $_POST[$fieldId];
298+
$at->AttributeAlternative[] = $alt;
297299
break;
298300
default:
299301
$at->AttributeValue = $_POST[$fieldId];
@@ -304,7 +306,7 @@
304306
}
305307
}
306308

307-
$res = $eduapi->SetCustomerAttribute($edutoken, $cmpArr);
309+
$res = $eduapi->SetCustomerContactAttributes($edutoken, $cmpArr);
308310
}
309311

310312
$persons = array();
@@ -326,6 +328,18 @@
326328
$subEvents = $eduapi->GetSubEvent($edutoken, $st->ToString(), $ft->ToString());
327329

328330
$pArr = array();
331+
332+
$so = new XSorting();
333+
$s = new XSort('SortIndex', 'ASC');
334+
$so->AddItem($s);
335+
336+
$fo = new XFiltering();
337+
$f = new XFilter('ShowOnWeb', '=', 'true');
338+
$fo->AddItem($f);
339+
$f = new XFilter('AttributeOwnerTypeID', '=', 3);
340+
$fo->AddItem($f);
341+
$personAttributes = $eduapi->GetAttribute($edutoken, $so->ToString(), $fo->ToString());
342+
329343
foreach($_POST['participantFirstName'] as $key => $value)
330344
{
331345
if($key == "0")
@@ -342,7 +356,6 @@
342356
$person->PersonPhone = trim($_POST['participantPhone'][$key]);
343357
$person->PersonMobile = trim($_POST['participantMobile'][$key]);
344358

345-
346359
$ft = new XFiltering();
347360
$f = new XFilter('CustomerID', '=', $customer->CustomerID);
348361
$ft->AddItem($f);
@@ -356,6 +369,37 @@
356369
$person = $matchingPersons[0];
357370
}
358371

372+
$cmpArr = array();
373+
374+
foreach($personAttributes as $attr)
375+
{
376+
$fieldId = "edu-attr_" . $attr->AttributeID;
377+
if(isset($_POST[$fieldId][$key]))
378+
{
379+
$at = new Attribute();
380+
$at->AttributeID = $attr->AttributeID;
381+
382+
switch($attr->AttributeTypeID)
383+
{
384+
case 1:
385+
//$at->AttributeChecked = true;
386+
break;
387+
case 5:
388+
$alt = new AttributeAlternative();
389+
$alt->AttributeAlternativeID = $_POST[$fieldId][$key];
390+
$at->AttributeAlternative[] = $alt;
391+
break;
392+
default:
393+
$at->AttributeValue = $_POST[$fieldId][$key];
394+
break;
395+
}
396+
397+
$cmpArr[] = $at;
398+
}
399+
}
400+
401+
$person->Attribute = $cmpArr;
402+
359403
$person->PersonEmail = trim($_POST['participantEmail'][$key]);
360404
$person->PersonPhone = trim($_POST['participantPhone'][$key]);
361405
$person->PersonMobile = trim($_POST['participantMobile'][$key]);
@@ -387,8 +431,6 @@
387431
}
388432
}
389433

390-
391-
392434
$pArr[] = $person;
393435

394436
if(!empty($person->PersonEmail) && !in_array($person->PersonEmail, $personEmail))
@@ -419,6 +461,37 @@
419461
$person = $matchingPersons[0];
420462
}
421463

464+
$cmpArr = array();
465+
466+
foreach($personAttributes as $attr)
467+
{
468+
$fieldId = "edu-attr_" . $attr->AttributeID . "-contact";
469+
if(isset($_POST[$fieldId]))
470+
{
471+
$at = new Attribute();
472+
$at->AttributeID = $attr->AttributeID;
473+
474+
switch($attr->AttributeTypeID)
475+
{
476+
case 1:
477+
//$at->AttributeChecked = true;
478+
break;
479+
case 5:
480+
$alt = new AttributeAlternative();
481+
$alt->AttributeAlternativeID = $_POST[$fieldId];
482+
$at->AttributeAlternative[] = $alt;
483+
break;
484+
default:
485+
$at->AttributeValue = $_POST[$fieldId];
486+
break;
487+
}
488+
489+
$cmpArr[] = $at;
490+
}
491+
}
492+
493+
$person->Attribute = $cmpArr;
494+
422495
if(isset($_POST['contactCivReg']))
423496
{
424497
$person->PersonCivicRegistrationNumber = trim($_POST['contactCivReg']);

content/template/bookingTemplate/participantView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
foreach($contactAttributes as $attr)
6565
{
66-
renderAttribute($attr, true);
66+
renderAttribute($attr, false, "contact");
6767
}
6868

6969
?>

eduadmin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin URI: http://www.eduadmin.se
1313
* Description: EduAdmin plugin to allow visitors to book courses at your website
1414
* Tags: booking, participants, courses, events, eduadmin, lega online
15-
* Version: 0.9.13
15+
* Version: 0.9.14
1616
* Requires at least: 3.0
1717
* Tested up to: 4.7
1818
* Author: Chris Gårdenberg, MultiNet Interactive AB
@@ -79,7 +79,7 @@ function edu_call_home()
7979
'wpVersion' => $wp_version,
8080
'token' => get_option('eduadmin-api-key'),
8181
'officialVersion' => file_exists(dirname(__FILE__) . "/.official.plugin.php"),
82-
'pluginVersion' => '0.9.13'
82+
'pluginVersion' => '0.9.14'
8383
);
8484

8585
$callHomeUrl = 'http://ws10.multinet.se/edu-plugin/wp_phone_home.php';

includes/_attributeFunctions.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
<?php
2-
function renderAttribute($attribute, $multiple = false)
2+
function renderAttribute($attribute, $multiple = false, $suffix = "")
33
{
4-
return;
54
switch($attribute->AttributeTypeID)
65
{
76
case 1: // Checkbox
8-
renderCheckField($attribute, $multiple);
7+
renderCheckField($attribute, $multiple, $suffix);
98
break;
109
case 2: // Textfält
11-
renderTextField($attribute, $multiple);
10+
renderTextField($attribute, $multiple, $suffix);
1211
break;
1312
case 3: // Nummerfält
14-
renderNumberField($attribute, $multiple);
13+
renderNumberField($attribute, $multiple, $suffix);
1514
break;
1615
case 4: // Flervärdesfält
17-
//renderTextField($attribute, $multiple);
16+
//renderTextField($attribute, $multiple, $suffix);
1817
break;
1918
case 5: // Dropdownlista
20-
renderSelectField($attribute, $multiple);
19+
renderSelectField($attribute, $multiple, $suffix);
2120
break;
2221
case 6: // Anteckningsfält
23-
renderTextAreaField($attribute, $multiple);
22+
renderTextAreaField($attribute, $multiple, $suffix);
2423
break;
2524
case 7: // Datumfält
26-
//renderDateField($attribute, $multiple);
25+
//renderDateField($attribute, $multiple, $suffix);
2726
break;
2827
case 8: // HTML
29-
//renderTextAreaField($attribute, $multiple);
28+
//renderTextAreaField($attribute, $multiple, $suffix);
3029
break;
3130
case 9: // Checkboxlista
32-
//renderCheckboxListField($attribute, $multiple);
31+
//renderCheckboxListField($attribute, $multiple, $suffix);
3332
break;
3433
case 10: // Pinkod
3534
break;
@@ -39,57 +38,57 @@ function renderAttribute($attribute, $multiple = false)
3938
}
4039
}
4140

42-
function renderCheckField($attribute, $multiple)
41+
function renderCheckField($attribute, $multiple, $suffix)
4342
{
4443
echo "<label><div class=\"inputLabel\">";
4544
echo $attribute->AttributeDescription;
4645
echo "</div><div class=\"inputHolder\">";
47-
echo "<input type=\"checkbox\" name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" />";
46+
echo "<input type=\"checkbox\" name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" />";
4847
echo "</div></label>";
4948
}
5049

51-
function renderTextField($attribute, $multiple)
50+
function renderTextField($attribute, $multiple, $suffix)
5251
{
5352
echo "<label><div class=\"inputLabel\">";
5453
echo $attribute->AttributeDescription;
5554
echo "</div><div class=\"inputHolder\">";
56-
echo "<input type=\"text\" name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" value=\"" . $attribute->AttributeValue . "\" />";
55+
echo "<input type=\"text\" name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" value=\"" . $attribute->AttributeValue . "\" />";
5756
echo "</div></label>";
5857
}
5958

60-
function renderNumberField($attribute, $multiple)
59+
function renderNumberField($attribute, $multiple, $suffix)
6160
{
6261
echo "<label><div class=\"inputLabel\">";
6362
echo $attribute->AttributeDescription;
6463
echo "</div><div class=\"inputHolder\">";
65-
echo "<input type=\"number\" name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" value=\"" . $attribute->AttributeValue . "\" />";
64+
echo "<input type=\"number\" name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" value=\"" . $attribute->AttributeValue . "\" />";
6665
echo "</div></label>";
6766
}
6867

69-
function renderDateField($attribute, $multiple)
68+
function renderDateField($attribute, $multiple, $suffix)
7069
{
7170
echo "<label><div class=\"inputLabel\">";
7271
echo $attribute->AttributeDescription;
7372
echo "</div><div class=\"inputHolder\">";
74-
echo "<input type=\"date\" name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" />";
73+
echo "<input type=\"date\" name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" />";
7574
echo "</div></label>";
7675
}
7776

78-
function renderTextAreaField($attribute, $multiple)
77+
function renderTextAreaField($attribute, $multiple, $suffix)
7978
{
8079
echo "<label><div class=\"inputLabel\">";
8180
echo $attribute->AttributeDescription;
8281
echo "</div><div class=\"inputHolder\">";
83-
echo "<textarea name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" rows=\"3\" resizable=\"resizable\">" . $attribute->AttributeValue . "</textarea>";
82+
echo "<textarea name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" rows=\"3\" resizable=\"resizable\">" . $attribute->AttributeValue . "</textarea>";
8483
echo "</div></label>";
8584
}
8685

87-
function renderSelectField($attribute, $multiple)
86+
function renderSelectField($attribute, $multiple, $suffix)
8887
{
8988
echo "<label><div class=\"inputLabel\">";
9089
echo $attribute->AttributeDescription;
9190
echo "</div><div class=\"inputHolder\">";
92-
echo "<select name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\">\n";
91+
echo "<select name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\">\n";
9392
foreach($attribute->AttributeAlternative as $val)
9493
{
9594
echo "\t<option value=\"" . $val->AttributeAlternativeID . "\">" . $val->AttributeAlternativeDescription . "</option>\n";
@@ -98,14 +97,14 @@ function renderSelectField($attribute, $multiple)
9897
echo "</div></label>";
9998
}
10099

101-
function renderCheckboxListField($attribute, $multiple)
100+
function renderCheckboxListField($attribute, $multiple, $suffix)
102101
{
103102
echo "<div class=\"inputLabel\">";
104103
echo $attribute->AttributeDescription;
105104
echo "</div><div class=\"inputHolder\">";
106105
foreach($attribute->AttributeAlternative as $val)
107106
{
108-
echo "\t<label><input type=\"checkbox\" name=\"edu-attr_" . $attribute->AttributeID . ($multiple ? "[]" : "") . "\" value=\"" . $val->AttributeAlternativeID . "\">" . $val->AttributeAlternativeDescription . "</label>\n";
107+
echo "\t<label><input type=\"checkbox\" name=\"edu-attr_" . $attribute->AttributeID . ($suffix != "" ? "-" . $suffix : "") . ($multiple ? "[]" : "") . "\" value=\"" . $val->AttributeAlternativeID . "\">" . $val->AttributeAlternativeDescription . "</label>\n";
109108
}
110109
echo "</div>";
111110
}

0 commit comments

Comments
 (0)