function CreateNewStaff()
{
    $PID = $_POST['personid'];
    $PT = $_POST['person_type'];
    $STID = $_POST['staff_id'];
    $res = manage_staff::Create_New_Staff($PID, $PT);
    if (!empty($res)) {
        Response::createObjectiveResponse(true, "{STID:" . $res . " ,PID:" . $PID . "}");
        die;
    } else {
        Response::createObjectiveResponse(false, ExceptionHandler::ConvertExceptionsToJsObject());
        die;
    }
}
Example #2
0
function IssueCorrectiveWrit()
{
    $start_date = isset($_POST["base_writ_issue"]) ? $_POST["base_execute_date"] : $_POST["corrective_date"];
    $end_date = $_POST["execute_date"];
    if (!isset($_POST["base_writ_issue"])) {
        if (manage_writ::Is_Writ_For_Correct($_POST["staff_id"], $_POST['corrective_date']) == null) {
            ExceptionHandler::PushException("در تاريخ شروع اصلاح حکم وجود ندارد .");
            //	header("location: ../ui/CorrectiveIssueWrit.php");
            Response::createObjectiveResponse(false, ExceptionHandler::ConvertExceptionsToJsObject());
            die;
        }
    }
    if (manage_staff::check_exist_staff_id($_POST["staff_id"]) == true) {
        /*if(isset($_POST["issue_date"]))
        			 $issueDate = $_POST["issue_date"] ; 
        		else*/
        $issueDate = DateModules::shNow();
        $writ_rec = manage_writ::IssueWrit($_POST["staff_id"], $_POST["writ_type_id"], $_POST["writ_subtype_id"], $_POST["execute_date"], $_POST["person_type"], $issueDate, true, true, $_POST["send_letter_no"], NULL, NULL, $_POST["base"]);
    }
    if ($writ_rec === false) {
        //header("location: ../ui/CorrectiveIssueWrit.php");
        Response::createObjectiveResponse(false, ExceptionHandler::ConvertExceptionsToJsObject());
        die;
    } else {
        if (isset($_POST["base_writ_issue"])) {
            $writ_type_id = $_POST["base_writ_type_id"];
            $writ_subtype_id = $_POST["base_writ_subtype_id"];
            $execute_date = $_POST["base_execute_date"];
            $base = $_POST["base_base"];
            $send_letter_no = $_POST["base_send_letter_no"];
            $issue_date = DateModules::shNow();
        } else {
            $execute_date = $_POST["corrective_date"];
            $writ_type_id = NULL;
            $writ_subtype_id = NULL;
            $base = NULL;
            $send_letter_no = NULL;
            $issue_date = NULL;
            $_POST["base_writ_issue"] = NULL;
        }
        //شروع اصلاح
        $ret = manage_writ::start_corrective_writ_issue($_POST["staff_id"], $execute_date, $writ_rec, $writ_type_id, $writ_subtype_id, $base, $send_letter_no, $issue_date, $_POST["base_writ_issue"]);
        if ($ret === false) {
            Response::createObjectiveResponse(false, ExceptionHandler::ConvertExceptionsToJsObject());
            die;
        }
        Response::createObjectiveResponse(true, "{WID:" . $ret->writ_id . ",WVER:" . $ret->writ_ver . ",STID:" . $ret->staff_id . "}");
        die;
    }
}
Example #3
0
	/** افزايش سنواتي */
	private function compute_salary_item2_02($writ_rec) {
		//param1 : افزايش سنوات سال قبل
		//param2 : ضريب افزايش سنواتي
		//param3 : درصد بسيج
		//param4 : مبلغ افزايش سنواتي بدون در نظر گرفتن گروه تشويقي و درصد بسيج
		//_____________________________________
		// چک کن که حکم قبلي وجود دارد يا خير

		$this_writ_year = substr(DateModules::Miladi_to_Shamsi($writ_rec['execute_date']), 0, 4);
		$one_year_ago = $this_writ_year - 1;
		$one_year_ago_first_day = $one_year_ago . "/01/01";
		$one_year_ago_last_day = $one_year_ago . "/12/30";
		$one_year_ago_last_day_writ = $one_year_ago . "/12/29";
		$Gone_year_ago_first_day = DateModules::Shamsi_to_Miladi($one_year_ago_first_day);
		$Gone_year_ago_last_day = DateModules::Shamsi_to_Miladi($one_year_ago_last_day_writ);
		$prior_writ = manage_writ::get_last_writ_by_date($writ_rec['staff_id'], DateModules::AddToGDate($writ_rec['execute_date'], -1, 0, 0));

		// در صورتی که حکم قبلی وجود داشته باشد که در همان سال باشد افزایش سنواتی آن تغییر نمی کند .
		if (!empty($prior_writ->writ_id)) {
			if (!DateModules::similar_year($writ_rec['execute_date'], $prior_writ->execute_date)) {
				$obj = new manage_writ_item($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id,
								($prior_writ->person_type == 5 ) ? SIT5_STAFF_ANNUAL_INC : SIT_STAFF_ANNUAL_INC);
				if (!empty($obj->writ_id)) {
					$this->param1 = $obj->param1;
					$this->param2 = $obj->param2;
					$this->param3 = $obj->param3;

					if (!$obj->param4)
						$this->param4 = $obj->value;

					return $obj->value;
				}
			}
		}

		//آخرين حکم قبل از سال شخص را استخراج مي کند.
		$prior_writ = manage_writ::get_last_writ_by_date($writ_rec['staff_id'], $Gone_year_ago_last_day);

		$prior_writ_year = substr(DateModules::Miladi_to_Shamsi($prior_writ->execute_date), 0, 4);

		//____________________________________________________
		//اولين حكم- محاسبه افزايش سنواتي در بدو استخدام
		if (empty($prior_writ->writ_id)) {
			//در بدو استخدام: جانبازي + آزادگي + سربازي + جبهه
			$this->param1 = 0;
			$this->param2 = 0;
			$this->param3 = 0;
			$this->value = 0;

			if ($writ_rec['military_duration'] > 30)
				$writ_rec['military_duration'] = 30;

			//سربازي : هر ماه 0/25% سالي 3% ، حداكثر 2/5 سال
			$this->param2 += $writ_rec['military_duration'] * 0.0025;

			if ($writ_rec['execute_date'] < DateModules::Shamsi_to_Miladi('1384-11-12')) {
				$temp = manage_person_devotion::GetAllDevotions("d.PersonID=" . $writ_rec["personID"]);

				for ($i = 0; $i < count($temp); $i++) {
					switch ($temp[$i]['devotion_type']) {
						case DEVOTION_TYPE_FIGHTER://رزمندگي
							//جبهه : ماهي 5/0% سالي 6% (سوابق تا قبل از 29/5/69
							$this->param2 += ($temp[$i]['amount'] / 30) * 0.005;
							break;
						case DEVOTION_TYPE_PRISONER://آزادگي
							//- آزادگي : ماهي 0.5% سالي 6%
							$this->param2 += ($temp[$i]['amount'] / 30) * 0.005;
							break;
						case DEVOTION_TYPE_WOUNDED://جانبازي
							//- جانبازي : هر 1% جانبازي 6/0%
							$this->param2 += $temp[$i]['amount'] * 0.006;
							break;
					}
				}
			}
			//____________________________________________
			// حقوق مبنا
			$base_salary = manage_writ::get_base_salary($writ_rec["writ_id"], $writ_rec["writ_ver"], $writ_rec["staff_id"], $writ_rec["person_type"]);

			if (in_array($writ_rec['person_type'], array(1, 2, 3))) {
				// حقوق مبنا بدون گروه تشویقی
				$nh_base_salary = manage_writ::get_base_salary($writ_rec["writ_id"], $writ_rec["writ_ver"], $writ_rec["staff_id"], $writ_rec["person_type"], false);
			}
			$value = $base_salary * $this->param2;
			if (in_array($writ_rec['person_type'], array(1, 2, 3))) {
				$this->param4 = $nh_base_salary * $this->param2;
			}

			return $value;
		}
		//احكام طول دوره خدمت
		else {
			//افزايش سنواتي سال قبل
			$obj = new manage_writ_item($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id,
							($prior_writ->person_type == 5 ) ? SIT5_STAFF_ANNUAL_INC : SIT_STAFF_ANNUAL_INC);
			$this->param1 = $obj->value;
			$this->param2 = $obj->param2;
			$this->param3 = $obj->param3;
			$this->param4 = $obj->param4;
			$this->param5 = $obj->param5;
			$this->param6 = $obj->param6;
			$this->param7 = $obj->param7;

			if ($writ_rec['emp_mode'] != EMP_MODE_ENGAGEMENT && in_array($writ_rec['person_type'], array(1, 2, 3))) {
				//ضريب افزايش سنواتي سال قبل
				$this->param2 = manage_writ_item::get_annual_coef($prior_writ_year, $writ_rec['staff_id']);
			} else {
				$this->param2 = 0.05;
			}

			if ($writ_rec['execute_date'] < DateModules::Shamsi_to_Miladi('1384/11/12')) {
				//درصد بسيج سال قبل
				$this->param3 = manage_writ_item::get_mobilization_coef($prior_writ_year, $writ_rec['staff_id']);
			} else if (manage_writ_item::get_writSalaryItem_value($writ_rec["writ_id"], $writ_rec["writ_ver"], $writ_rec["staff_id"], 287) > 0)
				$this->param3 = 0;
			else
				$this->param3 = manage_writ_item::get_mobilization_coef($prior_writ_year, $writ_rec['staff_id']);

			$base_salary = manage_writ::get_base_salary($prior_writ->writ_id, $prior_writ->writ_ver, $prior_writ->staff_id, $prior_writ->person_type);

			if (in_array($writ_rec['person_type'], array(1, 2, 3))) {
				$nh_base_salary = manage_writ::get_base_salary($writ_rec["writ_id"], $writ_rec["writ_ver"], $writ_rec["staff_id"], $writ_rec["person_type"], false);
			}

			if (!($base_salary > 0))
				return false;


			$duplicate_duration = 0;
			if (!empty($writ_rec['last_retired_pay'])) {
				if ($writ_rec['last_retired_pay'] >= $Gone_year_ago_first_day &&
						$writ_rec['last_retired_pay'] < $Gone_year_ago_last_day) {
					$jlast_retired_pay = DateModules::Miladi_to_Shamsi($writ_rec['last_retired_pay']);
					$duplicate_duration = ceil(DateModules::getDateDiff($one_year_ago_last_day, $jlast_retired_pay));
				} else if ($writ_rec['last_retired_pay'] <= $Gone_year_ago_first_day) {
					$duplicate_duration = 360;
				}
			}

			$year_work_days = manage_staff::compute_year_work_days($writ_rec['staff_id'], $Gone_year_ago_first_day, $Gone_year_ago_last_day);
			if ($year_work_days > 360) {
				$year_work_days = 360;
			}
			//نسبت کارکرد در سال قبل.
			$annual_inc_duration = ($year_work_days + $duplicate_duration) / 360;

			//فرمول محاسبه براي سال دوم به بعد.
			$value = (($base_salary + $this->param1) * $this->param2 * $annual_inc_duration) +
					($this->param3 * $base_salary ) + $this->param1;

			if (in_array($writ_rec['person_type'], array(1, 2, 3))) {
				$this->param4 = (($nh_base_salary + $this->param1) * $this->param2 * $annual_inc_duration) +
						$this->param1;
			}
		}

		return $value;
	}
