| 14098 |
anikendra |
1 |
<?php
|
|
|
2 |
App::uses('AppController', 'Controller');
|
|
|
3 |
/**
|
|
|
4 |
* Exceptionalnlcs Controller
|
|
|
5 |
*
|
|
|
6 |
* @property Exceptionalnlc $Exceptionalnlc
|
|
|
7 |
* @property PaginatorComponent $Paginator
|
|
|
8 |
*/
|
|
|
9 |
class MasterDatasController 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 |
public function admin_index() {
|
| 14539 |
anikendra |
25 |
/*$page = $this->request->query('page');
|
| 14098 |
anikendra |
26 |
if(!isset($page)){
|
|
|
27 |
$page = 1;
|
|
|
28 |
}
|
|
|
29 |
$limit = Configure::read('admindashboardlimit');
|
|
|
30 |
$params = array(
|
|
|
31 |
'fields' => array('_id','brand','source_product_name', 'available_price', 'thumbnail','category','category_id','in_stock','marketPlaceUrl','mrp','rank','source_id','source_product_name','url'),
|
|
|
32 |
'conditions' => array('source_id' => array('$ne' => 0)),
|
|
|
33 |
'order' => array('_id' => -1),
|
|
|
34 |
'limit' => $limit,
|
|
|
35 |
'page' => $page,
|
|
|
36 |
);
|
|
|
37 |
$masterdata = $this->MasterData->find('all', $params);
|
|
|
38 |
$this->loadModel('Category');
|
|
|
39 |
$categories = $this->Category->find('list');
|
|
|
40 |
$storemapping = Configure::read('storemapping');
|
| 14539 |
anikendra |
41 |
$this->set(compact('masterdata','categories','page','storemapping'));*/
|
|
|
42 |
$page = $this->request->query('page');
|
|
|
43 |
if(!isset($page)){
|
|
|
44 |
$page = 1;
|
|
|
45 |
}
|
|
|
46 |
$limit = Configure::read('admindashboardlimit');
|
|
|
47 |
$offset = ($page - 1)*$limit;
|
|
|
48 |
$search = '';
|
|
|
49 |
$url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
|
|
|
50 |
$response = $this->make_request($url,null);
|
|
|
51 |
$storemapping = Configure::read('storemapping');
|
|
|
52 |
$this->set('masterdata', $response);
|
|
|
53 |
$this->set(compact('page','search','storemapping'));
|
| 14098 |
anikendra |
54 |
}
|
|
|
55 |
|
| 15039 |
manas |
56 |
public function admin_show($id=null){
|
|
|
57 |
$limit = 10;
|
|
|
58 |
$page = 1;
|
|
|
59 |
$params = array(
|
|
|
60 |
'fields' => array('_id','brand','source_product_name', 'available_price', 'thumbnail','category','category_id','in_stock','marketPlaceUrl','mrp','rank','source_id','source_product_name','url'),
|
|
|
61 |
'conditions' => array('source_id' => array('$ne' => 0)),
|
|
|
62 |
'order' => array('_id' => -1),
|
|
|
63 |
'limit' => $limit,
|
|
|
64 |
'page' => $page,
|
|
|
65 |
);
|
|
|
66 |
$masterdata = $this->MasterData->find('all', $params);
|
|
|
67 |
$this->set(compact('masterdata'));
|
|
|
68 |
}
|
| 14098 |
anikendra |
69 |
public function admin_edit($id = null) {
|
|
|
70 |
$id = (integer) $id;
|
|
|
71 |
if (!$id && empty($this->data)) {
|
|
|
72 |
$this->flash(__('Invalid Post', true), array('action' => 'index'));
|
|
|
73 |
}
|
|
|
74 |
if (!empty($this->data)) {
|
|
|
75 |
if ($this->MasterData->save($this->data)) {
|
|
|
76 |
$this->flash(__('The data has been saved.', true), array('action' => 'index'));
|
|
|
77 |
} else {
|
|
|
78 |
}
|
|
|
79 |
}
|
|
|
80 |
if (empty($this->data)) {
|
|
|
81 |
$this->data = $this->MasterData->read(null, $id);
|
|
|
82 |
debug($this->data);
|
|
|
83 |
}
|
|
|
84 |
}
|
| 14509 |
anikendra |
85 |
|
| 14600 |
anikendra |
86 |
public function admin_add() {
|
|
|
87 |
if ($this->request->is('post')) {
|
|
|
88 |
$this->log(print_r($this->request->data,1),'masterdatas');
|
|
|
89 |
$url = $this->apihost."masterData/addOrUpdateMaster/?addNew=1";
|
|
|
90 |
$data = $this->request->data['MasterData'];
|
|
|
91 |
$url = $this->generateMultiUrl($url,$data);
|
|
|
92 |
$data['identifier'] = (string)$data['identifier'];
|
|
|
93 |
$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
|
|
|
94 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
|
|
95 |
$response = $this->make_request($url,$jsonVar);
|
|
|
96 |
if (key($response)) {
|
|
|
97 |
$this->Session->setFlash(current($response));
|
|
|
98 |
return $this->redirect(array('action' => 'search'));
|
|
|
99 |
} else {
|
|
|
100 |
$this->Session->setFlash(current($response));
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
$sources = Configure::read('storemapping');
|
|
|
104 |
$sources[0] = 'Other';
|
|
|
105 |
// $this->set('sources',$sources);
|
|
|
106 |
// $this->set('source_ids',Configure::read('storemapping'));
|
|
|
107 |
$this->set('categories',Configure::read('Categories'));
|
|
|
108 |
$stock_statuses = array(0=>'OOS',1=>'In Stock');
|
|
|
109 |
$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
|
|
|
110 |
$shortage_status = array(0=>'No',1=>'Yes');
|
| 15250 |
anikendra |
111 |
$buyBoxFlag = array(1 => 'Yes', 0 => 'No');
|
| 18798 |
naman |
112 |
$arrSubCategory = Configure::read('arrSubCategory');
|
|
|
113 |
$this->set(compact('stock_statuses','statuses','sources','shortage_status','buyBoxFlag','arrSubCategory'));
|
| 14600 |
anikendra |
114 |
}
|
|
|
115 |
|
|
|
116 |
public function admin_addtoexisting() {
|
|
|
117 |
if ($this->request->is('post')) {
|
|
|
118 |
$this->log(print_r($this->request->data,1),'masterdatas');
|
|
|
119 |
$url = $this->apihost."masterData/addOrUpdateMaster/?addToExisting=1";
|
|
|
120 |
$data = $this->request->data['MasterData'];
|
|
|
121 |
$url = $this->generateMultiUrl($url,$data);
|
|
|
122 |
$data['identifier'] = (string)$data['identifier'];
|
|
|
123 |
$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
|
|
|
124 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
|
|
125 |
$response = $this->make_request($url,$jsonVar);
|
|
|
126 |
if (key($response)) {
|
|
|
127 |
$this->Session->setFlash(current($response));
|
|
|
128 |
return $this->redirect(array('action' => 'search'));
|
|
|
129 |
} else {
|
|
|
130 |
$this->Session->setFlash(current($response));
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
$sources = Configure::read('storemapping');
|
|
|
134 |
$sources[0] = 'Other';
|
|
|
135 |
// $this->set('sources',$sources);
|
|
|
136 |
// $this->set('source_ids',Configure::read('storemapping'));
|
|
|
137 |
$this->set('categories',Configure::read('Categories'));
|
|
|
138 |
$stock_statuses = array(0=>'OOS',1=>'In Stock');
|
|
|
139 |
$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
|
|
|
140 |
$shortage_status = array(0=>'No',1=>'Yes');
|
| 15250 |
anikendra |
141 |
$buyBoxFlag = array(1 => 'Yes', 0 => 'No');
|
| 18798 |
naman |
142 |
$arrSubCategory = Configure::read('arrSubCategory');
|
|
|
143 |
$this->set(compact('stock_statuses','statuses','sources','shortage_status','buyBoxFlag','arrSubCategory'));
|
| 14600 |
anikendra |
144 |
}
|
|
|
145 |
|
|
|
146 |
public function admin_update($id) {
|
|
|
147 |
if ($this->request->is('post')) {
|
|
|
148 |
$this->log(print_r($this->request->data,1),'masterdatas');
|
|
|
149 |
$url = $this->apihost."masterData/addOrUpdateMaster/?update=1";
|
|
|
150 |
$data = $this->request->data['MasterData'];
|
|
|
151 |
if(isset($data['multi']) && !empty($data['multi'])){
|
|
|
152 |
$url .= '&multi=1';
|
|
|
153 |
unset($data['multi']);
|
|
|
154 |
}
|
|
|
155 |
$url = $this->generateMultiUrl($url,$data);
|
|
|
156 |
$data['identifier'] = (string)$data['identifier'];
|
|
|
157 |
$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
|
|
|
158 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
|
|
159 |
$response = $this->make_request($url,$jsonVar);
|
|
|
160 |
if (key($response)) {
|
|
|
161 |
$this->Session->setFlash(current($response));
|
|
|
162 |
return $this->redirect(array('action' => 'search'));
|
|
|
163 |
} else {
|
|
|
164 |
$this->Session->setFlash(current($response));
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
$url = $this->apihost."masterData/getSkuById/$id";
|
|
|
168 |
$temp = $this->make_request($url,null);
|
|
|
169 |
$data = json_decode($temp[0],1);
|
|
|
170 |
$sources = Configure::read('storemapping');
|
|
|
171 |
$sources[0] = 'Other';
|
|
|
172 |
// $this->set('sources',$sources);
|
|
|
173 |
// $this->set('source_ids',Configure::read('storemapping'));
|
|
|
174 |
$this->set('categories',Configure::read('Categories'));
|
|
|
175 |
$stock_statuses = array(0=>'OOS',1=>'In Stock');
|
|
|
176 |
$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
|
|
|
177 |
$shortage_status = array(0=>'No',1=>'Yes');
|
| 15250 |
anikendra |
178 |
$buyBoxFlag = array(1 => 'Yes', 0 => 'No');
|
| 18798 |
naman |
179 |
$arrSubCategory = Configure::read('arrSubCategory');
|
|
|
180 |
$this->set(compact('stock_statuses','statuses','sources','shortage_status','data','buyBoxFlag','arrSubCategory'));
|
| 14600 |
anikendra |
181 |
}
|
|
|
182 |
|
| 14509 |
anikendra |
183 |
public function admin_search(){
|
|
|
184 |
$page = $this->request->query('page');
|
|
|
185 |
if(!isset($page)){
|
|
|
186 |
$page = 1;
|
|
|
187 |
}
|
|
|
188 |
$limit = Configure::read('admindashboardlimit');
|
|
|
189 |
$offset = ($page - 1)*$limit;
|
|
|
190 |
$search = urlencode($this->request->query('search'));
|
|
|
191 |
$url = $this->apihost."Catalog/searchMaster/?search=$search&limit=$limit&offset=$offset";
|
|
|
192 |
$response = $this->make_request($url,null);
|
| 14517 |
anikendra |
193 |
$storemapping = Configure::read('storemapping');
|
| 14509 |
anikendra |
194 |
$this->set('masterdata', $response);
|
| 14517 |
anikendra |
195 |
$this->set(compact('page','search','storemapping'));
|
| 14509 |
anikendra |
196 |
}
|
| 15077 |
anikendra |
197 |
|
|
|
198 |
public function admin_autoupdates(){
|
|
|
199 |
$page = $this->request->query('page');
|
|
|
200 |
if(!isset($page)){
|
|
|
201 |
$page = 1;
|
|
|
202 |
}
|
|
|
203 |
$limit = Configure::read('admindashboardlimit');
|
|
|
204 |
$offset = ($page - 1)*$limit;
|
|
|
205 |
$search = urlencode($this->request->query('search'));
|
|
|
206 |
if(!empty($search)){
|
|
|
207 |
$type = $this->request->query('type');
|
|
|
208 |
$url = $this->apihost."Catalog/searchProducts/?class=Notifications&$type=$search";
|
|
|
209 |
}else{
|
|
|
210 |
$url = $this->apihost."Catalog/notification/?limit=$limit&offset=$offset";
|
|
|
211 |
}
|
|
|
212 |
$autoupdates = $this->make_request($url,null);
|
|
|
213 |
$this->set(compact('page','autoupdates'));
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
public function admin_scheduleupdate(){
|
|
|
217 |
if ($this->request->is('post')) {
|
|
|
218 |
$data = $this->request->data['MasterData'];
|
|
|
219 |
$this->log(print_r($data,1),'scheduleupdates');
|
|
|
220 |
$data['startDate'] = mktime($data['startDate']['hour'],$data['startDate']['min'],0,$data['startDate']['month'],$data['startDate']['day'],$data['startDate']['year'])*1000;
|
|
|
221 |
$data['endDate'] = mktime($data['endDate']['hour'],$data['endDate']['min'],0,$data['endDate']['month'],$data['endDate']['day'],$data['endDate']['year'])*1000;
|
|
|
222 |
$url = $this->apihost."Catalog/notification";
|
|
|
223 |
$url = $this->generateMultiUrl($url,$data);
|
|
|
224 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
|
|
225 |
$response = $this->make_request($url,$jsonVar);
|
|
|
226 |
if (key($response)) {
|
|
|
227 |
$this->Session->setFlash(current($response));
|
|
|
228 |
return $this->redirect(array('action' => 'autoupdates'));
|
|
|
229 |
} else {
|
|
|
230 |
$this->Session->setFlash(current($response));
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
public function admin_editscheduledupdate($id,$skuBundleId,$model,$brand,$startDate,$endDate){
|
|
|
236 |
if ($this->request->is('post')) {
|
|
|
237 |
$data = $this->request->data['MasterData'];
|
|
|
238 |
$this->log(print_r($data,1),'scheduleupdates');
|
|
|
239 |
$data['startDate'] = mktime($data['startDate']['hour'],$data['startDate']['min'],0,$data['startDate']['month'],$data['startDate']['day'],$data['startDate']['year'])*1000;
|
|
|
240 |
$data['endDate'] = mktime($data['endDate']['hour'],$data['endDate']['min'],0,$data['endDate']['month'],$data['endDate']['day'],$data['endDate']['year'])*1000;
|
|
|
241 |
// debug($data);die;
|
|
|
242 |
$url = $this->apihost."Catalog/updateCollection";
|
|
|
243 |
$data1 = $data2 = $data;
|
|
|
244 |
$data1['class'] = 'Notifications';
|
|
|
245 |
unset($data1['endDate']);
|
|
|
246 |
$data2['class'] = 'Notifications';
|
|
|
247 |
unset($data2['startDate']);
|
|
|
248 |
$jsonVar = json_encode($data1, JSON_NUMERIC_CHECK );
|
|
|
249 |
$response = $this->make_request($url,$jsonVar);
|
|
|
250 |
$jsonVar = json_encode($data2, JSON_NUMERIC_CHECK );
|
|
|
251 |
$response = $this->make_request($url,$jsonVar);
|
|
|
252 |
if (key($response)) {
|
|
|
253 |
// $this->Session->setFlash(current($response));
|
|
|
254 |
return $this->redirect(array('action' => 'autoupdates'));
|
|
|
255 |
} else {
|
|
|
256 |
$this->Session->setFlash(current($response));
|
|
|
257 |
}
|
|
|
258 |
}
|
|
|
259 |
$this->set(compact('id','skuBundleId','brand','model','startDate','endDate'));
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
public function admin_deletescheduledupdate($id){
|
|
|
263 |
if ($this->remove($id,'Notifications')) {
|
|
|
264 |
$this->Session->setFlash(__('The sku scheme deal has been deleted.'));
|
|
|
265 |
} else {
|
|
|
266 |
$this->Session->setFlash(__('The sku scheme could not be deleted. Please, try again.'));
|
|
|
267 |
}
|
|
|
268 |
return $this->redirect(array('action' => 'autoupdates'));
|
|
|
269 |
}
|
| 14098 |
anikendra |
270 |
}
|