/** * تنها با استفاده از اين تابع مي توان حکم جديد صادر کرد * @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; }
/** * ط§ط·ظ„ط§ط¹ط§طھ ظ…ط±ط¨ظˆط· ط¨ظ‡ ط¢ط®ط±غŒظ† طع©ظ… ظپط±ط¯ ط±ط§ ط¯ط± ط§ط·ظ„ط§ط¹ط§طھ ظپط±ط¯ * (staff ط¬ط¯ظˆظ„) * ظ‚ط±ط§ط± ظ…غŒ ط¯ظ‡ط¯ * * @param string $staff_id * */ public static function SetStaffLastWrit($staff_id) { $lastWritObj = manage_writ::GetLastWrit($staff_id); /*@var $lastWritObj manage_writ*/ $staffObj = new manage_staff(); if (!empty($lastWritObj->writ_id)) { $staffObj->staff_id = $staff_id; $staffObj->last_writ_id = $lastWritObj->writ_id; $staffObj->last_writ_ver = $lastWritObj->writ_ver; $staffObj->post_id = $lastWritObj->post_id; $staffObj->ouid = $lastWritObj->ouid; return $staffObj->EditStaff(); } else { $staffObj->staff_id = $staff_id; $staffObj->last_writ_id = PDONULL; $staffObj->last_writ_ver = PDONULL; $staffObj->post_id = PDONULL; $staffObj->ouid = PDONULL; $lastWritObj->cost_center_id = PDONULL; return $staffObj->EditStaff(); } }