public function run($args)
 {
     $list = array("catalog_users", "catalog_firms", "catalog_tours", "catalog_firms_service", "catalog_firms_items");
     for ($i = 0; $i < sizeof($list); $i++) {
         $catalog = SiteHelper::getCamelCase($list[$i]);
         $listItems = $catalog::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("!EXISTS(SELECT id FROM notifications_queue WHERE catalog='" . $list[$i] . "' AND item_id=" . $list[$i] . "_as.id)")->setLimit(50)->setOrderBy("rating"));
         //$listItems = $catalog::fetchAll( DBQueryParamsClass::CreateParams()->setConditions("id=13")->setLimit( 100 )->setOrderBy("rating") );
         if (sizeof($listItems) > 0) {
             foreach ($listItems as $item) {
                 $tableName = $item->tableName();
                 switch ($item->tableName()) {
                     case "catalog_users":
                         if ($item->active == 0) {
                             AutoNotifier::onRegistration($item);
                         } else {
                             $countFirms = CatalogFirms::count(DBQueryParamsClass::CreateParams()->setConditions("user_id=:uid")->setParams(array(":uid" => $item->id)));
                             if ($countFirms == 0) {
                                 $tableName = "catalog_users_con";
                                 AutoNotifier::onRegistrationConfirm($item);
                             } else {
                                 continue 2;
                             }
                         }
                         break;
                     case "catalog_firms":
                         $item->onAddFirm(new CModelEvent($item), array("status" => "reminder"));
                         break;
                     case "catalog_tours":
                         $item->onAddTour(new CModelEvent($item), array("status" => "reminder"));
                         break;
                     case "catalog_firms_items":
                         $item->onAddFirmsItems(new CModelEvent($item), array("status" => "reminder"));
                         break;
                     case "catalog_firms_service":
                         $item->onAddFirmsService(new CModelEvent($item), array("status" => "reminder"));
                         break;
                     case "catalog_firms_banner":
                         $item->onAddFirmsBanners(new CModelEvent($item), array("status" => "reminder"));
                         break;
                 }
                 AutoNotifier::addInNotificationsQueue($tableName, $item->id, 0);
             }
             return "";
         }
     }
 }
 public function run($args)
 {
     $list = NotificationsQueue::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("date<=:date AND step>-1")->setParams(array(":date" => time()))->setLimit(50)->setCache(0));
     foreach ($list as $item) {
         $catalogClass = SiteHelper::getCamelCase($item->catalog);
         $itemObj = $catalogClass::fetch($item->item_id);
         if (!$item->step) {
             $item->step = 0;
         }
         $step = $item->step < 8 ? $item->step + 1 : -1;
         //print_r( $item );
         // Добавляем в очередь на нотификацию
         // В течении 24 часов после добавления или сохранения пользователю приходят уведомления
         // О том что заполнил не полностью, не опубликовал, не добавил картинок и т.д.
         AutoNotifier::addInNotificationsQueue($item->catalog, $itemObj->id, $step);
         switch ($item->catalog) {
             case "catalog_users":
                 AutoNotifier::onRegistration($itemObj);
                 break;
             case "catalog_users_con":
                 AutoNotifier::onRegistrationConfirm($itemObj);
                 break;
             case "catalog_firms":
                 $itemObj->onAddFirm(new CModelEvent($itemObj), array("status" => "reminder"));
                 break;
             case "catalog_tours":
                 $itemObj->onAddTour(new CModelEvent($itemObj), array("status" => "reminder"));
                 break;
             case "catalog_firms_items":
                 $itemObj->onAddFirmsItems(new CModelEvent($itemObj), array("status" => "reminder"));
                 break;
             case "catalog_firms_service":
                 $itemObj->onAddFirmsService(new CModelEvent($itemObj), array("status" => "reminder"));
                 break;
             case "catalog_firms_banner":
                 $itemObj->onAddFirmsBanners(new CModelEvent($itemObj), array("status" => "reminder"));
                 break;
         }
     }
 }