| 17630 |
naman |
1 |
<?php
|
|
|
2 |
App::uses('AppController', 'Controller');
|
|
|
3 |
/**
|
|
|
4 |
* Exceptionalnlcs Controller
|
|
|
5 |
*
|
|
|
6 |
* @property Exceptionalnlc $Exceptionalnlc
|
|
|
7 |
* @property PaginatorComponent $Paginator
|
|
|
8 |
*/
|
|
|
9 |
class DealobjectsController extends AppController {
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Components
|
|
|
13 |
*
|
|
|
14 |
* @var array
|
|
|
15 |
*/
|
|
|
16 |
public $components = array('Paginator');
|
|
|
17 |
|
|
|
18 |
public function beforeFilter() {
|
|
|
19 |
parent::beforeFilter();
|
|
|
20 |
// Configure::load('live');
|
|
|
21 |
$this->apihost = Configure::read('pythonapihost');
|
|
|
22 |
}
|
|
|
23 |
/**
|
|
|
24 |
* admin_index method
|
|
|
25 |
*
|
|
|
26 |
* @return void
|
|
|
27 |
*/
|
|
|
28 |
public function admin_index() {
|
|
|
29 |
$page = $this->request->query('page');
|
|
|
30 |
if(!isset($page)){
|
|
|
31 |
$page = 1;
|
|
|
32 |
}
|
|
|
33 |
$limit = Configure::read('admindashboardlimit');
|
|
|
34 |
$offset = ($page - 1)*$limit;
|
|
|
35 |
$url = $this->apihost."featuredDeals/getAllFeaturedDealObject/?limit=$limit&offset=$offset";
|
|
|
36 |
$response = $this->make_request($url,null);
|
|
|
37 |
$this->set('dealobjects', $response);
|
|
|
38 |
$this->set('page',$page);
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* admin_view method
|
|
|
43 |
*
|
|
|
44 |
* @throws NotFoundException
|
|
|
45 |
* @param string $id
|
|
|
46 |
* @return void
|
|
|
47 |
*/
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* admin_add method
|
|
|
52 |
*
|
|
|
53 |
* @return void
|
|
|
54 |
*/
|
|
|
55 |
public function admin_add() {
|
|
|
56 |
if ($this->request->is('post')) {
|
|
|
57 |
// date_default_timezone_set('UTC');
|
|
|
58 |
$otherrank = array();
|
|
|
59 |
$othercat = array();
|
|
|
60 |
$othercat['mobilerank'] = $this->request->data['Dealobjects']['Mobiles'];
|
|
|
61 |
$othercat['tabletrank'] = $this->request->data['Dealobjects']['Tablets'];
|
|
|
62 |
$othercat['accessrank'] = $this->request->data['Dealobjects']['Accessories'];
|
|
|
63 |
$rankandcat['3'] = $othercat['mobilerank'];
|
|
|
64 |
$rankandcat['5'] = $othercat['tabletrank'];
|
|
|
65 |
$rankandcat['6'] = $othercat['accessrank'];
|
|
|
66 |
$this->request->data['Dealobjects']['startDate'] = 1000*mktime($this->request->data['Dealobjects']['startDate']['hour'],$this->request->data['Dealobjects']['startDate']['min'],0,$this->request->data['Dealobjects']['startDate']['month'],$this->request->data['Dealobjects']['startDate']['day'],$this->request->data['Dealobjects']['startDate']['year']);
|
|
|
67 |
$this->request->data['Dealobjects']['endDate'] = 1000*mktime($this->request->data['Dealobjects']['endDate']['hour'],$this->request->data['Dealobjects']['endDate']['min'],0,$this->request->data['Dealobjects']['endDate']['month'],$this->request->data['Dealobjects']['endDate']['day'],$this->request->data['Dealobjects']['endDate']['year']);
|
|
|
68 |
$form_val = array();
|
|
|
69 |
$form_val['_id'] = $this->request->data['Dealobjects']['id'];
|
|
|
70 |
|
|
|
71 |
$form_val['startDate'] = $this->request->data['Dealobjects']['startDate'];
|
|
|
72 |
$form_val['endDate'] = $this->request->data['Dealobjects']['endDate'];
|
|
|
73 |
$form_val['otherInfo'] = $rankandcat;
|
| 19281 |
manas |
74 |
$form_val['offer_id'] = $this->request->data['Dealobjects']['OfferId'];
|
| 17630 |
naman |
75 |
$url = $this->apihost."featuredDeals/addFeaturedDealObject";
|
|
|
76 |
$response = $this->make_request($url,json_encode($form_val,JSON_NUMERIC_CHECK));
|
|
|
77 |
if (key($response)) {
|
|
|
78 |
$this->Session->setFlash(current($response));
|
|
|
79 |
return $this->redirect(array('action' => 'index'));
|
|
|
80 |
} else {
|
|
|
81 |
$this->Session->setFlash(current($response));
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
/**
|
|
|
88 |
* admin_delete method
|
|
|
89 |
*
|
|
|
90 |
* @throws NotFoundException
|
|
|
91 |
* @param string $id
|
|
|
92 |
* @return void
|
|
|
93 |
*/
|
|
|
94 |
|
|
|
95 |
public function admin_delete($id = null) {
|
|
|
96 |
$url = $this->apihost."deleteFeaturedDealObject/".$id;
|
|
|
97 |
$response = $this->make_request($url,null);
|
|
|
98 |
if (key($response)) {
|
|
|
99 |
$this->Session->setFlash(current($response));
|
|
|
100 |
return $this->redirect(array('action' => 'index'));
|
|
|
101 |
} else {
|
|
|
102 |
$this->Session->setFlash(current($response));
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
}
|