Skip to content

Commit

Permalink
Merge pull request #895 from inbaz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BigAndini authored Oct 16, 2016
2 parents c82219f + 36759fe commit 5180b95
Show file tree
Hide file tree
Showing 23 changed files with 2,386 additions and 160 deletions.
5 changes: 3 additions & 2 deletions config/autoload/sepa.global.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

return array(
/*return array(
'ERS\SEPA' => array(
'iban' => 'NL84 INGB 0007 8721 92',
'bic' => 'INGBNL2A',
'owner' => 'STICHTING EUROPEAN JUGGLING ASSOCIATION',
'bank' => 'ING BANK N.V.',
'country' => 'Netherlands',
)
);
);*/
return array();
8 changes: 0 additions & 8 deletions module/Admin/src/Admin/Controller/BankaccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,9 @@ public function uploadCsvAction() {
$hashes = array();
$separator = substr($data['separator'], 0, 1);
while (($row_data = fgetcsv($handle, 1000, $separator)) !== FALSE) {
#while (($row_data = fgetcsv($handle, 1000, ",")) !== FALSE) {
#$hash = md5(implode($row_data));

$bs = new Entity\BankStatement();
#$bs->setBankStatementCols($row_data);
$bs->setBankAccount($bankaccount);
$bs->setBankAccountCsv($bankAccountCsv);
#$bs->setHash($hash);
$bs->setStatus('new');
foreach($row_data as $column => $value) {
$bsc = new Entity\BankStatementCol();
Expand All @@ -375,9 +370,6 @@ public function uploadCsvAction() {
$bsc->setBankStatement($bs);
$bs->addBankStatementCol($bsc);
}
/*if($fix_amount) {
$bs->getAmount()->setValue((float) $bs->getAmount()->getValue());
}*/
$bs->generateHash();

$bankstatement = $em->getRepository('ErsBase\Entity\BankStatement')
Expand Down
42 changes: 29 additions & 13 deletions module/Admin/src/Admin/Controller/CronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ private function createMatch(Entity\BankStatement $statement, Entity\Code $code)
$paid = true;
echo $matchInfo." (exact)".PHP_EOL;
} elseif($order_amount < $statement_amount) {
$paid = true;
#$paid = true;
$paid = false;
echo $matchInfo." (overpaid)".PHP_EOL;
} else {
$paid = false;
Expand Down Expand Up @@ -490,10 +491,15 @@ public function sendEticketsAction() {
}
echo PHP_EOL;

$config = $emailService = $this->getServiceLocator()
->get('config');

foreach($packages as $package) {
# prepare email (participant, buyer)
$emailService = new Service\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new Service\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$emailService->setFrom($config['ERS']['info_mail']);

$order = $package->getOrder();
$participant = $package->getParticipant();
Expand All @@ -512,10 +518,10 @@ public function sendEticketsAction() {
$emailService->addTo($user);*/

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "[EJC 2016] E-Ticket for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$subject = "[".$config['ERS']['name_short']."] "._('E-Ticket for')." ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$emailService->setSubject($subject);

$viewModel = new ViewModel(array(
Expand Down Expand Up @@ -895,10 +901,15 @@ public function sorryEticketSepaAction() {
$packages = $qb->getQuery()->getResult();
echo "found ".count($packages)." packages.".PHP_EOL;

$config = $emailService = $this->getServiceLocator()
->get('config');

foreach($packages as $package) {
# prepare email (participant, buyer)
$emailService = new Service\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new Service\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$emailService->setFrom($config['ERS']['info_mail']);

$order = $package->getOrder();
$participant = $package->getParticipant();
Expand All @@ -918,10 +929,10 @@ public function sorryEticketSepaAction() {
$emailService->addTo($user);*/

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "[EJC 2016] Your E-Ticket is not valid for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$subject = "[".$config['ERS']['name_short']."] Your E-Ticket is not valid for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$emailService->setSubject($subject);

$viewModel = new ViewModel(array(
Expand Down Expand Up @@ -961,10 +972,15 @@ public function sorryEticketCcAction() {
$packages = $qb->getQuery()->getResult();
echo "found ".count($packages)." packages.".PHP_EOL;

$config = $emailService = $this->getServiceLocator()
->get('config');

foreach($packages as $package) {
# prepare email (participant, buyer)
$emailService = new Service\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new Service\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$emailService->setFrom($config['ERS']['info_mail']);

$order = $package->getOrder();
$participant = $package->getParticipant();
Expand All @@ -984,10 +1000,10 @@ public function sorryEticketCcAction() {
$emailService->addTo($user);*/

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "[EJC 2016] Your E-Ticket is not valid for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$subject = "[".$config['ERS']['name_short']."] Your E-Ticket is not valid for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$emailService->setSubject($subject);

$viewModel = new ViewModel(array(
Expand Down
20 changes: 14 additions & 6 deletions module/Admin/src/Admin/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,12 @@ public function sendEticketsAction() {
}

# prepare email (participant, buyer)
$emailService = new Service\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new Service\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$config = $this->getServiceLocator()
->get('config');
$emailService->setFrom($config['ERS']['info_mail']);

$order = $package->getOrder();
$participant = $package->getParticipant();
Expand All @@ -361,7 +365,7 @@ public function sendEticketsAction() {
}

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "Your registration for EJC 2016 (order ".$order->getCode()->getValue().")";
Expand Down Expand Up @@ -434,14 +438,18 @@ public function sendPaymentReminderAction() {
->findOneBy(array('id' => $id));

# prepare email (participant, buyer)
$emailService = new Service\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new Service\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$config = $this->getServiceLocator()
->get('config');
$emailService->setFrom($config['ERS']['info_mail']);

$buyer = $order->getBuyer();
$emailService->addTo($buyer);

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "[EJC 2016] Payment reminder for your order: ".$order->getCode()->getValue();
Expand Down
15 changes: 11 additions & 4 deletions module/Admin/src/Admin/Controller/PackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ public function recalculateAction() {
if($order->getPaymentStatus() == 'paid') {
$order->setPaymentStatus('unpaid');
}
$order->setOrderSum($order->getPrice());
$order->setTotalSum($order->getSum());
$em->persist($order);

$itemBefore->setStatus($statusCancelled);
$em->persist($itemBefore);
Expand Down Expand Up @@ -523,8 +526,12 @@ public function sendEticketAction() {
}

# prepare email (participant, buyer)
$emailService = new ersService\EmailService();
$emailService->setFrom('[email protected]');
#$emailService = new ersService\EmailService();
$emailService = $this->getServiceLocator()
->get('ErsBase\Service\EmailService');
$config = $this->getServiceLocator()
->get('config');
$emailService->setFrom($config['ERS']['info_mail']);

$order = $package->getOrder();
$participant = $package->getParticipant();
Expand All @@ -541,10 +548,10 @@ public function sendEticketAction() {
}

$bcc = new Entity\User();
$bcc->setEmail('[email protected]');
$bcc->setEmail($config['ERS']['info_mail']);
$emailService->addBcc($bcc);

$subject = "[EJC 2016] E-Ticket for ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$subject = "[".$config['ERS']['name_short']."] "._('E-Ticket for')." ".$participant->getFirstname()." ".$participant->getSurname()." (order ".$order->getCode()->getValue().")";
$emailService->setSubject($subject);

$viewModel = new ViewModel(array(
Expand Down
94 changes: 62 additions & 32 deletions module/Admin/src/Admin/Controller/StatisticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@ public function orgasAction() {
$em = $this->getServiceLocator()
->get('Doctrine\ORM\EntityManager');

/*$orderSelectFields = array('COUNT(o.id) AS ordercount', 'SUM(o.order_sum) AS ordersum, SUM(o.total_sum) AS totalsum');
$qb = $em->createQueryBuilder();
$qb->select(array_merge(array('s status, s.value label'), $orderSelectFields))
->from('ErsBase\Entity\Status', 's')
->leftJoin('s.orders', 'o')
->where('s.value', ':status');
#->groupBy('s.value')
#->orderBy('s.position');
$qb->setParameter('status', 'paid');
$paymentStatusStats = $qb->getQuery()->getResult();*/

/*$byStatusGroups = array('active' => array(), 'inactive' => array());
foreach($paymentStatusStats AS $statusData) {
$group = ($statusData['status']->getActive() ? 'active' : 'inactive');
$byStatusGroups[$group][] = $statusData;
}*/

$qb1 = $em->getRepository('ErsBase\Entity\Order')->createQueryBuilder('o');
$qb1->select(array('SUM(o.order_sum) as ordersum'));
$qb1->join('o.status', 's');
Expand Down Expand Up @@ -307,28 +288,77 @@ public function participantsAction() {
// otherwise array_merge does not do what we want (overwrite default values if present)
$pseudoIdColumn = "CONCAT('x', prod.id) pseudoId";

$productStats = array_merge(
// get all products with all counts at 0 first (default values)
array_column($em->createQueryBuilder()
->select($pseudoIdColumn, 'prod.name label', '0 usercount', '0 itemcount')
$productStatsBase = array_column($em->createQueryBuilder()
->select(
$pseudoIdColumn,
'prod.name label',
'COUNT(DISTINCT u.id) AS usercount',
'COUNT(i.id) itemcount')
->from('ErsBase\Entity\Product', 'prod')
->join('prod.items', 'i')
->join('i.status', 's', 'WITH', 's.active = 1')
->join('i.package', 'p')
->join('p.user', 'u')
->groupBy('prod.id')
->orderBy('prod.position')
->getQuery()->getResult(), NULL, 'pseudoId');

$productStatsPaid = array_column($em->createQueryBuilder()
->select(
$pseudoIdColumn,
#'prod.name label',
#'COUNT(DISTINCT u.id) AS usercount',
'COUNT(i.id) paid')
->from('ErsBase\Entity\Product', 'prod')
->join('prod.items', 'i')
->join('i.status', 's', 'WITH', 's.active = 1')
->join('i.package', 'p')
->join('p.user', 'u')
->where($qb->expr()->eq('s.value', ':status'))
->groupBy('prod.id')
->orderBy('prod.position')
->getQuery()->getResult(),
NULL, 'pseudoId'),

// calculate actual counts by product
array_column($em->createQueryBuilder()
->select($pseudoIdColumn, 'prod.name label', 'COUNT(DISTINCT u.id) AS usercount', 'COUNT(i.id) itemcount')
->setParameter('status', 'paid')
->getQuery()->getResult(), NULL, 'pseudoId');

$productStatsOrdered = array_column($em->createQueryBuilder()
->select(
$pseudoIdColumn,
#'prod.name label',
#'COUNT(DISTINCT u.id) AS usercount',
'COUNT(i.id) ordered')
->from('ErsBase\Entity\Product', 'prod')
->join('prod.items', 'i')
->join('i.status', 's', 'WITH', 's.active = 1')
->join('i.package', 'p')
->join('p.user', 'u')
->where($qb->expr()->eq('s.value', ':status'))
->groupBy('prod.id')
->orderBy('prod.position')
->getQuery()->getResult(),
NULL, 'pseudoId')
);
->setParameter('status', 'ordered')
->getQuery()->getResult(), NULL, 'pseudoId');

$productStatsCancelled = array_column($em->createQueryBuilder()
->select(
$pseudoIdColumn,
#'prod.name label',
#'COUNT(DISTINCT u.id) AS usercount',
'COUNT(i.id) cancelled')
->from('ErsBase\Entity\Product', 'prod')
->join('prod.items', 'i')
->join('i.status', 's', 'WITH', 's.active = 0')
->join('i.package', 'p')
->join('p.user', 'u')
->where($qb->expr()->eq('s.value', ':status'))
->groupBy('prod.id')
->orderBy('prod.position')
->setParameter('status', 'cancelled')
->getQuery()->getResult(), NULL, 'pseudoId');

$productStats = array_merge_recursive(
$productStatsBase,
$productStatsPaid,
$productStatsOrdered,
$productStatsCancelled);


/*
Expand Down
21 changes: 15 additions & 6 deletions module/Admin/view/admin/statistic/participants.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ $this->headTitle($title);

<div class="row">

<div class="col-md-6">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">Participants by product type</div>
<table class="table table-striped">
<thead>
<tr>
<th>Product</th>
<th>Participant count</th>
<th>Item count</th>
<th>Average items<br>per participant</th>
<th>product</th>
<th>participants</th>
<th>active<br>items</th>
<th>paid</th>
<th>ordered</th>
<th>cancelled</th>
<th>average items<br>per participant</th>
</tr>
</thead>
<tbody>
Expand All @@ -94,13 +97,19 @@ $this->headTitle($title);
<td><?php echo $this->escapeHtml($value['label']); ?></td>
<td><?php echo $value['usercount']; ?></td>
<td><?php echo $value['itemcount']; ?></td>
<td><?php echo $value['paid']; ?></td>
<td><?php echo $value['ordered']; ?></td>
<td><?php echo $value['cancelled']; ?></td>
<td><?php echo number_format($value['itemcount'] / $value['usercount'], 3); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Items by product variant</div>
<div class="panel-body">
Expand Down
Loading

0 comments on commit 5180b95

Please sign in to comment.