/** * Crea una nueva cuenta en la BBDD * * @return bool */ public function createAccount() { $query = 'INSERT INTO accounts SET ' . 'account_customerId = :accountCustomerId,' . 'account_categoryId = :accountCategoryId,' . 'account_name = :accountName,' . 'account_login = :accountLogin,' . 'account_url = :accountUrl,' . 'account_pass = :accountPass,' . 'account_IV = :accountIV,' . 'account_notes = :accountNotes,' . 'account_dateAdd = NOW(),' . 'account_userId = :accountUserId,' . 'account_userGroupId = :accountUserGroupId,' . 'account_otherUserEdit = :accountOtherUserEdit,' . 'account_otherGroupEdit = :accountOtherGroupEdit'; $data['accountCustomerId'] = $this->getAccountCustomerId(); $data['accountCategoryId'] = $this->getAccountCategoryId(); $data['accountName'] = $this->getAccountName(); $data['accountLogin'] = $this->getAccountLogin(); $data['accountUrl'] = $this->getAccountUrl(); $data['accountPass'] = $this->getAccountPass(); $data['accountIV'] = $this->getAccountIV(); $data['accountNotes'] = $this->getAccountNotes(); $data['accountUserId'] = $this->getAccountUserId(); $data['accountUserGroupId'] = $this->getAccountUserGroupId(); $data['accountOtherUserEdit'] = $this->getAccountOtherUserEdit(); $data['accountOtherGroupEdit'] = $this->getAccountOtherGroupEdit(); if (DB::getQuery($query, __FUNCTION__, $data) === false) { return false; } $this->setAccountId(DB::$lastId); $Log = new Log(__FUNCTION__); if (is_array($this->getAccountUserGroupsId())) { if (!Groups::addGroupsForAccount($this->getAccountId(), $this->getAccountUserGroupsId())) { $Log->addDescription(_('Error al actualizar los grupos secundarios')); $Log->writeLog(); $Log->resetDescription(); } } if (is_array($this->getAccountUsersId())) { if (!UserAccounts::addUsersForAccount($this->getAccountId(), $this->getAccountUsersId())) { $Log->addDescription(_('Error al actualizar los usuarios de la cuenta')); $Log->writeLog(); $Log->resetDescription(); } } $accountInfo = array('customer_name'); $this->getAccountInfoById($accountInfo); $Log->setAction(_('Nueva Cuenta')); $Log->addDescription(Html::strongText(_('Cliente') . ': ') . $this->_cacheParams['customer_name']); $Log->addDescription(Html::strongText(_('Cuenta') . ': ') . $this->getAccountName() . " (" . $this->getAccountId() . ")"); $Log->writeLog(); Email::sendEmail($Log); return true; }