Пример #1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     Yii::app()->page->title = "Лог по турам";
     if ($this->beginCache("console_log_tours", array('duration' => 3600 * 12))) {
         $listTours = CatLogToursAll::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("date2")->setLimit(50)->setCache(0));
         $listToursParams = CatLogToursParams::fetchAll(DBQueryParamsClass::CreateParams()->setOrderBy("date2")->setLimit(50)->setCache(0));
         $rows = "";
         for ($i = 0; $i < sizeof($listTours); $i++) {
             if (!empty($rows)) {
                 $rows .= ",";
             }
             $rows .= "['" . date("d.m", strtotime($listTours[$i]->date2)) . "', " . $listTours[$i]->count . ", " . $listToursParams[$i]->count_category . ", " . $listToursParams[$i]->count_country . " ]";
         }
         $this->render("index", array("rows" => $rows, "listToursParams" => $listToursParams));
         $this->endCache();
     }
 }
Пример #2
0
 static function saveCatLogTours($tourId)
 {
     // Сохронякем индивидуальный лог
     $check = CatLogTours::findByAttributes(array("tour_id" => $tourId, "date2" => date("Y-m")));
     if (sizeof($check) > 0) {
         $check[0]->count++;
         $check[0]->save();
     } else {
         $check = new CatLogTours();
         $check->count = 1;
         $check->tour_id = $tourId;
         $check->date2 = date("Y-m");
         if (!$check->save()) {
             print_r($check->getErrors());
         }
     }
     // Сохронякем индивидуальный общий лог
     $check = CatLogToursAll::findByAttributes(array("date2" => date("Y-m-d")));
     if (sizeof($check) > 0) {
         $check[0]->count++;
         $check[0]->save();
     } else {
         $check = new CatLogToursAll();
         $check->count = 1;
         $check->date2 = date("Y-m-d");
         if (!$check->save()) {
             print_r($check->getErrors());
         }
     }
 }