Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="table table-hover">
- <thead>
- <tr>
- <th scope="col">#</th>
- <th scope="col">Дата</th>
- <th scope="col">Способ доставки</th>
- <th scope="col">Способ оплаты</th>
- <th scope="col">Сумма заказа</th>
- <th scope="col">Статус</th>
- <th scope="col"></th>
- </tr>
- </thead>
- <tbody>
- [[!pdoPage?
- &element=`historyOrder`
- &chunk=`historyOrder`
- &chunk_product=`historyOrderProduct`
- &chunk_modal=`historyOrderModal`
- &limit=`10`
- &tplPageWrapper=`@INLINE <div class="pagination_prof"><ul class="pagination">[[+first]][[+prev]][[+pages]][[+next]][[+last]]</ul></div>`
- ]]
- </tbody>
- </table>
- [[!+page.nav]]
- <div class="modal" tabindex="-1" role="dialog" id="orderModal">
- <div class="modal-dialog md_pp" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">Состав заказа №<span class="orderNum"></span></h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- function historyOrder(id_order){
- $.ajax({
- url: "/cabinet/istoriya-zakazov?id="+id_order+"&ajax=1",
- type: 'GET',
- dataType: 'html',
- success: function (o) {
- $('.orderNum').html(id_order);
- $('#orderModal .modal-body').html(o);
- $('#orderModal').modal('show');
- }
- });
- }
- </script>
- -----------------------------
- <?php
- $totalVar=$modx->getOption('totalVar', $scriptProperties, 'total');
- $limit=$modx->getOption('limit', $scriptProperties, 10);
- $offset=$modx->getOption('offset', $scriptProperties, 0);
- $chunk= (empty($chunk))?'historyOrder':$chunk;
- $chunk_product= (empty($chunk_product))?'historyOrderProduct':$chunk_product;
- $chunk_modal= (empty($chunk_modal))?'historyOrderModal':$chunk_modal;
- $user = $modx->getUser();
- $userid=$user->get('id');
- if(!$userid)return;
- $modx->addPackage('shopkeeper3', $modx->getOption('core_path').'components/shopkeeper3/model/');
- $status=array('default','Новый','Принят к оплате',"Отправлен","Выполнен","Отменен","Оплата получена");
- if(!$_GET['ajax']){
- ##########
- //count page
- $q = $modx->newQuery('shk_order');
- $q->where(array(
- 'userid' => $userid
- ));
- $q->select(array(
- "count(*) as total"
- ));
- $s = $q->prepare();
- $s->execute();
- $rows = $s->fetchAll(PDO::FETCH_ASSOC);
- $modx->setPlaceholder($totalVar,$rows[0]['total']);//pdoPage
- ###########
- $q = $modx->newQuery('shk_order');
- $q->where(array(
- 'userid' => $userid
- ));
- $q->limit($limit, $offset);
- $q->sortby('id', 'DESC');
- $orders = $modx->getCollection('shk_order', $q);
- $item='';
- foreach ($orders as $p) {
- $item.=$modx->getChunk($chunk,array(
- 'id'=> $p->get('id'),
- 'price'=>$p->get('price'),
- 'date'=>$p->get('date'),
- 'delivery'=> $p->get('delivery'),
- 'payment'=> $p->get('payment'),
- 'status'=> $status[$p->get('status')],
- )
- );
- }
- }else{
- #########################################################################################################
- /*товар*/
- $id=(int)$_GET['id'];
- $order = $modx->getObject('shk_order', $id);
- $contacts=json_decode($order->get('contacts'),true);
- $contacts=array_column($contacts,'value','name');
- $item='';
- $purchases = $modx->getCollection('shk_purchases', array('order_id' => $id));
- $count=0;
- foreach ($purchases as $p) {
- // print_r( $p->toArray());
- $data=json_decode($p->get('data'),true);
- $options=json_decode($p->get('options'),true);
- $art=$data ['articul']?$data ['articul']:$options ['article'][0] ;
- $brand=$data ['brand']?$data ['brand']:$options ['brand'][0] ;
- $stock=$data ['stock']?$data ['stock']:$options ['stock'][0] ;
- $count+=$p->get('count');
- $item.=$modx->getChunk($chunk_product,array(
- 'name'=> $p->get('name'),
- 'price'=> $p->get('price'),
- 'count'=> $p->get('count'),
- 'art'=> $art,
- 'brand'=> $brand,
- 'stock'=> $stock,
- )
- );
- }
- echo $modx->getChunk($chunk_modal,array(
- 'order_id'=>$id,
- 'item'=>$item,
- 'price'=>$order->get('price'),
- 'count'=> $count,
- 'fullname'=>$contacts['fullname'],
- 'email'=>$order->get('email'),
- 'phone'=>$contacts['phone'],
- 'city'=>$contacts['city'],
- 'zip'=>$contacts['zip'],
- 'address'=>$contacts['address'],
- 'message'=>$contacts['message'],
- 'date'=>$order->get('date'),
- 'delivery'=>$order->get('delivery'),
- 'delivery_price'=>$order->get('delivery_price'),
- 'payment'=>$order->get('payment'),
- ));
- exit;
- }
- return $item;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement