pnd8_rasp/app/engine/core/attrs/datereal.php

44 lines
1.0 KiB
PHP

<?php
class attr_datereal extends attr {
function getDBType() {
return "date";
}
function render_input() {
if ($this->getAttrSetting('mand'))
$defval = date('Y-m-d');
else
$defval = '';
$cv = $this->getCurVal();
$tpl = '<input type="date" class="form-control" autocomplete="off" name="'.$this->attr_name.'" id="'.$this->attr_name.'" value="'.($cv?date('Y-m-d', $cv):$defval).'">';
return $tpl;
}
function lPost() {
$time = strtotime($_POST[$this->attr_name] . ' 00:00:00');
if ( $time == false ) {
$time = $_POST[$this->attr_name];
}
if (empty($_POST[$this->attr_name]) && !$this->getAttrSetting('mand') ) {
$time = 0;
}
$this->obj->set($this->attr_name, date('Y-m-d', $time));
}
function render_text( $crop = false ) {
if ( $this->getCurVal() ) {
return $this->getCurVal();
} else {
return '';
}
}
}
?>