Beispiel #1
0
		                <td width="40%"><a href="/backend/<?php 
        echo \Core\Route::controller();
        ?>
/edit/<?php 
        echo $obj->id;
        ?>
"><?php 
        echo $obj->name;
        ?>
</a></td>
		                <td width="10%"><?php 
        echo ($obj->p_name or strlen($obj->place_name) != 0) ? \Modules\Afisha\Models\Afisha::getItemPlace($obj) : '----';
        ?>
</td>
		                <td width="10%"><?php 
        echo \Modules\Afisha\Models\Afisha::getItemPrice($obj);
        ?>
 </td>
		                <td width="20%"><a href="/afisha/<?php 
        echo $obj->alias;
        ?>
" target="_blank"><?php 
        echo $obj->alias;
        ?>
</a></td>
		                <td width="10%"><?php 
        echo date('d.m.Y', $obj->event_date);
        ?>
</td>
		                <td><?php 
        echo $obj->main_show ? '<span style="color: green;">Да</span>' : '<span style="color: red">Нет</span>';
Beispiel #2
0
 public function moreAffisheAction()
 {
     $page = (int) Arr::get($_POST, 'page');
     if (!isset($page)) {
         $this->error('Ошибка загрузки');
     }
     // list posts
     if (isset($_SESSION['idCity'])) {
         // select places id
         $places = DB::select('id')->from('places')->where('city_id', '=', $_SESSION['idCity'])->where('status', '=', DB::expr(1))->as_object()->execute();
         $ids = array();
         foreach ($places as $key => $value) {
             $ids[] = $value->id;
         }
         if (count($ids) == 0) {
             $ids[] = 0;
         }
     }
     $dbObj = DB::select('afisha.*', array('places.name', 'p_name'), array(DB::expr('MIN(prices.price)'), 'p_from'), array(DB::expr('MAX(prices.price)'), 'p_to'))->from('afisha')->join('places', 'left outer')->on('afisha.place_id', '=', 'places.id')->on('places.status', '=', DB::expr(1))->join('prices', 'left outer')->on('afisha.id', '=', 'prices.afisha_id')->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()));
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $result = $dbObj->group_by('afisha.id')->order_by('afisha.event_date')->limit(Config::get('limit'))->offset(($page - 1) * (int) Config::get('limit'))->execute()->as_array();
     foreach ($result as $key => $value) {
         $result[$key]['p_name'] = Afisha\Models\Afisha::getItemPlace($value, true);
         $result[$key]['cost'] = Afisha\Models\Afisha::getItemPrice($value, true);
         $result[$key]['event_date'] = date('j', $value['event_date']) . ' ' . Dates::month(date('n', $value['event_date'])) . ' ' . date('Y', $value['event_date']);
         if (!is_file(HOST . HTML::media('images/afisha/medium/' . $value['image']))) {
             $result[$key]['image'] = false;
         }
     }
     // Count of all posts
     $dbObj = DB::select(array(DB::expr('COUNT(afisha.id)'), 'count'))->from('afisha');
     if (isset($_SESSION['idCity'])) {
         $dbObj->where_open()->where('afisha.place_id', 'IN', $ids)->or_where('afisha.city_id', '=', $_SESSION['idCity'])->where_close();
     }
     $count = $dbObj->where('afisha.status', '=', 1)->where('afisha.event_date', '>', DB::expr(time()))->as_object()->execute()->current()->count;
     // Set view button more load
     $showBut = true;
     if ($count <= Config::get('limit') * $page) {
         $showBut = false;
     }
     // Render template
     $this->success(array('result' => $result, 'showBut' => $showBut));
 }