public function getSession($id)
 {
     $data = array();
     $social_actions = SocialAction::with('socialTarget', 'user')->where('id', $id)->first();
     if ($social_actions == false) {
         return App::abort('404');
     }
     $photos = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->get();
     $donations = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->orderBy('id', 'desc')->get();
     $user = User::getUserId($social_actions->user_id);
     $social_target_id = SocialTarget::getAll();
     $social_action_category_id = SocialActionCategory::getAll();
     $city_id = City::getAll();
     $data = array('social_action' => $social_actions, 'photos' => $photos, 'donations' => $donations, 'user' => $user, 'social_target_id' => $social_target_id, 'social_action_category_id' => $social_action_category_id, 'city_id' => $city_id);
     Session::put('type_name', 'SocialAction');
     Session::put('type_id', $social_actions->social_target_id);
     return Redirect::route('buat-aksi-sosial');
 }
示例#2
0
 public function searchjsonAction()
 {
     $keyword = strtolower($this->getRequest()->getParam('term'));
     $numOfItem = (int) Zend_Registry::get('Setting')->autocomplete_limit;
     if ($numOfItem > 0) {
         list($Pager, $aRespon['cities']) = City::getAll(array('LOWER(city_id) || LOWER(tags) LIKE ?' => "%{$keyword}%"), 1, $numOfItem);
         $numOfItem = $numOfItem - $Pager->getNumResults();
     }
     if ($numOfItem > 0) {
         //Search countries three
         $aRespon['countries'] = Countries::getAll(array('LOWER(countries_id) LIKE ? OR  LOWER(tags) LIKE ?' => array("%{$keyword}%", "%{$keyword}%")), $numOfItem);
         $numOfItem = $numOfItem - count($aRespon['countries']);
     }
     header('Content-Type: text/html; charset=iso-8859-1');
     $search = ucwords($keyword);
     $keywords = array($keyword, $search, ucfirst(str_replace(' ', '', $keyword)), ucfirst(str_replace(' ', '', My_Plugin_Libs::unUnicode($keyword))));
     $response = array();
     $address = '';
     //rebuil to autocomplete struc
     foreach ($aRespon as $location => $data) {
         foreach ($data as $Obj) {
             $link = '';
             if ($location == 'cities') {
                 $label = $Obj->name . ', ' . $Obj->Countries->name;
                 $link = $Obj->getLink();
                 $country = $Obj->Countries->name;
             } elseif ($location == 'countries') {
                 $label = $Obj->name;
                 $link = $Obj->getLink();
                 $country = $Obj->name;
             } else {
                 $label = $Obj->name;
                 $link = $Obj->getLink();
                 $country = $Obj->Countries->name;
                 $address = $Obj->address;
             }
             $response[] = array('location' => $location, 'link' => $link, 'id' => $Obj->id, 'label' => str_replace($keywords, '<b>' . $search . '</b>', $label), 'value' => $label, 'country' => $country, 'address' => str_replace($keywords, '<b>' . $search . '</b>', $address));
         }
     }
     echo json_encode($response);
 }
 public function getSession($id)
 {
     // init
     $data = array();
     // get social target data - with slug
     $social_target = SocialTarget::with(array('city', 'category'))->where('id', '=', $id)->where('status', '=', 1)->first();
     if ($social_target == null) {
         return App::abort('404');
     }
     // get photos
     $photos = Photo::where('type_name', '=', 'social_targets')->where('type_id', '=', $social_target->id)->where('status', '=', 1)->get();
     // get social actions
     $social_actions = SocialAction::with(array('city', 'category'))->where('social_target_id', '=', $social_target->id)->where('status', '=', 1)->orderBy('id', 'desc')->get();
     // set data
     $data = array('social_target' => $social_target, 'photos' => $photos, 'social_actions' => $social_actions);
     $data['social_target_id'] = SocialTarget::getAll();
     $data['social_action_category_id'] = SocialActionCategory::getAll();
     $data['city_id'] = City::getAll();
     Session::put('type_name', 'SocialTarget');
     Session::put('type_id', $social_target->id);
     return Redirect::route('buat-aksi-sosial');
 }
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../City.php";
session_start();
if (empty($_SESSION['list_of_cities'])) {
    $_SESSION['list_of_cities'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('cities.html.twig', array('cities' => City::getAll()));
});
$app->post("/cities", function () use($app) {
    $city = new City($_POST['description'], $_POST['landmark']);
    ///connects to label id on cities.html.twig
    $city->save();
    return $app['twig']->render('create_city.html.twig', array('newcity' => $city));
});
$app->post("/delete_cities", function () use($app) {
    City::deleteAll();
    return $app['twig']->render('delete_cities.html.twig');
});
return $app;
示例#5
0
                        Add 
                    </a><br/><br/>
                    <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                        <thead>
                            <tr>
                                <th>Id</th>
                                <th>City </th>
                                <th>State </th>
                                <th>Status</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
$cityObj = new City();
$rows = $cityObj->getAll();
foreach ($rows as $row) {
    ?>
  

                                <tr>
                                    <td><?php 
    echo $row['id'];
    ?>
</td>
                                    <td class="center"><?php 
    echo $row['name'];
    ?>
</td>
                                    <td class="center"><?php 
    echo $row['state_name'];
示例#6
0
 public function editprofile()
 {
     $data['city'] = City::getAll();
     $data['photo'] = Photo::getByUser(Auth::user()->id);
     return View::make('bagikasih.edit_profile.index', $data);
 }
示例#7
0
 public function create()
 {
     $data['event_category'] = EventCategory::getbyStatus();
     $data['city'] = City::getAll();
     return View::make('bagikasih.event.create', $data);
 }