Revize 2020
Přidáno uživatelem David Raška před více než 11 roky(ů)
freenetis/branches/1.1/application/controllers/bank_transfers.php | ||
---|---|---|
// form
|
||
$form = new Forge('bank_transfers/add/'.$baa_id);
|
||
|
||
$form->set_attr('class', 'form_class')
|
||
->set_attr('method', 'post');
|
||
$form->set_attr('method', 'post');
|
||
|
||
// counteraccount
|
||
$form->group('Counteraccount');
|
freenetis/branches/1.1/application/controllers/members.php | ||
---|---|---|
$member->transaction_start();
|
||
|
||
// change member
|
||
$member->entrance_date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
|
||
$member->entrance_date = $date;
|
||
|
||
// get members account
|
||
$account = ORM::factory('account')->where(array
|
freenetis/branches/1.1/application/controllers/members_whitelists.php | ||
---|---|---|
}
|
||
|
||
$permanent = $this->input->post('permanent');
|
||
$since = $this->input->post('since');
|
||
$until = $this->input->post('until');
|
||
$since = date_parse($this->input->post('since'));
|
||
$until = date_parse($this->input->post('until'));
|
||
|
||
// prepare
|
||
$sd = date::create($since['day'], $since['month'], $since['year']);
|
freenetis/branches/1.1/application/controllers/membership_interrupts.php | ||
---|---|---|
|
||
$method = $this->form->from->method;
|
||
$member_id = $this->input->$method('member_id');
|
||
$from = $this->input->$method('from');
|
||
$to = $this->input->$method('to');
|
||
$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']);
|
freenetis/branches/1.1/application/i18n/cs_CZ/validation.php | ||
---|---|---|
// Field types
|
||
'alpha' => 'písmena abecedy',
|
||
'alpha_dash' => 'alphabetical, dash, and underscore',
|
||
'date_interval' => 'Datum není v platném intervalu',
|
||
'digit' => 'číslice',
|
||
'numeric' => 'číslo',
|
||
'gps' => 'Chybný formát GPS souřadnice',
|
freenetis/branches/1.1/application/libraries/forge/Form_Date.php | ||
---|---|---|
protected $data = array
|
||
(
|
||
'name' => '',
|
||
'class' => 'dropdown',
|
||
'class' => 'date',
|
||
);
|
||
|
||
protected $protect = array('type');
|
||
... | ... | |
// Precision for the parts, you can use @ to insert a literal @ symbol
|
||
protected $parts = array
|
||
(
|
||
'day' => array(1),
|
||
'day' => array(),
|
||
'month' => array(),
|
||
'year' => array(),
|
||
);
|
||
... | ... | |
{
|
||
// Set options for date generation
|
||
$this->parts[substr($method, 0, -1)] = $args;
|
||
|
||
// Add rule
|
||
|
||
$this->rules('time_interval');
|
||
|
||
return $this;
|
||
}
|
||
|
||
... | ... | |
// Import base data
|
||
$data = $this->data;
|
||
|
||
// Get the options and default selection
|
||
$time = $this->time_array(arr::remove('value', $data));
|
||
|
||
|
||
// No labels or values
|
||
unset($data['label']);
|
||
|
||
$input = '';
|
||
// count date limit
|
||
$maxDate = '';
|
||
$minDate = '';
|
||
|
||
foreach($this->parts as $type => $val)
|
||
{
|
||
if (is_int($type))
|
||
if (empty($val))
|
||
{
|
||
// Just add the separators
|
||
$input .= $val;
|
||
continue;
|
||
}
|
||
|
||
// Set this input name
|
||
$data['name'] = $this->data['name'].'['.$type.']';
|
||
|
||
// Set the selected option
|
||
$selected = $time[$type];
|
||
|
||
if ($type == 'am_pm')
|
||
|
||
if ($type == 'year')
|
||
{
|
||
// Options are static
|
||
$options = array('AM' => 'AM', 'PM' => 'PM');
|
||
$minDate .= '-'.(intval(date('Y')) - intval($val[0])).'Y ';
|
||
|
||
if (count($val) > 1)
|
||
{
|
||
$diff = intval($val[1]) - intval(date('Y'));
|
||
|
||
$maxDate .= '+'.$diff.'Y ';
|
||
}
|
||
}
|
||
else
|
||
else if ($type == 'month')
|
||
{
|
||
// minute(s), hour(s), etc
|
||
$type .= 's';
|
||
|
||
// Use the date helper to generate the options
|
||
$options = empty($val) ? date::$type() : call_user_func_array(array('date', $type), $val);
|
||
$minDate .= '-'.(intval(date('m')) - intval($val[0])).'m ';
|
||
|
||
if (count($val) > 1)
|
||
{
|
||
$diff = intval($val[1]) - intval(date('m'));
|
||
|
||
$maxDate .= '+'.$diff.'m ';
|
||
}
|
||
}
|
||
|
||
$input .= form::dropdown($data, $options, $selected);
|
||
else if ($type == 'day')
|
||
{
|
||
$minDate .= '-'.(intval(date('d')) - intval($val[0])).'d ';
|
||
|
||
if (count($val) > 1)
|
||
{
|
||
$diff = intval($val[1]) - intval(date('d'));
|
||
|
||
$maxDate .= '+'.$diff.'d ';
|
||
}
|
||
}
|
||
}
|
||
|
||
// convert timestamp to readable format
|
||
$converted_data = $data;
|
||
$converted_data['value'] = date('Y-m-d', $data['value']);
|
||
$converted_data['minDate'] = trim($minDate);
|
||
$converted_data['maxDate'] = trim($maxDate);
|
||
|
||
$input = form::input($converted_data);
|
||
|
||
return $input;
|
||
}
|
||
|
||
protected function time_array($timestamp)
|
||
|
||
public function rule_time_interval()
|
||
{
|
||
$time = array_combine
|
||
(
|
||
array('month', 'day', 'year', 'hour', 'minute', 'am_pm'),
|
||
explode('--', date('n--j--Y--g--i--A', $timestamp))
|
||
);
|
||
|
||
// Minutes should always be in 5 minute increments
|
||
//$time['minute'] = num::round($time['minute'], current($this->parts['minute']));
|
||
|
||
return $time;
|
||
// timestamp
|
||
$ts = $this->data['value'];
|
||
|
||
// get min date
|
||
// min year
|
||
if (empty($this->parts['year']))
|
||
{
|
||
$min_y = date('Y');
|
||
}
|
||
else
|
||
{
|
||
$min_y = $this->parts['year'][0];
|
||
}
|
||
|
||
// min month
|
||
if (empty($this->parts['month']))
|
||
{
|
||
$min_m = date('m');
|
||
}
|
||
else
|
||
{
|
||
$min_m = $this->parts['month'][0];
|
||
}
|
||
|
||
// min day
|
||
if (empty($this->parts['day']))
|
||
{
|
||
$min_d = date('d');
|
||
}
|
||
else
|
||
{
|
||
$min_d = $this->parts['day'][0];
|
||
}
|
||
|
||
// get max date
|
||
// max year
|
||
if (count($this->parts['year']) == 2)
|
||
{
|
||
$max_y = $this->parts['year'][1];
|
||
$max_set = TRUE;
|
||
}
|
||
else
|
||
{
|
||
$max_y = date('Y');
|
||
}
|
||
|
||
// max month
|
||
if (count($this->parts['month']) == 2)
|
||
{
|
||
$max_m = $this->parts['month'][1];
|
||
$max_set = TRUE;
|
||
}
|
||
else
|
||
{
|
||
$max_m = date('m');
|
||
}
|
||
|
||
// max day
|
||
if (count($this->parts['day']) == 2)
|
||
{
|
||
$max_d = $this->parts['day'][1];
|
||
$max_set = TRUE;
|
||
}
|
||
else
|
||
{
|
||
$max_d = date('d');
|
||
}
|
||
|
||
// get min, max timestamps
|
||
$min_ts = mktime(0, 0, 0, $min_m, $min_d, $min_y);
|
||
|
||
// check if given date is in interval
|
||
if ($ts < $min_ts)
|
||
{
|
||
$this->errors['date_interval'] = TRUE;
|
||
}
|
||
|
||
// max interval set
|
||
if (isset($max_set) && $max_set)
|
||
{
|
||
$max_ts = mktime(0, 0, 0, $max_m, $max_d, $max_y);
|
||
|
||
if ($ts > $max_ts)
|
||
{
|
||
$this->errors['date_interval'] = TRUE;
|
||
}
|
||
}
|
||
}
|
||
|
||
protected function load_value()
|
||
... | ... | |
|
||
$time = $this->input_value($this->name);
|
||
|
||
if (!is_array($time))
|
||
{
|
||
$time = array();
|
||
}
|
||
|
||
// Make sure all the required inputs keys are set
|
||
$time += $this->time_array(time());
|
||
|
||
$this->data['value'] = mktime
|
||
(
|
||
date::adjust($time['hour'], $time['am_pm']),
|
||
$time['minute'],
|
||
0,
|
||
$time['month'],
|
||
$time['day'],
|
||
$time['year']
|
||
);
|
||
$this->data['value'] = strtotime($time);
|
||
}
|
||
|
||
} // End Form Dateselect
|
freenetis/branches/1.1/application/views/js/base.php | ||
---|---|---|
// activate date picker on class .date after focus
|
||
$('.date').live('focus', function ()
|
||
{
|
||
var date_input = $(this);
|
||
$(this).datepicker({
|
||
dateFormat: 'yy-mm-dd',
|
||
changeMonth: true,
|
||
changeYear: true,
|
||
showOtherMonths: true,
|
||
selectOtherMonths: true,
|
||
yearRange: 'c-100:c+100',
|
||
minDate: date_input.attr('minDate'),
|
||
maxDate: date_input.attr('maxDate'),
|
||
onClose: function(dateText, inst)
|
||
{
|
||
$(this).trigger('keyup');
|
freenetis/branches/1.1/system/i18n/en_US/validation.php | ||
---|---|---|
// Field types
|
||
'alpha' => 'alphabetical',
|
||
'alpha_dash' => 'alphabetical, dash, and underscore',
|
||
'date_interval' => 'Date is not in valid interval',
|
||
'digit' => 'digit',
|
||
'numeric' => 'numeric',
|
||
'gps' => 'Wrong format of GPS coordinate',
|
Také k dispozici: Unified diff
Nove:
- closes #598 - Sjednoceni policek datumu u formularu pomoci jQuery datepicker
Upravy:
- uprava nekolika controleru aby fungovaly s datepickerem