amm-dev-tem team mailing list archive
-
amm-dev-tem team
-
Mailing list archive
-
Message #00000
[Branch ~amm-dev-tem/amm/trunk] Rev 22: Added a membership renewal functionnality
------------------------------------------------------------
revno: 22
committer: The Whole Life To Learn <thewholelifetolearn@xxxxxxxxx>
branch nick: sources
timestamp: Mon 2011-05-30 16:30:19 +0200
message:
Added a membership renewal functionnality
modified:
app/controllers/members_controller.php
app/models/member.php
app/views/members/edit.ctp
app/views/members/index.ctp
--
lp:amm
https://code.launchpad.net/~amm-dev-tem/amm/trunk
Your team AMM dev team is subscribed to branch lp:amm.
To unsubscribe from this branch go to https://code.launchpad.net/~amm-dev-tem/amm/trunk/+edit-subscription
=== modified file 'app/controllers/members_controller.php'
--- app/controllers/members_controller.php 2011-05-30 11:19:15 +0000
+++ app/controllers/members_controller.php 2011-05-30 14:30:19 +0000
@@ -20,6 +20,7 @@
function add() {
if (!empty($this->data)) {
$this->Member->create();
+ debug($this->Member->data);
if ($this->Member->save($this->data)) {
$this->Session->setFlash(__('The member has been saved', true));
$this->redirect(array('action' => 'index'));
@@ -157,6 +158,24 @@
$this->Session->setFlash(__('Member was not deleted', true));
$this->redirect(array('action' => 'index'));
}
+
+ function renew($id = null) {
+ if (!$id && empty($this->data)) {
+ $this->Session->setFlash(__('Invalid member', true));
+ $this->redirect(array('action' => 'index'));
+ }
+ $this->data = $this->Member->read(null, $id);
+ $this->Member->renew();
+ if ($this->Member->save()) {
+ $this->Session->setFlash(__('The membership has been renewed. The medical certificat must be submitted for this renewal', true));
+ $this->redirect(array('action' => 'index'));
+ } else {
+ $this->Session->setFlash(__('The membership could not be renewed. Please, try again.', true));
+ $this->redirect(array('action' => 'index'));
+ }
+
+ }
+
function admin_index() {
$this->Member->recursive = 0;
$this->set('members', $this->paginate());
=== modified file 'app/models/member.php'
--- app/models/member.php 2011-05-30 11:19:15 +0000
+++ app/models/member.php 2011-05-30 14:30:19 +0000
@@ -147,4 +147,16 @@
)
);
+ function renew() {
+ $this->id = null;
+ $this->data['Member']['id'] = null;
+ $this->data['Member']['medical_certificat'] = null;
+ $this->data['Member']['membership_date'] = date('Y-m-d');
+ $tmp = array();
+ foreach($this->data['Authorization'] as $auth) {
+ $tmp[] = $auth['AuthorizationsMember']['authorization_id'];
+ }
+ $this->data['Authorization'] = array('Authorization' => $tmp);
+ }
+
}
=== modified file 'app/views/members/edit.ctp'
--- app/views/members/edit.ctp 2011-05-30 11:19:15 +0000
+++ app/views/members/edit.ctp 2011-05-30 14:30:19 +0000
@@ -2,8 +2,7 @@
echo $this->Html->script('jquery-1.6.x.min');
$this->Js->get('#MemberEditForm')->event('submit',
- "alert('formular submit');
- if($('#MemberFile').val() == '') {
+ "if($('#MemberFile').val() == '') {
$('#MemberFile').parent('div').detach();
}
return true;", true);
=== modified file 'app/views/members/index.ctp'
--- app/views/members/index.ctp 2011-05-30 11:19:15 +0000
+++ app/views/members/index.ctp 2011-05-30 14:30:19 +0000
@@ -38,6 +38,7 @@
<td class="actions">
<?php echo $this->Html->link(__('View', true), array('action' => 'view', $member['Member']['id'])); ?>
<?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $member['Member']['id'])); ?>
+ <?php echo $this->Html->link(__('Renew', true), array('action' => 'renew', $member['Member']['id'])); ?>
<?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $member['Member']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['Member']['id'])); ?>
</td>
</tr>