<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Browserpush_Plugin_Task_Jobs extends Core_Plugin_Task_Abstract
{
  public function execute()
  {
    $table = Engine_Api::_()->getDbTable('scheduleds', 'browserpush');
    $tableName = $table->info('name');
    $select = $table->select()->from($tableName)->where('scheduled_time IS NOT NULL AND scheduled_time != ""')->where('scheduled_time <= ?', date('Y-m-d H:i:s'))->where('sent =?', 0);
    $results = $table->fetchAll($select);
    foreach ($results as $values) {
      Engine_Api::_()->browserpush()->sendNotification($values);
    }
  }
}
