| Line 47... |
Line 47... |
| 47 |
*/
|
47 |
*/
|
| 48 |
public function admin_search() {
|
48 |
public function admin_search() {
|
| 49 |
$type = $this->request->query('type');
|
49 |
$type = $this->request->query('type');
|
| 50 |
$search = $this->request->query('search');
|
50 |
$search = $this->request->query('search');
|
| 51 |
$url = $this->apihost."Catalog/searchProducts/?class=".Inflector::pluralize($this->name)."&$type=$search";
|
51 |
$url = $this->apihost."Catalog/searchProducts/?class=".Inflector::pluralize($this->name)."&$type=$search";
|
| - |
|
52 |
$url = $this->apihost."Catalog/searchProducts/?class=".Inflector::pluralize($this->name)."&$type=$search";
|
| - |
|
53 |
debug($url);
|
| 52 |
$response = $this->make_request($url,null);
|
54 |
$response = $this->make_request($url,null);
|
| 53 |
$this->set('featureddeals', $response);
|
55 |
$this->set('featureddeals', $response);
|
| 54 |
$this->set('page',1);
|
56 |
$this->set('page',1);
|
| 55 |
$this->render('admin_index');
|
57 |
$this->render('admin_index');
|
| 56 |
}
|
58 |
}
|
| Line 60... |
Line 62... |
| 60 |
*
|
62 |
*
|
| 61 |
* @return void
|
63 |
* @return void
|
| 62 |
*/
|
64 |
*/
|
| 63 |
public function admin_add() {
|
65 |
public function admin_add() {
|
| 64 |
if ($this->request->is('post')) {
|
66 |
if ($this->request->is('post')) {
|
| - |
|
67 |
// date_default_timezone_set('UTC');
|
| 65 |
$this->request->data['FeaturedDeal']['startDate'] = 1000*mktime($this->request->data['FeaturedDeal']['startDate']['hour'],$this->request->data['FeaturedDeal']['startDate']['min'],0,$this->request->data['FeaturedDeal']['startDate']['month'],$this->request->data['FeaturedDeal']['startDate']['day'],$this->request->data['FeaturedDeal']['startDate']['year']);
|
68 |
$this->request->data['FeaturedDeal']['startDate'] = 1000*mktime($this->request->data['FeaturedDeal']['startDate']['hour'],$this->request->data['FeaturedDeal']['startDate']['min'],0,$this->request->data['FeaturedDeal']['startDate']['month'],$this->request->data['FeaturedDeal']['startDate']['day'],$this->request->data['FeaturedDeal']['startDate']['year']);
|
| 66 |
$this->request->data['FeaturedDeal']['endDate'] = 1000*mktime($this->request->data['FeaturedDeal']['endDate']['hour'],$this->request->data['FeaturedDeal']['endDate']['min'],0,$this->request->data['FeaturedDeal']['endDate']['month'],$this->request->data['FeaturedDeal']['endDate']['day'],$this->request->data['FeaturedDeal']['endDate']['year']);
|
69 |
$this->request->data['FeaturedDeal']['endDate'] = 1000*mktime($this->request->data['FeaturedDeal']['endDate']['hour'],$this->request->data['FeaturedDeal']['endDate']['min'],0,$this->request->data['FeaturedDeal']['endDate']['month'],$this->request->data['FeaturedDeal']['endDate']['day'],$this->request->data['FeaturedDeal']['endDate']['year']);
|
| - |
|
70 |
// echo "startDate ", $this->request->data['FeaturedDeal']['startDate'];
|
| - |
|
71 |
// debug($this->request->data['FeaturedDeal']['startDate']);
|
| 67 |
// $this->request->data['FeaturedDeal']['rankDetails']= array($this->request->data['FeaturedDeal']['type'] => $this->request->data['FeaturedDeal']['rankDetails']);
|
72 |
// $this->request->data['FeaturedDeal']['rankDetails']= array($this->request->data['FeaturedDeal']['type'] => $this->request->data['FeaturedDeal']['rankDetails']);
|
| 68 |
// unset($this->request->data['FeaturedDeal']['rankDetails']);
|
73 |
//// unset($this->request->data['FeaturedDeal']['rankDetails']);
|
| - |
|
74 |
// $form_detail = array();
|
| - |
|
75 |
$form_val = array();
|
| 69 |
unset($this->request->data['FeaturedDeal']['type']);
|
76 |
$form_val['skuBundleId'] = $this->request->data['FeaturedDeal']['skuBundleId'];
|
| 70 |
foreach ($this->request->data['FeaturedDeal']['rankDetails'] as $key => $value) {
|
77 |
$form_val['rank'] = $this->request->data['FeaturedDeal']['rankDetails'][0];
|
| - |
|
78 |
$form_val['thresholdPrice'] = $this->request->data['FeaturedDeal']['thresholdPrice'];
|
| 71 |
if(empty($value)){
|
79 |
$form_val['startDate'] = $this->request->data['FeaturedDeal']['startDate'];
|
| 72 |
unset($this->request->data['FeaturedDeal']['rankDetails'][$key]);
|
80 |
$form_val['endDate'] = $this->request->data['FeaturedDeal']['endDate'];
|
| 73 |
}
|
81 |
|
| 74 |
}
|
82 |
|
| 75 |
$this->log(print_r($this->request->data,1),'featuredeals');
|
- |
|
| 76 |
$url = $this->apihost."featuredDeals/addFeaturedDeals";
|
83 |
$url = $this->apihost."featuredDeals/addFeaturedDeals";
|
| - |
|
84 |
$response = $this->make_request($url,json_encode($form_val,JSON_NUMERIC_CHECK));
|
| - |
|
85 |
|
| - |
|
86 |
// unset($this->request->data['FeaturedDeal']['type']);
|
| - |
|
87 |
// foreach ($this->request->data['FeaturedDeal']['rankDetails'] as $key => $value) {
|
| - |
|
88 |
// if(empty($value)){
|
| - |
|
89 |
// unset($this->request->data['FeaturedDeal']['rankDetails'][$key]);
|
| - |
|
90 |
// }
|
| - |
|
91 |
// }
|
| - |
|
92 |
// $this->log(print_r($this->request->data,1),'featuredeals');
|
| - |
|
93 |
// // $url = $this->apihost."featuredDeals/addFeaturedDeals";
|
| 77 |
$data = $this->request->data['FeaturedDeal'];
|
94 |
// // $data = $this->request->data['FeaturedDeal'];
|
| 78 |
$url = $this->generateMultiUrl($url,$data);
|
95 |
// // $url = $this->generateMultiUrl($url,$data);
|
| - |
|
96 |
// debug($url);
|
| 79 |
$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
97 |
// // $jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
|
| - |
|
98 |
// // $jsonVar = json_encode($form_val,JSON_NUMERIC_CHECK);
|
| 80 |
$response = $this->make_request($url,$jsonVar);
|
99 |
// // $response = $this->make_request($url,$jsonVar);
|
| - |
|
100 |
|
| 81 |
if (key($response)) {
|
101 |
if (key($response)) {
|
| 82 |
$this->Session->setFlash(current($response));
|
102 |
$this->Session->setFlash(current($response));
|
| 83 |
return $this->redirect(array('action' => 'index'));
|
103 |
return $this->redirect(array('action' => 'index'));
|
| 84 |
} else {
|
104 |
} else {
|
| 85 |
$this->Session->setFlash(current($response));
|
105 |
$this->Session->setFlash(current($response));
|