← Back to team overview

amm-dev-tem team mailing list archive

[Branch ~amm-dev-tem/amm/trunk] Rev 28: 'Person' HABTM 'Ranks' and modification of 'view' in 'People'

 

------------------------------------------------------------
revno: 28
committer: The Whole Life To Learn <thewholelifetolearn@xxxxxxxxx>
branch nick: sources
timestamp: Tue 2011-05-31 20:55:15 +0200
message:
  'Person' HABTM 'Ranks' and modification of 'view' in 'People'
modified:
  app/models/person.php
  app/views/people/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/models/person.php'
--- app/models/person.php	2011-05-30 15:15:31 +0000
+++ app/models/person.php	2011-05-31 18:55:15 +0000
@@ -206,8 +206,24 @@
 			'finderQuery' => '',
 			'deleteQuery' => '',
 			'insertQuery' => ''
+		),
+		'Rank' => array(
+			'className' => 'Rank',
+			'joinTable' => 'person_infos',
+			'foreignKey' => 'person_id',
+			'associationForeignKey' => 'rank_id',
+			'unique' => true,
+			'conditions' => '',
+			'fields' => '',
+			'order' => '',
+			'limit' => '',
+			'offset' => '',
+			'finderQuery' => '',
+			'deleteQuery' => '',
+			'insertQuery' => ''
 		)
 	);
