First pass at implementing a new lock tracking mechnism. Not complete, but the basics seem to work
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1038 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
18
site/views/elements/locks.ctp
Normal file
18
site/views/elements/locks.ctp
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['Name'] = array('index' => 'name', 'formatter' => 'longname');
|
||||
$cols['Quantity'] = array('index' => 'qty', 'formatter' => 'number');
|
||||
$cols['Key'] = array('index' => 'key', 'formatter' => 'shortname');
|
||||
$cols['Last Key'] = array('index' => 'last_key', 'formatter' => 'shortname');
|
||||
$cols['Comment'] = array('index' => 'comment', 'formatter' => 'comment');
|
||||
|
||||
// Render the grid
|
||||
$grid
|
||||
->columns($cols)
|
||||
->sortField('Name')
|
||||
->defaultFields(array('Name'))
|
||||
->searchFields(array('Name'))
|
||||
->render($this, isset($config) ? $config : null,
|
||||
array_diff(array_keys($cols), array('Comment')));
|
||||
48
site/views/locks/edit.ctp
Normal file
48
site/views/locks/edit.ctp
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
//pr($this->data);
|
||||
?>
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
// Reset the form
|
||||
function newKey(dig) {
|
||||
$('#LockKey').val(("000000000" + Math.floor(Math.random()*(Math.pow(10,dig)))) . slice(-1*dig));
|
||||
}
|
||||
|
||||
--></script>
|
||||
|
||||
<?php
|
||||
; // alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* Lock Edit
|
||||
*/
|
||||
|
||||
echo '<div class="lock edit">' . "\n";
|
||||
|
||||
echo $form->create('Lock', array('action' => 'edit')) . "\n";
|
||||
echo $form->input('id') . "\n";
|
||||
|
||||
echo($this->element
|
||||
('form_table',
|
||||
array('class' => 'item lock detail',
|
||||
'caption' => isset($this->data['Lock']) ? 'Edit Lock' : 'New Lock',
|
||||
'fields' => array
|
||||
('name' => array('label_attributes' => array('class' => 'empty'),
|
||||
'after' => ("Name of the Lock Set")),
|
||||
'key' => array('label_attributes' => array('class' => 'empty'),
|
||||
'after' => ('(<A HREF="#" ONCLICK="newKey(4); return false;">New</A>) Key Code / Combination')),
|
||||
'qty' => array('label_attributes' => array('class' => 'empty'),
|
||||
'after' => ("Quantity")),
|
||||
'comment' => array('label_attributes' => array('class' => 'optional empty'),
|
||||
'after' => 'Optional: Comments about this lock set.'),
|
||||
))) . "\n");
|
||||
|
||||
echo $form->submit(isset($this->data['Lock']) ? 'Update' : 'Add New Lock') . "\n";
|
||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
||||
echo $form->end() . "\n";
|
||||
echo '</div>' . "\n";
|
||||
43
site/views/locks/view.ctp
Normal file
43
site/views/locks/view.ctp
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
echo '<div class="lock view">' . "\n";
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* Lock Detail Main Section
|
||||
*/
|
||||
|
||||
$lock = $lock['Lock'];
|
||||
|
||||
$rows = array();
|
||||
$rows[] = array('Name', $lock['name']);
|
||||
$rows[] = array('Quantity', $lock['qty']);
|
||||
$rows[] = array('Key', $lock['key']);
|
||||
if (!empty($lock['last_key']))
|
||||
$rows[] = array('Last Key', $lock['last_key']);
|
||||
$rows[] = array('Comment', $lock['comment']);
|
||||
|
||||
echo $this->element('table',
|
||||
array('class' => 'item lock detail',
|
||||
'caption' => 'Lock Information',
|
||||
'rows' => $rows,
|
||||
'column_class' => array('field', 'value')));
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* Supporting Elements Section
|
||||
*/
|
||||
|
||||
echo '<div CLASS="detail supporting">' . "\n";
|
||||
|
||||
/* End "detail supporting" div */
|
||||
echo '</div>' . "\n";
|
||||
|
||||
/* End page div */
|
||||
echo '</div>' . "\n";
|
||||
142
site/views/units/lock.ctp
Normal file
142
site/views/units/lock.ctp
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
/**********************************************************************
|
||||
* Because we make use of functions here,
|
||||
* we need to put our top level variables somewhere
|
||||
* we can access them.
|
||||
*/
|
||||
$this->varstore = compact('locks');
|
||||
|
||||
function lockDiv($obj) {
|
||||
|
||||
$div =
|
||||
// BEGIN lock-div
|
||||
'<DIV>' . "\n" .
|
||||
// BEGIN lock-fieldset
|
||||
'<FIELDSET CLASS="lock subset">' . "\n" .
|
||||
'<LEGEND>Lock #%{id} (%{remove})</LEGEND>' . "\n" .
|
||||
|
||||
// BEGIN lock-n-div
|
||||
'<div id="lock-%{id}-div">' . "\n" .
|
||||
|
||||
$obj->element
|
||||
('form_table',
|
||||
array('class' => "item lock entry",
|
||||
'field_prefix' => 'Lock.%{id}',
|
||||
'fields' => array
|
||||
(
|
||||
'id' => array('name' => 'Lock',
|
||||
'label_attributes' => array('class' => 'required'),
|
||||
'opts' => array('options' => $obj->varstore['locks']),
|
||||
'after' => "Select the lock."),
|
||||
|
||||
))) . "\n" .
|
||||
|
||||
// END lock-n-div
|
||||
'</div>' . "\n" .
|
||||
|
||||
// END lock-fieldset
|
||||
'</FIELDSET>' . "\n" .
|
||||
// END lock-div
|
||||
'</DIV>'
|
||||
;
|
||||
|
||||
return $div;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* Javascript
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
function addLock(flash) {
|
||||
addDiv('lock-entry-id', 'lock', 'locks', flash, <?php
|
||||
echo FormatHelper::phpVarToJavascript
|
||||
(lockDiv($this),
|
||||
null,
|
||||
' ');
|
||||
?>
|
||||
);
|
||||
}
|
||||
|
||||
// Reset the form
|
||||
function resetForm() {
|
||||
$('#locks').html('');
|
||||
$('#lock-entry-id').val(1);
|
||||
|
||||
<?php foreach ($this->data['Lock'] AS $lock): ?>
|
||||
addDiv('lock-entry-id', 'lock', 'locks', false, <?php
|
||||
echo FormatHelper::phpVarToJavascript
|
||||
(lockDiv($this),
|
||||
null,
|
||||
' ');
|
||||
?>
|
||||
);
|
||||
$('#Lock'+($('#lock-entry-id').val()-1)+'Id').val(<?php echo $lock['id'] ?>);
|
||||
<?php endforeach; ?>
|
||||
|
||||
if ($("#lock-entry-id").val() == 1) {
|
||||
addDiv('lock-entry-id', 'lock', 'locks', false, <?php
|
||||
echo FormatHelper::phpVarToJavascript
|
||||
(lockDiv($this),
|
||||
null,
|
||||
' ');
|
||||
?>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
resetForm();
|
||||
});
|
||||
|
||||
--></script>
|
||||
|
||||
<?php
|
||||
; // alignment
|
||||
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
* Unit-Lock Edit
|
||||
*/
|
||||
|
||||
echo '<div class="unit-lock edit">' . "\n";
|
||||
|
||||
echo $form->create('Unit', array('action' => 'lock')) . "\n";
|
||||
echo $form->hidden('id') . "\n";
|
||||
|
||||
?>
|
||||
|
||||
<div CLASS="dynamic-set">
|
||||
<fieldset CLASS="lock superset">
|
||||
<legend>Locks</legend>
|
||||
<input type="hidden" id="lock-entry-id" value="0">
|
||||
<div id="locks"></div>
|
||||
<fieldset> <legend>
|
||||
<a href="#" onClick="addLock(true); return false;">Add a Lock</a>
|
||||
</legend> </fieldset>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
; // Alignment
|
||||
|
||||
echo $form->submit('Update Locks') . "\n";
|
||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
||||
echo $form->end() . "\n";
|
||||
echo '</div>' . "\n";
|
||||
|
||||
echo "\n<PRE>\n";
|
||||
echo print_r($this->data, true);
|
||||
echo print_r($this->varstore, true);
|
||||
echo "\n</PRE>\n";
|
||||
|
||||
Reference in New Issue
Block a user