<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Date_eu extends codexForms { function Date_eu($name,$params) { codexForms::initiate($name,$params); } function prepForDisplay($value){ if(!empty($value) AND ($value != 0 AND $value != "0000-00-00")){ $explode = explode('-',$value); return date('F j, Y',mktime(0,0,0,$explode[1],$explode[2],$explode[0])); } else return ''; } function prepForDB($value){ $valori=explode("/",$value); $date_eu=$valori[2]."-".$valori[1]."-".$valori[0]; return ($date_eu); } function getHTML() { $CI = &get;_instance(); $CI->codextemplates->css_assets('css-datepicker','ui.datepicker.css'); $CI->codextemplates->js('js-datepicker','ui.datepicker.eu.js'); $html = $this->prefix; //format the data with eu format $valori=explode("-",$this->value); $new_date_eu=$valori[2]."/".$valori[1]."/".$valori[0]; if($this->getMessage($this->name)) $html .= '<div class="failure">'.$this->getMessage($this->name).'</div>'; $html .= ' <label for="'.$this->element_name.'"> '.$this->label.' </label>'; $html .=' <input class="text" id="codexdatepicker'.$this->name.'" type="text" value="'.$new_date_eu.'" name="'.$this->element_name.'" '.$this->getAttributes($this->attributes).'> '; $js ="$(document).ready(function() { $('#codexdatepicker".$this->name."').datepicker({dateFormat: 'dd/mm/yy'}); });"; $CI->codextemplates->inlineJS('js-'.$this->name.'-init',$js); $html .= $this->suffix; return $html; } } ?>