Exemplo n.º 1
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;
    }
}
Exemplo n.º 2
0
 /**
  * از تاريخ شروع اصلاح ، صدور حکم اصلاحي را شروع مي کند.
  *
  * @param unknown_type $staff_id
  * @param unknown_type $corrective_date
  * @param unknown_type $writ_rec
  * @param unknown_type $writ_type_id
  * @param unknown_type $writ_subtype_id
  * @param unknown_type $base
  * @param unknown_type $send_letter_no
  * @param unknown_type $issue_date
  * @param unknown_type $base_writ_issue
  * @return unknown
  */
 public function CorrectiveIssueAction($base_writ_issue)
 {
     $stobj = new manage_staff("", "", $this->staff_id);
     if ($stobj->staff_id == null || $stobj->staff_id == "") {
         parent::PushException(ERROR_STAFF_ID_NOT_FOUND);
         return false;
     }
     $staff_rec = $stobj;
     $PersonID = $staff_rec->PersonID;
     $this->person_type = $staff_rec->person_type;
     //ابتدا چک مي شود که در تاريخ شروع اصلاح حکمي وجود دارد يا خير ؟
     $exist_writ_rec = manage_writ::Is_Writ_For_Correct($this->staff_id, $this->corrective_date);
     // چنانچه حکمي نباشد و صدور حکم پايه نيز تيک نخورده باشد خطا مي دهد.
     if ($exist_writ_rec == NULL && !$base_writ_issue) {
         parent::PushException("در تاريخ شروع اصلاح حکم وجود ندارد .");
         return false;
     } else {
         if ($base_writ_issue) {
             $exist_writ_rec = manage_writ::IssueWrit($this->staff_id, $this->writ_type_id, $this->writ_subtype_id, $this->corrective_date, $this->person_type, $this->issue_date, false, false, $this->send_letter_no, $this->writ_id, $this->writ_ver, $this->base);
             if ($exist_writ_rec != false) {
                 manage_writ_item::compute_writ_items($exist_writ_rec->writ_id, $exist_writ_rec->writ_ver, $exist_writ_rec->staff_id);
                 return $exist_writ_rec;
                 /*header("location: ../ui/view_writ.php?WID=" . $exist_writ_rec->writ_id .
                 			"&WVER=" . $exist_writ_rec->writ_ver . "&STID=" . $exist_writ_rec->staff_id);
                 		die();*/
             }
             return $exist_writ_rec;
         } elseif ($exist_writ_rec != NULL) {
             //در اين قسمت حکمي را که روي ان ورژن مي خورد فقط ثبت سابقه مي کند.
             $exist_writ_rec->history_only = "1";
             PdoDataAccess::update("writs", $exist_writ_rec, "writ_id=:wid AND writ_ver=:wver AND staff_id=:stid\n\t\t\t\tAND  state=" . WRIT_PERSONAL, array(":wid" => $exist_writ_rec->writ_id, ":wver" => $exist_writ_rec->writ_ver, ":stid" => $exist_writ_rec->staff_id));
             //$exist_writ_rec->send_letter_no = null ;
             $exist_writ_rec->history_only = 0;
             //وضعيت حكم به نسخه جديد حكم منتقل نمي شود
             $exist_writ_rec->state = null;
             $exist_writ_rec->correct_completed = null;
             $exist_writ_rec->writ_ver = $exist_writ_rec->writ_ver + 1;
             $exist_writ_rec->corrective_date = DateModules::Shamsi_to_Miladi($this->corrective_date);
             $exist_writ_rec->corrective_writ_id = $this->writ_id;
             $exist_writ_rec->corrective_writ_ver = $this->writ_ver;
             $exist_writ_rec->correct_completed = WRIT_CORRECTING;
             //آخرين مدرک تحصيلي فرد را بر مي دارد.
             $education_level_rec = manage_person_education::GetEducationLevelByDate($PersonID, $exist_writ_rec->execute_date);
             $exist_writ_rec->education_level = $education_level_rec['max_education_level'];
             $exist_writ_rec->sfid = $education_level_rec['sfid'];
             $exist_writ_rec->sbid = $education_level_rec['sbid'];
             //تعداد فرزندان محاسبه مي گردد.
             $where = "PersonID=" . $PersonID . "\n\t\t\t\t\t  AND (dependency = 5 or dependency = 6)\n\t\t\t\t\t  AND birth_date <='" . $exist_writ_rec->execute_date . "'";
             $no = manage_person_dependency::CountDependency($where);
             $exist_writ_rec->children_count = $no;
             //تعداد افراد تحت کفالت
             $exist_writ_rec->included_children_count = manage_person_dependency::bail_count($PersonID, $exist_writ_rec->person_type, $exist_writ_rec->execute_date, $exist_writ_rec->execute_date);
             if ($exist_writ_rec->person_type == HR_EMPLOYEE || $exist_writ_rec->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\tfrom persons p inner join staff s on p.personid = s.personid \n\t\t\t\t\t\t\t\twhere s.staff_id=" . $exist_writ_rec->staff_id;
                 $Pres = parent::runquery($Pqry);
                 if ($Pres[0]["sex"] == 1 && $exist_writ_rec->person_type == 2 && ($Pres[0]["military_duration_day"] > 0 || $Pres[0]["military_duration"] > 0)) {
                     $totalDayWrt = DateModules::ymd_to_days($exist_writ_rec->onduty_year, $exist_writ_rec->onduty_month, $exist_writ_rec->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 = $exist_writ_rec->onduty_year;
                 }
                 $exist_writ_rec->base = $Vyear + 1;
                 /*}*/
             }
             //$this->set_writ_sign_info();
             /* if($exist_writ_rec->person_type == HR_PROFESSOR )
                         {
                             $this->writ_signature_post_owner = 'محمد کافی' ; 
                             $this->writ_signature_post_title = ' رئیس دانشگاه ';
                         }
             			else {
             				$exist_writ_rec->writ_signature_post_owner = ($this->issue_date > '2014-02-01') ? 'ابوالقاسم ساقی' : WRIT_SIGNATURE_POST_OWNER ;
             			}*/
             //..........
             if ($exist_writ_rec->person_type == HR_PROFESSOR && $exist_writ_rec->staff_id != '111551') {
                 $exist_writ_rec->writ_signature_post_owner = 'محمد کافی';
                 $exist_writ_rec->writ_signature_post_title = ' رئیس دانشگاه';
                 //$this->writ_signature_post_title = ' رئیس دانشگاه ';
             } else {
                 if ($exist_writ_rec->person_type == HR_PROFESSOR && $exist_writ_rec->staff_id == '111551') {
                     //$this->writ_signature_post_owner = 'محمدجواد وریدی' ;
                     $exist_writ_rec->writ_signature_post_owner = 'ابوالفضل باباخانی';
                     $exist_writ_rec->writ_signature_post_title = 'معاون اداری ومالی دانشگاه';
                 } else {
                     $exist_writ_rec->writ_signature_post_owner = $exist_writ_rec->issue_date > '2014-02-01' ? 'ابوالقاسم ساقی' : WRIT_SIGNATURE_POST_OWNER;
                 }
             }
             //.............
             $return = parent::insert("writs", $exist_writ_rec);
             if ($return == 0) {
                 parent::PushException("ايجاد با شکست مواجه شد");
                 return false;
             }
             manage_writ_item::compute_writ_items($exist_writ_rec->writ_id, $exist_writ_rec->writ_ver, $exist_writ_rec->staff_id);
             return $exist_writ_rec;
             /*  header("location: ../ui/view_writ.php?WID=" . $exist_writ_rec->writ_id .
             		    	"&WVER=" . $exist_writ_rec->writ_ver . "&STID=" . $exist_writ_rec->staff_id);
             			die();*/
         }
     }
 }