/** * * parametre olarak gelen array deki 'id' li kaydın, info_firm_keys tablosundaki private key ve value değerlerini oluşturur !! * @author Okan CIRAN * @version v 1.0 17.03.2016 * @param array $params * @return array * @throws \PDOException */ public function setNetworkKey($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $CountryCode = NULL; $CountryCodeValue = 'TR'; if (isset($params['country_id']) && $params['country_id'] != "") { $CountryCode = SysCountrys::getCountryCode(array('country_id' => $params['country_id'])); if (\Utill\Dal\Helper::haveRecord($CountryCode)) { $CountryCodeValue = $CountryCode['resultSet'][0]['country_code']; } } $statement = $pdo->prepare("\n UPDATE info_firm_keys\n SET \n network_key = CONCAT('" . $CountryCodeValue . "',ostim_id_generator())\n WHERE \n firm_id = :firm_id"); $statement->bindValue(':firm_id', $params['firm_id'], \PDO::PARAM_INT); $update = $statement->execute(); $affectedRows = $statement->rowCount(); $errorInfo = $statement->errorInfo(); $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * info_users tablosundaki urge ci personel kaydı oluşturur !! * @author Okan CIRAN * @version v 1.0 31.08.2016 * @param array | null $args * @return array * @throws PDOException */ public function insertUrgePerson($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $kontrol = $this->haveRecords($params); // username kontrolu if (!\Utill\Dal\Helper::haveRecord($kontrol)) { $userId = $this->getUserId(array('pk' => $params['pk'])); // bı pk var mı if (\Utill\Dal\Helper::haveRecord($userId)) { $opUserIdValue = $userId['resultSet'][0]['user_id']; $roleId = 64; if (isset($params['role_id']) && $params['role_id'] != "") { $roleId = $params['role_id']; } $languageIdValue = 647; if (isset($params['preferred_language']) && $params['preferred_language'] != "") { $languageIdValue = $params['preferred_language']; } $operationIdValue = -1; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 43, 'type_id' => 1)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $ConsultantId = 1001; $getConsultant = SysOsbConsultants::getConsultantIdForTableName(array('table_name' => 'info_users', 'operation_type_id' => $operationIdValue, 'language_id' => $languageIdValue)); if (\Utill\Dal\Helper::haveRecord($getConsultant)) { $ConsultantId = $getConsultant['resultSet'][0]['consultant_id']; } $CountryCode = NULL; $CountryCodeValue = 'TR'; if (isset($params['country_id']) && $params['country_id'] != "") { $CountryCode = SysCountrys::getCountryCode(array('country_id' => $params['country_id'])); if (\Utill\Dal\Helper::haveRecord($CountryCode)) { $CountryCodeValue = $CountryCode['resultSet'][0]['country_code']; } } $password = '******'; $sql = " \n INSERT INTO info_users(\n operation_type_id, \n username,\n language_id,\n op_user_id,\n role_id,\n password,\n consultant_id,\n network_key\n )\n VALUES ( " . intval($operationIdValue) . ", \n '" . $params['username'] . "', \n " . intval($languageIdValue) . ",\n " . intval($opUserIdValue) . ",\n " . intval($roleId) . ",\n '" . $password . "', \n " . intval($ConsultantId) . ",\n CONCAT('U','" . $CountryCodeValue . "',ostim_userid_generator())\n )"; $statement = $pdo->prepare($sql); // echo debugPDO($sql, $params); $result = $statement->execute(); $insertID = $pdo->lastInsertId('info_users_id_seq'); $errorInfo = $statement->errorInfo(); if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) { throw new \PDOException($errorInfo[0]); } /* * kullanıcı için gerekli olan private key ve value değerleri yaratılılacak. */ $xc = $this->setPrivateKey(array('id' => $insertID)); if ($xc['errorInfo'][0] != "00000" && $xc['errorInfo'][1] != NULL && $xc['errorInfo'][2] != NULL) { throw new \PDOException($xc['errorInfo']); } /* * kullanıcı bilgileri info_users_detail tablosuna kayıt edilecek. */ $xc = $this->insertUrgePersonDetail(array('id' => $insertID, 'op_user_id' => $opUserIdValue, 'role_id' => $roleId, 'language_id' => $languageIdValue, 'name' => $params['name'], 'surname' => $params['surname'], 'auth_email' => $params['auth_email'], 'root_id' => $insertID, 'consultant_id' => $ConsultantId, 'password' => $password)); if ($xc['errorInfo'][0] != "00000" && $xc['errorInfo'][1] != NULL && $xc['errorInfo'][2] != NULL) { throw new \PDOException($xc['errorInfo']); } $xjobs = ActProcessConfirm::insert(array('op_user_id' => intval($opUserIdValue), 'operation_type_id' => intval($operationIdValue), 'table_column_id' => intval($insertID), 'cons_id' => intval($ConsultantId), 'preferred_language_id' => intval($languageIdValue))); if ($xjobs['errorInfo'][0] != "00000" && $xjobs['errorInfo'][1] != NULL && $xjobs['errorInfo'][2] != NULL) { throw new \PDOException($xjobs['errorInfo']); } $logDbData = $this->getUsernamePrivateKey(array('id' => $insertID)); if ($logDbData['errorInfo'][0] != "00000" && $logDbData['errorInfo'][1] != NULL && $logDbData['errorInfo'][2] != NULL) { throw new \PDOException($logDbData['errorInfo']); } $this->insertLogUser(array('oid' => $insertID, 'username' => $logDbData['resultSet'][0]['username'], 'sf_private_key_value' => $logDbData['resultSet'][0]['sf_private_key_value'], 'sf_private_key_value_temp' => $logDbData['resultSet'][0]['sf_private_key_value_temp'])); /* * danısman tablosuna kaydedelim. */ $xc = $this->insertUrgePersonSysOsbPerson(array('op_user_id' => intval($opUserIdValue), 'user_id' => intval($insertID), 'osb_cluster_id' => intval($params['cluster_id']))); if ($xc['errorInfo'][0] != "00000" && $xc['errorInfo'][1] != NULL && $xc['errorInfo'][2] != NULL) { throw new \PDOException($xc['errorInfo']); } $userInfo = $this->getUrgePersonRoleAndClusterInformation(array('id' => $insertID)); if (\Utill\Dal\Helper::haveRecord($userInfo)) { $kumeValue = $userInfo['resultSet'][0]['clusters']; $roleValue = $userInfo['resultSet'][0]['role']; $keyValue = $userInfo['resultSet'][0]['key']; $xcSendingMail = InfoUsersSendingMail::insertSendingMail(array('user_id' => intval($insertID), 'auth_email' => $params['auth_email'], 'act_email_template_id' => 1, 'op_user_id' => intval($opUserIdValue), 'key' => $keyValue)); if ($xcSendingMail['errorInfo'][0] != "00000" && $xcSendingMail['errorInfo'][1] != NULL && $xcSendingMail['errorInfo'][2] != NULL) { throw new \PDOException($xcSendingMail['errorInfo']); } /* * email gönderelim */ $xcUserInfo = InfoUsersSendingMail::sendMailUrgeNewPerson(array('auth_email' => $params['auth_email'], 'herkimse' => $params['name'] . ' ' . $params['surname'], 'kume' => $kumeValue, 'rol' => $roleValue, 'key' => $keyValue)); if ($xcUserInfo['errorInfo'][0] != "00000" && $xcUserInfo['errorInfo'][1] != NULL && $xcUserInfo['errorInfo'][2] != NULL) { throw new \PDOException($xcUserInfo['errorInfo']); } } $insertID = $xc['lastInsertId']; $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "lastInsertId" => $insertID); } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23505'; // 23505 unique_violation $errorInfoColumn = 'username'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }