This commit is contained in:
qronald
2017-05-23 10:08:44 -04:00
parent 0242efa6b0
commit c0e80d1d32
2 changed files with 28 additions and 17 deletions

View File

@@ -129,15 +129,20 @@ switch ($_POST['action']) {
echo G::json_encode( $result );
break;
case 'exitsGroupName':
require_once 'classes/model/Groupwf.php';
G::LoadClass( 'Groupswf' );
$oGroup = new Groupwf();
$oCriteria = $oGroup->loadByGroupname( $_POST['GRP_NAME'] );
$oDataset = GroupwfPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$aRow = $oDataset->getRow();
$response = ($aRow) ? 'true' : 'false';
$groupName = strip_tags($_POST['GRP_NAME']);
if ($groupName) {
require_once 'classes/model/Groupwf.php';
G::LoadClass('Groupswf');
$oGroup = new Groupwf();
$oCriteria = $oGroup->loadByGroupname($_POST['GRP_NAME']);
$oDataset = GroupwfPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
$response = ($aRow) ? \G::json_encode(['success' => true]) : \G::json_decode(['success' => false]);
} else {
$response = \G::json_encode(['success' => true, 'msg' => \G::LoadTranslation('ID_FIELD_INVALID')]);
}
echo $response;
break;
case 'saveNewGroup':

View File

@@ -182,7 +182,13 @@ Ext.onReady(function(){
text: _("ID_SAVE"),
handler: function (btn, ev)
{
if( newForm.getForm().findField('name').getValue().trim() == "") {
var reg = new RegExp(/(<([^>]+)>)/ig),
nameGroups = newForm.getForm().findField('name').getValue();
if (reg.test(nameGroups)){
Ext.Msg.alert(_('ID_WARNING'), _("ID_FIELD_INVALID", _("ID_GROUP_NAME")));
newForm.getForm().findField('name').setValue("");
return false;
} else if (nameGroups.trim() == "") {
Ext.Msg.alert(_('ID_WARNING'), _("ID_FIELD_REQUIRED", _("ID_GROUP_NAME")));
newForm.getForm().findField('name').setValue("");
return false;
@@ -434,8 +440,8 @@ CheckGroupName = function(grp_name, function_success, function_failure){
params: {action: 'exitsGroupName', GRP_NAME: grp_name},
success: function(resp, opt){
viewport.getEl().unmask();
var checked = eval(resp.responseText);
(!checked) ? function_success() : function_failure();
var response = JSON.parse(resp.responseText);
(!response.success) ? function_success() : function_failure(response.msg);
},
failure: function(r,o) {
viewport.getEl().unmask();
@@ -452,11 +458,11 @@ SaveNewGroupAction = function(){
};
//Show Duplicate Group Name Message
DuplicateGroupName = function(){
Ext.getCmp("btnCreateSave").setDisabled(false);
Ext.getCmp("btnUpdateSave").setDisabled(false);
PMExt.warning(_('ID_GROUPS'), _('ID_MSG_GROUP_NAME_EXISTS'));
DuplicateGroupName = function (msg) {
Ext.getCmp("btnCreateSave").setDisabled(false);
Ext.getCmp("btnUpdateSave").setDisabled(false);
newForm.getForm().findField('name').setValue("");
PMExt.warning(_('ID_GROUPS'), msg ? msg : _('ID_MSG_GROUP_NAME_EXISTS'));
};
//Save New Group