Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2490

Přidáno uživatelem David Raška před více než 9 roky(ů)

Novinky:
refs #965: Neomezeny konec preruseni

Opravy:
Oprava nefunkcniho overovani kolize vice preruseni clenstvi

Zobrazit rozdíly:

freenetis/branches/1.2/application/controllers/membership_interrupts.php
$this->form = new Forge('membership_interrupts/add/'.$member->id);
$this->form->group('Basic data');
$this->form->hidden('member_id')
->value($member->id);
if ($member->type != Member_Model::TYPE_FORMER)
{
......
->years(date('Y')-10, date('Y')+10)
->rules('required');
$this->form->date('to')
$to_date = $this->form->date('to')
->label('Date to')
->years(date('Y')-10, date('Y')+10)
->rules('required')
->callback(array($this, 'valid_interrupt_interval'));
if (intval(Settings::get('membership_interrupt_maximum')) == 0)
{
$to_date->infinity($this->form);
}
$this->form->textarea('comment')
->rules('length[0,250]|required')
->style('width: 350px');
$this->form->submit('Save');
// form validation
if ($this->form->validate())
{
$form_data = $this->form->as_array();
try
{
$membership_interrupt = new Membership_interrupt_Model();
......
$membership_interrupt->transaction_start();
$from = date('Y-m-d', $form_data['from']);
$to = date('Y-m-d', $form_data['to']);
if (isset($form_data["to_infinity"]) && $form_data["to_infinity"] != "1")
{
$to = date('Y-m-d', $form_data['to']);
}
else
{
$to = '9999-12-31';
}
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_special_type(Fee_Model::MEMBERSHIP_INTERRUPT);
......
$this->form = new Forge();
$this->form->group('Basic data');
$this->form->hidden('member_id')
->value($member->id);
if ($member->type != Member_Model::TYPE_FORMER)
{
......
->years(date('Y')-10, date('Y')+10)
->rules('required')
->value(strtotime($membership_interrupt->members_fee->activation_date));
$this->form->date('to')
$to_date = $this->form->date('to')
->label('Date to (last day in month)')
->years(date('Y')-10, date('Y')+10)
->rules('required')
->callback(array($this, 'valid_interrupt_interval'))
->value(strtotime($membership_interrupt->members_fee->deactivation_date));
if (intval(Settings::get('membership_interrupt_maximum')) == 0)
{
$to_date->infinity($this->form);
if ($membership_interrupt->members_fee->deactivation_date == '9999-12-31')
{
$this->form->inputs['to_infinity']->checked(TRUE);
$this->form->inputs['to']->disabled('disabled');
}
}
$this->form->textarea('comment')
->rules('length[0,250]|required')
......
$membership_interrupt->transaction_start();
$from = date('Y-m-d', $form_data['from']);
$to = date('Y-m-d', $form_data['to']);
if (isset($form_data["to_infinity"]) && $form_data["to_infinity"] != "1")
{
$to = date('Y-m-d', $form_data['to']);
}
else
{
$to = '9999-12-31';
}
$membership_interrupt->comment = $form_data['comment'];
......
{
self::error(PAGE);
}
$method = $this->form->from->method;
$member_id = $this->input->$method('member_id');
$from = date_parse($this->input->$method('from'));
$to = date_parse($this->input->$method('to'));
$from_date = date::round_month($from['day'], $from['month'], $from['year']);
$to_date = date::round_month($to['day'], $to['month'], $to['year']);
$diff = date::diff_month($to_date, $from_date);
if ($diff < 0)
{
$input->add_error('required', __(
freenetis/branches/1.2/application/libraries/forge/Form_Date.php
'year' => array(),
);
protected $parent_form = NULL;
public function __construct($name)
{
// Set name
......
return parent::__call($method, $args);
}
/**
* Adds infinity checkbox after input
* @param Forge $form Parent Forge of Date input
* @return Form_Date $this
*/
public function infinity(&$form)
{
$this->class("join1 ".$this->class);
$this->parent_form = &$form;
$this->parent_form->checkbox($this->data['name']."_infinity")
->class("join2 infinitycheckbox")
->label("Unlimited");
// add infinity rule as first
$rules = $this->rules;
$old_rules = implode('|', $rules);
if (!empty($old_rules))
{
$old_rules = '|'.$old_rules;
}
$this->rules('=infinity'.$old_rules);
return $this;
}
public function html_element()
{
// Import base data
......
}
}
}
// convert timestamp to readable format
$converted_data = $data;
$converted_data['value'] = ($data['value'] ? date('Y-m-d', $data['value']) : '');
$converted_data['value'] = ($data['value'] ? (is_numeric($data['value']) ? date('Y-m-d', $data['value']) : date('Y-m-d', strtotime($data['value']))) : '');
$converted_data['minDate'] = trim($minDate);
$converted_data['maxDate'] = trim($maxDate);
......
return $input;
}
public function rule_infinity()
{
if ($this->parent_form == NULL ||
!isset($this->parent_form->inputs[$this->name."_infinity"]))
{
return;
}
$this->parent_form->inputs[$this->name."_infinity"]->validate();
// remove rules and callbacks
if ($this->parent_form->inputs[$this->name."_infinity"]->checked)
{
$this->rules("-required|time_interval");
$this->callbacks = array();
}
}
public function rule_time_interval()
{
freenetis/branches/1.2/application/libraries/forge/Form_Input.php
if (!empty($this->rules))
{
foreach ($this->rules as $rule)
foreach ($this->rules as &$rule)
{
if (($offset = strpos($rule, '[')) !== FALSE)
{
freenetis/branches/1.2/application/views/js/base.php
input_add_increase_decrease_buttons($(e));
}
});
$('.infinitycheckbox').change(function()
{
var id = this.id.replace('_infinity', '');
if (this.checked)
{
$("#"+id).attr('disabled', 'disabled');
//$("#"+id).nextAll('.error').remove();
}
else
{
$("#"+id).removeAttr('disabled');
}
}).trigger('change');
// dialog with help
$('.help_hint').unbind('click').bind('click', function ()
freenetis/branches/1.2/media/css/style.css
margin-right: 5px;
}
input.infinitycheckbox {
margin: 0px 5px 0px 10px;
width: initial;
}
.error_text {
color: white;
background-color: red;

Také k dispozici: Unified diff