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); $Account->setAccountNotes($accountNotes); $Account->setAccountUserEditId($currentUserId); $Account->setAccountUsersId($accountOtherUsers); $Account->setAccountUserGroupsId($accountOtherGroups);
SP\Customer::updateCustomer($itemId); if (is_array($customFields)) { foreach ($customFields as $id => $value) { $CustomFields = new \SP\CustomFields($id, $itemId, $value); $CustomFields->updateCustomField(); } } } catch (\SP\SPException $e) { SP\Response::printJSON($e->getMessage(), 2); } SP\Response::printJSON(_('Cliente actualizado'), 0, $doActionOnClose); } } } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS_DELETE) { try { SP\Customer::deleteCustomer($itemId); SP\CustomFields::deleteCustomFieldForItem($itemId, \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMERS); } catch (\SP\SPException $e) { SP\Response::printJSON($e->getMessage()); } SP\Response::printJSON(_('Cliente eliminado'), 0, $doActionOnClose); } } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CATEGORIES_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CATEGORIES_EDIT || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CATEGORIES_DELETE) { // Variables POST del formulario $frmCategoryName = SP\Request::analyze('name'); $frmCategoryDesc = SP\Request::analyze('description'); if ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CATEGORIES_NEW || $actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CATEGORIES_EDIT) { if (!$frmCategoryName) { SP\Response::printJSON(_('Es necesario un nombre de categoría'), 2); } SP\Category::$categoryName = $frmCategoryName;