private function onBeforeInsert() { /*if($this->check_send_letter_no() === false ) return false ; */ $query = "\n\t\t\tselect w.writ_id, w.writ_ver , w.emp_mode , w.execute_date\n\t\t\tfrom HRM_writs w\n\t\t\t\tinner join HRM_staff s on(w.writ_id=s.last_writ_id and w.writ_ver=s.last_writ_ver AND s.staff_id=w.staff_id)\n where s.staff_id=" . $this->staff_id; $temp = parent::runquery($query); if (count($temp) != 0) { if ($temp[0]['emp_mode'] == EMP_MODE_RUSTICATION) { parent::PushException(NOT_ALLOW_ERR_RUSTICATION && $this->execute_date > $temp[0]['execute_date']); return false; } if ($temp[0]['emp_mode'] == EMP_MODE_RE_BUY && $this->execute_date > $temp[0]['execute_date']) { parent::PushException(NOT_ALLOW_ERR_RE_BUY); return false; } } if (empty($this->emp_mode) || $this->emp_mode == 0) { $this->emp_mode = 1; } if ($this->writ_id == '') { $this->writ_id = parent::GetLastID('writs', 'writ_id'); } if (empty($this->issue_date)) { $this->issue_date = $this->execute_date; } if (empty($this->pay_date)) { $this->pay_date = $this->execute_date; } if (empty($this->onduty_year)) { $this->onduty_year = 0; } if (empty($this->onduty_month)) { $this->onduty_month = 0; } if (empty($this->onduty_day)) { $this->onduty_day = 0; } //----------------- new ------------ if ($this->pay_date < $this->issue_date) { parent::PushException(WRIT_PAY_DATE_MUST_BE_GREATHER_OR_EQUAL_ISSUE_DATE); return false; } //------------------------ if ($this->person_type == HR_PROFESSOR || $this->person_type == HR_EMPLOYEE) { if ($this->post_id > 0) { $lastWritObj = self::GetLastWrit($this->staff_id); if ($lastWritObj->writ_id == "" || $lastWritObj->execute_date <= $this->execute_date) { if (!manage_posts::is_valid($this->post_id, $this->execute_date, $this->staff_id)) { return false; } } } } // احکام ديگري که در اين روز صادر شده غيرفعال مي کند if ($this->history_only != 1) { if ($this->writ_enter_state(WRIT_PERSONAL, $this->staff_id, $this->execute_date, $this->writ_id, $this->writ_ver) === false) { return false; } } return true; }