Beispiel #1
0
 public function action_write()
 {
     $this->template->page_title = 'Write Article';
     $user = new Model_User();
     $session = Session::instance()->get('user');
     $view = View::factory('cp/entries/write');
     $view->author = $users->get_user_by_session_id($session);
     if ($this->request->method() === Request::POST) {
         if (!Security::check($this->request->post('csrf_token'))) {
             throw new HTTP_Exception_401("Bad token!");
         }
         $post_title = $this->request->post('title');
         $post_slug = $this->request->post('slug');
         $post_content = $this->request->post('content');
         $post_author = $this->request->post('author');
         $post_date = time();
         if (empty($post_title) and empty($post_content) and empty($post_author) and empty($post_date)) {
             throw new Exception('Please don`t make empty fields!');
         }
         if (empty($post_slug)) {
             $post_slug = URL::title($post_title, '_');
         }
         $entry = new Model_Entry();
         $data = array('title' => $post_title, 'slug' => $post_slug, 'content' => $post_content, 'author' => $post_author, 'date' => $post_date);
         $insert_entry = $entry->insert_entry($data);
         if (!$insert_entry) {
             throw new Exception('Check if you are connected to database!');
         }
         $this->request->redirect('cp/entries/write/');
     }
     $this->template->content = $view->render();
 }
Beispiel #2
0
 public function action_index()
 {
     $pagination = Pagination::factory(array('total_items' => Model::factory('entry')->get_count(), 'items_per_page' => 2, 'view' => 'pagination/digg'));
     $this->template->page_title = 'Home, exacly! :)';
     $entry = new Model_Entry();
     $view = View::factory('home/main');
     $view->entries = $entry->get_entries($pagination->items_per_page, $pagination->offset);
     $view->pagination = $pagination;
     $this->template->content = $view->render();
 }
 /**
  * フリーマーケット詳細表示画面
  *
  * @access public
  * @param mixed $fleamarket_id フリーマーケットID
  * @return void
  * @author ida
  */
 public function get_detail($fleamarket_id)
 {
     Asset::css('jquery-ui.min.css', array(), 'add_css');
     Asset::js('jquery-ui.min.js', array(), 'add_js');
     if (!$fleamarket_id) {
         return $this->forward('errors/notfound', 404);
     }
     $fleamarket = \Model_Fleamarket::findDetail($fleamarket_id);
     if (!$fleamarket) {
         return $this->forward('errors/notfound', 404);
     }
     $this->setHtmlReplace(array('AREA' => $this->getArea($fleamarket['prefecture_id']), 'AREA_NAME' => $this->getAreaName($fleamarket['prefecture_id']), 'FLEAMARKET_NAME' => $fleamarket['name'], 'LOCATION_ID' => $fleamarket['location_id'], 'LOCATION_NAME' => $fleamarket['location_name']));
     $fleamarket_abouts = \Model_Fleamarket_About::findByFleamarketId($fleamarket_id);
     $fleamarket_images = \Model_Fleamarket_Image::findByFleamarketId($fleamarket_id);
     $entry_styles = \Model_Fleamarket_Entry_Style::findByFleamarketId($fleamarket_id);
     $entries = \Model_Entry::getTotalEntryByFleamarketId($fleamarket_id);
     $fleamarket['entries'] = $entries;
     $view_model = \ViewModel::forge('search/detail');
     $view_model->set('fleamarket', $fleamarket, false);
     $view_model->set('fleamarket_images', $fleamarket_images, false);
     $view_model->set('fleamarket_abouts', $fleamarket_abouts, false);
     $view_model->set('fleamarket_entry_styles', $entry_styles, false);
     $view_model->set('entries', $entries, false);
     $view_model->set('prefectures', \Config::get('master.prefectures'), false);
     $view_model->set('user', $this->login_user, false);
     $this->template->content = $view_model;
 }
 /**
  * view method
  *
  * @access public
  * @return void
  * @author ida
  */
 public function view()
 {
     $this->entry_styles = \Config::get('master.entry_styles');
     $this->item_categories = \Model_Entry::getItemCategories();
     $this->entry_statuses = \Model_Entry::getEntryStatuses();
     $this->devices = \Model_Entry::getDevices();
 }
