Exemplo n.º 1
0
     $Account->setAccountOtherUserEdit($accountUserEditEnabled);
     $Account->setAccountOtherGroupEdit($accountGroupEditEnabled);
     // Crear cuenta
     if ($Account->createAccount()) {
         if (is_array($customFields)) {
             foreach ($customFields as $id => $value) {
                 $CustomFields = new \SP\CustomFields($id, $Account->getAccountId(), $value);
                 $CustomFields->addCustomField();
             }
         }
         SP\Response::printJSON(_('Cuenta creada'), 0);
     }
     SP\Response::printJSON(_('Error al crear la cuenta'), 0);
     break;
 case \SP\Controller\ActionsInterface::ACTION_ACC_EDIT:
     SP\Customer::$customerName = $newCustomer;
     // Comprobar si se ha introducido un nuevo cliente
     if ($customerId === 0 && $newCustomer) {
         try {
             SP\Customer::addCustomer();
             $customerId = SP\Customer::$customerLastId;
         } catch (\SP\SPException $e) {
             SP\Response::printJSON($e->getMessage());
         }
     }
     $Account->setAccountId($accountId);
     $Account->setAccountName($accountName);
     $Account->setAccountCategoryId($categoryId);
     $Account->setAccountCustomerId($customerId);
     $Account->setAccountLogin($accountLogin);
     $Account->setAccountUrl($accountUrl);
Exemplo n.º 2
0
        } 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;
        if ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_NEW) {
            try {
                SP\Customer::addCustomer($itemId);
                if (is_array($customFields)) {
                    foreach ($customFields as $id => $value) {
                        $CustomFields = new \SP\CustomFields($id, SP\Customer::$customerLastId, $value);
                        $CustomFields->addCustomField();
                    }
                }
            } catch (\SP\SPException $e) {
                SP\Response::printJSON($e->getMessage(), 2);
            }
            SP\Response::printJSON(_('Cliente creado'), 0, $doActionOnClose);
        } else {