Exemplo n.º 1
0
                SP\Response::printJSON(_('Perfil creado'), 0, $doActionOnClose);
            }
            SP\Response::printJSON(_('Error al crear el perfil'));
        } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_EDIT) {
            if ($Profile->profileUpdate()) {
                SP\Response::printJSON(_('Perfil actualizado'), 0, $doActionOnClose);
            }
            SP\Response::printJSON(_('Error al actualizar el perfil'));
        }
    } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_USR_PROFILES_DELETE) {
        $resProfileUse = SP\Profile::checkProfileInUse($Profile->getId());
        if ($resProfileUse['users'] > 0) {
            $uses[] = _('Usuarios') . " (" . $resProfileUse['users'] . ")";
            SP\Response::printJSON(_('No es posible eliminar') . ';;' . _('Perfil en uso por:') . ';;' . implode(';;', $uses));
        } else {
            if ($Profile->profileDelete()) {
                SP\Response::printJSON(_('Perfil eliminado'), 0, $doActionOnClose);
            }
            SP\Response::printJSON(_('Error al eliminar el perfil'));
        }
    }
} elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE) {
    // Variables POST del formulario
    $frmCustomerName = SP\Request::analyze('name');
    $frmCustomerDesc = SP\Request::analyze('description');
    if ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_EDIT) {
        if (!$frmCustomerName) {
            SP\Response::printJSON(_('Es necesario un nombre de cliente'), 2);
        }
        SP\Customer::$customerName = $frmCustomerName;
        SP\Customer::$customerDescription = $frmCustomerDesc;