Subversion Repositories SmartDukaan

Rev

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

Rev 13633 Rev 14346
Line 2... Line 2...
2
class OrderpushShell extends AppShell {
2
class OrderpushShell extends AppShell {
3
    public $uses = array('PythonApi','Order');
3
    public $uses = array('PythonApi','Order');
4
 
4
 
5
    public function main() {
5
    public function main() {
6
	Configure::load('live');
6
	Configure::load('live');
7
	$options = array('conditions'=>array('status'=>'mapped'),'recursive'=>-1);
7
	$options = array('conditions'=>array('status'=>'ORDER_NOT_CREATED'),'recursive'=>-1);
8
	$orders = $this->Order->find('all',$options);
8
	$orders = $this->Order->find('all',$options);
9
	if(!empty($orders)) {
9
	if(!empty($orders)) {
10
		foreach($orders AS $order) {
10
		foreach($orders AS $order) {
11
			$response = $this->PythonApi->postOrders($order);
11
			$response = $this->PythonApi->postOrders($order);
12
			if(!empty($response) && $response['result']) {
12
			if(!empty($response) && $response['result']) {
13
				$sql = "UPDATE orders SET status = 'processed' WHERE id = ".$order['Order']['id'];
13
				$sql = "UPDATE orders SET status = '". $response['result']."' WHERE id = ".$order['Order']['id'];
14
				$this->Order->query($sql);
14
				$this->Order->query($sql);
15
			}
15
			}
16
		}
16
		}
17
	}
17
	}
18
    }
18
    }