function GroupCancelWrit() { ini_set('max_execution_time', 1000); //300 seconds = 5 minutes ini_set("memory_limit", '500M'); $where = "s.person_type=" . $_POST["person_type"]; $whereParams = array(); //------------------------ Make Where Clause ---------------------- if (!empty($_REQUEST["ouid"])) { $where .= " AND ( o.ouid = :ouid OR o.parent_path LIKE '%,:ouid,%' OR o.parent_path LIKE '%:ouid,%' OR o.parent_path LIKE '%,:ouid%' ) "; $whereParams[":ouid"] = $_REQUEST["ouid"]; } if (!empty($_POST["from_PersonID"])) { $where .= " AND p.PersonID >= :f_personid"; $whereParams[":f_personid"] = $_POST["from_PersonID"]; } if (!empty($_POST["to_PersonID"])) { $where .= " AND p.PersonID <= :t_personid"; $whereParams[":t_personid"] = $_POST["to_PersonID"]; } if (!empty($_POST["from_issue_date"])) { $where .= " AND issue_date <= :f_issue_date"; $whereParams[":f_issue_date"] = $_POST["from_issue_date"]; } if (!empty($_POST["to_issue_date"])) { $where .= " AND issue_date >= :t_issue_date"; $whereParams[":t_issue_date"] = $_POST["to_issue_date"]; } if (!empty($_POST["execute_date"])) { $execute_date = DateModules::Shamsi_to_Miladi($_POST["execute_date"]); $where .= " AND execute_date = :exe_date"; $whereParams[":exe_date"] = $execute_date; } if (!empty($_POST["writ_type_id"])) { $where .= " AND w.writ_type_id = :writ_type_id"; $whereParams[":writ_type_id"] = $_POST["writ_type_id"]; } if (!empty($_POST["writ_subtype_id"])) { $where .= " AND w.writ_subtype_id = :writ_subtype_id"; $whereParams[":writ_subtype_id"] = $_POST["writ_subtype_id"]; } //----------------------------------------------------------------- /*$where .= " AND bf.MasterID in (1,2) AND if( tbl1.personid is not null , bf.MasterID in (1) , ( bf.MasterID in (1,2) and tbl1.personid is null ) )" ; */ $query = "SELECT s.staff_id,\n\t\t \t w.writ_id,\n\t\t w.writ_ver,\n\t\t w.writ_type_id,\n\t\t w.writ_subtype_id,\n\t\t w.issue_date,\n\t\t w.execute_date,\n\t\t p.pfname,\n\t\t\t p.plname\n\t\t\t \n\t\n\t\t FROM writs w\n\t\t \tJOIN org_new_units o ON(w.ouid=o.ouid)\n\t\t\t\tJOIN staff s ON (s.staff_id=w.staff_id)\n\t\t\t\t\n JOIN persons p ON(s.PersonID = p.PersonID and s.person_type=p.person_type)\t\t\t\t\n \n\t\t WHERE " . $where; /*inner join Basic_Info bf on(bf.TypeID=6 AND bf.InfoID=w.education_level) left join (select personid from bases where BaseType in(4) AND BaseStatus = 'NORMAL') tbl1 on tbl1.personid = s.personid*/ $staff_dt = PdoDataAccess::runquery($query, $whereParams); //echo PdoDataAccess::GetLatestQueryString() ; die() ; if (count($staff_dt) == 0) { echo "موارد انتخابی شما هیچ حکمی را برای ابطال شامل نمی شود."; die; } $log_obj = new manage_writ_group_cancel_log(); $success_count = 0; $unsuccess_count = 0; for ($index = 0; $index < count($staff_dt); $index++) { /*if(manage_writ::IsUsed($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"])) { ExceptionHandler::PushException("از حکم در جای دیگری استفاده شده است."); $log_obj->make_unsuccess_rows($staff_dt[$index], ExceptionHandler::GetExceptionsToString("<br>")); $unsuccess_count++; }*/ if (manage_writ::get_writ_state($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"]) != WRIT_PERSONAL) { ExceptionHandler::PushException("این حکم منتقل شده است."); $log_obj->make_unsuccess_rows($staff_dt[$index]); $unsuccess_count++; } else { if (!manage_writ::RemoveWrit($staff_dt[$index]["writ_id"], $staff_dt[$index]["writ_ver"], $staff_dt[$index]["staff_id"])) { $log_obj->make_unsuccess_rows($staff_dt[$index]); $unsuccess_count++; } else { $log_obj->make_success_row($staff_dt[$index]); $success_count++; } } /*if($index == 0) { $log_obj->finalize(); echo $log_obj->make_result(); die(); }*/ } $log_obj->finalize(); echo $log_obj->make_result(); die; }
$objPerson = new manage_person("", $staff_id); } else { $objPerson = new manage_person($_REQUEST["PID"]); } $fullInfo = manage_person::GetAllPersons("p.PersonID=:pid", array(":pid" => $objPerson->PersonID)); //............................................ if (isset($_REQUEST["ExeDate"])) { $exedate = $_REQUEST["ExeDate"]; } else { $exedate = $FullWrt[0]['execute_date']; } //............................................ $state = $FullWrt[0]["state"]; //............................................ $readOnly = false; $state = manage_writ::get_writ_state($_REQUEST["WID"], $writver, $_REQUEST["STID"]); $pay_calc = manage_writ::check_for_use_in_pay_calc($_REQUEST["WID"], $writver, $_REQUEST["STID"]); if ($pay_calc == null) { if ($state == WRIT_PERSONAL && ($objWrt->check_corrective_state() == 'NOT_CORRECTING' || $objWrt->writ_has_new_version())) { ExceptionHandler::PushException('اين حکم در صدور حکم اصلاحي استفاده شده است و امکان تغيير آن وجود ندارد', ExceptionHandler::ExceptionType_warning); $readOnly = true; } else { if ($state != WRIT_PERSONAL) { ExceptionHandler::PushException("این حکم منتقل شده است و امکان ویرایش آن وجود ندارد", ExceptionHandler::ExceptionType_warning); $readOnly = true; } } } else { if ($pay_calc != null && $state != WRIT_PERSONAL) { ExceptionHandler::PushException(" این حکم در محاسبه حقوق" . " " . $pay_calc . " " . "استفاده شده است و امکان ویرایش آن وجود ندارد.", ExceptionHandler::ExceptionType_warning); $readOnly = true;