Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 10-03-2017 08:35:39

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1716

Daily Cron Tasks

HI Nick

Any idea why this block of code doesn't work inside a daily cron task

Code:

if (date('j') === '1') { 
          $sql = 'SELECT id FROM core_users WHERE purchonacct='.$this->CORE_DB->quote(1);
     
          $accountlist= $this->CORE_DB->sql_do(array('sql' => $sql, 'table' => 'core_users', 'order' => array('id' => 'ASC')));

           foreach ($accountlist as $num => $account) {
                
                $sql = 'SELECT sum(ordertotal) FROM ecom_orders WHERE email = '.$this->CORE_DB->quote($account['id']).' AND orderbalance<>' . $this->CORE_DB->quote('0.00').' AND statusinit=' . $this->CORE_DB->quote(1).' AND paymethod=' . $this->CORE_DB->quote('purchonacct');     
                
                $result=$this->CORE_DB->sql_do(array('sql' => $sql, 'table' => 'ecom_orders'));

                if ($result[0]['sum(ordertotal)']>0){

                     $this->exec_namespace(array('app' => 'ecom', 'namespace' => 'accountstatement', 'type' => '*', 'params' => $account['id']));

                       if ($this->debug) {$this->debugger("Sent Statement:".$account['id']);}
                }

           }
}

I have just duplicated a similar cron job(which I have done before), changed the name, class name and $class.

It is supposed to check for 1st of month, and then send statements for a payonaccount accounts with an outstanding balance.

Code is inside function exec() and CORE_DB is declared.

Code works correctly if run outside of the cron task. so I know there are no errors in the code and the accountstatement namespace is set up correctly.


Rob

Offline

 

#2 10-03-2017 12:26:18

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19861
Website

Re: Daily Cron Tasks

Check your class names, etc, making sure nothing is screwed up with that, and you said CORE_DB is declared in the constructor, so that rules that out.


Nick Hendler

Offline

 

Board footer