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