mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-29 11:23:54 +01:00
New widget for durations: floating point input with an optional selectbox to specify a unit (hours or days). The storage format is configurabe and can be either minutes (integer) or hours or days as float
This commit is contained in:
parent
e233ade4c9
commit
ef3e6bc4f4
@ -204,7 +204,7 @@ implement only a subset of XUL. Here are the main differences:</p>
|
|||||||
(or as tooltip for buttons or general in gtk).
|
(or as tooltip for buttons or general in gtk).
|
||||||
If the user has JavaScript switched off, the help-texts get NOT submitted, as this is detected.
|
If the user has JavaScript switched off, the help-texts get NOT submitted, as this is detected.
|
||||||
If the helptext starts with a '@' it is replaced by the value of the content-array at this
|
If the helptext starts with a '@' it is replaced by the value of the content-array at this
|
||||||
index (with the '@'-removed).
|
index (with the '@'-removed and after expanding the variables).
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -216,7 +216,7 @@ implement only a subset of XUL. Here are the main differences:</p>
|
|||||||
This attribute controls certain aspects of the different widgets. It's meaning and xml / xul-values
|
This attribute controls certain aspects of the different widgets. It's meaning and xml / xul-values
|
||||||
are document with the widgets.
|
are document with the widgets.
|
||||||
If the options-string starts with a '@' it is replaced by the value of the content-array at this
|
If the options-string starts with a '@' it is replaced by the value of the content-array at this
|
||||||
index (with the '@'-removed).
|
index (with the '@'-removed and after expanding the variables).
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -288,6 +288,8 @@ implement only a subset of XUL. Here are the main differences:</p>
|
|||||||
of 'all' can be used to indicate it should span all remaining cells of a row.
|
of 'all' can be used to indicate it should span all remaining cells of a row.
|
||||||
This is not supported by xul-grid's at the moment, but is planned to be.<p>
|
This is not supported by xul-grid's at the moment, but is planned to be.<p>
|
||||||
<b>class</b>: the CSS class for the widget.
|
<b>class</b>: the CSS class for the widget.
|
||||||
|
If the class-string starts with a '@' it is replaced by the value of the content-array at this
|
||||||
|
index (with the '@'-removed and after expanding the variables).
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -615,8 +617,9 @@ implement only a subset of XUL. Here are the main differences:</p>
|
|||||||
<td>
|
<td>
|
||||||
<date options="Y-m-d,1"/><p>
|
<date options="Y-m-d,1"/><p>
|
||||||
<date type="date-time"/><p>
|
<date type="date-time"/><p>
|
||||||
<date type="date-timeonly" options="H:i"/>
|
<date type="date-timeonly" options="H:i"/><p>
|
||||||
<date type="date-houronly"/>
|
<date type="date-houronly"/><p>
|
||||||
|
<date type="date-duration"/>
|
||||||
</td>
|
</td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
<td>date</td>
|
<td>date</td>
|
||||||
@ -639,7 +642,13 @@ implement only a subset of XUL. Here are the main differences:</p>
|
|||||||
<b>Sub-widgets</b>: <b>date-time</b>: a date and a time and <b>date-timeonly</b> or <b>date-houronly</b>: only a time / hour<br />
|
<b>Sub-widgets</b>: <b>date-time</b>: a date and a time and <b>date-timeonly</b> or <b>date-houronly</b>: only a time / hour<br />
|
||||||
These widgets allow the input of times too or only, they use 12h am/pm or 24h format as
|
These widgets allow the input of times too or only, they use 12h am/pm or 24h format as
|
||||||
specified in the user prefs.<br />
|
specified in the user prefs.<br />
|
||||||
<i>If readonly is set, this widget can be used to display a date, without the need to convert it.</i>
|
<i>If readonly is set, this widget can be used to display a date, without the need to convert it.</i><p>
|
||||||
|
<b>Duration</b> a floating point input with an optional selectbox for the unit (hours or days)<br>
|
||||||
|
<b>Options</b>: [duration-storage-format] [,[duration-display][,hours_per_day]]<br />
|
||||||
|
<b>duration-storage-format</b>: 'h' = hours (float), 'd' = days (float), default minutes (integer)<br />
|
||||||
|
<b>duration-display</b>: 'd' = days, 'h' = hours, 'dh' = days or hours with selectbox, optional '%' allows to enter a percentage<br />
|
||||||
|
<b>hours_per_day</b>: conversation between hours and (working) day, default 8
|
||||||
|
<b>hours_per_day</b>: conversation between hours and (working) day, default 8
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
'date-time' => 'Date+Time', // date + time
|
'date-time' => 'Date+Time', // date + time
|
||||||
'date-timeonly' => 'Time', // time
|
'date-timeonly' => 'Time', // time
|
||||||
'date-houronly' => 'Hour', // hour
|
'date-houronly' => 'Hour', // hour
|
||||||
|
'date-duration' => 'Duration', // duration
|
||||||
);
|
);
|
||||||
var $dateformat; // eg. Y-m-d, d-M-Y
|
var $dateformat; // eg. Y-m-d, d-M-Y
|
||||||
var $timeformat; // 12 or 24
|
var $timeformat; // 12 or 24
|
||||||
@ -90,13 +91,16 @@
|
|||||||
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||||
{
|
{
|
||||||
$type = $cell['type'];
|
$type = $cell['type'];
|
||||||
list($data_format,$options) = explode(',',$cell['size']);
|
if ($type == 'date-duration')
|
||||||
|
{
|
||||||
|
return $this->pre_process_duration($name,$value,$cell,$readonlys,$extension_data,$tmpl);
|
||||||
|
}
|
||||||
|
list($data_format,$options,$options2) = explode(',',$cell['size']);
|
||||||
if ($type == 'date-houronly' && empty($data_format)) $data_format = 'H';
|
if ($type == 'date-houronly' && empty($data_format)) $data_format = 'H';
|
||||||
$extension_data = array(
|
$extension_data = array(
|
||||||
'data_format' => $data_format,
|
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
|
'data_format' => $data_format,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$value)
|
if (!$value)
|
||||||
{
|
{
|
||||||
$value = array(
|
$value = array(
|
||||||
@ -304,6 +308,100 @@
|
|||||||
return True; // extra Label is ok
|
return True; // extra Label is ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pre-processing of the duration extension
|
||||||
|
*
|
||||||
|
* Options contain $data_format,$input_format,$hours_per_day
|
||||||
|
* - data_format: d = days, h = hours, default minutes
|
||||||
|
* - input_format: d = days, h = hours, default hours+days (selectbox), optional % = allow to enter a percent value (no conversation)
|
||||||
|
* - hours_per_day: default 8 (workday)
|
||||||
|
*
|
||||||
|
* @param string $name form-name of the control
|
||||||
|
* @param mixed &$value value / existing content, can be modified
|
||||||
|
* @param array &$cell array with the widget, can be modified for ui-independent widgets
|
||||||
|
* @param array &$readonlys names of widgets as key, to be made readonly
|
||||||
|
* @param mixed &$extension_data data the extension can store persisten between pre- and post-process
|
||||||
|
* @param object &$tmpl reference to the template we belong too
|
||||||
|
* @return boolean true if extra label is allowed, false otherwise
|
||||||
|
*/
|
||||||
|
function pre_process_duration($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
|
||||||
|
{
|
||||||
|
$readonly = $readonlys || $cell['readonly'];
|
||||||
|
list($data_format,$input_format,$hours_per_day) = explode(',',$cell['size']);
|
||||||
|
if (!$hours_per_day) $hours_per_day = 8; // workday is 8 hours
|
||||||
|
if (($percent_allowed = strstr($input_format,'%') !== false))
|
||||||
|
{
|
||||||
|
$input_format = str_replace('%','',$input_format);
|
||||||
|
}
|
||||||
|
if ($input_format != 'h' && $input_format != 'd') $input_format = 'dh'; // hours + days
|
||||||
|
|
||||||
|
$extension_data = array(
|
||||||
|
'type' => $cell['type'],
|
||||||
|
'data_format' => $data_format,
|
||||||
|
'unit' => ($unit = $input_format == 'd' ? 'd' : 'h'),
|
||||||
|
'input_format' => $input_format,
|
||||||
|
'hours_per_day' => $hours_per_day,
|
||||||
|
'percent_allowed'=> $percent_allowed,
|
||||||
|
);
|
||||||
|
switch($data_format)
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
$value *= $hours_per_day;
|
||||||
|
// fall-through
|
||||||
|
case 'h': case 'H':
|
||||||
|
$value *= 60;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$cell['type'] = 'text';
|
||||||
|
$cell['size'] = '4,,/^-?[0-9]*[,.]?[0-9]*'.($percent_allowed ? '%?' : '').'$/';
|
||||||
|
$cell_name = $cell['name'];
|
||||||
|
$cell['name'] .= '[value]';
|
||||||
|
|
||||||
|
if ($input_format == 'dh' && $value >= 60*$hours_per_day)
|
||||||
|
{
|
||||||
|
$unit = 'd';
|
||||||
|
}
|
||||||
|
$value = !$value ? '' : round($value / 60 / ($unit == 'd' ? $hours_per_day : 1),3);
|
||||||
|
|
||||||
|
if (!$readonly && $input_format == 'dh') // selectbox to switch between hours and days
|
||||||
|
{
|
||||||
|
$value = array(
|
||||||
|
'value' => $value,
|
||||||
|
'unit' => $unit,
|
||||||
|
);
|
||||||
|
$tpl =& new etemplate;
|
||||||
|
$tpl->init('*** generated fields for duration','','',0,'',0,0); // make an empty template
|
||||||
|
// keep the editor away from the generated tmpls
|
||||||
|
$tpl->no_onclick = true;
|
||||||
|
|
||||||
|
$selbox =& $tpl->empty_cell('select',$cell_name.'[unit]');
|
||||||
|
$selbox['sel_options'] = array(
|
||||||
|
'h' => 'hours',
|
||||||
|
'd' => 'days',
|
||||||
|
);
|
||||||
|
|
||||||
|
$tpl->data[0] = array();
|
||||||
|
$tpl->data[1] =array(
|
||||||
|
'A' => $cell,
|
||||||
|
'B' => $selbox,
|
||||||
|
);
|
||||||
|
$tpl->set_rows_cols();
|
||||||
|
$tpl->size = ',,,,0';
|
||||||
|
|
||||||
|
unset($cell['size']);
|
||||||
|
$cell['type'] = 'template';
|
||||||
|
$cell['name'] = $tpl->name;
|
||||||
|
unset($cell['label']);
|
||||||
|
$cell['obj'] = &$tpl;
|
||||||
|
}
|
||||||
|
elseif (!$readonly || $value)
|
||||||
|
{
|
||||||
|
$cell['no_lang'] = 2;
|
||||||
|
$cell['label'] .= ($cell['label'] ? ' ' : '') . '%s '.($input_format == 'h' ? lang('hours') : lang('days'));
|
||||||
|
}
|
||||||
|
return True; // extra Label is ok
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* postprocessing method, called after the submission of the form
|
* postprocessing method, called after the submission of the form
|
||||||
*
|
*
|
||||||
@ -328,6 +426,40 @@
|
|||||||
{
|
{
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
if ($extension_data['type'] == 'date-duration')
|
||||||
|
{
|
||||||
|
if (is_array($value)) // template with selectbox
|
||||||
|
{
|
||||||
|
$unit = $value['unit'];
|
||||||
|
$value = $value['value'];
|
||||||
|
}
|
||||||
|
elseif (!preg_match('/^-?[0-9]*[,.]?[0-9]*'.($extension_data['percent_allowed'] ? '%?' : '').'$/',$value_in))
|
||||||
|
{
|
||||||
|
$GLOBALS['phpgw_info']['etemplate']['validation_errors'][$name] = lang("'%1' is not a valid floatingpoint number !!!",$value_in);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value = $value_in;
|
||||||
|
$unit = $extension_data['unit'];
|
||||||
|
}
|
||||||
|
if ($extension_data['percent_allowed'] && substr($value,-1) == '%')
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
$value = (int) round(str_replace(',','.',$value) * 60 * ($unit == 'd' ? $extension_data['hours_per_day'] : 1));
|
||||||
|
|
||||||
|
switch($extension_data['data_format'])
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
$value /= (float) $extension_data['hours_per_day'];
|
||||||
|
// fall-through
|
||||||
|
case 'h': case 'H':
|
||||||
|
$value /= 60.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$no_date = substr($extension_data['type'],-4) == 'only';
|
$no_date = substr($extension_data['type'],-4) == 'only';
|
||||||
|
|
||||||
if ($value['today'])
|
if ($value['today'])
|
||||||
|
@ -79,6 +79,7 @@ cut etemplate de Ausschneiden
|
|||||||
date+time etemplate de Datum+Uhrzeit
|
date+time etemplate de Datum+Uhrzeit
|
||||||
datum etemplate de Datum
|
datum etemplate de Datum
|
||||||
day etemplate de Tag
|
day etemplate de Tag
|
||||||
|
days etemplate de Tage
|
||||||
db ensures that every row has a unique value in that column etemplate de die Datenbank stelt sicher das alle Zeilen einen einmaligen Wert in dieser Spalte haben
|
db ensures that every row has a unique value in that column etemplate de die Datenbank stelt sicher das alle Zeilen einen einmaligen Wert in dieser Spalte haben
|
||||||
db-specific index options (comma-sep.), eg. mysql(fulltext) or mysql(100) for the indexed length of a col etemplate de DB-spezifische Index-Optionen (Komma-getrennt), zB. mysql(FULLTEXT) oder mysql(100) für die indizierte Länge der Spalte
|
db-specific index options (comma-sep.), eg. mysql(fulltext) or mysql(100) for the indexed length of a col etemplate de DB-spezifische Index-Optionen (Komma-getrennt), zB. mysql(FULLTEXT) oder mysql(100) für die indizierte Länge der Spalte
|
||||||
db-tools etemplate de DB-Tools
|
db-tools etemplate de DB-Tools
|
||||||
@ -107,6 +108,7 @@ documentation etemplate de Dokumentation
|
|||||||
drop a table - this can not be undone etemplate de Tabelle löschen (drop) - NICHT rückgänig zu machen
|
drop a table - this can not be undone etemplate de Tabelle löschen (drop) - NICHT rückgänig zu machen
|
||||||
drop table etemplate de Tabelle löschen
|
drop table etemplate de Tabelle löschen
|
||||||
dump4setup etemplate de Dump4Setup
|
dump4setup etemplate de Dump4Setup
|
||||||
|
duration etemplate de Dauer
|
||||||
edit etemplate de Bearbeiten
|
edit etemplate de Bearbeiten
|
||||||
edit embeded css styles or of the applications app.css file etemplate de bearbeitet die eingebetteten CSS Stile oder die app.css Datei der Anwendung
|
edit embeded css styles or of the applications app.css file etemplate de bearbeitet die eingebetteten CSS Stile oder die app.css Datei der Anwendung
|
||||||
edit the etemplate spez. above etemplate de das oben spezifizierte eTemplate bearbeiten
|
edit the etemplate spez. above etemplate de das oben spezifizierte eTemplate bearbeiten
|
||||||
@ -165,6 +167,7 @@ height, disabled etemplate de H
|
|||||||
help etemplate de Hilfe
|
help etemplate de Hilfe
|
||||||
horizontal rule etemplate de Waagrechte Linie
|
horizontal rule etemplate de Waagrechte Linie
|
||||||
hour etemplate de Stunde
|
hour etemplate de Stunde
|
||||||
|
hours etemplate de Stunden
|
||||||
html etemplate de HTML
|
html etemplate de HTML
|
||||||
if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell etemplate de wenn das Feld deaktiviert ist, wird eine leere Tabellenzelle angezeigt, zum (zeitweisen) Entfernen eines Feldes
|
if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell etemplate de wenn das Feld deaktiviert ist, wird eine leere Tabellenzelle angezeigt, zum (zeitweisen) Entfernen eines Feldes
|
||||||
image etemplate de Grafik
|
image etemplate de Grafik
|
||||||
|
@ -79,6 +79,7 @@ cut etemplate en Cut
|
|||||||
date+time etemplate en Date+Time
|
date+time etemplate en Date+Time
|
||||||
datum etemplate en Datum
|
datum etemplate en Datum
|
||||||
day etemplate en Day
|
day etemplate en Day
|
||||||
|
days etemplate en days
|
||||||
db ensures that every row has a unique value in that column etemplate en DB ensures that every row has a unique value in that column
|
db ensures that every row has a unique value in that column etemplate en DB ensures that every row has a unique value in that column
|
||||||
db-specific index options (comma-sep.), eg. mysql(fulltext) or mysql(100) for the indexed length of a col etemplate en db-specific index options (comma-sep.), eg. mysql(FULLTEXT) or mysql(100) for the indexed length of a col
|
db-specific index options (comma-sep.), eg. mysql(fulltext) or mysql(100) for the indexed length of a col etemplate en db-specific index options (comma-sep.), eg. mysql(FULLTEXT) or mysql(100) for the indexed length of a col
|
||||||
db-tools etemplate en DB-Tools
|
db-tools etemplate en DB-Tools
|
||||||
@ -107,6 +108,7 @@ documentation etemplate en Documentation
|
|||||||
drop a table - this can not be undone etemplate en Drop a table - this can NOT be undone
|
drop a table - this can not be undone etemplate en Drop a table - this can NOT be undone
|
||||||
drop table etemplate en Drop Table
|
drop table etemplate en Drop Table
|
||||||
dump4setup etemplate en Dump4Setup
|
dump4setup etemplate en Dump4Setup
|
||||||
|
duration etemplate en Duration
|
||||||
edit etemplate en Edit
|
edit etemplate en Edit
|
||||||
edit embeded css styles or of the applications app.css file etemplate en edit embeded CSS styles or of the applications app.css file
|
edit embeded css styles or of the applications app.css file etemplate en edit embeded CSS styles or of the applications app.css file
|
||||||
edit the etemplate spez. above etemplate en edit the eTemplate spez. above
|
edit the etemplate spez. above etemplate en edit the eTemplate spez. above
|
||||||
@ -165,6 +167,7 @@ height, disabled etemplate en Height, Disabled
|
|||||||
help etemplate en Help
|
help etemplate en Help
|
||||||
horizontal rule etemplate en Horizontal Rule
|
horizontal rule etemplate en Horizontal Rule
|
||||||
hour etemplate en Hour
|
hour etemplate en Hour
|
||||||
|
hours etemplate en hours
|
||||||
html etemplate en Html
|
html etemplate en Html
|
||||||
if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell etemplate en if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell
|
if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell etemplate en if field is disabled an empty table-cell is displayed, for (temporal) removement of a field/cell
|
||||||
image etemplate en Image
|
image etemplate en Image
|
||||||
|
Loading…
Reference in New Issue
Block a user