Example #4
0
function saveTax()
{
    $return = manage_staff::SaveStaffTax($_POST['PersonID'], $_POST['staff_id'], $_POST['sum_paied_pension']);
    echo $return ? Response::createObjectiveResponse(true, $_POST['PersonID']) : Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString("\n"));
    die;
}
Example #5
0
function changePT()
{
    $PersonID = $_POST["PersonID"];
    $new_person_type = $_POST["new_person_type"];
    $NID = $_POST["NationalCode"];
    $obj = new manage_person();
    $obj->PersonID = $PersonID;
    $obj->person_type = $new_person_type;
    $obj->national_code = $NID;
    $staffObject = new manage_staff($PersonID, $_POST["old_person_type"]);
    unset($staffObject->staff_id);
    $staffObject->person_type = $new_person_type;
    $staffObject->AddStaff();
    $return = $obj->EditPerson(null, null);
    echo $return ? Response::createObjectiveResponse(true, $PersonID) : Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString("\n"));
    die;
}
Example #6
0
function ChangeSandoogh()
{
    $temp = manage_staff::change_Retired_Pay();
    $no = count($temp);
    echo dataReader::getJsonData($temp, $no, $_GET["callback"]);
    die;
}
Example #7
0
 public static function RemoveWrit($writ_id, $writ_ver, $staff_id)
 {
     $obj = new manage_writ($writ_id, $writ_ver, $staff_id);
     if (!$obj->onBeforeDelete()) {
         return false;
     }
     $DB = PdoDataAccess::getPdoObject();
     /*@var $DB PDO*/
     $DB->beginTransaction();
     $return = PdoDataAccess::delete("writ_salary_items", "writ_id=:wid AND writ_ver=:wver AND staff_id=:stid", array(":wid" => $obj->writ_id, ":wver" => $obj->writ_ver, ":stid" => $obj->staff_id));
     if ($return === false) {
         $DB->rollBack();
         return false;
     }
     $return = PdoDataAccess::delete("writs", "writ_id=:wid AND writ_ver=:wver AND staff_id=:stid", array(":wid" => $obj->writ_id, ":wver" => $obj->writ_ver, ":stid" => $obj->staff_id));
     if ($return === false) {
         $DB->rollBack();
         return false;
     }
     $daObj = new DataAudit();
     $daObj->ActionType = DataAudit::Action_delete;
     $daObj->MainObjectID = $obj->staff_id;
     $daObj->TableName = "writs";
     $daObj->execute();
     $last_writ_obj = manage_staff::GetLastWrit($obj->staff_id);
     if ($last_writ_obj) {
         //__________________________________________________
         // دادن پست حكم قبلي به فرد در صورت خالي بودن اين پست
         if ($obj->is_last($obj->staff_id, $obj->execute_date) && $last_writ_obj->post_id != $obj->post_id) {
             if (!manage_posts::change_user_post($obj->staff_id, $obj->post_id, $last_writ_obj->post_id, $obj->execute_date)) {
                 $DB->rollBack();
                 return false;
             }
         }
     }
     if ($obj->history_only != HISTORY_ONLY) {
         if (!manage_writ::change_writ_state(WRIT_PERSONAL, WRIT_PERSONAL, $obj->writ_id, $obj->writ_ver, $obj->staff_id, $obj->execute_date, $DB)) {
             $DB->rollBack();
             return false;
         }
     }
     //__________________________________________________
     //در صورت حذف يک حکم نسخه قبلي آن را در صورتي که به حقوق منتقل نشده است فعال مي کند
     if (!manage_staff::SetStaffLastWrit($obj->staff_id)) {
         $DB->rollBack();
         return false;
     }
     $DB->commit();
     return true;
 }
Example #8
0
 static function RemovePerson($PersonID)
 {
     $pdo = PdoDataAccess::getPdoObject();
     if ($pdo->beginTransaction()) {
         $whereParam = array(":PID" => $PersonID);
         require_once 'dependent.class.php';
         if (count(manage_person_dependency::GetAllDependency("PersonID=:PID", $whereParam)) != 0) {
             return "فرد مورد نظر دارای وابستگی می باشد و قابل حذف نیست";
         }
         $return = manage_staff::remove($PersonID, "", $pdo);
         if (!$return) {
             $pdo->rollBack();
             return false;
         }
         $return = PdoDataAccess::delete("HRM_persons", "PersonID=:PID", $whereParam, $pdo);
         if (!$return) {
             $pdo->rollBack();
             return false;
         }
         $pdo->commit();
         $daObj = new DataAudit();
         $daObj->ActionType = DataAudit::Action_delete;
         $daObj->MainObjectID = $PersonID;
         $daObj->TableName = "persons";
         $daObj->execute();
         return true;
     } else {
         return false;
     }
     return true;
 }
Example #9
0
 static function Create_New_Staff($personid, $persontype)
 {
     $obj = new manage_staff($personid, $persontype);
     if ($persontype == 3 || $persontype == 5) {
         $obj->person_type = 2;
     } else {
         if ($persontype == 2) {
             $obj->person_type = 1;
         }
     }
     $old_staff_id = $obj->staff_id;
     $ret = $obj->AddStaff();
     if ($ret == true) {
         //--------------------------------------------------
         $qry = " select * from staff_tax_history where staff_id=" . $old_staff_id . " AND payed_tax_value IS NOT NULL ";
         $tmp = PdoDataAccess::runquery($qry);
         if (count($tmp) > 0) {
             $Newobj = new manage_staff_tax($old_staff_id);
             parent::FillObjectByArray($Newobj, $tmp[0]);
             $Newobj->staff_id = $obj->staff_id;
             $Newobj->tax_history_id = parent::GetLastID('staff_tax_history', 'tax_history_id') + 1;
             if (PdoDataAccess::insert("staff_tax_history", $Newobj) === false) {
                 return false;
             }
         }
         //................. آزاد کردن پست سازمانی شماره شناسایی قبلی ...................
         $qry = " update position set staff_id= null where staff_id = " . $old_staff_id;
         PdoDataAccess::runquery($qry);
         //..................................................
         $query = " update persons set person_type = " . $obj->person_type . " where  personid =" . $obj->PersonID;
         PdoDataAccess::runquery($query);
         if (ExceptionHandler::GetExceptionCount() == 0) {
             return $obj->staff_id;
         }
     }
     return false;
 }