init
This commit is contained in:
50
include/SugarFields/Fields/Datetimecombo/Datetimecombo.js
Normal file
50
include/SugarFields/Fields/Datetimecombo/Datetimecombo.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
function Datetimecombo(datetime,field,timeformat,tabindex,showCheckbox,checked,allowEmptyHM){this.datetime=datetime;this.allowEmptyHM=allowEmptyHM;if(typeof this.datetime=="undefined"||datetime==''||trim(datetime).length<10){this.datetime="";var d=new Date();var month=d.getMonth();var date=d.getDate();var year=d.getYear();var hours=d.getHours();var minutes=d.getMinutes();}
|
||||
this.fieldname=field;this.hrs=parseInt(datetime.substring(11,13),10);this.mins=parseInt(datetime.substring(14,16),10);if(this.mins>0&&this.mins<15){this.mins=15;}else if(this.mins>15&&this.mins<30){this.mins=30;}else if(this.mins>30&&this.mins<45){this.mins=45;}else if(this.mins>45){this.hrs+=1;this.mins=0;}
|
||||
this.timeformat=timeformat;this.tabindex=tabindex==null||isNaN(tabindex)?1:tabindex;this.timeseparator=this.timeformat.substring(2,3);this.has12Hours=/^11/.test(this.timeformat);this.hasMeridiem=/am|pm/i.test(this.timeformat);if(this.hasMeridiem){this.pm=/pm/.test(this.timeformat);}
|
||||
this.meridiem=this.hasMeridiem?trim(this.datetime.substring(16)):'';this.datetime=this.datetime.substr(0,10);this.showCheckbox=showCheckbox;this.checked=checked;document.getElementById(this.fieldname+'_date').value=this.datetime;}
|
||||
Datetimecombo.prototype.jsscript=function(callback){text='\nfunction update_'+this.fieldname+'(calendar) {';text+='\nif(calendar != null) {';text+='\ncalendar.onUpdateTime();';text+='\ncalendar.onSetTime();';text+='\ncalendar.hide();';text+='\n}'
|
||||
text+='\nd = document.getElementById("'+this.fieldname+'_date").value;';text+='\nh = document.getElementById("'+this.fieldname+'_hours").value;';text+='\nm = document.getElementById("'+this.fieldname+'_minutes").value;';text+='\nnewdate = d + " " + h + "'+this.timeseparator+'" + m;';if(this.hasMeridiem){text+='\nif(typeof document.getElementById("'+this.fieldname+'_meridiem") != "undefined") {';text+='\n newdate += document.getElementById("'+this.fieldname+'_meridiem").value;';text+='\n}';}
|
||||
text+='\nif(trim(newdate) =="'+this.timeseparator+'") newdate="";';text+='\ndocument.getElementById("'+this.fieldname+'").value = newdate;';text+='\n'+callback;text+='\n}';return text;}
|
||||
Datetimecombo.prototype.html=function(callback){var text='<select class="datetimecombo_time" size="1" id="'+this.fieldname+'_hours" tabindex="'+this.tabindex+'" onchange="combo_'+this.fieldname+'.update(); '+callback+'">';var h1=this.has12Hours?1:0;var h2=this.has12Hours?12:23;if(this.allowEmptyHM){text+='<option></option>';}
|
||||
for(i=h1;i<=h2;i++){val=i<10?"0"+i:i;text+='<option value="'+val+'" '+(i==this.hrs?"SELECTED":"")+'>'+val+'</option>';}
|
||||
text+='\n</select> ';text+=this.timeseparator;text+='\n <select class="datetimecombo_time" size="1" id="'+this.fieldname+'_minutes" tabindex="'+this.tabindex+'" onchange="combo_'+this.fieldname+'.update(); '+callback+'">';if(this.allowEmptyHM){text+='\n<option></option>';}
|
||||
text+='\n<option value="00" '+(this.mins==0?"SELECTED":"")+'>00</option>';text+='\n<option value="15" '+(this.mins==15?"SELECTED":"")+'>15</option>';text+='\n<option value="30" '+(this.mins==30?"SELECTED":"")+'>30</option>';text+='\n<option value="45" '+(this.mins==45?"SELECTED":"")+'>45</option>';text+='\n</select>';if(this.hasMeridiem){text+='\n ';text+='\n<select class="datetimecombo_time" size="1" id="'+this.fieldname+'_meridiem" tabindex="'+this.tabindex+'" onchange="combo_'+this.fieldname+'.update(); '+callback+'">';if(this.allowEmptyHM){text+='\n<option></option>';}
|
||||
text+='\n<option value="'+(this.pm?"am":"AM")+'" '+(/am/i.test(this.meridiem)?"SELECTED":"")+'>'+(this.pm?"am":"AM")+'</option>';text+='\n<option value="'+(this.pm?"pm":"PM")+'" '+(/pm/i.test(this.meridiem)?"SELECTED":"")+'>'+(this.pm?"pm":"PM")+'</option>';text+='\n</select>';}
|
||||
if(this.showCheckbox){text+='\n<input style="visibility:hidden;" type="checkbox" name="'+this.fieldname+'_flag" id="'+this.fieldname+'_flag" tabindex="'+this.tabindex+'" onchange="combo_'+this.fieldname+'.update(); '+callback+'" '+(this.checked?'CHECKED':'')+'>';}
|
||||
return text;};Datetimecombo.prototype.update=function(){id=this.fieldname+'_date';d=window.document.getElementById(id).value;id=this.fieldname+'_hours';h=window.document.getElementById(id).value;id=this.fieldname+'_minutes';m=window.document.getElementById(id).value;newdate=d+' '+h+this.timeseparator+m;if(this.hasMeridiem){ampm=document.getElementById(this.fieldname+"_meridiem").value;newdate+=ampm;}
|
||||
if(trim(newdate)==""+this.timeseparator+""){newdate='';}
|
||||
document.getElementById(this.fieldname).value=newdate;if(this.showCheckbox){flag=this.fieldname+'_flag';date=this.fieldname+'_date';hours=this.fieldname+'_hours';mins=this.fieldname+'_minutes';if(document.getElementById(flag).checked){document.getElementById(flag).value=1;document.getElementById(this.fieldname).value='';document.getElementById(date).disabled=true;document.getElementById(hours).disabled=true;document.getElementById(mins).disabled=true;}else{document.getElementById(flag).value=0;document.getElementById(date).disabled=false;document.getElementById(hours).disabled=false;document.getElementById(mins).disabled=false;}}};
|
||||
120
include/SugarFields/Fields/Datetimecombo/EditView.tpl
Executable file
120
include/SugarFields/Fields/Datetimecombo/EditView.tpl
Executable file
@@ -0,0 +1,120 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
{{capture name=idname assign=idname}}{{sugarvar key='name'}}{{/capture}}
|
||||
{{if !empty($displayParams.idName)}}
|
||||
{{assign var=idname value=$displayParams.idName}}
|
||||
{{/if}}
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr valign="middle">
|
||||
<td nowrap>
|
||||
<input autocomplete="off" type="text" id="{{$idname}}_date" value="{$fields[{{sugarvar key='name' stringFormat=true}}].value}" size="11" maxlength="10" title='{{$vardef.help}}' tabindex="{{$tabindex}}" onblur="combo_{{$idname}}.update(); {{if isset($displayParams.updateCallback)}}{{$displayParams.updateCallback}}{{/if}}">
|
||||
<img border="0" src="{sugar_getimagepath file='jscalendar.gif'}" alt="{$APP.LBL_ENTER_DATE}" id="{{$idname}}_trigger" align="absmiddle">
|
||||
{{if empty($displayParams.splitDateTime)}}
|
||||
</td>
|
||||
<td nowrap>
|
||||
{{else}}
|
||||
<br>
|
||||
{{/if}}
|
||||
<div id="{{$idname}}_time_section"></div>
|
||||
{{if $displayParams.showNoneCheckbox}}
|
||||
<script type="text/javascript">
|
||||
function set_{{$idname}}_values(form) {ldelim}
|
||||
if(form.{{$idname}}_flag.checked) {ldelim}
|
||||
form.{{$idname}}_flag.value=1;
|
||||
form.{{$idname}}.value="";
|
||||
form.{{$idname}}.readOnly=true;
|
||||
{rdelim} else {ldelim}
|
||||
form.{{$idname}}_flag.value=0;
|
||||
form.{{$idname}}.readOnly=false;
|
||||
{rdelim}
|
||||
{rdelim}
|
||||
</script>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{if $displayParams.showFormats}}
|
||||
<tr valign="middle">
|
||||
<td nowrap>
|
||||
<span class="dateFormat">{$USER_DATEFORMAT}</span>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<span class="dateFormat">{$TIME_FORMAT}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</table>
|
||||
<input type="hidden" id="{{$idname}}" name="{{$idname}}" value="{$fields[{{sugarvar key='name' stringFormat=true}}].value}">
|
||||
<script type="text/javascript" src="include/SugarFields/Fields/Datetimecombo/Datetimecombo.js"></script>
|
||||
<script type="text/javascript">
|
||||
var combo_{{$idname}} = new Datetimecombo("{$fields[{{sugarvar key='name' stringFormat=true}}].value}", "{{$idname}}", "{$TIME_FORMAT}", "{{$tabindex}}", '{{$displayParams.showNoneCheckbox}}', '{$fields[{{sugarvar key='name' stringFormat=true}}_flag].value}', true);
|
||||
//Render the remaining widget fields
|
||||
text = combo_{{$idname}}.html('{{$displayParams.updateCallback}}');
|
||||
document.getElementById('{{$idname}}_time_section').innerHTML = text;
|
||||
|
||||
//Call eval on the update function to handle updates to calendar picker object
|
||||
eval(combo_{{$idname}}.jsscript('{{$displayParams.updateCallback}}'));
|
||||
|
||||
addToValidate('{$form_name}',"{{$idname}}_date",'date',false,"{{$idname}}");
|
||||
addToValidateBinaryDependency('{$form_name}',"{{$idname}}_hours", 'alpha', false, "{$APP.ERR_MISSING_REQUIRED_FIELDS} {$APP.LBL_HOURS}" ,"{{$idname}}_date");
|
||||
addToValidateBinaryDependency('{$form_name}', "{{$idname}}_minutes", 'alpha', false, "{$APP.ERR_MISSING_REQUIRED_FIELDS} {$APP.LBL_MINUTES}" ,"{{$idname}}_date");
|
||||
addToValidateBinaryDependency('{$form_name}', "{{$idname}}_meridiem", 'alpha', false, "{$APP.ERR_MISSING_REQUIRED_FIELDS} {$APP.LBL_MERIDIEM}","{{$idname}}_date");
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function update_{{$idname}}_available() {ldelim}
|
||||
YAHOO.util.Event.onAvailable("{{$idname}}_date", this.handleOnAvailable, this);
|
||||
{rdelim}
|
||||
|
||||
update_{{$idname}}_available.prototype.handleOnAvailable = function(me) {ldelim}
|
||||
|
||||
Calendar.setup ({ldelim}
|
||||
onClose : update_{{$idname}},
|
||||
inputField : "{{$idname}}_date",
|
||||
ifFormat : "{$CALENDAR_FORMAT}",
|
||||
daFormat : "{$CALENDAR_FORMAT}",
|
||||
button : "{{$idname}}_trigger",
|
||||
singleClick : true,
|
||||
step : 1,
|
||||
weekNumbers:false
|
||||
{rdelim});
|
||||
|
||||
//Call update for first time to round hours and minute values
|
||||
combo_{{$idname}}.update();
|
||||
{rdelim}
|
||||
|
||||
var obj_{{$idname}} = new update_{{$idname}}_available();
|
||||
</script>
|
||||
110
include/SugarFields/Fields/Datetimecombo/SearchView.tpl
Executable file
110
include/SugarFields/Fields/Datetimecombo/SearchView.tpl
Executable file
@@ -0,0 +1,110 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
*}
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr valign="middle">
|
||||
<td nowrap>
|
||||
<input autocomplete="off" type="text" id="{{sugarvar key='name'}}_date" value="{$fields[{{sugarvar key='name' stringFormat=true}}].value}" size="11" maxlength="10" title='{{$vardef.help}}' tabindex="{{$tabindex}}" onblur="combo_{{sugarvar key='name'}}.update(); {{if isset($displayParams.updateCallback)}}{{$displayParams.updateCallback}}{{/if}}">
|
||||
<img border="0" src="{sugar_getimagepath file='jscalendar.gif'}" alt="{$APP.LBL_ENTER_DATE}" id="{{sugarvar key='name'}}_trigger" align="absmiddle">
|
||||
{{if empty($displayParams.splitDateTime)}}
|
||||
</td>
|
||||
<td nowrap>
|
||||
{{else}}
|
||||
<br>
|
||||
{{/if}}
|
||||
<div id="{{sugarvar key='name'}}_time_section"></div>
|
||||
{{if $displayParams.showNoneCheckbox}}
|
||||
<script type="text/javascript">
|
||||
function set_{{sugarvar key='name'}}_values(form) {ldelim}
|
||||
if(form.{{sugarvar key='name'}}_flag.checked) {ldelim}
|
||||
form.{{sugarvar key='name'}}_flag.value=1;
|
||||
form.{{sugarvar key='name'}}.value="";
|
||||
form.{{sugarvar key='name'}}.readOnly=true;
|
||||
{rdelim} else {ldelim}
|
||||
form.{{sugarvar key='name'}}_flag.value=0;
|
||||
form.{{sugarvar key='name'}}.readOnly=false;
|
||||
{rdelim}
|
||||
{rdelim}
|
||||
</script>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{if $displayParams.showFormats}}
|
||||
<tr valign="middle">
|
||||
<td nowrap>
|
||||
<span class="dateFormat">{$USER_DATEFORMAT}</span>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<span class="dateFormat">{$TIME_FORMAT}</span>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</table>
|
||||
<input type="hidden" id="{{sugarvar key='name'}}" name="{{sugarvar key='name'}}" value="{$fields[{{sugarvar key='name' stringFormat=true}}].value}">
|
||||
<script type="text/javascript" src="include/SugarFields/Fields/Datetimecombo/Datetimecombo.js"></script>
|
||||
<script type="text/javascript">
|
||||
var combo_{{sugarvar key='name'}} = new Datetimecombo("{$fields[{{sugarvar key='name' stringFormat=true}}].value}", "{{sugarvar key='name'}}", "{$TIME_FORMAT}", "{{$tabindex}}", '{{$displayParams.showNoneCheckbox}}', '{$fields[{{sugarvar key='name' stringFormat=true}}_flag].value}', true);
|
||||
//Render the remaining widget fields
|
||||
text = combo_{{sugarvar key='name'}}.html('{{$displayParams.updateCallback}}');
|
||||
document.getElementById('{{sugarvar key='name'}}_time_section').innerHTML = text;
|
||||
|
||||
//Call eval on the update function to handle updates to calendar picker object
|
||||
eval(combo_{{sugarvar key='name'}}.jsscript('{{$displayParams.updateCallback}}'));
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function update_{{sugarvar key='name'}}_available() {ldelim}
|
||||
YAHOO.util.Event.onAvailable("{{sugarvar key='name'}}_date", this.handleOnAvailable, this);
|
||||
{rdelim}
|
||||
|
||||
update_{{sugarvar key='name'}}_available.prototype.handleOnAvailable = function(me) {ldelim}
|
||||
Calendar.setup ({ldelim}
|
||||
onClose : update_{{sugarvar key='name'}},
|
||||
inputField : "{{sugarvar key='name'}}_date",
|
||||
ifFormat : "{$CALENDAR_FORMAT}",
|
||||
daFormat : "{$CALENDAR_FORMAT}",
|
||||
button : "{{sugarvar key='name'}}_trigger",
|
||||
singleClick : true,
|
||||
step : 1,
|
||||
weekNumbers:false
|
||||
{rdelim});
|
||||
|
||||
//Call update for first time to round hours and minute values
|
||||
combo_{{sugarvar key='name'}}.update();
|
||||
{rdelim}
|
||||
|
||||
var obj_{{sugarvar key='name'}} = new update_{{sugarvar key='name'}}_available();
|
||||
</script>
|
||||
109
include/SugarFields/Fields/Datetimecombo/SugarFieldDatetimecombo.php
Executable file
109
include/SugarFields/Fields/Datetimecombo/SugarFieldDatetimecombo.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License version 3 as published by the
|
||||
* Free Software Foundation with the addition of the following permission added
|
||||
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||||
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||||
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with
|
||||
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA.
|
||||
*
|
||||
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||||
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||||
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||||
* technical reasons, the Appropriate Legal Notices must display the words
|
||||
* "Powered by SugarCRM".
|
||||
********************************************************************************/
|
||||
require_once('include/SugarFields/Fields/Base/SugarFieldBase.php');
|
||||
|
||||
class SugarFieldDatetimecombo extends SugarFieldBase {
|
||||
|
||||
function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
global $timedate;
|
||||
$displayParams['dateFormat'] = $timedate->get_cal_date_format();
|
||||
|
||||
$displayParams['timeFormat'] = $timedate->get_user_time_format();
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Datetimecombo/EditView.tpl');
|
||||
}
|
||||
|
||||
function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
|
||||
// Create Smarty variables for the Calendar picker widget
|
||||
if(!isset($displayParams['showMinutesDropdown'])) {
|
||||
$displayParams['showMinutesDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showHoursDropdown'])) {
|
||||
$displayParams['showHoursDropdown'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showNoneCheckbox'])) {
|
||||
$displayParams['showNoneCheckbox'] = false;
|
||||
}
|
||||
|
||||
if(!isset($displayParams['showFormats'])) {
|
||||
$displayParams['showFormats'] = false;
|
||||
}
|
||||
|
||||
global $timedate;
|
||||
$displayParams['dateFormat'] = $timedate->get_cal_date_format();
|
||||
|
||||
$displayParams['timeFormat'] = $timedate->get_user_time_format();
|
||||
$this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
|
||||
return $this->fetch('include/SugarFields/Fields/Datetimecombo/SearchView.tpl');
|
||||
}
|
||||
|
||||
|
||||
public function save(&$bean, &$inputData, &$field, &$def, $prefix = '') {
|
||||
global $timedate;
|
||||
if ( !isset($inputData[$prefix.$field]) ) {
|
||||
//$bean->$field = '';
|
||||
return;
|
||||
}
|
||||
|
||||
if(strpos($inputData[$prefix.$field], ' ') > 0) {
|
||||
$bean->$field = $timedate->to_db($inputData[$prefix.$field]);
|
||||
} else {
|
||||
$GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $inputData[$prefix.$field]);
|
||||
//Default to assume date format value
|
||||
$bean->$field = $timedate->to_db_date($inputData[$prefix.$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user