Skip to content

Commit

Permalink
Merge pull request #86 from conferencetools/supplementary-tickets
Browse files Browse the repository at this point in the history
Supplementary tickets
  • Loading branch information
carnage authored Dec 18, 2017
2 parents 900589f + 7daaf27 commit 3a16fd6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 23 deletions.
5 changes: 5 additions & 0 deletions assets/css/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ body { margin-top:20px; }
vertical-align: middle;
width: 50%;
}
.credit-card-box .display-td-full {
display: table-cell;
vertical-align: middle;
width: 100%;
}
/* Just looks nicer */
.credit-card-box .panel-heading img {
min-width: 180px;
Expand Down
10 changes: 7 additions & 3 deletions src/Controller/TicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function purchaseAction()
return $this->redirect()->toRoute('tickets/complete', ['purchaseId' => $purchaseId]);
}

$form = new PurchaseForm($purchase->getTicketCount());
$form = new PurchaseForm($purchase);

if ($this->getRequest()->isPost()) {
$noPayment = true;
Expand All @@ -219,8 +219,12 @@ public function purchaseAction()

$delegateInfo = [];

for ($i = 0; $i < $purchase->getTicketCount(); $i++) {
$delegateInfo[] = Delegate::fromArray($data['delegates_' . $i]);
foreach ($purchase->getTickets() as $i => $ticket) {
if (!$ticket->getTicketType()->isSupplementary()) {
$delegateInfo[] = Delegate::fromArray($data['delegates_' . $i]);
} else {
$delegateInfo[] = Delegate::emptyObject();
}
}

$command = new CompletePurchase($purchaseId, $data['purchase_email'], ...$delegateInfo);
Expand Down
5 changes: 3 additions & 2 deletions src/Domain/Service/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Configuration
*
* @var DiscountCode[]
*/
private $discountCodes;
private $discountCodes = [];

/**
* Contains metadata about tickets eg when they are available for sale
Expand Down Expand Up @@ -179,7 +179,8 @@ private function addTicketInformation(array $ticket, string $identifier)
$identifier,
$price,
$ticket['name'],
$ticket['description'] ?? ''
$ticket['description'] ?? '',
$ticket['supplementary'] ?? false
);

$this->avaliableTickets[$identifier] = $ticket['available'];
Expand Down
22 changes: 20 additions & 2 deletions src/Domain/ValueObject/TicketType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,25 @@ final class TicketType
*/
private $description;

public function __construct(string $identifier, Price $price, string $displayName, string $description = '')
{
/**
* @var boolean
* @Jms\Type("boolean")
* @ORM\Column(type="boolean")
*/
private $supplementary = false;

public function __construct(
string $identifier,
Price $price,
string $displayName,
string $description = '',
bool $supplementary = false
) {
$this->identifier = $identifier;
$this->price = $price;
$this->displayName = $displayName;
$this->description = $description;
$this->supplementary = $supplementary;
}

public function getIdentifier(): string
Expand All @@ -67,4 +80,9 @@ public function getDescription(): string
{
return $this->description;
}

public function isSupplementary(): bool
{
return $this->supplementary;
}
}
11 changes: 8 additions & 3 deletions src/Form/PurchaseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace ConferenceTools\Tickets\Form;

use ConferenceTools\Tickets\Domain\ReadModel\TicketRecord\PurchaseRecord;
use ConferenceTools\Tickets\Domain\ReadModel\TicketRecord\TicketRecord;
use ConferenceTools\Tickets\Domain\ValueObject\Delegate;
use ConferenceTools\Tickets\Form\Fieldset\DelegateInformation;
use ConferenceTools\Tickets\Hydrator\DelegateHydrator;
Expand All @@ -15,7 +17,7 @@

class PurchaseForm extends Form
{
public function __construct($tickets)
public function __construct(PurchaseRecord $purchase)
{
parent::__construct('delegate-form');
$this->add(['type' => Hidden::class, 'name' => 'stripe_token']);
Expand All @@ -28,8 +30,11 @@ public function __construct($tickets)
]
]);

for ($i = 0; $i < $tickets; $i++) {
$this->add(['type' => DelegateInformation::class, 'name' => 'delegates_' . $i]);
foreach ($purchase->getTickets() as $i => $ticket) {
/** @var TicketRecord $ticket */
if (!$ticket->getTicketType()->isSupplementary()) {
$this->add(['type' => DelegateInformation::class, 'name' => 'delegates_' . $i]);
}
}

$this->add(new Csrf('security'));
Expand Down
5 changes: 4 additions & 1 deletion view/tickets/ticket/complete.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
<?=$ticket->getTicketType()->getDisplayName()?>
</td>
<td class="col-xs-6">
<a href="<?= $this->serverUrl() . $url?>">Manage</a>
<?php if (!$ticket->getTicketType()->isSupplementary()): ?>
<a href="<?= $this->serverUrl() . $url?>">Manage</a>
<?php endif;?>

</td>
</tr>
<?php endforeach;?>
Expand Down
31 changes: 19 additions & 12 deletions view/tickets/ticket/purchase.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,27 @@ $this->headLink()->appendStylesheet('/css/card.css');
</div>
</div>

<?php for($i = 0; $i < $purchase->getTicketCount(); $i++):?>
<div class="panel panel-default credit-card-box">
<div class="panel-heading display-table" >
<div class="row display-tr" >
<h3 class="panel-title display-td" >Delegate Information <?=$i+1?></h3>
<div class="display-td" ></div>
<?php
$i = 0;
foreach ($this->purchase->getTickets() as $id => $ticket):
if (!$ticket->getTicketType()->isSupplementary()):?>

<div class="panel panel-default credit-card-box">
<div class="panel-heading display-table" >
<div class="row display-tr" >
<h3 class="panel-title display-td-full" >Delegate Information <?=++$i?> (<?=$ticket->getTicketType()->getDisplayName()?>) </h3>
</div>
</div>
<div class="panel-body">
<p class="help-block">You can complete this information later if you wish</p>
<?php echo $this->formCollection($this->form->get('delegates_' . $id));?>
</div>
</div>
<div class="panel-body">
<p class="help-block">You can complete this information later if you wish</p>
<?php echo $this->formCollection($this->form->get('delegates_' . $i));?>
</div>
</div>
<?php endfor;?>

<?php
endif;
endforeach;
?>
<?php echo $this->formHidden($this->form->get('security'))?>
</form>
</div>
Expand Down

0 comments on commit 3a16fd6

Please sign in to comment.