noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
idate.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@noalyss.eu
22
23 /**
24 *\file
25 \brief Html Input Date type
26 */
27
28
29/// Html Input : Input a date format dd.mm.yyyy
30/// The property title should be set to indicate what it is expected
31/// @see calendar-setup.js
32
33class IDate extends HtmlInput
34{
35
37 var $title;
39 static $firstDate=0; //<! first day in the calendar : 0 for sunday
40
41 function __construct($name='', $value='', $p_id="")
42 {
43 parent::__construct($name, $value, $p_id);
44 $this->title="";
45 $this->placeholder="dd.mm.yyyy";
46 $this->extra="";
47 $this->style=' class="input_text" ';
48 $this->autofocus=false;
49 $this->javascript='onchange="format_date(this)"';
50 }
51
52 /**
53 * @return string
54 */
55 public function get_title()
56 {
57 return $this->title;
58 return $this;
59 }
60
61 /**
62 * @param string $title
63 */
64 public function set_title($title)
65 {
66 $this->title = $title;
67 return $this;
68 }
69
70 /**
71 * @return false
72 */
73 public function get_autofocus()
74 {
75 return $this->autofocus;
76 return $this;
77 }
78
79 /**
80 * @param false $autofocus
81 */
82 public function set_autofocus($autofocus)
83 {
84 $this->autofocus = $autofocus;
85 return $this;
86 }
87
88 /**
89 * @return mixed
90 */
91 public function get_firstDate()
92 {
93 return self::$firstDate;
94 }
95
96 /**
97 * @param mixed $firstDate
98 */
99 static function set_firstDate($firstDate)
100 {
101 if (isNumber($firstDate)==0){
102 throw new Exception("IDATE1: invalide data");
103 }
104 self::$firstDate= $firstDate;
105 }
106
107
108 /*!\brief show the html input of the widget */
109
110 public function input($p_name=null, $p_value=null)
111 {
112 $this->name=($p_name==null)?$this->name:$p_name;
113 $this->value=($p_value==null)?$this->value:$p_value;
114 if ($this->readOnly==true)
115 return $this->display();
116 if ($this->id=="") $this->id=self::generate_id($this->name);
117 $autofocus=($this->autofocus)?" autofocus ":"";
118 $strAttribute=$this->get_node_attribute();
119
120 $r=sprintf('
121 <input type="text" name="%s" id="%s"
122 class="input_text"
123 size="10" style="width:6em"
124 value ="%s"
125 placeholder="%s"
126 title="%s"
127 pattern="[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}"
128 %s
129 %s
130 />
131 <span class="smallbutton icon"
132 style="color:cornflowerblue"
133 id="%s_trigger"
134 />
135 &#xe811;
136 </span>
137 ',$this->name,$this->id,$this->value,$this->placeholder,$this->title,
138 $this->javascript,
139 $strAttribute,
140 $this->id
141 );
142 // @see calendar-setup.js
143 $r.=sprintf('<script type="text/javascript">
144 Calendar.setup({'.
145 'inputField : "%s",
146 ifFormat : "%%d.%%m.%%Y",
147 button : "%s_trigger",
148 align : "Bl",
149 singleClick : true,
150 firstDay:%s
151 });
152 </script>'
153 ,$this->id,
154 $this->id,
155 self::$firstDate);
156 return $r;
157 }
158
159 /*!\brief print in html the readonly value of the widget */
160
161 public function display()
162 {
163 $r="<span> ".$this->value;
164 $r.='<input type="hidden" name="'.$this->name.'"'.
165 'id="'.$this->id.'"'.
166 ' value = "'.$this->value.'"></span>';
167 return $r;
168 }
169
170 static public function test_me()
171 {
172
173 }
174
175}
isNumber($p_int)
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$ret javascript
$opd_description style
$from_poste name
static generate_id($p_prefix)
generate an unique id for a widget,
get_node_attribute()
Insert attribute inside a INPUT TYPE, these attribute can be retrieved in javascript with element....
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
set_autofocus($autofocus)
static $firstDate
get_title()
get_autofocus()
set_title($title)
__construct($name='', $value='', $p_id="")
display()
print in html the readonly value of the widget
static set_firstDate($firstDate)
input($p_name=null, $p_value=null)
show the html input of the widget
get_firstDate()
static test_me()
$anc_filter placeholder
$anc_filter title
$icard readOnly
$poste extra