Quellcode durchsuchen

fixed mark as send in Notify

Piotr Labudda vor 10 Jahren
Ursprung
Commit
da9d9ad69a
2 geänderte Dateien mit 12 neuen und 6 gelöschten Zeilen
  1. 2 2
      SE/se-lib/Route/Cron.php
  2. 10 4
      SE/se-lib/Route/Notify.php

+ 2 - 2
SE/se-lib/Route/Cron.php

@@ -117,9 +117,9 @@ class Route_Cron extends RouteBase {
 				foreach ($listWhen as $when => $listWhat) {
 				foreach ($listWhen as $when => $listWhat) {
 					if (!empty($listWhat)) {
 					if (!empty($listWhat)) {
 						$reminders = array_keys($listWhat);
 						$reminders = array_keys($listWhat);
-						echo "<p>Sending to {$who} reminders [" . implode(",", $reminders) . "]</p>" . "\n";
+						echo "<p>Sending to {$who} reminders [" . implode(",", $reminders) . "] at '{$when}'</p>" . "\n";
 						$notify->send($who, $listWhat, $when, $forceMail = 'plabudda@biall-net.pl');
 						$notify->send($who, $listWhat, $when, $forceMail = 'plabudda@biall-net.pl');
-						$notify->markAsSent($who, $reminders);
+						$notify->markAsSent($who, $listWhat, $when);
 					}
 					}
 				}
 				}
 			}
 			}

+ 10 - 4
SE/se-lib/Route/Notify.php

@@ -61,8 +61,9 @@ class Route_Notify extends RouteBase {
 		}
 		}
 
 
 		if ('1' == V::get('send', 0, $_POST, 'int')) {
 		if ('1' == V::get('send', 0, $_POST, 'int')) {
-			$this->send($usrLogin, $notifyTypeList);
-			$this->markAsSent($usrLogin, $notifyTypeList);
+			SE_Layout::alert('warning', "TODO: fix send, mark as sent");
+			//$this->send($usrLogin, $notifyTypeList);
+			//$this->markAsSent($usrLogin, $notifyTypeList);
 		}
 		}
 
 
 		$urlParts = array();// index.php?_route=Notify&_task=generateUserReminders&usrLogin=magdalena.cichosz&reminder[]=msgs
 		$urlParts = array();// index.php?_route=Notify&_task=generateUserReminders&usrLogin=magdalena.cichosz&reminder[]=msgs
@@ -247,15 +248,18 @@ function refreshPreview() {
 		return reset($aliasy);
 		return reset($aliasy);
 	}
 	}
 
 
-	public function markAsSent($usrLogin, $notifyTypeList) {
-		$sqlReminderTypes = "'" . implode("','", $notifyTypeList) . "'";
+	public function markAsSent($usrLogin, $reminders, $when) {
+//		$sqlReminderTypes = "'" . implode("','", $notifyTypeList) . "'";
+		$sqlReminderTypes = "'" . implode("','", array_keys($reminders)) . "'";
 		$sth = DB::getPDO()->prepare("
 		$sth = DB::getPDO()->prepare("
 			update CRM_NOTIFY
 			update CRM_NOTIFY
 			set `last_exec_time` = NOW()
 			set `last_exec_time` = NOW()
 			where `who` = :login
 			where `who` = :login
+				and `when` = :when
 				and `what` in({$sqlReminderTypes})
 				and `what` in({$sqlReminderTypes})
 		");
 		");
 		$sth->bindValue(':login', $usrLogin, PDO::PARAM_STR);
 		$sth->bindValue(':login', $usrLogin, PDO::PARAM_STR);
+		$sth->bindValue(':when', $when, PDO::PARAM_STR);
 		$sth->execute();
 		$sth->execute();
 	}
 	}
 
 
@@ -860,6 +864,7 @@ function refreshPreview() {
 				and u.EMPLOYEE_TYPE = 'Pracownik'
 				and u.EMPLOYEE_TYPE = 'Pracownik'
 				and n.`who` is not null
 				and n.`who` is not null
 			group by u.ADM_ACCOUNT
 			group by u.ADM_ACCOUNT
+			order by n.last_exec_time asc
 			limit :limit
 			limit :limit
 		");
 		");
 		$sth->bindValue(':limit', $limit, PDO::PARAM_INT);
 		$sth->bindValue(':limit', $limit, PDO::PARAM_INT);
@@ -884,6 +889,7 @@ function refreshPreview() {
 			from CRM_NOTIFY n
 			from CRM_NOTIFY n
 			where n.`who` in({$sqlUsers})
 			where n.`who` in({$sqlUsers})
 				and {$sqlWhenFltr}
 				and {$sqlWhenFltr}
+			order by n.last_exec_time asc
 		");
 		");
 		$sth->execute();
 		$sth->execute();
 		$rawReminders = $sth->fetchAll();
 		$rawReminders = $sth->fetchAll();