Subversion Repositories SmartDukaan

Rev

Rev 13633 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
class OrderpushShell extends AppShell {
    public $uses = array('PythonApi','Order');

    public function main() {
        Configure::load('live');
        $options = array('conditions'=>array('status'=>'ORDER_NOT_CREATED'),'recursive'=>-1);
        $orders = $this->Order->find('all',$options);
        if(!empty($orders)) {
                foreach($orders AS $order) {
                        $response = $this->PythonApi->postOrders($order);
                        if(!empty($response) && $response['result']) {
                                $sql = "UPDATE orders SET status = '". $response['result']."' WHERE id = ".$order['Order']['id'];
                                $this->Order->query($sql);
                        }
                }
        }
    }
}