Fixes, adding corrections to the validation for the name field in the calendar Edit form
This commit is contained in:
@@ -39,10 +39,12 @@ G::LoadClass ( 'calendar' );
|
|||||||
$calendarObj = new calendar ( );
|
$calendarObj = new calendar ( );
|
||||||
if ((isset ( $_GET ['id'] )) && ($_GET ['id'] != "")) {
|
if ((isset ( $_GET ['id'] )) && ($_GET ['id'] != "")) {
|
||||||
$fields = $calendarObj->getCalendarInfo ( $CalendarUid );
|
$fields = $calendarObj->getCalendarInfo ( $CalendarUid );
|
||||||
|
$fields ['OLD_NAME'] = $fields['CALENDAR_NAME'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (isset ( $fields ['CALENDAR_UID'] ))) { //For a new Calendar
|
if (! (isset ( $fields ['CALENDAR_UID'] ))) { //For a new Calendar
|
||||||
$fields ['CALENDAR_UID'] = $CalendarUid;
|
$fields ['CALENDAR_UID'] = $CalendarUid;
|
||||||
|
$fields ['OLD_NAME'] = '';
|
||||||
//Default Business Hour
|
//Default Business Hour
|
||||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
|
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
|
||||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
|
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ switch ($RBAC->userCanAccess('PM_SETUP_ADVANCE'))
|
|||||||
}
|
}
|
||||||
// validating the fields
|
// validating the fields
|
||||||
$message = array();
|
$message = array();
|
||||||
|
$oldName = isset($_POST['oldName'])?$_POST['oldName']:'';
|
||||||
|
|
||||||
switch ($_POST['action']){
|
switch ($_POST['action']){
|
||||||
case 'calendarName':
|
case 'calendarName':
|
||||||
require_once ('classes/model/CalendarDefinition.php');
|
require_once ('classes/model/CalendarDefinition.php');
|
||||||
@@ -50,13 +52,20 @@ switch ($_POST['action']){
|
|||||||
$aCalendarDefinitions = end($aCalendars);
|
$aCalendarDefinitions = end($aCalendars);
|
||||||
// var_dump($aCalendarDefinitions);
|
// var_dump($aCalendarDefinitions);
|
||||||
foreach($aCalendarDefinitions as $aDefinitions) {
|
foreach($aCalendarDefinitions as $aDefinitions) {
|
||||||
if ($aDefinitions['CALENDAR_NAME']!=$_POST['name']){
|
if (trim($_POST['name'])==''){
|
||||||
$validated = true;
|
|
||||||
} else {
|
|
||||||
$validated = false;
|
$validated = false;
|
||||||
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
|
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ($aDefinitions['CALENDAR_NAME']!=$_POST['name']){
|
||||||
|
$validated = true;
|
||||||
|
} else {
|
||||||
|
if ($aDefinitions['CALENDAR_NAME']!=$oldName) {
|
||||||
|
$validated = false;
|
||||||
|
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'calendarDates':
|
case 'calendarDates':
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||||
<tbody><tr style="display: none;">
|
<tbody><tr style="display: none;">
|
||||||
<td colspan="2">{$form.CALENDAR_UID}</td>
|
<td colspan="2">{$form.CALENDAR_UID}</td>
|
||||||
|
</tr>
|
||||||
|
<tbody><tr style="display: none;">
|
||||||
|
<td colspan="2">{$form.OLD_NAME}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="FormTitle" colspan="2" align="">{$form.DEFINITION_TITLE}</td>
|
<td class="FormTitle" colspan="2" align="">{$form.DEFINITION_TITLE}</td>
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
<en>Ndar Uid
|
<en>Ndar Uid
|
||||||
</en>
|
</en>
|
||||||
</CALENDAR_UID>
|
</CALENDAR_UID>
|
||||||
|
<OLD_NAME type="hidden" size='32' maxlength='32' >
|
||||||
|
</OLD_NAME>
|
||||||
|
|
||||||
<DEFINITION_TITLE type="title" enablehtml="0">
|
<DEFINITION_TITLE type="title" enablehtml="0">
|
||||||
<en><![CDATA[Calendar Definition]]></en>
|
<en><![CDATA[Calendar Definition]]></en>
|
||||||
</DEFINITION_TITLE>
|
</DEFINITION_TITLE>
|
||||||
@@ -16,6 +19,7 @@
|
|||||||
<CALENDAR_STATUS type="checkbox" value="ACTIVE" falsevalue="INACTIVE" defaultvalue="ACTIVE" labelonright="1" enablehtml="0">
|
<CALENDAR_STATUS type="checkbox" value="ACTIVE" falsevalue="INACTIVE" defaultvalue="ACTIVE" labelonright="1" enablehtml="0">
|
||||||
<en><![CDATA[Active]]></en>
|
<en><![CDATA[Active]]></en>
|
||||||
</CALENDAR_STATUS>
|
</CALENDAR_STATUS>
|
||||||
|
|
||||||
<WorkDays type="title" enablehtml="0">
|
<WorkDays type="title" enablehtml="0">
|
||||||
<en><![CDATA[Work Days]]></en>
|
<en><![CDATA[Work Days]]></en>
|
||||||
</WorkDays>
|
</WorkDays>
|
||||||
@@ -68,8 +72,13 @@ function submit1 () {
|
|||||||
return validateForm(this.form);
|
return validateForm(this.form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit2 (){
|
function submit2 () {
|
||||||
invalidCalendarName = validateCalendarName();
|
if (getField('OLD_NAME').value==''){
|
||||||
|
invalidCalendarName = validateCalendarName('');
|
||||||
|
} else {
|
||||||
|
invalidCalendarName = validateCalendarName(getField('OLD_NAME').value);
|
||||||
|
}
|
||||||
|
|
||||||
var startHourMessage= '';
|
var startHourMessage= '';
|
||||||
var endHourMessage='';
|
var endHourMessage='';
|
||||||
var invalidNameMessage = '';
|
var invalidNameMessage = '';
|
||||||
@@ -409,12 +418,18 @@ function cancel(){
|
|||||||
window.location = 'calendarList';
|
window.location = 'calendarList';
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateCalendarName(){
|
function validateCalendarName(name){
|
||||||
var validateMessage = '';
|
var validateMessage = '';
|
||||||
|
var oldName = '';
|
||||||
|
if (name!='') {
|
||||||
|
oldName = '&oldName='+name;
|
||||||
|
}
|
||||||
|
var arguments = 'action=calendarName&name='+getField("CALENDAR_NAME").value+oldName;
|
||||||
|
|
||||||
var oRPC = new leimnud.module.rpc.xmlhttp({
|
var oRPC = new leimnud.module.rpc.xmlhttp({
|
||||||
url : 'calendarValidate',
|
url : 'calendarValidate',
|
||||||
async : false,
|
async : false,
|
||||||
args : 'action=calendarName&name='+getField("CALENDAR_NAME").value
|
args : arguments
|
||||||
});
|
});
|
||||||
oRPC.make();
|
oRPC.make();
|
||||||
validateMessage=oRPC.xmlhttp.responseText;
|
validateMessage=oRPC.xmlhttp.responseText;
|
||||||
|
|||||||
Reference in New Issue
Block a user