通达OA2017版流程中心触发器应用实例

本文介绍了一个基于PHP的公告通知审批流程实现方案,并详细解释了如何根据审批结果发送短信提醒给相关人员的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?php

include_once "inc/td.class.php";
include_once "inc/conn.php";
include_once "inc/utility_all.php";
include_once "inc/utility_org.php";
include_once "inc/flow_engine/engine/TFlowEngine.php";
$arr_para = TFlowEngine::get_para_data($RUN_ID);
$arr_data = TFlowEngine::get_data($RUN_ID);
$notify_id = intval($arr_para["NOTIFY_ID"]);
$notify_leader_app = ($arr_data["notify_group.notify_auditer_app"] == _("同意") ? 1 : ($arr_data["notify_group.notify_leader_app"] == _("不同意") ? 2 : 0));
$notify_leader_reason = $arr_data["notify_group.notify_auditer_reason"];
$cur_date = date("Y-m-d", time());

if ($notify_id) {
	if ($notify_leader_app == 1) {
		$query = "update NOTIFY set PUBLISH='1',AUDITER='" . $_SESSION["LOGIN_USER_ID"] . "',AUDIT_DATE='$cur_date' where NOTIFY_ID='$notify_id'";
		exequery(TD::conn(), $query);
	}
	else if ($notify_leader_app == 2) {
		$query = "update NOTIFY set PUBLISH='3',AUDITER='" . $_SESSION["LOGIN_USER_ID"] . "',AUDIT_DATE='$cur_date',REASON='$notify_leader_reason' where NOTIFY_ID='$notify_id'";
		exequery(TD::conn(), $query);
	}

	$para_array = get_sys_para("SMS_REMIND");
	$para_value = $para_array["SMS_REMIND"];
	$remind_array = explode("|", $para_value);
	$sms_remind = $remind_array[0];
	$sms2_remind = $remind_array[1];
	$sms3_remind = $remind_array[2];

	if (find_id($sms_remind, 1)) {
		include_once "inc/utility_sms1.php";
		$user_id_str = "";
		$query = "select * from notify where NOTIFY_ID='$notify_id'";
		$cursor = exequery(TD::conn(), $query);

		if ($row = mysql_fetch_array($cursor)) {
			$to_id = $row["TO_ID"];
			$from_id = $row["FROM_ID"];
			$subject = $row["SUBJECT"];
			$summary = $row["SUMMARY"];
			$begin_date = $row["BEGIN_DATE"];
			$end_date = $row["END_DATE"];
			$priv_id = $row["PRIV_ID"];
			$send_time = $row["SEND_TIME"];
			$to_user_id = $row["USER_ID"];

			if ($notify_leader_app == 1) {
				$sms_content0 = sprintf(_("您提交的公告通知,标题:%s审批已通过。"), csubstr($subject, 0, 100));
				$remind_url0 = "1:notify/manage/index.php";
				send_sms($send_time, $_SESSION["LOGIN_USER_ID"], $from_id, 1, $sms_content0, $remind_url0);
				$sms_content = _("请查看公告通知!") . "\n" . _("标题:") . csubstr($subject, 0, 100);

				if ($summary) {
					$sms_content .= "\n" . _("内容简介:") . $summary;
				}

				if ($to_id == "ALL_DEPT") {
					$query2 = "select USER_ID from USER where (NOT_LOGIN = 0 or NOT_MOBILE_LOGIN = 0)";
				}
				else {
					$query2 = "select USER_ID from USER where (NOT_LOGIN = 0 or NOT_MOBILE_LOGIN = 0) and (find_in_set(DEPT_ID,'$to_id') or find_in_set(USER_PRIV,'$priv_id') or find_in_set(USER_ID,'$to_user_id'))";
				}

				$cursor2 = exequery(TD::conn(), $query2);

				while ($row2 = mysql_fetch_array($cursor2)) {
					$user_id_str .= $row2["USER_ID"] . ",";
				}

				$my_array = explode(",", $priv_id);
				$array_count = sizeof($my_array);

				for ($I = 0; $I < $array_count; $I++) {
					if ($my_array[$I] == "") {
						continue;
					}

					$query3 = "select USER_ID from USER where (NOT_LOGIN = 0 or NOT_MOBILE_LOGIN = 0) and find_in_set('$my_array[$I]',USER_PRIV_OTHER)";
					$cursor3 = exequery(TD::conn(), $query3);

					while ($row3 = mysql_fetch_array($cursor3)) {
						if (!find_id($user_id_str, $row3["USER_ID"])) {
							$user_id_str .= $row3["USER_ID"] . ",";
						}
					}
				}

				$user_id_str_array = explode(",", $user_id_str);
				$user_id_str_array_count = sizeof($user_id_str_array);

				for ($I = 0; $I < $user_id_str_array_count; $I++) {
					if ($user_id_str_array[$I] == "") {
						continue;
					}

					$func_id_str = GetfunmenuByuserID($user_id_str_array[$I]);

					if (!find_id($func_id_str, 4)) {
						$user_id_str = str_replace($user_id_str_array[$I], "", $user_id_str);
					}
				}

				if (td_trim($user_id_str)) {
					$remind_url = "1:notify/show/read_notify.php?NOTIFY_ID=" . $notify_id;
					send_sms("", $_SESSION["LOGIN_USER_ID"], $user_id_str, 1, $sms_content, $remind_url, $notify_id);
				}
			}
			else if ($notify_leader_app == 2) {
				$sms_content0 = sprintf(_("您提交的公告通知,标题:%s审批未通过,原因是:%s"), csubstr($subject, 0, 100), $notify_leader_reason);
				$remind_url0 = "1:notify/manage/index.php";
				send_sms($send_time, $_SESSION["LOGIN_USER_ID"], $from_id, 1, $sms_content0, $remind_url0);
			}
		}
	}
}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hai7425

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值