Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created December 25, 2014 02:51
Show Gist options
  • Save taleeb35/bda717e1c403fb86c802 to your computer and use it in GitHub Desktop.
Save taleeb35/bda717e1c403fb86c802 to your computer and use it in GitHub Desktop.
Add.ctp (Form)
<div class="controls form">
<?php echo $this->Form->create('Control'); ?>
<?php $week_days = array(1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday", 7 => "Sunday"); ?>
<?php $month_days = array(01 => 01, 02 => 02, 03 => 03, 04 => 04, 05 => 05, 06 => 06, 07 => 07, 08 => 08, 09 => 09, 10 => 10, 11 => 11, 12 => 12, 13 => 13,
14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23, 24 => 24,
25 => 25, 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30, 31 => 31); ?>
<?php $month_days_quarter = array(01 => 01, 02 => 02, 03 => 03, 04 => 04, 05 => 05, 06 => 06, 07 => 07, 08 => 08, 09 => 09, 10 => 10, 11 => 11, 12 => 12, 13 => 13,
14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23, 24 => 24,
25 => 25, 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30); ?>
<?php $quarter_month = array(1 => "Month 1", 2 => "Month 2", 3 => "Month 3"); ?>
<fieldset>
<legend><?php echo __('Add Control'); ?></legend>
<?php
echo $this->Form->input('name',array('label' => 'Task Title'));
echo $this->Form->input('description',array('label' => 'Task Description'));
echo $this->Ck->load('Control.description');
/* echo $this->Form->input('testing_procedure');
echo $this->Ck->load('Control.TestingProcedure');
echo $this->Form->input('success_criteria');
echo $this->Ck->load('Control.SuccessCriteria'); */
echo $this->Form->input('control_frequency_id', array('id' => 'frequency')); ?>
<div id="weekly" style="margin-left: -10px;">
<?php echo $this->Form->input('day_number',array('type' => 'select','options' => $week_days)); ?>
</div>
<div id="monthly" style="margin-left: -10px;">
<?php echo $this->Form->input('day_number',array('type' => 'select','options' => $month_days)); ?>
</div>
<div id="quarterly" style="margin-left: -10px;">
<?php echo $this->Form->input('select_quarter_month',array('type' => 'select', 'options' => $quarter_month));
echo $this->Form->input('select_quarter_date' ,array('type' => 'select', 'options' => $month_days_quarter)); ?>
</div>
<div id="annualy" style="margin-left: -10px;">
<?php echo $this->Form->input('select_month',array('type' => 'date', 'dateFormat' => 'M', 'empty' => 'Choose Month'));
echo $this->Form->input('select_date' ,array('type' => 'select', 'options' => $month_days)); ?>
</div>
<?php echo $this->Form->input('owner_id'); ?>
<?php //echo $this->Form->input('risk_level_id'); ?>
</fieldset>
<?php echo $this->Form->end(__('Submit'));?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('List Controls'), array('action' => 'index'));?></li>
</ul>
</div>
<script type="text/javascript">
$('#weekly,#monthly,#quarterly,#annualy').hide();
$('#frequency').change(function(){
var selection = $("option:selected", this).text();
switch(selection) {
case 'Weekly':
$('#weekly').show();
$('#monthly').hide();
$('#annualy').hide();
$('#quarterly').hide();
break;
case 'Monthly':
$('#monthly').show();
$('#weekly').hide();
$('#annualy').hide();
$('#quarterly').hide();
break;
case 'Quarterly':
$('#quarterly').show();
$('#weekly').hide();
$('#annualy').hide();
$('#monthly').hide();
break;
case 'Annual':
$('#annualy').show();
$('#weekly').hide();
$('#quarterly').hide();
$('#monthly').hide();
break;
default:
$('#weekly,#monthly,#quarterly,#annualy').hide();
break;
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment