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; }
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; }