Beispiel #5
0
 public function action_view()
 {
     $entry_id = $this->request->param('id');
     $this->template->page_title = 'Entry #' . $entry_id;
     $slug = $this->request->param('slug');
     if (!$entry_id) {
         throw new Exception('ID must not be empty!');
     }
     $entry = new Model_Entry();
     $view = View::factory('entries/view');
     $view->entries = $entry->get_entry_by_id($entry_id);
     if (!$view->entries) {
         throw new Exception('There is not any entry with this ID!');
     }
     $this->template->content = $view->render();
 }
 /**
  * 反響項目を取得する
  *
  * @access private
  * @param
  * @return array
  * @author ida
  */
 private function getLinkFromList()
 {
     if (!empty($this->fleamarket_id)) {
         $link_from_list = $this->fieldsets['fleamarket']->field('link_from_list');
         $result = \Model_Fleamarket::explodeLinkFromList($link_from_list->value);
     } else {
         $result = \Model_Entry::getLinkFromList();
     }
     return $result;
 }
Beispiel #7
0
 public function action_delete($id = null)
 {
     if (!isset($_SESSION['user_id'])) {
         return Response::redirect('login');
     }
     is_null($id) and Response::redirect('Entry');
     if ($entry = Model_Entry::find($id)) {
         $entry->delete();
     }
     Response::redirect('entry');
 }
 /**
  * フリーマーケット情報に紐づくフリーマーケット出店形態情報を取得する
  *
  * @access private
  * @param array $fleamarket フリーマーケット情報
  * @return array
  * @author ida
  */
 private function getFleamarketEntryStyle($fleamarket)
 {
     if (!$fleamarket) {
         return false;
     }
     $entry_style_fields = array('field' => array('entry_style_id', 'booth_fee', 'max_booth', 'reservation_booth_limit'));
     $entry_styles = \Model_Fleamarket_Entry_Style::findByFleamarketId($fleamarket['fleamarket_id'], $entry_style_fields);
     $fleamarket['entry_styles'] = $entry_styles;
     $total_reserved_booth = 0;
     $entry = \Model_Entry::getTotalEntryByFleamarketId($fleamarket['fleamarket_id'], false);
     if ($entry) {
         $total_reserved_booth = $entry[0]['reserved_booth'];
     }
     $fleamarket['total_reserved_booth'] = $total_reserved_booth;
     return $fleamarket;
 }
 /**
  * 空きブース判定
  *
  * @access public
  * @param mixed $fleamarket_id
  * @return bool
  * @author kobayasi
  */
 public static function hasEmptyBooth($fleamarket_id = null)
 {
     if (!$fleamarket_id) {
         $fleamarket_id = $this->fleamarket_id;
     }
     $max_booth = 0;
     $max_booth_result = \Model_Fleamarket_Entry_Style::getMaxBoothByFleamarketId($fleamarket_id, false);
     if (isset($max_booth_result[0]['max_booth'])) {
         $max_booth = $max_booth_result[0]['max_booth'];
     }
     $total_entry = 0;
     $total_entry_result = \Model_Entry::getTotalEntryByFleamarketId($fleamarket_id, false);
     if (isset($total_entry_result[0]['reserved_booth'])) {
         $total_entry = $total_entry_result[0]['reserved_booth'];
     }
     return $max_booth - $total_entry > 0;
 }
                  <div class="errorMessage"><?php 
        echo $errors['item_genres'];
        ?>
