Subversion Repositories SmartDukaan

Rev

Rev 14539 | Rev 15039 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14539 Rev 14600
Line 68... Line 68...
68
			$this->data = $this->MasterData->read(null, $id);
68
			$this->data = $this->MasterData->read(null, $id);
69
			debug($this->data);
69
			debug($this->data);
70
		}
70
		}
71
	}
71
	}
72
 
72
 
-
 
73
	public function admin_add() {
-
 
74
		if ($this->request->is('post')) {
-
 
75
			$this->log(print_r($this->request->data,1),'masterdatas');
-
 
76
			$url = $this->apihost."masterData/addOrUpdateMaster/?addNew=1";
-
 
77
			$data = $this->request->data['MasterData'];
-
 
78
			$url = $this->generateMultiUrl($url,$data);
-
 
79
			$data['identifier'] = (string)$data['identifier'];
-
 
80
			$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
-
 
81
			$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
-
 
82
			$response = $this->make_request($url,$jsonVar);
-
 
83
			if (key($response)) {
-
 
84
				$this->Session->setFlash(current($response));
-
 
85
				return $this->redirect(array('action' => 'search'));
-
 
86
			} else {
-
 
87
				$this->Session->setFlash(current($response));
-
 
88
			}	
-
 
89
		}
-
 
90
		$sources = Configure::read('storemapping');
-
 
91
		$sources[0] = 'Other';
-
 
92
		// $this->set('sources',$sources);
-
 
93
		// $this->set('source_ids',Configure::read('storemapping'));
-
 
94
		$this->set('categories',Configure::read('Categories'));
-
 
95
		$stock_statuses = array(0=>'OOS',1=>'In Stock');
-
 
96
		$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
-
 
97
		$shortage_status = array(0=>'No',1=>'Yes');
-
 
98
		$this->set(compact('stock_statuses','statuses','sources','shortage_status'));
-
 
99
	}
-
 
100
 
-
 
101
	public function admin_addtoexisting() {
-
 
102
		if ($this->request->is('post')) {
-
 
103
			$this->log(print_r($this->request->data,1),'masterdatas');
-
 
104
			$url = $this->apihost."masterData/addOrUpdateMaster/?addToExisting=1";
-
 
105
			$data = $this->request->data['MasterData'];
-
 
106
			$url = $this->generateMultiUrl($url,$data);
-
 
107
			$data['identifier'] = (string)$data['identifier'];
-
 
108
			$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
-
 
109
			$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
-
 
110
			$response = $this->make_request($url,$jsonVar);
-
 
111
			if (key($response)) {
-
 
112
				$this->Session->setFlash(current($response));
-
 
113
				return $this->redirect(array('action' => 'search'));
-
 
114
			} else {
-
 
115
				$this->Session->setFlash(current($response));
-
 
116
			}	
-
 
117
		}
-
 
118
		$sources = Configure::read('storemapping');
-
 
119
		$sources[0] = 'Other';
-
 
120
		// $this->set('sources',$sources);
-
 
121
		// $this->set('source_ids',Configure::read('storemapping'));
-
 
122
		$this->set('categories',Configure::read('Categories'));
-
 
123
		$stock_statuses = array(0=>'OOS',1=>'In Stock');
-
 
124
		$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
-
 
125
		$shortage_status = array(0=>'No',1=>'Yes');
-
 
126
		$this->set(compact('stock_statuses','statuses','sources','shortage_status'));
-
 
127
	}
-
 
128
 
-
 
129
	public function admin_update($id) {
-
 
130
		if ($this->request->is('post')) {
-
 
131
			$this->log(print_r($this->request->data,1),'masterdatas');
-
 
132
			$url = $this->apihost."masterData/addOrUpdateMaster/?update=1";			
-
 
133
			$data = $this->request->data['MasterData'];
-
 
134
			if(isset($data['multi']) && !empty($data['multi'])){
-
 
135
				$url .= '&multi=1';
-
 
136
				unset($data['multi']);
-
 
137
			}
-
 
138
			$url = $this->generateMultiUrl($url,$data);
-
 
139
			$data['identifier'] = (string)$data['identifier'];
-
 
140
			$data['secondaryIdentifier'] = (string)$data['secondaryIdentifier'];
-
 
141
			$jsonVar = json_encode($data, JSON_NUMERIC_CHECK );
-
 
142
			$response = $this->make_request($url,$jsonVar);
-
 
143
			if (key($response)) {
-
 
144
				$this->Session->setFlash(current($response));
-
 
145
				return $this->redirect(array('action' => 'search'));
-
 
146
			} else {
-
 
147
				$this->Session->setFlash(current($response));
-
 
148
			}	
-
 
149
		}
-
 
150
		$url = $this->apihost."masterData/getSkuById/$id";
-
 
151
		$temp = $this->make_request($url,null);
-
 
152
		$data = json_decode($temp[0],1);
-
 
153
		$sources = Configure::read('storemapping');
-
 
154
		$sources[0] = 'Other';
-
 
155
		// $this->set('sources',$sources);
-
 
156
		// $this->set('source_ids',Configure::read('storemapping'));
-
 
157
		$this->set('categories',Configure::read('Categories'));
-
 
158
		$stock_statuses = array(0=>'OOS',1=>'In Stock');
-
 
159
		$statuses = array(2=>'EOL',1=>'Active',3=>'In Process',4=>'Exclusive');
-
 
160
		$shortage_status = array(0=>'No',1=>'Yes');
-
 
161
		$this->set(compact('stock_statuses','statuses','sources','shortage_status','data'));
-
 
162
	}
-
 
163
 
73
	public function admin_search(){
164
	public function admin_search(){
74
		$page = $this->request->query('page');
165
		$page = $this->request->query('page');
75
		if(!isset($page)){
166
		if(!isset($page)){
76
			$page = 1;
167
			$page = 1;
77
		}
168
		}