/** * delete olayında önce kaydın active özelliğini pasif e olarak değiştiriyoruz. * daha sonra deleted= 1 ve active = 1 olan kaydı oluşturuyor. * böylece tablo içerisinde loglama mekanizması için gerekli olan kayıt oluşuyor. * @version 25.04.2016 * @param type $id * @param type $params * @return array * @throws PDOException */ public function deletedAct($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $opUserId = InfoUsers::getUserId(array('pk' => $params['pk'])); if (\Utill\Dal\Helper::haveRecord($opUserId)) { $opUserIdValue = $opUserId['resultSet'][0]['user_id']; $getFirm = InfoFirmProfile::getCheckIsThisFirmRegisteredUser(array('cpk' => $params['cpk'], 'op_user_id' => $opUserIdValue)); if (\Utill\Dal\Helper::haveRecord($getFirm)) { $getFirmId = $getFirm['resultSet'][0]['firm_id']; //$kontrol = $this->haveRecords($params); $kontrol = $this->haveRecords(array('id' => $params['id'], 'firm_id' => $getFirmId)); if (!\Utill\Dal\Helper::haveRecord($kontrol)) { $this->makePassive(array('id' => $params['id'])); $operationIdValue = -3; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 32, 'type_id' => 3)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $languageId = NULL; $languageIdValue = 647; if (isset($params['language_code']) && $params['language_code'] != "") { $languageId = SysLanguage::getLanguageId(array('language_code' => $params['language_code'])); if (\Utill\Dal\Helper::haveRecord($languageId)) { $languageIdValue = $languageId['resultSet'][0]['id']; } } $profilePublic = 0; if (isset($params['profile_public']) && $params['profile_public'] != "") { $profilePublic = intval($params['profile_public']); } $sql = " \n INSERT INTO info_firm_verbal(\n firm_id, \n consultant_id,\n operation_type_id, \n language_id,\n op_user_id,\n profile_public, \n act_parent_id, \n about,\n about_eng,\n verbal1_title, \n verbal1, \n verbal2_title, \n verbal2, \n verbal3_title, \n verbal3, \n verbal1_title_eng, \n verbal1_eng, \n verbal2_title_eng, \n verbal2_eng, \n verbal3_title_eng, \n verbal3_eng,\n consultant_confirm_type_id, \n confirm_id,\n language_parent_id,\n cons_allow_id,\n active,\n deleted\n ) \n SELECT \n firm_id, \n consultant_id, \n " . intval($operationIdValue) . " AS operation_type_id,\n language_id, \n " . intval($opUserIdValue) . " AS op_user_id, \n profile_public, \n act_parent_id, \n about,\n about_eng,\n verbal1_title,\n verbal1,\n verbal2_title,\n verbal2,\n verbal3_title,\n verbal3,\n verbal1_title_eng,\n verbal1_eng,\n verbal2_title_eng,\n verbal2_eng,\n verbal3_title_eng,\n verbal3_eng, \n consultant_confirm_type_id, \n confirm_id,\n language_parent_id,\n cons_allow_id,\n 1,\n 1\n FROM info_firm_verbal \n WHERE id = " . intval($params['id']) . " \n "; $statement_act_insert = $pdo->prepare($sql); $insert_act_insert = $statement_act_insert->execute(); // echo debugPDO($sql, $params); $affectedRows = $statement_act_insert->rowCount(); $insertID = $pdo->lastInsertId('info_firm_verbal_id_seq'); /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_firm_verbal', 'id' => $params['id'])); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; $languageIdValue = $consIdAndLanguageId['resultSet'][0]['language_id']; } $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']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { // 23505 unique_violation $errorInfo = '23505'; $pdo->rollback(); $result = $kontrol; return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => ''); } } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'cpk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * delete olayında önce kaydın active özelliğini pasif e olarak değiştiriyoruz. * daha sonra deleted= 1 ve active = 1 olan kaydı oluşturuyor. * böylece tablo içerisinde loglama mekanizması için gerekli olan kayıt oluşuyor. * @version 21.04.2016 * @param type $id * @param type $params * @return array * @throws PDOException */ public function deletedAct($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $opUserId = InfoUsers::getUserId(array('pk' => $params['pk'])); if (\Utill\Dal\Helper::haveRecord($opUserId)) { $opUserIdValue = $opUserId['resultSet'][0]['user_id']; $this->makePassive(array('id' => $params['id'])); $operationIdValue = -3; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 42, 'type_id' => 3)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $sql = " \n INSERT INTO info_users_socialmedia(\n user_id, \n profile_public, \n op_user_id, \n operation_type_id, \n consultant_id, \n sys_socialmedia_id, \n act_parent_id, \n user_link,\n active,\n deleted\n )\n SELECT \n user_id,\n profile_public, \n " . intval($opUserIdValue) . " AS op_user_id, \n " . intval($operationIdValue) . " AS operation_type_id, \n consultant_id, \n sys_socialmedia_id,\n act_parent_id, \n user_link,\n 1,\n 1 \n FROM info_users_socialmedia \n WHERE id = " . intval($params['id']) . " \n "; $statement_act_insert = $pdo->prepare($sql); // echo debugPDO($sql, $params); $insert_act_insert = $statement_act_insert->execute(); $affectedRows = $statement_act_insert->rowCount(); $insertID = $pdo->lastInsertId('info_users_socialmedia_id_seq'); /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_users_socialmedia', 'id' => $params['id'])); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; $languageIdValue = $consIdAndLanguageId['resultSet'][0]['language_id']; } $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']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * parametre olarak gelen 'id' li kaydın password unu update yapar !! * @author Okan CIRAN * @version v 1.0 02.09.2016 * @param array | null $args * @param type $params * @return array * @throws PDOException */ public function setPersonPassword($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $userId = $this->getUserId(array('pk' => $params['key'])); if (\Utill\Dal\Helper::haveRecord($userId)) { $opUserIdValue = $userId['resultSet'][0]['user_id']; /* * kullanıcı için gerekli olan private key ve value değerleri yaratılılacak. */ $xcDeletedOnTheLink = InfoUsersSendingMail::setDeletedOnTheLinks(array('key' => $params['key'])); if ($xcDeletedOnTheLink['errorInfo'][0] != "00000" && $xcDeletedOnTheLink['errorInfo'][1] != NULL && $xcDeletedOnTheLink['errorInfo'][2] != NULL) { throw new \PDOException($xcDeletedOnTheLink['errorInfo']); } $affectedRows = $xcDeletedOnTheLink['affectedRowsCount']; if ($affectedRows == 1) { $active = 0; $operationIdValue = -2; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 43, 'type_id' => 2)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } /* * parametre olarak gelen array deki 'id' li kaydın, info_users tablosundaki * alanlarını update eder !! username update edilmez. */ $this->updateInfoUsers(array('id' => $opUserIdValue, 'op_user_id' => $opUserIdValue, 'active' => $active, 'operation_type_id' => $operationIdValue, 'language_id' => 647, 'password' => $params['password'])); /* * parametre olarak gelen array deki 'id' li kaydın, info_users_details tablosundaki * active = 0 ve deleted = 0 olan kaydın active alanını 1 yapar !! */ $this->setUserDetailsDisables(array('id' => $opUserIdValue)); $operationIdValueDetail = -2; $operationIdDetail = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 40, 'type_id' => 2)); if (\Utill\Dal\Helper::haveRecord($operationIdDetail)) { $operationIdValueDetail = $operationIdDetail['resultSet'][0]['id']; } $sql = " \n INSERT INTO info_users_detail(\n profile_public, \n operation_type_id,\n active,\n name,\n surname,\n auth_email,\n language_id,\n op_user_id,\n root_id,\n act_parent_id,\n auth_allow_id,\n password \n ) \n SELECT \n 0 AS profile_public, \n " . intval($operationIdValueDetail) . " AS operation_type_id,\n " . intval($active) . " AS active, \n name, \n surname,\n auth_email, \n language_id, \n " . intval($opUserIdValue) . " AS op_user_id,\n a.root_id,\n a.act_parent_id,\n 1,\n '" . $params['password'] . "' AS password\n FROM info_users_detail a\n WHERE root_id =" . intval($opUserIdValue) . " \n AND active =1 AND deleted =0 and \n c_date = (SELECT MAX(c_date) \n\t\t\t\t\t\tFROM info_users_detail WHERE root_id =a.root_id\n\t\t\t\t\t\tAND active =1 AND deleted =0) \n "; $statementActInsert = $pdo->prepare($sql); // echo debugPDO($sql, $params); $insertAct = $statementActInsert->execute(); $affectedRows = $statementActInsert->rowCount(); $insertID = $pdo->lastInsertId('info_users_detail_id_seq'); $errorInfo = $statementActInsert->errorInfo(); if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) { throw new \PDOException($errorInfo[0]); } /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_users_detail', 'id' => $insertID)); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; // $languageIdValue = $consIdAndLanguageId ['resultSet'][0]['language_id']; } $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' => 647)); if ($xjobs['errorInfo'][0] != "00000" && $xjobs['errorInfo'][1] != NULL && $xjobs['errorInfo'][2] != NULL) { throw new \PDOException($xjobs['errorInfo']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { $errorInfo = '23502'; /// 23502 user_id not_null_violation $errorInfoColumn = 'key'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23502'; /// 23502 user_id not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * @author Okan CIRAN * @ info_firm_profile tablosuna yeni bir kayıt oluşturur. !! * @version v 1.0 06.01.2016 * @param array | null $args * @return array * @throws \PDOException */ public function insertTemp($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $opUserId = InfoUsers::getUserIdTemp(array('pktemp' => $params['pktemp'])); if (\Utill\Dal\Helper::haveRecord($opUserId)) { $opUserIdValue = $opUserId['resultSet'][0]['user_id']; $kontrol = $this->haveRecords($params); if (!\Utill\Dal\Helper::haveRecord($kontrol)) { $operationIdValue = -1; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 23, 'type_id' => 1)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $ConsultantId = 1001; $getConsultant = SysOsbConsultants::getConsultantIdForTableName(array('table_name' => 'info_firm_profile', 'operation_type_id' => $operationIdValue)); if (\Utill\Dal\Helper::haveRecord($getConsultant)) { $ConsultantId = $getConsultant['resultSet'][0]['consultant_id']; } $foundationYearx = NULL; if (isset($params['foundation_yearx']) && $params['foundation_yearx'] != "") { $foundationYearx = $params['foundation_yearx']; } //to_timestamp(1451599200 ) $languageId = NULL; $languageIdValue = 647; if (isset($params['language_code']) && $params['language_code'] != "") { $languageId = SysLanguage::getLanguageId(array('language_code' => $params['language_code'])); if (\Utill\Dal\Helper::haveRecord($languageId)) { $languageIdValue = $languageId['resultSet'][0]['id']; } } $sql = " \n INSERT INTO info_firm_profile(\n profile_public, \n country_id, \n firm_name, \n web_address, \n tax_office, \n tax_no, \n sgk_sicil_no, \n ownership_status_id, \n language_code, \n language_id,\n op_user_id, \n consultant_id,\n operation_type_id, \n foundation_yearx, \n firm_name_short,\n act_parent_id, \n description,\n description_eng,\n duns_number,\n logo\n )\n VALUES (\n " . intval($params['profile_public']) . ", \n " . intval($params['country_id']) . ",\n :firm_name, \n :web_address, \n :tax_office, \n :tax_no,\n :sgk_sicil_no, \n " . intval($params['ownership_status_id']) . ",\n :language_code, \n " . intval($languageIdValue) . ",\n " . intval($opUserIdValue) . ",\n " . intval($ConsultantId) . ",\n " . intval($operationIdValue) . ",\n " . intval($foundationYearx) . " ,\n :firm_name_short,\n (SELECT last_value FROM info_firm_profile_id_seq),\n :description,\n :description_eng,\n :duns_number,\n :logo\n ) "; $statementInsert = $pdo->prepare($sql); $statementInsert->bindValue(':firm_name', $params['firm_name'], \PDO::PARAM_STR); $statementInsert->bindValue(':web_address', $params['web_address'], \PDO::PARAM_STR); $statementInsert->bindValue(':tax_office', $params['tax_office'], \PDO::PARAM_STR); $statementInsert->bindValue(':tax_no', $params['tax_no'], \PDO::PARAM_STR); $statementInsert->bindValue(':sgk_sicil_no', $params['sgk_sicil_no'], \PDO::PARAM_STR); $statementInsert->bindValue(':language_code', $params['language_code'], \PDO::PARAM_STR); $statementInsert->bindValue(':firm_name_short', $params['firm_name_short'], \PDO::PARAM_STR); $statementInsert->bindValue(':description', $params['description'], \PDO::PARAM_STR); $statementInsert->bindValue(':description_eng', $params['description_eng'], \PDO::PARAM_STR); $statementInsert->bindValue(':duns_number', $params['duns_number'], \PDO::PARAM_STR); $statementInsert->bindValue(':logo', $params['logo'], \PDO::PARAM_STR); // echo debugPDO($sql, $params); $result = $statementInsert->execute(); $insertID = $pdo->lastInsertId('info_firm_profile_id_seq'); $errorInfo = $statementInsert->errorInfo(); if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) { throw new \PDOException($errorInfo[0]); } InfoFirmKeys::insert(array('firm_id' => $insertID, 'country_id' => $params['country_id'])); $this->insertCompanyUser(array('firm_id' => $insertID, 'language_id' => $languageIdValue, 'consultant_id' => $ConsultantId, 'user_id' => $opUserIdValue, 'op_user_id' => $opUserIdValue)); $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "lastInsertId" => $insertID); } else { $errorInfo = '23505'; // 23505 unique_violation $errorInfoColumn = 'firm_name'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * @author Okan CIRAN * @ info_users_addresses tablosundan parametre olarak gelen id kaydın active alanını 1 yapar ve * yeni yeni kayıt oluşturarak deleted ve active = 1 olarak yeni kayıt yapar. ! * @version v 1.0 02.02.2016 * @param array | null $args * @return array * @throws \PDOException */ public function deletedActTemp($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $userId = InfoUsers::getUserIdTemp(array('pktemp' => $params['pktemp'])); if (\Utill\Dal\Helper::haveRecord($userId)) { $userIdValue = $userId['resultSet'][0]['user_id']; $operationIdValue = -3; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 38, 'type_id' => 3)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $this->makePassive(array('id' => $params['id'])); $statementInsert = $pdo->prepare(" \n INSERT INTO info_users_addresses (\n user_id, \n active, \n deleted,\n op_user_id, \n operation_type_id,\n act_parent_id, \n language_id,\n address_type_id, \n address1, \n address2, \n postal_code, \n country_id, \n city_id, \n borough_id, \n city_name, \n description, \n description_eng,\n profile_public,\n consultant_id, \n language_parent_id, \n consultant_id, \n act_parent_id\n ) \n \n SELECT\n user_id,\n 1 AS active, \n 1 AS deleted, \n " . intval($userIdValue) . " AS op_user_id, \n " . intval($operationIdValue) . ",\n act_parent_id, \n language_id,\n address_type_id, \n address1, \n address2, \n postal_code, \n country_id, \n city_id, \n borough_id, \n city_name, \n description, \n description_eng,\n profile_public,\n confirm_id, \n language_parent_id , \n consultant_id, \n act_parent_id\n FROM info_users_addresses \n WHERE id =" . intval($params['id']) . " \n )"); $insertAct = $statementInsert->execute(); $affectedRows = $statementInsert->rowCount(); $errorInfo = $statementInsert->errorInfo(); if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) { throw new \PDOException($errorInfo[0]); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { $errorInfo = '23502'; /// 23502 not_null_violation $errorInfoColumn = 'pk / op_user_id'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }