Pagination PHP Class Code Examples

This page contains top rated real world PHP examples of class Pagination extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: DefaultController.php Project: ochiem/app-cms
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     /* @var $postType PostType */
     /* @var $post Post */
     /* @var $taxonomies Taxonomy[] */
     /* @var $taxonomy Taxonomy */
     /* @var $lastMedia Media */
     $response = Yii::$app->response;
     $response->headers->set('Content-Type', 'text/xml; charset=UTF-8');
     $response->format = $response::FORMAT_RAW;
     $postTypes = PostType::find()->select(['id', 'post_type_slug'])->all();
     $taxonomies = Taxonomy::find()->select(['id', 'taxonomy_slug'])->all();
     $items = [];
     foreach ($postTypes as $postType) {
         if (!isset($this->_option['post_type'][$postType->id]['enable']) || !$this->_option['post_type'][$postType->id]['enable']) {
             continue;
         }
         if ($post = $postType->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC])->one()) {
             $lastmod = new \DateTime($post->post_modified, new \DateTimeZone(Option::get('time_zone')));
             $query = $postType->getPosts()->andWhere(['post_status' => 'publish']);
             $countQuery = clone $query;
             $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->_option['entries_per_page']]);
             for ($i = 1; $i <= $pages->pageCount; $i++) {
                 $items[] = ['loc' => Yii::$app->urlManager->hostInfo . Url::to(['view', 'type' => 'p', 'slug' => $postType->post_type_slug, 'page' => $i]), 'lastmod' => $lastmod->format('r')];
             }
         }
     }
     foreach ($taxonomies as $taxonomy) {
         if (!isset($this->_option['taxonomy'][$taxonomy->id]['enable']) || !$this->_option['taxonomy'][$taxonomy->id]['enable']) {
             continue;
         }
         if ($terms = $taxonomy->terms) {
             $post = Post::find()->from(['post' => Post::tableName()])->innerJoinWith(['terms' => function ($query) {
                 /* @var $query \yii\db\ActiveQuery */
                 $query->from(['term' => Term::tableName()]);
             }])->where(['IN', 'term.id', ArrayHelper::getColumn($terms, 'id')])->andWhere(['post.post_status' => 'publish'])->orderBy(['post.id' => SORT_DESC])->one();
             if ($post) {
                 $query = $taxonomy->getTerms();
                 $lastmod = new \DateTime($post->post_modified, new \DateTimeZone(Option::get('time_zone')));
                 $countQuery = clone $query;
                 $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->_option['entries_per_page']]);
                 for ($i = 1; $i <= $pages->pageCount; $i++) {
                     $items[] = ['loc' => Yii::$app->urlManager->hostInfo . Url::to(['view', 'type' => 'c', 'slug' => $taxonomy->taxonomy_slug, 'page' => $i]), 'lastmod' => $lastmod->format('r')];
                 }
             }
         }
     }
     if (isset($this->_option['media']['enable']) && $this->_option['media']['enable']) {
         $query = Media::find();
         $countQuery = clone $query;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->_option['entries_per_page']]);
         if ($lastMedia = $query->orderBy(['id' => SORT_DESC])->one()) {
             $lastmod = new \DateTime($lastMedia->media_modified, new \DateTimeZone(Option::get('time_zone')));
             for ($i = 1; $i <= $pages->pageCount; $i++) {
                 $items[] = ['loc' => Yii::$app->urlManager->hostInfo . Url::to(['view', 'type' => 'm', 'slug' => 'media', 'page' => $i]), 'lastmod' => $lastmod->format('r')];
             }
         }
     }
     return $this->renderPartial('index', ['items' => $items]);
 }
