Skip to content

Commit

Permalink
The module should now be zk 3.0 compliant. I will be testing in a pro…
Browse files Browse the repository at this point in the history
…duction environment at some point.
  • Loading branch information
paustian committed Sep 3, 2020
1 parent 1505b34 commit 5169a56
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 407 deletions.
1 change: 1 addition & 0 deletions Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function editAction(Request $request, WebsiteFeeSubsEntity $subscriber =

if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();

if (!$doMerge) {
$em->persist($subscriber);
}
Expand Down
33 changes: 18 additions & 15 deletions Controller/SubscribeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace Paustian\WebsiteFeeModule\Controller;

use Paustian\WebsiteFeeModule\Entity\WebsiteFeeSubsEntity;
use Zikula\Bundle\CoreBundle\Controller\AbstractController;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down Expand Up @@ -166,7 +167,7 @@ public function subscribepaypalAction(Request $request) : Response {
private function _cancelSubscription(int $uid, int $item_no) : void {
$subscription = $this->_get_sub($item_no);
$gid = $subscription->getWsfgroupid();

$e = "";
if (!$this->_modifyUser($gid, $uid, false, $e)) {
//write an error to the error log;
$this->_set_error("Unable to cancel subscription: $e");
Expand All @@ -176,6 +177,7 @@ private function _cancelSubscription(int $uid, int $item_no) : void {
private function _addSubscription(int $uid, int $item_no) : void {
$subscription = $this->_get_sub($item_no);
$gid = $subscription->getWsfgroupid();
$e = "";
if (!$this->_modifyUser($gid, $uid, true, $e)) {
//write an error to the error log;
$this->_set_error("Unable to add subscription: $e");
Expand Down Expand Up @@ -303,7 +305,7 @@ private function _enterTransaction(int $uid,

//now grab the data out of the subsciption table
$subscript_info = $this->_get_sub($item_number);
if ($subscript_info == null) {
if (empty($subscript_info)) {
$this->_set_error("No item for the item number. Check your subscription setup to insure that your Subscription Item Number matches what you are putting in your paypal button");
return false;
}
Expand All @@ -314,18 +316,19 @@ private function _enterTransaction(int $uid,
$this->_set_error("Incorrect reciever Email:" . $receiver_email . ", correct Email should be:" . $email);
return false;
}
if($subscr_type !== "subscr_cancel"){
$payment_amt = $subscript_info->getWsfpaymentamount();
//I added a range because Paypal was being cute and adding tax
if (($payment_gross == -1) || ((($payment_amt - 2) < $payment_gross) && (($payment_amt + 2) > $payment_gross))) {
$payment_gross = $payment_amt;
}

$payment_amt = $subscript_info->getWsfpaymentamount();
//I added a range because Paypal was being cute and adding tax
if (($payment_gross == -1) || ((($payment_amt - 2) < $payment_gross) && (($payment_amt + 2) > $payment_gross))) {
$payment_gross = $payment_amt;
}

// check that payment_amount/payment_currency are correct
if ($payment_gross != $payment_amt) {
//wrong amount payed
$this->_set_error("payment inccorect: " . $payment_gross . ", correct amount should be: " . $payment_amt);
return false;
// check that payment_amount/payment_currency are correct
if ($payment_gross != $payment_amt) {
//wrong amount payed
$this->_set_error("payment inccorect: " . $payment_gross . ", correct amount should be: " . $payment_amt);
return false;
}
}

$transaction = new WebsiteFeeTransEntity();
Expand All @@ -352,7 +355,7 @@ private function _enterTransaction(int $uid,
* @param int $item_number
* @return array
*/
private function _get_sub(int $item_number) : array {
private function _get_sub(int $item_number) : ?WebsiteFeeSubsEntity {
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder();
if (isset($item_number) && is_numeric($item_number)) {
Expand All @@ -367,7 +370,7 @@ private function _get_sub(int $item_number) : array {
$the_item = $query->getResult();

if (empty($the_item)) {
throw new NotFoundHttpException($this->trans('Unable to get subscriber.'));
return null;
}
return $the_item[0];
}
Expand Down
6 changes: 3 additions & 3 deletions Entity/WebsiteFeeErrorsEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Paustian\WebsiteFeeModule\Entity;

use Symfony\Component\Validator\Constraints\DateTime;
use DateTime;
use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -86,7 +86,7 @@ public function getWsferroeexp() : string {
return $this->wsferroeexp;
}

public function getWsferrdate() : datetime {
public function getWsferrdate() : DateTime {
return $this->wsferrdate;
}

Expand All @@ -106,7 +106,7 @@ public function setWsferroeexp(string $wsferroeexp) : void {
$this->wsferroeexp = $wsferroeexp;
}

public function setWsferrdate(datetime $wsferrdate) : void {
public function setWsferrdate(DateTime $wsferrdate) : void {
$this->wsferrdate = $wsferrdate;
}

Expand Down
8 changes: 4 additions & 4 deletions Entity/WebsiteFeeSubsEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WebsiteFeeSubsEntity extends EntityAccess {
* WebsiteFeeSubs id
*
* @ORM\Id
* @ORM\Column(type="integer", length=20)
* @ORM\Column(type="integer", length=11)
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
Expand All @@ -48,7 +48,7 @@ class WebsiteFeeSubsEntity extends EntityAccess {
/**
* wsfitem item number that is ordered
*
* @ORM\Column(type="integer", length=20)
* @ORM\Column(type="integer", length=11)
* @Assert\Type(
* type="integer",
* message="The value {{ value }} is not a valid {{ type }}.")
Expand All @@ -67,7 +67,7 @@ class WebsiteFeeSubsEntity extends EntityAccess {
private $wsfpaymentamount;

/**
* WebsiteFeeSubs wsfsubsname -- the name of the subscription.
* WebsiteFeeSubs wsfemail -- the name of the subscription.
* @ORM\Column(type="string", length=255)
* @Assert\Email(message = "The email '{{ value }}' is not a valid email.")
*
Expand Down Expand Up @@ -117,7 +117,7 @@ public function setWsfsubsname(string $wsfsubsname) : void {
$this->wsfsubsname = $wsfsubsname;
}

public function setWsfitem(string $wsfitem) : void {
public function setWsfitem(int $wsfitem) : void {
$this->wsfitem = $wsfitem;
}

Expand Down
6 changes: 3 additions & 3 deletions Entity/WebsiteFeeTransEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Paustian\WebsiteFeeModule\Entity;

use Symfony\Component\Validator\Constraints\DateTime;
use DateTime;
use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function getWsfemail() : string {
return $this->wsfemail;
}

public function getWsfpaydate() : datetime {
public function getWsfpaydate() : DateTime {
return $this->wsfpaydate;
}

Expand All @@ -117,7 +117,7 @@ public function setWsfemail(string $wsfemail) : void {
$this->wsfemail = $wsfemail;
}

public function setWsfpaydate(datetime $wsfpaydate) : void {
public function setWsfpaydate(DateTime $wsfpaydate) : void {
$this->wsfpaydate = $wsfpaydate;
}

Expand Down
50 changes: 24 additions & 26 deletions Resources/views/Admin/websitefee_admin_edit.html.twig
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
{% form_theme form '@ZikulaFormExtension/Form/bootstrap_4_zikula_admin_layout.html.twig' %}
<div class="container-fluid">
<div class="row">
<h3>
<span class="fa fa-edit"></span>
{{ "Edit a Subscription" | trans }}
</h3>
<p>{{ "Fill in the details for a subscription. This is the data PayPal will check against for adding subscriptions. The group ID is the group to which the user should be added." | trans }}</p>
{{ showflashes() }}
{{ form_start(form) }}
{{ form_errors(form) }}
<fieldset>
<legend>{{ 'Subscriber' | trans }}</legend>
{{ form_row(form.wsfsubsname) }}
{{ form_row(form.wsfitem) }}
{{ form_row(form.wsfpaymentamount) }}
{{ form_row(form.wsfemail) }}
{{ form_row(form.wsfgroupid) }}
</fieldset>
<div class="form-group">
<div class="col-lg-offset-3 col-lg-9">
{{ form_widget(form.save, {'attr': {'class': 'btn btn-success'}}) }}
{{ form_widget(form.cancel, {'attr': {'class': 'btn btn-cancel'}}) }}
</div>
</div>
{{ form_end(form) }}
</div>

<h3>
<span class="fa fa-edit"></span>
{{ "Edit a Subscription" | trans }}
</h3>
<p>{{ "Fill in the details for a subscription. This is the data PayPal will check against for adding subscriptions. The group ID is the group to which the user should be added." | trans }}</p>
{{ showflashes() }}
{{ form_start(form) }}
{{ form_errors(form) }}
<fieldset>
<legend>{{ 'Subscriber' | trans }}</legend>
{{ form_row(form.wsfsubsname) }}
{{ form_row(form.wsfitem) }}
{{ form_row(form.wsfpaymentamount) }}
{{ form_row(form.wsfemail) }}
{{ form_row(form.wsfgroupid) }}
</fieldset>
<div class="form-group">
<div class="col-lg-offset-3 col-lg-9">
{{ form_widget(form.save, {'attr': {'class': 'btn btn-success'}}) }}
{{ form_widget(form.cancel, {'attr': {'class': 'btn btn-cancel'}}) }}
</div>
</div>
{{ form_end(form) }}

10 changes: 4 additions & 6 deletions Resources/views/Admin/websitefee_admin_index.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<div class="container-fluid">
<p>{{ 'Welcome to the administration interface for the WebsiteFeeModule module. The only item you set up from here is ' | trans }}
<a href="{{ path('paustianwebsitefeemodule_admin_edit') }}">{{ 'subscriptions' | trans }}</a>. {{' The rest of the interaction is
done through an interface with paypal. Go to PayPals' | trans }} <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_button-management">{{'button creation tool' | trans }}</a>
{{ ' to create your button. Remember to add the custom parameter with the user id in it' | trans }}</p>
</div>
<p>{{ 'Welcome to the administration interface for the WebsiteFeeModule module. The only item you set up from here is ' | trans }}
<a href="{{ path('paustianwebsitefeemodule_admin_edit') }}">{{ 'subscriptions' | trans }}</a>. {{' The rest of the interaction is
done through an interface with paypal. Go to PayPals' | trans }} <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_button-management">{{'button creation tool' | trans }}</a>
{{ ' to create your button. Remember to add the custom parameter with the user id in it' | trans }}</p>
37 changes: 18 additions & 19 deletions Resources/views/Admin/websitefee_admin_modify.html.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<div class="container-fluid">
<table class="table table-striped">
<thead>
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'Subscription Name' | trans }}</th>
<th> {{ 'Actions' | trans }} </th>
</tr>
</thead>
<tbody>
{% for item in subs %}
<tr>
<th>{{ 'Subscription Name' | trans }}</th>
<th> {{ 'Actions' | trans }} </th>
<td>{{ item.wsfsubsname }}</td>
<td class="actions">
<a href="{{ path('paustianwebsitefeemodule_admin_edit', {subscriber: item.id}) }}" class="fas fa-edit"></a>
<a href="{{ path('paustianwebsitefeemodule_admin_delete', {subscriber: item.id}) }}" class="fas fa-trash" onclick="return confirm('Are you sure you want to delete this subscription information?')"></a>
</td>
</tr>
</thead>
<tbody>
{% for item in subs %}
<tr>
<td>{{ item.wsfsubsname }}</td>
<td class="actions">
<a href="{{ path('paustianwebsitefeemodule_admin_edit', {subscriber: item.id}) }}" class="fas fa-edit"></a>
<a href="{{ path('paustianwebsitefeemodule_admin_delete', {subscriber: item.id}) }}" class="fas fa-trash" onclick="return confirm('Are you sure you want to delete this subscription information?')"></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</tbody>
</table>

52 changes: 25 additions & 27 deletions Resources/views/Admin/websitefee_admin_modifyerrs.html.twig
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
<div class="container-fluid">
<table class="table table-striped table-fixed">
<thead>
<table class="table table-striped table-fixed">
<thead>
<tr>
<th>{{ 'Request' | trans }}</th>
<th>{{ 'Response' | trans }}</th>
<th>{{ 'Error Expression' | trans }}</th>
<th>{{ 'Date' | trans }}</th>
<th> {{ 'Actions' | trans }} </th>
</tr>
</thead>
<tbody>
{% for item in errors %}
<tr>
<th>{{ 'Request' | trans }}</th>
<th>{{ 'Response' | trans }}</th>
<th>{{ 'Error Expression' | trans }}</th>
<th>{{ 'Date' | trans }}</th>
<th> {{ 'Actions' | trans }} </th>
<td>{{ item.wsfrequest }}</td>
<td>{{ item.wsfrespone }}</td>
<td>{{ item.wsferroeexp }}</td>
<td>{{ item.wsferrdate.date }}</td>
<td class="actions">
<a href="{{ path('paustianwebsitefeemodule_admin_deleteerror', {error: item.id}) }}" class="fas fa-trash" onclick="return confirm('Are you sure you want to delete this subscription information?')"></a>
</td>
</tr>
</thead>
<tbody>
{% for item in errors %}
<tr>
<td>{{ item.wsfrequest }}</td>
<td>{{ item.wsfrespone }}</td>
<td>{{ item.wsferroeexp }}</td>
<td>{{ item.wsferrdate.date }}</td>
<td class="actions">
<a href="{{ path('paustianwebsitefeemodule_admin_deleteerror', {error: item.id}) }}" class="fas fa-trash" onclick="return confirm('Are you sure you want to delete this subscription information?')"></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<form action="{{ path('paustianwebsitefeemodule_admin_deleteerror') }}" method='POST'>
<button type='submit' name='deleteAll' value='deleteAll'>{{ 'Delete All' | trans }}</button>
</form>
</div>
{% endfor %}
</tbody>
</table>
<form action="{{ path('paustianwebsitefeemodule_admin_deleteerror') }}" method='POST'>
<button type='submit' name='deleteAll' value='deleteAll'>{{ 'Delete All' | trans }}</button>
</form>
Loading

0 comments on commit 5169a56

Please sign in to comment.