/** * تنها با استفاده از اين تابع مي توان حکم جديد صادر کرد * @return boolean : قرار مي دهد ExceptionHandler اگر صدور حکم با موفقيت انجام نشود توضيح خطا را در */ private function IssueWritAction($indiv = NULL) { $temp = parent::runquery("select last_writ_id,last_writ_ver,staff_id,PersonID,person_type from HRM_staff\n \t\t\t\t\t\t\t\t\t\t\twhere staff_id=" . $this->staff_id . " and person_type =" . $this->person_type); if (count($temp) == 0) { parent::PushException(ERROR_STAFF_ID_NOT_FOUND); return false; } $staff_rec = $temp[0]; $PersonID = $staff_rec['PersonID']; //___________________________________________________________ //در صورتي که روال ناتمام اصلاح وجود دارد if ($this->correct_is_not_completed($this->staff_id)) { parent::PushException(ERROR_CORRECT_IS_NOT_COMPLETED); return false; } //___________________________________________________________ //در صورتي که حکم خودکار است کنترلهاي زير اعمال شود $is_auto = $this->is_auto_writ($this->execute_date, $this->person_type); if ($is_auto) { //___________________________________________________________ $lastWritObj = manage_writ::GetLastWrit($this->staff_id); $writ_subtype_obj = new manage_writ_subType($this->person_type, $this->writ_type_id, $this->writ_subtype_id); //......................................................................................... if (($this->person_type == 5 || $writ_subtype_obj->emp_state == 2) && $this->contract_start_date != NULL && substr(DateModules::miladi_to_shamsi($this->execute_date), 0, 4) != substr(DateModules::miladi_to_shamsi($this->contract_start_date), 0, 4)) { parent::PushException(ER_CONTRACT_DATE); return false; } //......................................................................................... //..... در صورتی که فرد بازنشسته باشد ولی آزاده باشد امکان صدور حکم برای فرد میسر می باشد ................ //.... جانباز نیز بهمین صورت................................................................... $Azadegi = manage_person_devotion::get_person_devotions($PersonID, "(2,3)"); //................................................................................................... //کنترل مي کند که در صورتي که شخص بازنشسته شده باشد براي او حکمي صادر نشود. if (!empty($lastWritObj->writ_id) && $lastWritObj->execute_date < $this->execute_date && !$this->history_only) { if (($lastWritObj->emp_mode == EMP_MODE_RETIRE && $Azadegi[0]['amount'] <= 0 || $lastWritObj->emp_mode == EMP_MODE_RE_BUY || $lastWritObj->emp_mode == EMP_MODE_RUSTICATION || $lastWritObj->emp_mode == EMP_MODE_PERMANENT_BREAK || $lastWritObj->emp_mode == EMP_MODE_BREAKAWAY || $lastWritObj->emp_mode == EMP_MODE_CONVEYANCE && $writ_subtype_obj->emp_mode != 16) && $this->corrective_writ_id == PDONULL) { parent::PushException(ERROR_FOR_RETIRED_PERSONS_CAN_NOT_ISSUE_WRIT); return false; } } //___________________________________________________________ } if (!empty($lastWritObj->writ_id)) { parent::FillObjectByObject($lastWritObj, $this); //--------بررسی مجدد تیک مربوط به سرپرست خانواده ---------------------------- $query = "select family_responsible from HRM_writs\n\t\t\t\t\t\twhere staff_id=:stfid and (history_only != " . HISTORY_ONLY . " OR history_only IS NULL)\n\t\t\t\t\t\t\torder by execute_date DESC,writ_id DESC,writ_ver DESC "; $whereParam = array(":stfid" => $this->staff_id); $resResponsible = parent::runquery($query, $whereParam); $this->family_responsible = $resResponsible[0]['family_responsible']; //-------------------------------------------------------------------------- //اگر حكم قبلي در محاسبه حقوق استفاده شده باشد و يا در وضعيت مياني باشد //اين حكم كه اطلاعات حكم قبلي را كپي مي كند نبايد مقدار وضعيت آن را نيز كپي كند $this->state = 1; if (!$this->corrective_writ_id && !$this->corrective_writ_ver || $this->corrective_writ_id == PDONULL && $this->corrective_writ_ver == PDONULL) { $this->correct_completed = 0; } //___________________________________________________________ //در صورتي که حکم يکي از شرايط زير را داشته باشد مي تواند بدون // رعايت توالي تاريخي صادر شود : // خودکار نباشد - حکم اصلاحي و يا در حال اصلاح باشد - حکم فقط ثبت سابقه باشد if ($this->is_new_writ($this->execute_date, $this->person_type) && !$this->corrective && $this->corrective_writ_id == PDONULL && !$this->history_only) { if ($this->execute_date < $lastWritObj->execute_date && $indiv == NULL) { parent::PushException(EXECUTE_DATE_OF_NORMAL_WRIT_CANT_BEFORE_LAST_ONE_ERR); return false; } } //__________________________________________________________ // محاسبه سنوات خدمت فرد $duty_duration = $this->duty_year_month_day($this->staff_id, "", $this->execute_date); $this->onduty_year = !empty($duty_duration['year']) ? $duty_duration['year'] : 0; $this->onduty_month = !empty($duty_duration['month']) ? $duty_duration['month'] : 0; $this->onduty_day = !empty($duty_duration['day']) ? $duty_duration['day'] : 0; /* if( $this->person_type != HR_CONTRACT ){ $related_duty_duration = $this->related_duty_years($this->staff_id, $this->execute_date, $this->post_id, "INSERT"); $this->related_onduty_year = !empty($related_duty_duration['year']) ? $related_duty_duration['year'] : 0; $this->related_onduty_month = !empty($related_duty_duration['month']) ? $related_duty_duration['month'] : 0; $this->related_onduty_day = !empty($related_duty_duration['day']) ? $related_duty_duration['day'] : 0; } */ if ($this->person_type == HR_EMPLOYEE || $this->person_type == HR_CONTRACT) { /*if($lastWritObj->execute_date > '2014-03-20') $this->base = $lastWritObj->base ; else {*/ $Pqry = " select sex , military_duration_day ,military_duration \n\t\t\t\t\t\t\t\t\tfrom HRM_persons p inner join HRM_staff s on p.personid = s.personid \n\t\t\t\t\t\t\t\t\t\t\twhere s.staff_id=" . $this->staff_id; $Pres = parent::runquery($Pqry); if ($Pres[0]["sex"] == 1 && $this->person_type == 2 && ($Pres[0]["military_duration_day"] > 0 || $Pres[0]["military_duration"] > 0)) { $totalDayWrt = DateModules::ymd_to_days($this->onduty_year, $this->onduty_month, $this->onduty_day); $totalDaySar = DateModules::ymd_to_days(0, $Pres[0]["military_duration"], $Pres[0]["military_duration_day"]); $resDay = $totalDayWrt - $totalDaySar; $Vyear = 0; $Vmonth = $Vday = 0; DateModules::day_to_ymd($resDay, $Vyear, $Vmonth, $Vday); $Vyear = $Vyear; } else { /*$totalDayWrt = DateModules::ymd_to_days($this->onduty_year, $this->onduty_month , $this->onduty_day ) ; $diffYear = DateModules::getDateDiff(DateModules::Now(),'2014-03-21'); $remainDay = $totalDayWrt - $diffYear ; DateModules::day_to_ymd($remainDay, $Ryear, $Rmonth, $Rday) ; $Vyear = $Ryear ;*/ $Vyear = $this->onduty_year; } $this->base = $Vyear + 1; /*}*/ } if ($this->person_type == HR_WORKER) { $qry = " select job_id\n\t\t\t\t\tfrom HRM_writs\n\t\t\t\t\twhere execute_date < '" . $this->execute_date . "' and staff_id = " . $this->staff_id . "\n\t\t\t\t\torder by execute_date Desc\n\t\t\t\t\tlimit 1 "; $resJob = PdoDataAccess::runquery($qry); $this->job_id = empty($resJob[0]['job_id']) ? 0 : $resJob[0]['job_id']; } //__________________________________________________________ } else { //___________________________________________________________ $this->onduty_year = 0; $this->onduty_month = 0; $this->onduty_day = 0; /* $this->related_onduty_year = 0; $this->related_onduty_month = 0; $this->related_onduty_day = 0; */ //$this->grade = 1 ; $this->family_responsible = 0; $this->job_id = PDONULL; } //___________________________________________________________ // محاسبه اطلاعات مربوط به آخرين مدرک تحصيلي فرد $education_level_rec = manage_person_education::GetEducationLevelByDate($PersonID, $this->execute_date, $is_auto); if ($education_level_rec === false) { //در صورتي که حکم دستي است بدون مدرک مي توان حکم را ثبت نمود if ($is_auto) { return false; } else { // در صورتي که حکم دستي و براي فرد مدرک تحصيلي مشخص نشده ، تحصيلات بيسواد ثبت مي شود $education_level_rec['max_education_level'] = '101'; } } $this->education_level = $education_level_rec != 101 ? $education_level_rec['max_education_level'] : '101'; $this->sfid = isset($education_level_rec['sfid']) ? $education_level_rec['sfid'] : ""; $this->sbid = isset($education_level_rec['sbid']) ? $education_level_rec['sbid'] : ""; if ($this->person_type == HR_CONTRACT) { //$this->job_id = 1111; } //__________________________________________________________ // محاسبه تعداد فرزندان $where = "PersonID=" . $PersonID . "\n\t\t\t\t AND (dependency = 5 or dependency = 6)\n\t\t\t\t AND birth_date <='" . $this->execute_date . "'"; $no = manage_person_dependency::CountDependency($where); $this->children_count = $no; //__________________________________________________________ // محاسبه افراد تحت تکفل فرد $this->included_children_count = manage_person_dependency::bail_count($PersonID, $this->person_type, $this->execute_date, $this->execute_date); //__________________________________________________________ // تعيين وضعيت تاهل و ايثارگري $person_obj = new manage_person($PersonID); $this->marital_status = $person_obj->marital_status; $this->military_status = $person_obj->military_status; $this->military_type = $person_obj->military_type; //__________________________________________________________ $this->writ_ver = 1; if ($this->corrective == true) { $this->corrective = 1; $this->description = ""; } else { if ($this->corrective_writ_id == PDONULL && $this->corrective_writ_ver == PDONULL) { $this->corrective = 0; $this->corrective_writ_id = PDONULL; $this->corrective_writ_ver = PDONULL; $this->corrective_date = '0000-00-00'; //PDONULL; } } $this->send_letter_date = $this->issue_date; $this->pay_date = $this->execute_date > $this->issue_date ? $this->execute_date : $this->issue_date; $this->ref_letter_no = !empty($lastWritObj->ref_letter_no) ? $lastWritObj->ref_letter_no : PDONULL; //$this->ref_letter_date = (!empty($lastWritObj->ref_letter_date) ) ? $lastWritObj->ref_letter_date : PDONULL ; //__________________________________________________________ //جايگزيني مقادير مربوط به نوع اصلي و فرعي حکم if ($writ_subtype_obj->time_limited != 1) { $this->contract_start_date = '0000-00-00'; PDONULL; $this->contract_end_date = '0000-00-00'; //PDONULL; } if ($writ_subtype_obj->salary_pay_proc > 0) { $this->salary_pay_proc = $writ_subtype_obj->salary_pay_proc; } if ($writ_subtype_obj->annual_effect > 0) { $this->annual_effect = $writ_subtype_obj->annual_effect; } if ($writ_subtype_obj->emp_state > 0) { $this->emp_state = $writ_subtype_obj->emp_state; } if ($writ_subtype_obj->emp_mode > 0) { $this->emp_mode = $writ_subtype_obj->emp_mode; } if ($writ_subtype_obj->worktime_type > 0) { $this->worktime_type = $writ_subtype_obj->worktime_type; } if ($writ_subtype_obj->post_effect == FREE_POST_EFFECT) { $this->post_id = PDONULL; } if (!$writ_subtype_obj->remember_distance) { $writ_subtype_obj->remember_distance = 0; } if ($writ_subtype_obj->remember_distance > 0) { $this->warning_date = DateModules::AddToGDate($this->execute_date, 0, $writ_subtype_obj->remember_distance); } else { $this->warning_date = '0000-00-00'; } //PDONULL; $this->warning_message = $writ_subtype_obj->remember_message; $this->description = $writ_subtype_obj->comments; if ($this->corrective == true || $this->corrective == 1) { $this->description = PDONULL; } $this->writ_signature_post_owner = $this->issue_date > '2014-02-01' ? ' مهدی پور' : WRIT_SIGNATURE_POST_OWNER; $this->writ_signature_post_title = WRIT_SIGNATURE_POST_TITLE; // براي افراد پيماني هر حکم جديد قرارداد جديد مي باشد . // بنابراين تاريخ شروع قرارداد تاريخ اجراي حکم خواهد بود . // تاريخ خاتمه قرارداد پرسنل قراردادي پايان سال خواهد بود . if ($writ_subtype_obj->time_limited == 1 && ($this->emp_state == EMP_STATE_CONTRACTUAL || $this->emp_state == EMP_STATE_SOLDIER_CONTRACTUAL || $this->emp_state == EMP_STATE_ONUS_SOLDIER_CONTRACTUAL)) { $this->contract_start_date = $this->execute_date; $arr = preg_split('/\\//', DateModules::Miladi_to_Shamsi($this->execute_date)); $Jdate = $arr[0] . "/12/29"; $this->contract_end_date = DateModules::Shamsi_to_Miladi($Jdate); } //__________________________________________________________ $this->remembered = PDONULL; $this->dont_transfer = PDONULL; if ($this->history_only && ($this->state == WRIT_PERSONAL || $this->state == PDONULL)) { $this->history_only = 1; } else { $this->history_only = 0; } //__________________________________________________________ $this->job_id = empty($this->job_id) ? PDONULL : $this->job_id; //--------------------- $pObj = new manage_person("", $this->staff_id); if ($pObj->sex == 2 && $pObj->marital_status == 1) { $this->family_responsible = 0; } if ($pObj->sex == 1 && ($this->person_type == 3 || $this->person_type == 5) && $this->marital_status == 2) { $this->family_responsible = 1; } if ($pObj->sex == 2 && $this->person_type == 5 && $this->execute_date > '2014-03-20') { $this->family_responsible = 0; } //............................................. $pdo = parent::getPdoObject(); /*@var $pdo PDO*/ $pdo->beginTransaction(); $this->writ_id = manage_writ::LastID() + 1; if (empty($this->writ_id)) { parent::PushException("خطاي کد آخرين رکورد"); $pdo->rollBack(); return false; } if (!$this->onBeforeInsert()) { $pdo->rollBack(); return false; } $return = parent::insert("HRM_writs", $this); if (!$return) { parent::PushException("ايجاد با شکست مواجه شد"); $pdo->rollBack(); return false; } $this->onAfterInsert(); $pdo->commit(); return true; }
function merging($main,$sub){ $dtmain = PdoDataAccess::runquery("select PersonID,concat_ws(' ',fname,lname,CompanyName) fullname from BSC_persons where PersonID=?",array($main)); $dtsub = PdoDataAccess::runquery("select PersonID,concat_ws(' ',fname,lname,CompanyName) fullname from BSC_persons where PersonID=?",array($sub)); if(count($dtmain) == 0 || count($dtsub) == 0) { echo "یکی از کد ها نا معتبر است"; } else { $PersonID1 = $main; $PersonID2 = $sub; echo $dtmain[0]["fullname"] . "<br>" . $dtsub[0]["fullname"] . "<br>"; PdoDataAccess::runquery("update LON_requests set LoanPersonID=? where LoanPersonID=?", array($PersonID1, $PersonID2)); echo "update LON_requests : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update BSC_OrgSigners set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update BSC_OrgSigners : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update BSC_PersonExpertDomain set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update BSC_PersonExpertDomain : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update BSC_licenses set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update BSC_licenses : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update CNT_contracts set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update CNT_contracts : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update DMS_packages set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update DMS_packages : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update PLN_experts set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update PLN_experts : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update PLN_plans set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update PLN_plans : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update DataAudit set PersonID=? where PersonID=?", array($PersonID1, $PersonID2)); echo "update DataAudit : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update DMS_documents set ObjectID=? where ObjectType='person' AND ObjectID=?", array($PersonID1, $PersonID2)); echo "update DMS_documents : " . PdoDataAccess::AffectedRows() . "<br>"; require_once 'framework/person/persons.class.php'; $obj = new BSC_persons($PersonID1); $obj2 = new BSC_persons($PersonID2); PdoDataAccess::FillObjectByObject($obj, $obj2); $obj->PersonID = $PersonID1; $result = $obj->EditPerson(); echo "copy persons properties : " . ($result ? "true" : "false") . "<br>"; PdoDataAccess::runquery("delete from BSC_persons where PersonID=?", array($PersonID2)); echo "delete BSC_persons : " . PdoDataAccess::AffectedRows() . "<br>"; $TafsiliID1 = PdoDataAccess::runquery("select * from ACC_tafsilis where TafsiliType=1 AND ObjectID=?",array($main)); $TafsiliID2 = PdoDataAccess::runquery("select * from ACC_tafsilis where TafsiliType=1 AND ObjectID=?",array($sub)); if(count($TafsiliID1) == 0 || count($TafsiliID2) == 0) { echo "یکی از کد ها فاقد تفصیلی است"; } else { $TafsiliID1 = $TafsiliID1[0]["TafsiliID"]; $TafsiliID2 = $TafsiliID2[0]["TafsiliID"]; PdoDataAccess::runquery("update ACC_DocItems set TafsiliID=? where TafsiliID=?", array($TafsiliID1, $TafsiliID2)); echo "update ACC_DocItems : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("update ACC_DocItems set TafsiliID2=? where TafsiliID2=?", array($TafsiliID1, $TafsiliID2)); echo "update ACC_DocItems : " . PdoDataAccess::AffectedRows() . "<br>"; PdoDataAccess::runquery("delete from ACC_tafsilis where TafsiliID=?", array($TafsiliID2)); echo "delete ACC_tafsilis : " . PdoDataAccess::AffectedRows() . "<br>"; } print_r(ExceptionHandler::PopAllExceptions()); } }
function SaveLoanRequest() { $obj = new LON_requests(); PdoDataAccess::FillObjectByArray($obj, $_POST); $obj->AgentGuarantee = isset($_POST["AgentGuarantee"]) ? "YES" : "NO"; $obj->guarantees = array(); $arr = array_keys($_POST); foreach ($arr as $index) { if (strpos($index, "guarantee") !== false) { $obj->guarantees[] = str_replace("guarantee_", "", $index); } } $obj->guarantees = implode(",", $obj->guarantees); $obj->IsFree = isset($_POST["IsFree"]) ? "YES" : "NO"; //------------------------------------------------------ if (isset($_SESSION["USER"]["portal"])) { if ($_SESSION["USER"]["IsAgent"] == "YES" || $_SESSION["USER"]["IsSupporter"] == "YES") { $obj->ReqPersonID = $_SESSION["USER"]["PersonID"]; if (isset($_POST["sending"]) && $_POST["sending"] == "true") { $obj->StatusID = 10; } else { $obj->StatusID = 1; } $obj->LoanID = Default_Agent_Loan; } if ($_SESSION["USER"]["IsCustomer"] == "YES") { if (!isset($obj->LoanPersonID)) { $obj->LoanPersonID = $_SESSION["USER"]["PersonID"]; } $obj->StatusID = 10; } } else { if (empty($obj->RequestID)) { $obj->LoanID = Default_Agent_Loan; $obj->StatusID = 1; } } if (empty($obj->RequestID)) { $obj->AgentGuarantee = isset($_POST["AgentGuarantee"]) ? "YES" : "NO"; $result = $obj->AddRequest(); if ($result) { ChangeStatus($obj->RequestID, $obj->StatusID, "", true); } else { echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString()); die; } $loanObj = new LON_loans($obj->LoanID); $PartObj = new LON_ReqParts(); PdoDataAccess::FillObjectByObject($loanObj, $PartObj); $PartObj->RequestID = $obj->RequestID; $PartObj->PartDesc = "شرایط اولیه"; $PartObj->FundWage = $loanObj->CustomerWage; $PartObj->PartAmount = $obj->ReqAmount; $PartObj->PartDate = PDONOW; $PartObj->AddPart(); } else { $result = $obj->EditRequest(); if ($result) { ChangeStatus($obj->RequestID, $obj->StatusID, "", true); } else { echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString()); die; } } //print_r(ExceptionHandler::PopAllExceptions()); echo Response::createObjectiveResponse($result, $obj->RequestID); die; }