| 13637 |
anikendra |
1 |
<?php
|
|
|
2 |
App::uses('AppController', 'Controller');
|
|
|
3 |
/**
|
|
|
4 |
* Skuschemes Controller
|
|
|
5 |
*
|
|
|
6 |
* @property Skuscheme $Skuscheme
|
|
|
7 |
* @property PaginatorComponent $Paginator
|
|
|
8 |
*/
|
|
|
9 |
class SkuschemesController extends AppController {
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Components
|
|
|
13 |
*
|
|
|
14 |
* @var array
|
|
|
15 |
*/
|
|
|
16 |
public $components = array('Paginator');
|
|
|
17 |
|
|
|
18 |
public $apihost;
|
|
|
19 |
|
|
|
20 |
public function beforeFilter() {
|
|
|
21 |
parent::beforeFilter();
|
| 13946 |
anikendra |
22 |
// Configure::load('live');
|
| 13637 |
anikendra |
23 |
$this->apihost = Configure::read('pythonapihost');
|
|
|
24 |
}
|
|
|
25 |
/**
|
|
|
26 |
* admin_index method
|
|
|
27 |
*
|
|
|
28 |
* @return void
|
|
|
29 |
*/
|
|
|
30 |
public function admin_index() {
|
| 14098 |
anikendra |
31 |
$page = $this->request->query('page');
|
|
|
32 |
if(!isset($page)){
|
|
|
33 |
$page = 1;
|
|
|
34 |
}
|
|
|
35 |
$limit = Configure::read('admindashboardlimit');
|
|
|
36 |
$offset = ($page - 1)*$limit;
|
|
|
37 |
$url = $this->apihost."discountInfo/getAllSkuSchemeDetails/?limit=$limit&offset=$offset";
|
| 13637 |
anikendra |
38 |
$response = $this->make_request($url,null);
|
|
|
39 |
$this->set('skuschemes',$response);
|
| 14098 |
anikendra |
40 |
$this->set('page',$page);
|
| 13637 |
anikendra |
41 |
// $this->Skuscheme->recursive = 0;
|
|
|
42 |
// $this->set('skuschemes', $this->Paginator->paginate());
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* admin_view method
|
|
|
47 |
*
|
|
|
48 |
* @throws NotFoundException
|
|
|
49 |
* @param string $id
|
|
|
50 |
* @return void
|
|
|
51 |
*/
|
| 14517 |
anikendra |
52 |
public function admin_search() {
|
|
|
53 |
$type = $this->request->query('type');
|
|
|
54 |
$search = $this->request->query('search');
|
|
|
55 |
$url = $this->apihost."Catalog/searchProducts/?class=SkuSchemeDetails&$type=$search";
|
|
|
56 |
$response = $this->make_request($url,null);
|
|
|
57 |
$this->set('skuschemes', $response);
|
|
|
58 |
$this->set('page',1);
|
|
|
59 |
$this->render('admin_index');
|
| 13637 |
anikendra |
60 |
}
|
|
|
61 |
|
| 14517 |
anikendra |
62 |
public function admin_searchdp() {
|
|
|
63 |
$type = $this->request->query('type');
|
|
|
64 |
$search = $this->request->query('search');
|
|
|
65 |
$url = $this->apihost."Catalog/searchProducts/?class=SkuDealerPrices&$type=$search";
|
|
|
66 |
$response = $this->make_request($url,null);
|
|
|
67 |
$this->set('dealerprices', $response);
|
|
|
68 |
$this->set('page',1);
|
|
|
69 |
$this->render('admin_dp');
|
|
|
70 |
}
|
|
|
71 |
|
| 13637 |
anikendra |
72 |
/**
|
|
|
73 |
* admin_add method
|
|
|
74 |
*
|
|
|
75 |
* @return void
|
|
|
76 |
*/
|
|
|
77 |
public function admin_add() {
|
|
|
78 |
if ($this->request->is('post')) {
|
| 13646 |
anikendra |
79 |
$data = $this->request->data['Skuscheme'];
|
| 13637 |
anikendra |
80 |
$url = $this->apihost."discountInfo/addSkuSchemeDetails";
|
| 14561 |
anikendra |
81 |
$url = $this->generateMultiUrl($url,$data);
|
| 13646 |
anikendra |
82 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
| 13637 |
anikendra |
83 |
$response = $this->make_request($url,$jsonVar);
|
|
|
84 |
if (key($response)) {
|
|
|
85 |
$this->Session->setFlash(current($response));
|
|
|
86 |
return $this->redirect(array('action' => 'index'));
|
|
|
87 |
} else {
|
|
|
88 |
$this->Session->setFlash(current($response));
|
| 13646 |
anikendra |
89 |
}
|
| 13637 |
anikendra |
90 |
}
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* admin_edit method
|
|
|
95 |
*
|
|
|
96 |
* @throws NotFoundException
|
|
|
97 |
* @param string $id
|
|
|
98 |
* @return void
|
|
|
99 |
*/
|
|
|
100 |
public function admin_edit($id = null) {
|
|
|
101 |
if (!$this->Skuscheme->exists($id)) {
|
|
|
102 |
throw new NotFoundException(__('Invalid skuscheme'));
|
|
|
103 |
}
|
|
|
104 |
if ($this->request->is(array('post', 'put'))) {
|
|
|
105 |
if ($this->Skuscheme->save($this->request->data)) {
|
|
|
106 |
$this->Session->setFlash(__('The skuscheme has been saved.'));
|
|
|
107 |
return $this->redirect(array('action' => 'index'));
|
|
|
108 |
} else {
|
|
|
109 |
$this->Session->setFlash(__('The skuscheme could not be saved. Please, try again.'));
|
|
|
110 |
}
|
|
|
111 |
} else {
|
|
|
112 |
$options = array('conditions' => array('Skuscheme.' . $this->Skuscheme->primaryKey => $id));
|
|
|
113 |
$this->request->data = $this->Skuscheme->find('first', $options);
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* admin_delete method
|
|
|
119 |
*
|
|
|
120 |
* @throws NotFoundException
|
|
|
121 |
* @param string $id
|
|
|
122 |
* @return void
|
|
|
123 |
*/
|
| 14517 |
anikendra |
124 |
public function admin_delete($id = null) {
|
|
|
125 |
if ($this->remove($id,'SkuSchemeDetails')) {
|
|
|
126 |
$this->Session->setFlash(__('The sku scheme deal has been deleted.'));
|
|
|
127 |
} else {
|
|
|
128 |
$this->Session->setFlash(__('The sku scheme could not be deleted. Please, try again.'));
|
| 13637 |
anikendra |
129 |
}
|
| 14517 |
anikendra |
130 |
return $this->redirect(array('action' => 'index'));
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
public function admin_deletedp($id = null) {
|
| 15848 |
anikendra |
134 |
$response = $this->remove($id,'SkuDealerPrices');
|
|
|
135 |
if ($response) {
|
|
|
136 |
$this->Session->setFlash(current($response));
|
| 13637 |
anikendra |
137 |
} else {
|
| 15848 |
anikendra |
138 |
$this->Session->setFlash(current($response));
|
| 13637 |
anikendra |
139 |
}
|
| 15848 |
anikendra |
140 |
return $this->redirect(array('action' => 'admin_dp'));
|
| 14099 |
anikendra |
141 |
}
|
| 14517 |
anikendra |
142 |
|
| 14099 |
anikendra |
143 |
public function admin_dp(){
|
|
|
144 |
$page = $this->request->query('page');
|
|
|
145 |
if(!isset($page)){
|
|
|
146 |
$page = 1;
|
|
|
147 |
}
|
|
|
148 |
$limit = Configure::read('admindashboardlimit');
|
|
|
149 |
$offset = ($page - 1)*$limit;
|
|
|
150 |
$url = $this->apihost."dealerPrices/getAllDealerPrice/?limit=$limit&offset=$offset";
|
|
|
151 |
$response = $this->make_request($url,null);
|
|
|
152 |
$this->set('dealerprices',$response);
|
|
|
153 |
$this->set('page',$page);
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
public function admin_adddp() {
|
|
|
157 |
if ($this->request->is('post')) {
|
|
|
158 |
$data = $this->request->data['Skuscheme'];
|
|
|
159 |
$url = $this->apihost."dealerPrices/addDealerPrice";
|
| 14561 |
anikendra |
160 |
$url = $this->generateMultiUrl($url,$data);
|
| 14099 |
anikendra |
161 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
|
|
162 |
$response = $this->make_request($url,$jsonVar);
|
|
|
163 |
if (key($response)) {
|
|
|
164 |
$this->Session->setFlash(current($response));
|
|
|
165 |
return $this->redirect(array('action' => 'admin_dp'));
|
|
|
166 |
} else {
|
|
|
167 |
$this->Session->setFlash(current($response));
|
|
|
168 |
}
|
|
|
169 |
}
|
| 16234 |
anikendra |
170 |
$showDps = array(0=>'No',1=>'Yes');
|
|
|
171 |
$this->set(compact('showDps'));
|
| 14099 |
anikendra |
172 |
}
|
|
|
173 |
}
|