- foreach($notifytimes as $newTimes){
- $newSearch = DB_DataObject::factory('core_notify');
- $newSearch->act_start = $newTimes;
- if($newSearch->find(true)){
- $newSearch->id = $w->id;
- $newSearch->recur_id = $w->id;
- $newSearch->act_when = $w->dtstart;
- $newSearch->onid = $w->onid;
- $newSearch->ontable = $w->ontable;
- $newSearch->person_id = $w->person_id;
- $newSearch->act_start = $w->dtstart;
+ }
+
+
+ function generateNotificationsSingle()
+ {
+
+
+ $notifytimes = $this->notifyTimes(2);
+ ////print_R($notifytimes);
+
+ $newSearch = DB_DataObject::factory('core_notify');
+ $newSearch->whereAdd( 'act_start > NOW()');
+ $newSearch->recur_id = $this->id;
+ $old = $newSearch->fetchAll('act_start', 'id');
+ // returns array('2012-12-xx'=>12, 'date' => id....)
+
+
+
+ foreach($notifytimes as $time){
+
+ if (isset($old[$time])) {
+ // we already have it...
+
+ $oo = DB_DataObject::Factory('core_notify');
+ $oo->get($old[$time]);
+ $oc = clone($oo);
+ $oo->evtype = $this->method()->name;
+ $oo->update($oc);
+
+ unset($old[$time]);
+ continue;
+ }
+ if (strtotime($time) < time()) {
+ // will not get deleted..
+ //echo "SKIP BEFORE NOW";
+ unset($old[$time]);
+ continue;