Example #2
Show file File: product.php Project: brunoxu/mycncart
0
 public function review()
 {
     $this->load->language('product/product');
     $this->load->model('catalog/review');
     $data['text_no_reviews'] = $this->language->get('text_no_reviews');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['reviews'] = array();
     $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
     $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
     foreach ($results as $result) {
         $data['reviews'][] = array('author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int) $result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $pagination = new Pagination();
     $pagination->total = $review_total;
     $pagination->page = $page;
     $pagination->limit = 5;
     $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $review_total ? ($page - 1) * 5 + 1 : 0, ($page - 1) * 5 > $review_total - 5 ? $review_total : ($page - 1) * 5 + 5, $review_total, ceil($review_total / 5));
     $this->response->setOutput($this->load->view('product/review', $data));
 }
Example #3
Show file File: coupon.php Project: TimeCheer/opencart
0
 public function history()
 {
     $this->load->language('marketing/coupon');
     $this->load->model('marketing/coupon');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['column_order_id'] = $this->language->get('column_order_id');
     $data['column_customer'] = $this->language->get('column_customer');
     $data['column_amount'] = $this->language->get('column_amount');
     $data['column_date_added'] = $this->language->get('column_date_added');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['histories'] = array();
     $results = $this->model_marketing_coupon->getCouponHistories($this->request->get['coupon_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $data['histories'][] = array('order_id' => $result['order_id'], 'customer' => $result['customer'], 'amount' => $result['amount'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $history_total = $this->model_marketing_coupon->getTotalCouponHistories($this->request->get['coupon_id']);
     $pagination = new Pagination();
     $pagination->total = $history_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('marketing/coupon/history', 'token=' . $this->session->data['token'] . '&coupon_id=' . $this->request->get['coupon_id'] . '&page={page}', true);
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $history_total ? ($page - 1) * 10 + 1 : 0, ($page - 1) * 10 > $history_total - 10 ? $history_total : ($page - 1) * 10 + 10, $history_total, ceil($history_total / 10));
     $this->response->setOutput($this->load->view('marketing/coupon_history', $data));
 }
Example #4
Show file File: ip.php Project: Samirdelvadia/opencart
0
 public function ip()
 {
     $this->load->language('fraud/ip');
     $this->load->model('fraud/ip');
     $this->load->model('customer/customer');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['text_loading'] = $this->language->get('text_loading');
     $data['column_ip'] = $this->language->get('column_ip');
     $data['column_total'] = $this->language->get('column_total');
     $data['column_date_added'] = $this->language->get('column_date_added');
     $data['column_action'] = $this->language->get('column_action');
     $data['button_remove'] = $this->language->get('button_remove');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['ips'] = array();
     $results = $this->model_fraud_ip->getIps(($page - 1) * 10, 10);
     foreach ($results as $result) {
         $data['ips'][] = array('ip' => $result['ip'], 'total' => $this->model_customer_customer->getTotalCustomersByIp($result['ip']), 'date_added' => date('d/m/y', strtotime($result['date_added'])), 'filter_ip' => $this->url->ssl('customer/customer', 'token=' . $this->session->data['token'] . '&filter_ip=' . $result['ip'], true));
     }
     $ip_total = $this->model_fraud_ip->getTotalIps();
     $pagination = new Pagination();
     $pagination->total = $ip_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->ssl('fraud/ip/ip', 'token=' . $this->session->data['token'] . '&page={page}', true);
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $ip_total ? ($page - 1) * 10 + 1 : 0, ($page - 1) * 10 > $ip_total - 10 ? $ip_total : ($page - 1) * 10 + 10, $ip_total, ceil($ip_total / 10));
     $this->response->setOutput($this->load->view('fraud/ip_ip', $data));
 }
Example #5
Show file File: userlist.php Project: cls1991/ryzomcore
0
/**
* This function is beign used to load info that's needed for the userlist page.
* this function will return all users by using he pagination class, so that it can be used in the template. Only Mods and Admins can browse this page though.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function userlist()
{
    if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
        $pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers");
        $pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email"));
        $pageResult['links'] = $pagination->getLinks(5);
        $pageResult['lastPage'] = $pagination->getLast();
        $pageResult['currentPage'] = $pagination->getCurrent();
        $i = 0;
        foreach ($pageResult['userlist'] as $user) {
            $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission();
            $i++;
        }
        if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
            $pageResult['isAdmin'] = "TRUE";
        }
        global $INGAME_WEBPATH;
        $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
        global $BASE_WEBPATH;
        $pageResult['base_webpath'] = $BASE_WEBPATH;
        return $pageResult;
    } else {
        //ERROR: No access!
        $_SESSION['error_code'] = "403";
        header("Cache-Control: max-age=1");
        header("Location: index.php?page=error");
        throw new SystemExit();
    }
}
Example #6
Show file File: google_base.php Project: brunoxu/mycncart
0
 public function category()
 {
     $this->load->language('extension/feed/google_base');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['text_loading'] = $this->language->get('text_loading');
     $data['column_google_category'] = $this->language->get('column_google_category');
     $data['column_category'] = $this->language->get('column_category');
     $data['column_action'] = $this->language->get('column_action');
     $data['button_remove'] = $this->language->get('button_remove');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['google_base_categories'] = array();
     $this->load->model('extension/feed/google_base');
     $results = $this->model_extension_feed_google_base->getCategories(($page - 1) * 10, 10);
     foreach ($results as $result) {
         $data['google_base_categories'][] = array('google_base_category_id' => $result['google_base_category_id'], 'google_base_category' => $result['google_base_category'], 'category_id' => $result['category_id'], 'category' => $result['category']);
     }
     $category_total = $this->model_extension_feed_google_base->getTotalCategories();
     $pagination = new Pagination();
     $pagination->total = $category_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('extension/feed/google_base/category', 'token=' . $this->session->data['token'] . '&page={page}', true);
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $category_total ? ($page - 1) * 10 + 1 : 0, ($page - 1) * 10 > $category_total - 10 ? $category_total : ($page - 1) * 10 + 10, $category_total, ceil($category_total / 10));
     $this->response->setOutput($this->load->view('extension/feed/google_base_category', $data));
 }
Example #7
Show file File: product.php Project: blogfor/pcu
0
 public function review()
 {
     $this->language->load('product/product');
     $this->load->model('catalog/review');
     $this->data['text_on'] = $this->language->get('text_on');
     $this->data['text_no_reviews'] = $this->language->get('text_no_reviews');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $this->data['reviews'] = array();
     $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
     $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
     foreach ($results as $result) {
         $this->data['reviews'][] = array('author' => $result['author'], 'text' => $result['text'], 'rating' => (int) $result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $review_total), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $pagination = new Pagination();
     $pagination->total = $review_total;
     $pagination->page = $page;
     $pagination->limit = 5;
     $pagination->text = $this->language->get('text_pagination');
     $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
     $this->data['pagination'] = $pagination->render();
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/product/review.tpl';
     } else {
         $this->template = 'default/template/product/review.tpl';
     }
     $this->response->setOutput($this->render());
 }
Example #8
Show file File: order.php Project: bcit-solutions/bcit-oc
0
 public function history()
 {
     $this->load->language('sale/order');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['column_date_added'] = $this->language->get('column_date_added');
     $data['column_status'] = $this->language->get('column_status');
     $data['column_notify'] = $this->language->get('column_notify');
     $data['column_comment'] = $this->language->get('column_comment');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['histories'] = array();
     $this->load->model('sale/order');
     $results = $this->model_sale_order->getOrderHistories($this->request->get['order_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $data['histories'][] = array('notify' => $result['notify'] ? $this->language->get('text_yes') : $this->language->get('text_no'), 'status' => $result['status'], 'comment' => nl2br($result['comment']), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $history_total = $this->model_sale_order->getTotalOrderHistories($this->request->get['order_id']);
     $pagination = new Pagination();
     $pagination->total = $history_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('sale/order/history', 'token=' . $this->session->data['token'] . '&order_id=' . $this->request->get['order_id'] . '&page={page}', 'SSL');
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $history_total ? ($page - 1) * 10 + 1 : 0, ($page - 1) * 10 > $history_total - 10 ? $history_total : ($page - 1) * 10 + 10, $history_total, ceil($history_total / 10));
     $this->response->setOutput($this->load->view('sale/order_history.tpl', $data));
 }
Example #9
Show file File: feeds.php Project: niiyatii/crowdmap
0
 /**
  * Displays all feeds.
  */
 public function index()
 {
     $this->template->header->this_page = Kohana::lang('ui_admin.feeds');
     $this->template->content = new View('feed/feeds');
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => ORM::factory('feed_item')->count_all()));
     $feeds = ORM::factory('feed_item')->orderby('item_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page'), $pagination->sql_offset);
     $this->template->content->feeds = $feeds;
     //Set default as not showing pagination. Will change below if necessary.
     $this->template->content->pagination = '';
     // Pagination and Total Num of Report Stats
     $plural = $pagination->total_items == 1 ? '' : 's';
     if ($pagination->total_items > 0) {
         $current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
         $total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
         if ($total_pages > 1) {
             // Paginate results
             $pagination_stats = Kohana::lang('ui_admin.showing_page') . ' ' . $current_page . ' ' . Kohana::lang('ui_admin.of') . ' ' . $total_pages . ' ' . Kohana::lang('ui_admin.pages');
             $this->template->content->pagination_stats = $pagination_stats;
             $this->template->content->pagination = $pagination;
         } else {
             // No pagination
             $this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.feeds');
         }
     } else {
         $this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.feeds');
     }
 }
Example #10
Show file File: product.php Project: Sharunya/v2.artstoneperm.ru
0
 public function review()
 {
     $this->load->language('product/product');
     $this->load->model('catalog/review');
     $data['text_no_reviews'] = $this->language->get('text_no_reviews');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['reviews'] = array();
     $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
     $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
     foreach ($results as $result) {
         $data['reviews'][] = array('author' => $result['author'], 'text' => nl2br($result['text']), 'rating' => (int) $result['rating'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $pagination = new Pagination();
     $pagination->total = $review_total;
     $pagination->page = $page;
     $pagination->limit = 5;
     $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $review_total ? ($page - 1) * 5 + 1 : 0, ($page - 1) * 5 > $review_total - 5 ? $review_total : ($page - 1) * 5 + 5, $review_total, ceil($review_total / 5));
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) {
         $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/review.tpl', $data));
     } else {
         $this->response->setOutput($this->load->view('default/template/product/review.tpl', $data));
     }
 }
Example #11
Show file File: PhotoController.php Project: sanmaowang/ycjl
0
 public function actionIndex()
 {
     $request = Yii::$app->request;
     $page_id = $request->get('page_id');
     $search = $request->get('search');
     $columns = Page::find()->where(['type' => 4])->all();
     if ($search) {
         $query = Photo::find()->where(['like', 'title', $search]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
         return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'post' => $post, 'columns' => $columns]);
     }
     if ($page_id) {
         $query = Photo::find()->where(['page_id' => $page_id, 'parent_id' => 0]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
     } else {
         $query = Photo::find()->where(['parent_id' => 0])->andWhere(['>', 'page_id', 1]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $photo = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
     }
     return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'photo' => $photo, 'columns' => $columns]);
 }
