amm-dev-tem team mailing list archive
-
amm-dev-tem team
-
Mailing list archive
-
Message #00004
[Branch ~amm-dev-tem/amm/trunk] Rev 21: 'Cleaned' views of 'Members'
------------------------------------------------------------
revno: 21
committer: The Whole Life To Learn <thewholelifetolearn@xxxxxxxxx>
branch nick: sources
timestamp: Mon 2011-05-30 13:19:15 +0200
message:
'Cleaned' views of 'Members'
added:
app/webroot/uploads/members/
modified:
app/controllers/members_controller.php
app/models/member.php
app/views/members/add.ctp
app/views/members/edit.ctp
app/views/members/index.ctp
app/views/members/view.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-27 07:58:31 +0000
+++ app/controllers/members_controller.php 2011-05-30 11:19:15 +0000
@@ -2,7 +2,7 @@
class MembersController extends AppController {
var $name = 'Members';
- var $helpers = array('Ajax', 'Javascript');
+ var $helpers = array('Js');
function index() {
$this->Member->recursive = 0;
@@ -27,12 +27,53 @@
$this->Session->setFlash(__('The member could not be saved. Please, try again.', true));
}
}
- $people = $this->Member->Person->find('list');
- $formulas = $this->Member->Formula->find('list');
- $guardian1s = $this->Member->Guardian1->find('list');
- $guardian2s = $this->Member->Guardian2->find('list');
- $emergency1s = $this->Member->Emergency1->find('list');
- $emergency2s = $this->Member->Emergency2->find('list');
+ $people = $this->Member->Person->find('list',
+ array(
+ 'order' => array(
+ 'Person.lastname' => 'asc',
+ 'Person.firstname' => 'asc'
+ )
+ )
+ );
+ $formulas = $this->Member->Formula->find('list',
+ array(
+ 'order' => array(
+ 'Formula.name' => 'asc'
+ )
+ )
+ );
+ $guardian1s = $this->Member->Guardian1->find('list',
+ array(
+ 'order' => array(
+ 'Guardian1.lastname' => 'asc',
+ 'Guardian1.firstname' => 'asc'
+ )
+ )
+ );
+ $guardian2s = $this->Member->Guardian2->find('list',
+ array(
+ 'order' => array(
+ 'Guardian2.lastname' => 'asc',
+ 'Guardian2.firstname' => 'asc'
+ )
+ )
+ );
+ $emergency1s = $this->Member->Emergency1->find('list',
+ array(
+ 'order' => array(
+ 'Emergency1.lastname' => 'asc',
+ 'Emergency1.firstname' => 'asc'
+ )
+ )
+ );
+ $emergency2s = $this->Member->Emergency2->find('list',
+ array(
+ 'order' => array(
+ 'Emergency2.lastname' => 'asc',
+ 'Emergency2.firstname' => 'asc'
+ )
+ )
+ );
$authorizations = $this->Member->Authorization->find('list');
$this->set(compact('people', 'formulas', 'guardian1s', 'guardian2s', 'emergency1s', 'emergency2s', 'authorizations'));
}
@@ -53,12 +94,53 @@
if (empty($this->data)) {
$this->data = $this->Member->read(null, $id);
}
- $people = $this->Member->Person->find('list');
- $formulas = $this->Member->Formula->find('list');
- $guardian1s = $this->Member->Guardian1->find('list');
- $guardian2s = $this->Member->Guardian2->find('list');
- $emergency1s = $this->Member->Emergency1->find('list');
- $emergency2s = $this->Member->Emergency2->find('list');
+ $people = $this->Member->Person->find('list',
+ array(
+ 'order' => array(
+ 'Person.lastname' => 'asc',
+ 'Person.firstname' => 'asc'
+ )
+ )
+ );
+ $formulas = $this->Member->Formula->find('list',
+ array(
+ 'order' => array(
+ 'Formula.name' => 'asc'
+ )
+ )
+ );
+ $guardian1s = $this->Member->Guardian1->find('list',
+ array(
+ 'order' => array(
+ 'Guardian1.lastname' => 'asc',
+ 'Guardian1.firstname' => 'asc'
+ )
+ )
+ );
+ $guardian2s = $this->Member->Guardian2->find('list',
+ array(
+ 'order' => array(
+ 'Guardian2.lastname' => 'asc',
+ 'Guardian2.firstname' => 'asc'
+ )
+ )
+ );
+ $emergency1s = $this->Member->Emergency1->find('list',
+ array(
+ 'order' => array(
+ 'Emergency1.lastname' => 'asc',
+ 'Emergency1.firstname' => 'asc'
+ )
+ )
+ );
+ $emergency2s = $this->Member->Emergency2->find('list',
+ array(
+ 'order' => array(
+ 'Emergency2.lastname' => 'asc',
+ 'Emergency2.firstname' => 'asc'
+ )
+ )
+ );
$authorizations = $this->Member->Authorization->find('list');
$this->set(compact('people', 'formulas', 'guardian1s', 'guardian2s', 'emergency1s', 'emergency2s', 'authorizations'));
}
=== modified file 'app/models/member.php'
--- app/models/member.php 2011-05-27 07:58:31 +0000
+++ app/models/member.php 2011-05-30 11:19:15 +0000
@@ -16,7 +16,7 @@
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
- //'allowEmpty' => false,
+ 'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
@@ -26,7 +26,7 @@
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
- //'allowEmpty' => false,
+ 'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
@@ -36,7 +36,7 @@
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
- //'allowEmpty' => false,
+ 'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
@@ -46,7 +46,7 @@
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
- //'allowEmpty' => false,
+ 'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
@@ -81,42 +81,42 @@
'foreignKey' => 'person_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Person.lastname ASC, Person.firstname ASC'
),
'Formula' => array(
'className' => 'Formula',
'foreignKey' => 'formula_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Formula.name ASC'
),
'Guardian1' => array(
'className' => 'Person',
'foreignKey' => 'guardian1_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Guardian1.lastname ASC, Guardian1.firstname ASC'
),
'Guardian2' => array(
'className' => 'Person',
'foreignKey' => 'guardian2_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Guardian2.lastname ASC, Guardian2.firstname ASC'
),
'Emergency1' => array(
'className' => 'Person',
'foreignKey' => 'emergency1_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Emergency1.lastname ASC, Emergency1.firstname ASC'
),
'Emergency2' => array(
'className' => 'Person',
'foreignKey' => 'emergency2_id',
'conditions' => '',
'fields' => '',
- 'order' => ''
+ 'order' => 'Emergency2.lastname ASC, Emergency2.firstname ASC'
)
);
@@ -138,4 +138,13 @@
)
);
+ var $actsAs = array(
+ 'Uploader.Attachment' => array(
+ 'file' => array(
+ 'uploadDir' => '/uploads/members/', // Where to upload to, relative to app webroot
+ 'dbColumn' => 'medical_certificat', // The database column name to save the path to
+ )
+ )
+ );
+
}
=== modified file 'app/views/members/add.ctp'
--- app/views/members/add.ctp 2011-05-27 07:58:31 +0000
+++ app/views/members/add.ctp 2011-05-30 11:19:15 +0000
@@ -1,18 +1,61 @@
<div class="members form">
-<?php echo $this->Form->create('Member');?>
+<?php echo $this->Form->create('Member', array('type' => 'file'));?>
<fieldset>
<legend><?php __('Add Member'); ?></legend>
<?php
- echo $this->Form->input('person_id');
- echo $this->Form->input('guardian1_id');
- echo $this->Form->input('guardian2_id');
- echo $this->Form->input('emergency1_id');
- echo $this->Form->input('emergency2_id');
- echo $this->Form->input('formula_id');
- echo $this->Form->input('membership_date');
- echo $this->Form->input('notes');
- echo $this->Form->input('medical_certificat');
- echo $this->Form->input('Authorization');
+ echo $this->Form->input('person_id', array('label' => __('Member', true)));
+ echo $this->Form->input('guardian1_id',
+ array(
+ 'label' => __('Guardian', true),
+ 'empty' => __('The member is not an underaged', true)
+ )
+ );
+ echo $this->Form->input('guardian2_id',
+ array(
+ 'label' => __('Guardian (optionnal)', true),
+ 'empty' => __('The member is not an underaged', true)
+ )
+ );
+ echo $this->Form->input('emergency1_id',
+ array(
+ 'label' => __('Emergency contact', true),
+ )
+ );
+ echo $this->Form->input('emergency2_id',
+ array(
+ 'label' => __('Emergency contact (optionnal)', true),
+ 'empty' => __('No second emergency contact is declared', true)
+ )
+ );
+ echo $this->Form->input('formula_id',
+ array(
+ 'label' => __('Formula', true)
+ )
+ );
+ echo $this->Form->input('membership_date',
+ array(
+ 'label' => __('Begin of membership', true),
+ 'dateFormat' => 'DMY',
+ 'minYear' => date('Y')-2,
+ 'maxYear' => date('Y')+1
+ )
+ );
+ echo $this->Form->input('file',
+ array(
+ 'label' => __('Medical certificat', true),
+ 'type' => 'file'
+ )
+ );
+ echo $this->Form->input('notes',
+ array(
+ 'label' => __('Notes/comments', true)
+ )
+ );
+ echo $this->Form->input('Authorization',
+ array(
+ 'label' => __('Authorizations accepted', true)
+ )
+ );
?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
=== modified file 'app/views/members/edit.ctp'
--- app/views/members/edit.ctp 2011-05-27 07:58:31 +0000
+++ app/views/members/edit.ctp 2011-05-30 11:19:15 +0000
@@ -1,19 +1,72 @@
+<?php
+echo $this->Html->script('jquery-1.6.x.min');
+
+$this->Js->get('#MemberEditForm')->event('submit',
+ "alert('formular submit');
+ if($('#MemberFile').val() == '') {
+ $('#MemberFile').parent('div').detach();
+ }
+ return true;", true);
+;?>
<div class="members form">
-<?php echo $this->Form->create('Member');?>
+<?php echo $this->Form->create('Member', array('type' => 'file'));?>
<fieldset>
<legend><?php __('Edit Member'); ?></legend>
<?php
echo $this->Form->input('id');
- echo $this->Form->input('person_id');
- echo $this->Form->input('guardian1_id');
- echo $this->Form->input('guardian2_id');
- echo $this->Form->input('emergency1_id');
- echo $this->Form->input('emergency2_id');
- echo $this->Form->input('formula_id');
- echo $this->Form->input('membership_date');
- echo $this->Form->input('notes');
- echo $this->Form->input('medical_certificat');
- echo $this->Form->input('Authorization');
+ echo $this->Form->input('person_id', array('label' => __('Member', true)));
+ echo $this->Form->input('guardian1_id',
+ array(
+ 'label' => __('Guardian', true),
+ 'empty' => __('The member is not an underaged', true)
+ )
+ );
+ echo $this->Form->input('guardian2_id',
+ array(
+ 'label' => __('Guardian (optionnal)', true),
+ 'empty' => __('The member is not an underaged', true)
+ )
+ );
+ echo $this->Form->input('emergency1_id',
+ array(
+ 'label' => __('Emergency contact', true),
+ )
+ );
+ echo $this->Form->input('emergency2_id',
+ array(
+ 'label' => __('Emergency contact (optionnal)', true),
+ 'empty' => __('No second emergency contact is declared', true)
+ )
+ );
+ echo $this->Form->input('formula_id',
+ array(
+ 'label' => __('Formula', true)
+ )
+ );
+ echo $this->Form->input('membership_date',
+ array(
+ 'label' => __('Begin of membership', true),
+ 'dateFormat' => 'DMY',
+ 'minYear' => date('Y')-2,
+ 'maxYear' => date('Y')+1
+ )
+ );
+ echo $this->Form->input('file',
+ array(
+ 'label' => __('Medical certificat', true),
+ 'type' => 'file'
+ )
+ );
+ echo $this->Form->input('notes',
+ array(
+ 'label' => __('Notes/comments', true)
+ )
+ );
+ echo $this->Form->input('Authorization',
+ array(
+ 'label' => __('Authorizations accepted', true)
+ )
+ );
?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
@@ -31,4 +84,5 @@
<li><?php echo $this->Html->link(__('List Authorizations', true), array('controller' => 'authorizations', 'action' => 'index')); ?> </li>
<li><?php echo $this->Html->link(__('New Authorization', true), array('controller' => 'authorizations', 'action' => 'add')); ?> </li>
</ul>
-</div>
\ No newline at end of file
+</div>
+<?php echo $this->Js->writeBuffer(); ?>
\ No newline at end of file
=== modified file 'app/views/members/index.ctp'
--- app/views/members/index.ctp 2011-05-27 07:58:31 +0000
+++ app/views/members/index.ctp 2011-05-30 11:19:15 +0000
@@ -2,16 +2,11 @@
<h2><?php __('Members');?></h2>
<table cellpadding="0" cellspacing="0">
<tr>
- <th><?php echo $this->Paginator->sort('id');?></th>
- <th><?php echo $this->Paginator->sort('person_id');?></th>
- <th><?php echo $this->Paginator->sort('guardian1_id');?></th>
- <th><?php echo $this->Paginator->sort('guardian2_id');?></th>
- <th><?php echo $this->Paginator->sort('emergency1_id');?></th>
- <th><?php echo $this->Paginator->sort('emergency2_id');?></th>
- <th><?php echo $this->Paginator->sort('formula_id');?></th>
- <th><?php echo $this->Paginator->sort('membership_date');?></th>
- <th><?php echo $this->Paginator->sort('notes');?></th>
- <th><?php echo $this->Paginator->sort('medical_certificat');?></th>
+ <th><?php echo $this->Paginator->sort(__('Member', true), 'person_id');?></th>
+ <th><?php echo __('Guardian(s)');?></th>
+ <th><?php echo __('Emergency');?></th>
+ <th><?php echo $this->Paginator->sort(__('Formula', true), 'formula_id');?></th>
+ <th><?php echo $this->Paginator->sort(__('Membership date', true), 'membership_date');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@@ -23,28 +18,23 @@
}
?>
<tr<?php echo $class;?>>
- <td><?php echo $member['Member']['id']; ?> </td>
<td>
<?php echo $this->Html->link($member['Person']['name'], array('controller' => 'people', 'action' => 'view', $member['Person']['id'])); ?>
</td>
<td>
- <?php echo $this->Html->link($member['Guardian1']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian1']['id'])); ?>
- </td>
- <td>
- <?php echo $this->Html->link($member['Guardian2']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian2']['id'])); ?>
- </td>
- <td>
- <?php echo $this->Html->link($member['Emergency1']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency1']['id'])); ?>
- </td>
- <td>
- <?php echo $this->Html->link($member['Emergency2']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency2']['id'])); ?>
+ <?php echo $this->Html->link($member['Guardian1']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian1']['id'])).' '.$this->Html->link($member['Guardian2']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian2']['id'])); ?>
+ </td>
+ <td>
+ <?php echo $this->Html->link($member['Emergency1']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency1']['id'])).' '.$this->Html->link($member['Emergency2']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency2']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($member['Formula']['name'], array('controller' => 'formulas', 'action' => 'view', $member['Formula']['id'])); ?>
</td>
- <td><?php echo $member['Member']['membership_date']; ?> </td>
- <td><?php echo $member['Member']['notes']; ?> </td>
- <td><?php echo $member['Member']['medical_certificat']; ?> </td>
+ <td>
+ <?php
+ $date = new DateTime($member['Member']['membership_date']);
+ echo $date->format('d F Y')
+ ?> </td>
<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'])); ?>
=== modified file 'app/views/members/view.ctp'
--- app/views/members/view.ctp 2011-05-27 07:58:31 +0000
+++ app/views/members/view.ctp 2011-05-30 11:19:15 +0000
@@ -1,32 +1,27 @@
<div class="members view">
<h2><?php __('Member');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
- <dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['id']; ?>
-
- </dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Person'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Member'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($member['Person']['name'], array('controller' => 'people', 'action' => 'view', $member['Person']['id'])); ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Guardian1'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Guardian'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($member['Guardian1']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian1']['id'])); ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Guardian2'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Guardian'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($member['Guardian2']['name'], array('controller' => 'people', 'action' => 'view', $member['Guardian2']['id'])); ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Emergency1'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Emergency'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($member['Emergency1']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency1']['id'])); ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Emergency2'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Emergency'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($member['Emergency2']['name'], array('controller' => 'people', 'action' => 'view', $member['Emergency2']['id'])); ?>
@@ -36,12 +31,15 @@
<?php echo $this->Html->link($member['Formula']['name'], array('controller' => 'formulas', 'action' => 'view', $member['Formula']['id'])); ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Membership Date'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Membership date'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
- <?php echo $member['Member']['membership_date']; ?>
+ <?php
+ $date = new DateTime($member['Member']['membership_date']);
+ echo $date->format('d F Y')
+ ?>
</dd>
- <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes'); ?></dt>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes/comments'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $member['Member']['notes']; ?>
@@ -51,6 +49,15 @@
<?php echo $member['Member']['medical_certificat']; ?>
</dd>
+ <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Authorizations accepted'); ?></dt>
+ <dd<?php if ($i++ % 2 == 0) echo $class;?>>
+ <ul>
+ <?php foreach ($member['Authorization'] as $authorization): ?>
+ <?php echo '<li>'.$authorization['name'].'</li>';?>
+ <?php endforeach; ?>
+ </ul>
+
+ </dd>
</dl>
</div>
<div class="actions">
@@ -68,39 +75,3 @@
<li><?php echo $this->Html->link(__('New Authorization', true), array('controller' => 'authorizations', 'action' => 'add')); ?> </li>
</ul>
</div>
-<div class="related">
- <h3><?php __('Related Authorizations');?></h3>
- <?php if (!empty($member['Authorization'])):?>
- <table cellpadding = "0" cellspacing = "0">
- <tr>
- <th><?php __('Id'); ?></th>
- <th><?php __('Name'); ?></th>
- <th class="actions"><?php __('Actions');?></th>
- </tr>
- <?php
- $i = 0;
- foreach ($member['Authorization'] as $authorization):
- $class = null;
- if ($i++ % 2 == 0) {
- $class = ' class="altrow"';
- }
- ?>
- <tr<?php echo $class;?>>
- <td><?php echo $authorization['id'];?></td>
- <td><?php echo $authorization['name'];?></td>
- <td class="actions">
- <?php echo $this->Html->link(__('View', true), array('controller' => 'authorizations', 'action' => 'view', $authorization['id'])); ?>
- <?php echo $this->Html->link(__('Edit', true), array('controller' => 'authorizations', 'action' => 'edit', $authorization['id'])); ?>
- <?php echo $this->Html->link(__('Delete', true), array('controller' => 'authorizations', 'action' => 'delete', $authorization['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $authorization['id'])); ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </table>
-<?php endif; ?>
-
- <div class="actions">
- <ul>
- <li><?php echo $this->Html->link(__('New Authorization', true), array('controller' => 'authorizations', 'action' => 'add'));?> </li>
- </ul>
- </div>
-</div>
=== added directory 'app/webroot/uploads/members'