</div>
                  <?php 
    }
    ?>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">このフリマをどこで知りましたか?</label>
                <div class="col-sm-10">
                  <select name="link_from" class="form-control">
                  <?php 
    if (empty($fleamarket->link_from_list) || trim($fleamarket->link_from_list) == '') {
        $link_from_list = \Model_Entry::getLinkFromList();
    } else {
        $link_from_list = \Model_Fleamarket::explodeLinkFromList($fleamarket->link_from_list);
    }
    foreach ($link_from_list as $key => $link_from) {
        $selected = '';
        if ($input['link_from'] == $link_from) {
            $selected = 'selected';
        }
        ?>
                    <option value="<?php 
        echo e($link_from);
        ?>
" <?php 
        echo $selected;
        ?>
$item_categories = array('1' => 'リサイクル品', '2' => '手作り品');
$item_genres = \Model_Entry::getItemGenres();
$link_from_list = \Model_Entry::getLinkFromList();
$entry_statuses = \Model_Entry::getEntryStatuses();
$fleamarkets = \Model_Fleamarket::find('all', array('select' => array('fleamarket_id')));
$users = \Model_User::find('all', array('select' => array('user_id')));
for ($i = 1; $i < 1000; $i++) {
    $item_category = array_rand($item_categories);
    $item_genre = array_rand($item_genres);
    $link_from = array_rand($link_from_list);
    $entry_status = array_rand($entry_statuses);
    while (true) {
        $fleamarket_key = array_rand($fleamarkets);
        $fleamarket = $fleamarkets[$fleamarket_key];
        $fleamarket_entry_styles = \Model_Fleamarket_Entry_Style::find('all', array('select' => array('fleamarket_entry_style_id'), 'where' => array(array('fleamarket_id', $fleamarket->fleamarket_id))));
        if ($fleamarket_entry_styles) {
            $fleamarket_entry_style_key = array_rand($fleamarket_entry_styles);
            $fleamarket_entry_style = $fleamarket_entry_styles[$fleamarket_entry_style_key];
            break;
        }
    }
    $user_key = array_rand($users);
    $user = $users[$user_key];
    $data = array('user_id' => $user->user_id, 'fleamarket_id' => $fleamarket->fleamarket_id, 'fleamarket_entry_style_id' => $fleamarket_entry_style->fleamarket_entry_style_id, 'reservation_number' => str_pad($fleamarket->fleamarket_id, 5, "0", STR_PAD_LEFT) . '-' . str_pad($i, 5, "0", STR_PAD_LEFT), 'item_category' => $item_category, 'item_genres' => $item_genres[$item_genre], 'reserved_booth' => mt_rand(1, 3), 'link_from' => $link_from_list[$link_from], 'remarks' => '初めてフリマを予約します' . $i, 'entry_status' => $entry_status, 'created_user' => 0);
    $entry = \Model_Entry::forge($data);
    $entry->save();
}
// foreach ($seeds as $line) {
// $model = Model_Entry::forge($line);
// $model->save();
// }
 /**
  * 出店予約のキャンセル
  *
  * @access public
  * @param
  * @return void
  * @author shimma
  * @autho ida
  */
 public function get_cancel()
 {
     $entry_id = \Input::get('entry_id');
     $cancel = \Input::get('cancel');
     if (!$entry_id || !$cancel) {
         \Session::set_flash('notice', \STATUS_FLEAMARKET_CANCEL_FAILED);
         \Response::redirect('/mypage', 'refresh');
     }
     $entry = \Model_Entry::find($entry_id);
     if (!$this->login_user->cancelEntry($entry_id, $this->login_user->user_id)) {
         \Session::set_flash('notice', \STATUS_FLEAMARKET_CANCEL_FAILED);
     } else {
         \Session::set_flash('notice', \STATUS_FLEAMARKET_CANCEL_SUCCESS);
         $entry = \Model_Entry::find($entry_id);
         $email_template_params = array('nick_name' => $this->login_user->nick_name, 'fleamarket.name' => $entry->fleamarket->name);
         $this->login_user->sendmail('common/user_cancel_fleamarket', $email_template_params);
     }
     //処理ページを見せ1秒後にマイページにリダイレクトさせる
     $this->setLazyRedirect('/mypage');
     $view = \View::forge('mypage/cancel');
     $view->set('cancel', $cancel);
     $this->template->content = $view;
 }
 /**
  * 予約履歴CSV出力
  *
  * @access public
  * @param
  * @return void
  * @author kobayashi
  * @author ida
  */
 public function action_csv()
 {
     $fleamarket = Model_Fleamarket::find(Input::param('fleamarket_id'));
     $csv = Lang::load('admin/csv');
     $data = array($csv['header']);
     $prefectures = \Config::get('master.prefectures');
     $entry_styles = \Config::get('master.entry_styles');
     $entry_statuses = \Model_Entry::getEntryStatuses();
     $gender_list = \Model_User::getGenderList();
     foreach ($fleamarket->entries as $entry) {
         if ($entry->user && $entry->fleamarket_entry_style) {
             $prefecture_id = $entry->user->prefecture_id;
             if (!isset($prefectures[$prefecture_id])) {
                 $prefecture_name = '-';
             } else {
                 $prefecture_name = $prefectures[$prefecture_id];
             }
             $data[] = array($entry->created_at, $fleamarket->event_date, $fleamarket->name, $entry->user->user_id, $entry->reservation_number, $entry_styles[$entry->fleamarket_entry_style->entry_style_id], $entry->reserved_booth, $entry->user->last_name . $entry->user->first_name, $entry->user->zip, $prefecture_name, $entry->user->address, $entry->user->tel, @$gender_list[$entry->user->gender], $entry->user->email, $entry_statuses[$entry->entry_status]);
         }
     }
     return $this->response_csv($data, $fleamarket->name);
 }
 /**
  * キャンセル待ち判定
  *
  * @access public
  * @param mixed $fleamarket_id
  * @return bool
  * @author kobayasi
  */
 public function hasWaiting($fleamarket_id)
 {
     if (!$this->has_waiting) {
         $entries = \Model_Entry::getUserEntriesByEntryStatus($this->user_id, \Model_Entry::ENTRY_STATUS_WAITING);
         foreach ($entries as $entry) {
             if ($entry['entry_status'] == Model_Entry::ENTRY_STATUS_WAITING) {
                 $this->has_waiting[] = $entry['fleamarket_id'];
             }
         }
     }
     return in_array($fleamarket_id, $this->has_waiting);
 }
Beispiel #15
0
 public function getLastId()
 {
     $lastid = new Model_Entry();
     return $lastid->getLastInsertId();
 }
 /**
  * 表示に必要なデータを取得し設定する
  *
  * @access private
  * @param object $view_model ビューモデル
  * @param array $input_data 入力データ
  * @return array
  * @author ida
  */
 private function setupData($view_model, $data)
 {
     $replace_data = array();
     $replace_data['user'] = $this->administrator;
     $mail_magazine_type = $data['mail_magazine_type'];
     switch ($mail_magazine_type) {
         case \Model_Mail_Magazine::MAIL_MAGAZINE_TYPE_ALL:
             $users = \Model_User::getActiveUsers();
             break;
         case \Model_Mail_Magazine::MAIL_MAGAZINE_TYPE_REQUEST:
             $users = \Model_User::getMailMagazineUserBy($data['prefecture_id'], $data['organization_flag']);
             $view_model->set('prefectures', \Config::get('master.prefectures'), false);
             break;
         case \Model_Mail_Magazine::MAIL_MAGAZINE_TYPE_RESEVED_ENTRY:
             $fleamarket_id = $data['reserved_fleamarket_id'];
             $users = \Model_Entry::getEntriesByFleamarketId($fleamarket_id, \Model_Entry::ENTRY_STATUS_RESERVED);
             $fleamarket = \Model_Fleamarket::find($fleamarket_id);
             $replace_data['fleamarket'] = $fleamarket;
             $view_model->set('fleamarket', $fleamarket, false);
             break;
         case \Model_Mail_Magazine::MAIL_MAGAZINE_TYPE_WAITING_ENTRY:
             $fleamarket_id = $data['waiting_fleamarket_id'];
             $users = \Model_Entry::getEntriesByFleamarketId($fleamarket_id, \Model_Entry::ENTRY_STATUS_WAITING);
             $fleamarket = \Model_Fleamarket::find($fleamarket_id);
             $replace_data['fleamarket'] = $fleamarket;
             $view_model->set('fleamarket', $fleamarket, false);
             break;
     }
     $view_model->set('users', $users, false);
     $body = $data['body'];
     $pattern = \Model_Mail_Magazine::getPatternParameter($mail_magazine_type);
     list($pattern, $replacement) = \Model_Mail_Magazine::createReplaceParameter($body, $pattern, $replace_data);
     $body = \Model_Mail_Magazine::replaceByParam($body, $pattern, $replacement);
     $view_model->set('body', $body, false);
     $view_model->set('input_data', $data, false);
     return array($view_model, $replace_data);
 }
 /**
  * キャンセル待ちしているエントリーを取得
  *
  * @access public
  * @param  void
  * @return Model_Entry の array
  * @author kobayasi
  */
 public function getWaitingEntry()
 {
     $entries = \Model_Entry::query()->where(array('fleamarket_id' => $this->fleamarket_id, 'fleamarket_entry_style_id' => $this->fleamarket_entry_style_id, 'entry_status' => \Model_Entry::ENTRY_STATUS_WAITING))->get();
     return $entries;
 }
 /**
  * フィールドセットを入力データから作成する
  *
  * @access private
  * @param
  * @return Fieldsetオブジェクト
  * @author kobayashi
  */
 private function createFieldset()
 {
     $fieldset = \Model_Entry::createFieldset(\Input::all());
     $fieldset->repopulate();
     return $fieldset;
 }
          <label class="col-sm-2 control-label">ブース数</label>
          <div class="col-sm-10"><?php 
echo e($input['reserved_booth']);
?>
</div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">出品予定品目</label>
          <div class="col-sm-10">
            <p><?php 
$item_category_define = \Model_Entry::getItemCategories();
echo e($item_category_define[$input['item_category']]);
?>
</p>
            <ul><?php 
$item_genres_define = \Model_Entry::getItemGenres();
foreach ($input['item_genres'] as $item_genre) {
    echo '<li>' . e($item_genres_define[$item_genre]) . "</li>";
}
?>
</ul>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">このフリマをどこで知りましたか</label>
          <div class="col-sm-10"><?php 
echo e($input['link_from']);
?>
</div>
        </div>
        <div id="submitButton" class="form-group">