Example #12
Show file File: vq2-admin_controller_sale_coupon.php Project: blogfor/pci
0
 public function history()
 {
     $this->language->load('sale/coupon');
     $this->load->model('sale/coupon');
     $this->data['text_no_results'] = $this->language->get('text_no_results');
     $this->data['column_order_id'] = $this->language->get('column_order_id');
     $this->data['column_customer'] = $this->language->get('column_customer');
     $this->data['column_amount'] = $this->language->get('column_amount');
     $this->data['column_date_added'] = $this->language->get('column_date_added');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $this->data['histories'] = array();
     $results = $this->model_sale_coupon->getCouponHistories($this->request->get['coupon_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $this->data['histories'][] = array('order_id' => $result['order_id'], 'customer' => $result['customer'], 'amount' => $result['amount'], 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $history_total = $this->model_sale_coupon->getTotalCouponHistories($this->request->get['coupon_id']);
     $pagination = new Pagination();
     $pagination->total = $history_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('sale/coupon/history', 'token=' . $this->session->data['token'] . '&coupon_id=' . $this->request->get['coupon_id'] . '&page={page}', 'SSL');
     $this->data['pagination'] = $pagination->render();
     $this->template = 'sale/coupon_history.tpl';
     $this->response->setOutput($this->render());
 }
Example #13
Show file File: voucher.php Project: Tambralinga/drupal-opencart
0
 public function history()
 {
     $this->language->load('sale/voucher');
     $this->load->model('sale/voucher');
     $this->data['text_no_results'] = $this->language->get('text_no_results');
     $this->data['column_order_id'] = $this->language->get('column_order_id');
     $this->data['column_customer'] = $this->language->get('column_customer');
     $this->data['column_amount'] = $this->language->get('column_amount');
     $this->data['column_date_added'] = $this->language->get('column_date_added');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $this->data['histories'] = array();
     $results = $this->model_sale_voucher->getVoucherHistories($this->request->get['voucher_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $this->data['histories'][] = array('order_id' => $result['order_id'], 'customer' => $result['customer'], 'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency')), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $history_total = $this->model_sale_voucher->getTotalVoucherHistories($this->request->get['voucher_id']);
     $pagination = new Pagination();
     $pagination->total = $history_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('sale/voucher/history', 'token=' . $this->session->data['token'] . '&voucher_id=' . $this->request->get['voucher_id'] . '&page={page}', 'SSL');
     $this->data['pagination'] = $pagination->render();
     $this->template = 'sale/voucher_history.tpl';
     $this->response->setOutput($this->render());
 }
Example #14
Show file File: invoice.php Project: mehulsbhatt/Logic-Invoice
0
 public function history()
 {
     $json = $this->load->language('billing/invoice');
     $this->load->model('billing/invoice');
     if (isset($this->request->get['invoice_id'])) {
         if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validateHistory()) {
             $this->model_billing_invoice->addHistory((int) $this->request->get['invoice_id'], $this->request->post, true);
             $json['success'] = $this->language->get('text_success');
         }
         if (!isset($this->request->get['page'])) {
             $page = 1;
         } else {
             $page = (int) $this->request->get['page'];
         }
         $histories = $this->model_billing_invoice->getHistoriesByInvoice((int) $this->request->get['invoice_id'], ($page - 1) * $this->config->get('config_limit_admin'), $this->config->get('config_limit_admin'));
         $json['histories'] = array();
         foreach ($histories as $history) {
             $json['histories'][] = array('status' => $history['status'], 'comment' => $history['comment'], 'date_added' => date($this->language->get('datetime_format_short'), strtotime($history['date_added'])));
         }
         $pagination = new Pagination();
         $pagination->total = $this->model_billing_invoice->getTotalHistoriesByInvoice((int) $this->request->get['invoice_id']);
         $pagination->page = $page;
         $pagination->limit = $this->config->get('config_limit_admin');
         $pagination->url = '{page}';
         $json['pagination'] = $pagination->render();
         $invoice_info = $this->model_billing_invoice->getInvoice((int) $this->request->get['invoice_id']);
         $json['status_id'] = $invoice_info['status_id'];
         $this->load->model('system/status');
         $json['statuses'] = $this->model_system_status->getStatuses();
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
Example #15
Show file File: PaginationTest.php Project: shsrain/ypyzApi
0
 public function testTotalPages()
 {
     $pagination = new Pagination(10, 1, 2);
     $this->assertEquals(5, $pagination->totalPages());
     $pagination = new Pagination(11, 1, 3);
     $this->assertEquals(4, $pagination->totalPages());
 }
Example #16
Show file File: plugins_update.php Project: cls1991/ryzomcore
0
/**
 * function plugins_update to get
 * plugins updates from the Database using pagination object.
 *
 * @author shubham meena mentored by Matthew Lagoe
 */
function plugins_update()
{
    if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
        $pagination = new Pagination("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId", "lib", 5, "Plugincache");
        $pageResult['plug'] = Gui_Elements::make_table($pagination->getElements(), array("getId", "getPluginName", "getPluginInfo", "getUpdateInfo"), array("id", "plugin_name", "plugin_info", "update_info"));
        $pageResult['links'] = $pagination->getLinks(5);
        $pageResult['lastPage'] = $pagination->getLast();
        $pageResult['currentPage'] = $pagination->getCurrent();
        global $INGAME_WEBPATH;
        $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
        // check if shard is online
        try {
            $dbs = new DBLayer("shard");
            $pageResult['shard'] = "online";
        } catch (PDOException $e) {
            $pageResult['shard'] = "offline";
        }
        return $pageResult;
    } else {
        // ERROR: No access!
        $_SESSION['error_code'] = "403";
        header("Cache-Control: max-age=1");
        header("Location: index.php?page=error");
        throw new SystemExit();
    }
}
Example #17
Show file File: plugins.php Project: cls1991/ryzomcore
0
/**
 * function plugins to get
 * plugins from the Database using pagination object
 *
 * @author shubham meena mentored by Matthew Lagoe
 */
function plugins()
{
    if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
        $pagination = new Pagination("SELECT * FROM plugins", "lib", 5, "Plugincache");
        $pageResult['plug'] = Gui_Elements::make_table($pagination->getElements(), array("getId", "getPluginName", "getPluginType", "getPluginPermission", "getPluginStatus", "getPluginInfo"), array("id", "plugin_name", "plugin_type", "plugin_permission", "plugin_status", "plugin_info"));
        $pageResult['links'] = $pagination->getLinks(5);
        $pageResult['lastPage'] = $pagination->getLast();
        $pageResult['currentPage'] = $pagination->getCurrent();
        global $INGAME_WEBPATH;
        $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
        // check if shard is online
        try {
            $dbs = new DBLayer("shard");
            $pageResult['shard'] = "online";
        } catch (PDOException $e) {
            $pageResult['shard'] = "offline";
        }
        return $pageResult;
    } else {
        // ERROR: No access!
        $_SESSION['error_code'] = "403";
        header("Cache-Control: max-age=1");
        header("Location: index.php?page=error");
        throw new SystemExit();
    }
}
Example #18
Show file File: PaginationTest.php Project: pierotofy/pierotofy.it
0
 function testPaginationView()
 {
     // 10 elementi, 10 per pagina (una sola pagina, quindi paginatore e' vuoto)
     $p = new Pagination(10, 10, 1);
     $view = new ViewBuilder("pagination/default.html", array('current_page' => 1, 'pages' => array(array('page' => 1, 'link' => '1'))));
     $this->assertTrue("" == $p->getNavigator("default.html", "#PAGE#"));
     // 11 elementi, 10 per pagina (pagina 1)
     $p = new Pagination(11, 10, 1);
     $view = new ViewBuilder("pagination/default.html", array('current_page' => 1, 'pages' => array(array('page' => 1, 'link' => '1'), array('page' => 2, 'link' => '2'))));
     $this->assertTrue($view->render() == $p->getNavigator("default.html", "#PAGE#"));
     // 11 elementi, 10 per pagina (pagina 2)
     $p = new Pagination(11, 10, 2);
     $view = new ViewBuilder("pagination/default.html", array('current_page' => 2, 'pages' => array(array('page' => 1, 'link' => '1'), array('page' => 2, 'link' => '2'))));
     $this->assertTrue($view->render() == $p->getNavigator("default.html", "#PAGE#"));
 }
Example #19
Show file File: PostController.php Project: sanmaowang/ycjl
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $request = Yii::$app->request;
     $page_id = $request->get('page_id');
     $search = $request->get('search');
     $columns = Page::find()->where(['type' => 3])->all();
     if ($search) {
         $query = Post::find()->where(['like', 'name', $search])->orWhere(['like', 'content', $search]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $post = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
         return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'post' => $post, 'columns' => $columns]);
     }
     if ($page_id) {
         $query = Post::find()->where(['page_id' => $page_id]);
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $post = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
     } else {
         $query = Post::find();
         $countQuery = clone $query;
         $pnation = new Pagination(['defaultPageSize' => 10, 'totalCount' => $countQuery->count()]);
         $post = $query->orderBy(['create_date' => SORT_DESC])->offset($pnation->offset)->limit($pnation->limit)->all();
     }
     return $this->render('index', ['page_id' => $page_id, 'pnation' => $pnation, 'post' => $post, 'columns' => $columns]);
 }
Example #20
Show file File: voucher.php Project: mirzavu/clothfarm
0
 public function history()
 {
     $this->load->language('sale/voucher');
     $this->load->model('sale/voucher');
     $data['text_no_results'] = $this->language->get('text_no_results');
     $data['column_order_id'] = $this->language->get('column_order_id');
     $data['column_customer'] = $this->language->get('column_customer');
     $data['column_amount'] = $this->language->get('column_amount');
     $data['column_date_added'] = $this->language->get('column_date_added');
     if (isset($this->request->get['page'])) {
         $page = $this->request->get['page'];
     } else {
         $page = 1;
     }
     $data['histories'] = array();
     $results = $this->model_sale_voucher->getVoucherHistories($this->request->get['voucher_id'], ($page - 1) * 10, 10);
     foreach ($results as $result) {
         $data['histories'][] = array('order_id' => $result['order_id'], 'customer' => $result['customer'], 'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency')), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])));
     }
     $history_total = $this->model_sale_voucher->getTotalVoucherHistories($this->request->get['voucher_id']);
     $pagination = new Pagination();
     $pagination->total = $history_total;
     $pagination->page = $page;
     $pagination->limit = 10;
     $pagination->url = $this->url->link('sale/voucher/history', 'token=' . $this->session->data['mtoken'] . '&voucher_id=' . $this->request->get['voucher_id'] . '&page={page}', 'SSL');
     $data['pagination'] = $pagination->render();
     $data['results'] = sprintf($this->language->get('text_pagination'), $history_total ? ($page - 1) * 10 + 1 : 0, ($page - 1) * 10 > $history_total - 10 ? $history_total : ($page - 1) * 10 + 10, $history_total, ceil($history_total / 10));
     $this->response->setOutput($this->load->view('sale/voucher_history.tpl', $data));
 }