+	
 	var $actsAs = array(
 		'Uploader.Attachment' => array(
 			'picture' => array(

=== modified file 'app/views/people/view.ctp'
--- app/views/people/view.ctp	2011-05-26 19:00:04 +0000
+++ app/views/people/view.ctp	2011-05-31 18:55:15 +0000
@@ -42,6 +42,33 @@
 			<?php echo $person['Person']['job']; ?>
 			&nbsp;
 		</dd>
+		<?php if (!empty($person['PersonInfo'])):?>
+		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Rank'); ?></dt>
+		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+			<?php echo $person['Rank'][0]['name']; ?>
+			&nbsp;
+		</dd>
+		<?php endif; ?>
+		<?php if (!empty($person['Event'])):?>
+		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Participates in: '); ?></dt>
+		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+			<ul>
+				<?php foreach ($person['Event'] as $event): ?>
+				<li><?php echo $event['name'];?></li>
+				<?php endforeach; ?>
+			</ul>
+		</dd>
+		<?php endif; ?>
+		<?php if (!empty($person['Place'])):?>
+		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Goes to: '); ?></dt>
+		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
+			<ul>
+				<?php foreach ($person['Place'] as $place): ?>
+				<li><?php echo $place['name'];?></li>
+				<?php endforeach; ?>
+			</ul>
+		</dd>
+		<?php endif; ?>
 		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes/comments'); ?></dt>
 		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
 			<?php echo $person['Person']['notes']; ?>
@@ -65,382 +92,4 @@
 		<li><?php echo $this->Html->link(__('List Places', true), array('controller' => 'places', 'action' => 'index')); ?> </li>
 		<li><?php echo $this->Html->link(__('New Place', true), array('controller' => 'places', 'action' => 'add')); ?> </li>
 	</ul>
-</div>
-<div class="related">
-	<h3><?php __('Related Members');?></h3>
-	<?php if (!empty($person['Member'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Guardian1 Id'); ?></th>
-		<th><?php __('Guardian2 Id'); ?></th>
-		<th><?php __('Emergency1 Id'); ?></th>
-		<th><?php __('Emergency2 Id'); ?></th>
-		<th><?php __('Formula Id'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Member'] as $member):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $member['id'];?></td>
-			<td><?php echo $member['person_id'];?></td>
-			<td><?php echo $member['guardian1_id'];?></td>
-			<td><?php echo $member['guardian2_id'];?></td>
-			<td><?php echo $member['emergency1_id'];?></td>
-			<td><?php echo $member['emergency2_id'];?></td>
-			<td><?php echo $member['formula_id'];?></td>
-			<td><?php echo $member['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'members', 'action' => 'view', $member['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'members', 'action' => 'edit', $member['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'members', 'action' => 'delete', $member['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $member['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Member', true), array('controller' => 'members', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Person Infos');?></h3>
-	<?php if (!empty($person['PersonInfo'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Rank Id'); ?></th>
-		<th><?php __('Media Accept'); ?></th>
-		<th><?php __('List Accept'); ?></th>
-		<th><?php __('Medical Certificat'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['PersonInfo'] as $personInfo):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $personInfo['id'];?></td>
-			<td><?php echo $personInfo['person_id'];?></td>
-			<td><?php echo $personInfo['rank_id'];?></td>
-			<td><?php echo $personInfo['media_accept'];?></td>
-			<td><?php echo $personInfo['list_accept'];?></td>
-			<td><?php echo $personInfo['medical_certificat'];?></td>
-			<td><?php echo $personInfo['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'person_infos', 'action' => 'view', $personInfo['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'person_infos', 'action' => 'edit', $personInfo['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'person_infos', 'action' => 'delete', $personInfo['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $personInfo['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Person Info', true), array('controller' => 'person_infos', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Members');?></h3>
-	<?php if (!empty($person['Guardian1'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Guardian1 Id'); ?></th>
-		<th><?php __('Guardian2 Id'); ?></th>
-		<th><?php __('Emergency1 Id'); ?></th>
-		<th><?php __('Emergency2 Id'); ?></th>
-		<th><?php __('Formula Id'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Guardian1'] as $guardian1):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $guardian1['id'];?></td>
-			<td><?php echo $guardian1['person_id'];?></td>
-			<td><?php echo $guardian1['guardian1_id'];?></td>
-			<td><?php echo $guardian1['guardian2_id'];?></td>
-			<td><?php echo $guardian1['emergency1_id'];?></td>
-			<td><?php echo $guardian1['emergency2_id'];?></td>
-			<td><?php echo $guardian1['formula_id'];?></td>
-			<td><?php echo $guardian1['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'members', 'action' => 'view', $guardian1['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'members', 'action' => 'edit', $guardian1['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'members', 'action' => 'delete', $guardian1['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $guardian1['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Guardian1', true), array('controller' => 'members', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Members');?></h3>
-	<?php if (!empty($person['Guardian2'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Guardian1 Id'); ?></th>
-		<th><?php __('Guardian2 Id'); ?></th>
-		<th><?php __('Emergency1 Id'); ?></th>
-		<th><?php __('Emergency2 Id'); ?></th>
-		<th><?php __('Formula Id'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Guardian2'] as $guardian2):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $guardian2['id'];?></td>
-			<td><?php echo $guardian2['person_id'];?></td>
-			<td><?php echo $guardian2['guardian1_id'];?></td>
-			<td><?php echo $guardian2['guardian2_id'];?></td>
-			<td><?php echo $guardian2['emergency1_id'];?></td>
-			<td><?php echo $guardian2['emergency2_id'];?></td>
-			<td><?php echo $guardian2['formula_id'];?></td>
-			<td><?php echo $guardian2['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'members', 'action' => 'view', $guardian2['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'members', 'action' => 'edit', $guardian2['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'members', 'action' => 'delete', $guardian2['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $guardian2['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Guardian2', true), array('controller' => 'members', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Members');?></h3>
-	<?php if (!empty($person['Emergency1'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Guardian1 Id'); ?></th>
-		<th><?php __('Guardian2 Id'); ?></th>
-		<th><?php __('Emergency1 Id'); ?></th>
-		<th><?php __('Emergency2 Id'); ?></th>
-		<th><?php __('Formula Id'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Emergency1'] as $emergency1):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $emergency1['id'];?></td>
-			<td><?php echo $emergency1['person_id'];?></td>
-			<td><?php echo $emergency1['guardian1_id'];?></td>
-			<td><?php echo $emergency1['guardian2_id'];?></td>
-			<td><?php echo $emergency1['emergency1_id'];?></td>
-			<td><?php echo $emergency1['emergency2_id'];?></td>
-			<td><?php echo $emergency1['formula_id'];?></td>
-			<td><?php echo $emergency1['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'members', 'action' => 'view', $emergency1['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'members', 'action' => 'edit', $emergency1['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'members', 'action' => 'delete', $emergency1['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $emergency1['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Emergency1', true), array('controller' => 'members', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Members');?></h3>
-	<?php if (!empty($person['Emergency2'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Person Id'); ?></th>
-		<th><?php __('Guardian1 Id'); ?></th>
-		<th><?php __('Guardian2 Id'); ?></th>
-		<th><?php __('Emergency1 Id'); ?></th>
-		<th><?php __('Emergency2 Id'); ?></th>
-		<th><?php __('Formula Id'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Emergency2'] as $emergency2):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $emergency2['id'];?></td>
-			<td><?php echo $emergency2['person_id'];?></td>
-			<td><?php echo $emergency2['guardian1_id'];?></td>
-			<td><?php echo $emergency2['guardian2_id'];?></td>
-			<td><?php echo $emergency2['emergency1_id'];?></td>
-			<td><?php echo $emergency2['emergency2_id'];?></td>
-			<td><?php echo $emergency2['formula_id'];?></td>
-			<td><?php echo $emergency2['notes'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'members', 'action' => 'view', $emergency2['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'members', 'action' => 'edit', $emergency2['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'members', 'action' => 'delete', $emergency2['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $emergency2['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Emergency2', true), array('controller' => 'members', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Events');?></h3>
-	<?php if (!empty($person['Event'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Name'); ?></th>
-		<th><?php __('Date Begin'); ?></th>
-		<th><?php __('Date End'); ?></th>
-		<th><?php __('Fullday'); ?></th>
-		<th><?php __('Notes'); ?></th>
-		<th><?php __('Fees'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Event'] as $event):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $event['id'];?></td>
-			<td><?php echo $event['name'];?></td>
-			<td><?php echo $event['date_begin'];?></td>
-			<td><?php echo $event['date_end'];?></td>
-			<td><?php echo $event['fullday'];?></td>
-			<td><?php echo $event['notes'];?></td>
-			<td><?php echo $event['fees'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'events', 'action' => 'view', $event['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'events', 'action' => 'edit', $event['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'events', 'action' => 'delete', $event['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $event['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Event', true), array('controller' => 'events', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
-<div class="related">
-	<h3><?php __('Related Places');?></h3>
-	<?php if (!empty($person['Place'])):?>
-	<table cellpadding = "0" cellspacing = "0">
-	<tr>
-		<th><?php __('Id'); ?></th>
-		<th><?php __('Name'); ?></th>
-		<th><?php __('Address'); ?></th>
-		<th><?php __('Address Complementary'); ?></th>
-		<th><?php __('Postal Code'); ?></th>
-		<th><?php __('Town'); ?></th>
-		<th><?php __('Description'); ?></th>
-		<th class="actions"><?php __('Actions');?></th>
-	</tr>
-	<?php
-		$i = 0;
-		foreach ($person['Place'] as $place):
-			$class = null;
-			if ($i++ % 2 == 0) {
-				$class = ' class="altrow"';
-			}
-		?>
-		<tr<?php echo $class;?>>
-			<td><?php echo $place['id'];?></td>
-			<td><?php echo $place['name'];?></td>
-			<td><?php echo $place['address'];?></td>
-			<td><?php echo $place['address_complementary'];?></td>
-			<td><?php echo $place['postal_code'];?></td>
-			<td><?php echo $place['town'];?></td>
-			<td><?php echo $place['description'];?></td>
-			<td class="actions">
-				<?php echo $this->Html->link(__('View', true), array('controller' => 'places', 'action' => 'view', $place['id'])); ?>
-				<?php echo $this->Html->link(__('Edit', true), array('controller' => 'places', 'action' => 'edit', $place['id'])); ?>
-				<?php echo $this->Html->link(__('Delete', true), array('controller' => 'places', 'action' => 'delete', $place['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $place['id'])); ?>
-			</td>
-		</tr>
-	<?php endforeach; ?>
-	</table>
-<?php endif; ?>
-
-	<div class="actions">
-		<ul>
-			<li><?php echo $this->Html->link(__('New Place', true), array('controller' => 'places', 'action' => 'add'));?> </li>
-		</ul>
-	</div>
-</div>
+</div>
\ No newline at end of file