Subversion Repositories SmartDukaan

Rev

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

Rev 13591 Rev 13633
Line 51... Line 51...
51
 * add method
51
 * add method
52
 *
52
 *
53
 * @return void
53
 * @return void
54
 */
54
 */
55
	public function add() {
55
	public function add() {
-
 
56
		$this->log(print_r($this->request->data,1),'orders');
56
		if ($this->request->is('post')) {
57
		if ($this->request->is('post')) {
57
			$this->Order->create();
58
			$this->Order->create();
-
 
59
			if(!empty($this->request->data['sub_tag'])){
-
 
60
				$this->request->data['status'] = 'mapped';
-
 
61
			}
58
			if ($this->Order->save($this->request->data)) {
62
			if ($this->Order->save($this->request->data)) {
59
				$result =array('success'=>true,'message'=>__('The order has been saved.'));
63
				$result =array('success'=>true,'message'=>__('The order has been saved.'));
-
 
64
/*
-
 
65
				$options = array('conditions'=>array('status'=>'mapped'),'recursive'=>-1);
-
 
66
				$order = $this->Order->find('first',$options);
-
 
67
				if(!empty($orders)) {
-
 
68
					foreach($orders AS $order) {
-
 
69
						$response = $this->PythonApi->postOrders($order);
-
 
70
						if(!empty($response) && $response['result']) {
-
 
71
							$sql = "UPDATE orders SET status = 'processed' WHERE id = ".$order['Order']['id'];
-
 
72
							$this->Order->query($sql);
-
 
73
						}
-
 
74
					}
-
 
75
				}
-
 
76
*/
60
			} else {
77
			} else {
61
				$result = array('success'=>false,'message'=>__('The order could not be saved. Please, try again.'));
78
				$result = array('success'=>false,'message'=>__('The order could not be saved. Please, try again.'));
62
			}
79
			}
63
			$this->response->type('json');
80
			$this->response->type('json');
64
			$this->layout = 'ajax';
81
			$this->layout = 'ajax';