Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created December 25, 2014 02:48
Show Gist options
  • Save taleeb35/7dcab765780969ca9a8d to your computer and use it in GitHub Desktop.
Save taleeb35/7dcab765780969ca9a8d to your computer and use it in GitHub Desktop.
Add Function
// This is my add function that save different value when different frequency is selected in form
if($this->request->data['Control']['control_frequency_id'] == 6) { // If Frequency is Annualy
$current_month = $this->request->data['Control']['select_month'];
$month= implode($current_month, ",");
$current_day = $this->request->data['Control']['select_date'];
$current_year = Date("Y");
$days = date("z", mktime(0,0,0,$month,$current_day,$current_year)); // Calculate the days
$this->request->data['Control']['day_number'] = $days; // Save the Days in database
} elseif($this->request->data['Control']['control_frequency_id'] == 4) { // If frequency is Quarterly
if($this->request->data['Control']['select_quarter_month'] == 1) {
$days = $this->request->data['Control']['select_quarter_date'];
$this->request->data['Control']['day_number'] = $days;
} elseif($this->request->data['Control']['select_quarter_month'] == 2) {
$days = $this->request->data['Control']['select_quarter_date'];
$total_days = $days + 30;
$this->request->data['Control']['day_number'] = $total_days;
} elseif($this->request->data['Control']['select_quarter_month'] == 3) {
$days = $this->request->data['Control']['select_quarter_date'];
$total_days = $days + 60;
$this->request->data['Control']['day_number'] = $total_days;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment