public function execute($respondentId = null, $organizationId = null)
    {
        $sql = "SELECT gcj_id_job
            FROM gems__comm_jobs
            WHERE gcj_active = 1";

        if ($organizationId) {
            $sql .= $this->db->quoteInto(
                    " AND (gcj_id_organization IS NULL OR gcj_id_organization = ?)",
                    $organizationId
                    );
        }

        $sql .= "
            ORDER BY gcj_id_order,
                CASE WHEN gcj_id_survey IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_round_description IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_track IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_organization IS NULL THEN 1 ELSE 0 END";

        $jobs = $this->db->fetchAll($sql);

        $batch = $this->getBatch();
        if ($jobs) {
            foreach ($jobs as $job) {
                $batch->addTask('Mail\\ExecuteMailJobTask', $job['gcj_id_job'], $respondentId, $organizationId);
            }
        } else {
            $this->getBatch()->addMessage($this->_('Nothing to do, please create a mail job first.'));
        }
        // When manually running the jobs, we do not start the monitortask
        if ($batch->getId() == 'cron') {
            $batch->addTask('Mail\\CronMailMonitorTask');
        }
    }
public function execute($respondentId = null, $organizationId = null)
    {
        $sql = "SELECT gcj_id_job
            FROM gems__comm_jobs
            WHERE gcj_active = 1";

        if ($organizationId) {
            $sql .= $this->db->quoteInto(
                    " AND (gcj_id_organization IS NULL OR gcj_id_organization = ?)",
                    $organizationId
                    );
        }

        $sql .= "
            ORDER BY gcj_id_order,
                CASE WHEN gcj_id_survey IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_round_description IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_track IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_organization IS NULL THEN 1 ELSE 0 END";

        $jobs = $this->db->fetchAll($sql);

        $batch = $this->getBatch();
        if ($jobs) {
            foreach ($jobs as $job) {
                $batch->addTask('Mail\\ExecuteMailJobTask', $job['gcj_id_job'], $respondentId, $organizationId);
            }
        } else {
            $this->getBatch()->addMessage($this->_('Nothing to do, please create a mail job first.'));
        }
        // When manually running the jobs, we do not start the monitortask
        if ($batch->getId() == 'cron') {
            $batch->addTask('Mail\\CronMailMonitorTask');
        }
    }
public function execute ( $ respondentId = null , $ organizationId = null ) { $ sql = "SELECT gcj_id_job
            FROM gems__comm_jobs
            WHERE gcj_active = 1" ; if ( $ organizationId ) { $ sql .= $ this -> db -> quoteInto ( " AND (gcj_id_organization IS NULL OR gcj_id_organization = ?)" , $ organizationId ) ; } $ sql .= "
            ORDER BY gcj_id_order,
                CASE WHEN gcj_id_survey IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_round_description IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_track IS NULL THEN 1 ELSE 0 END,
                CASE WHEN gcj_id_organization IS NULL THEN 1 ELSE 0 END" ; $ jobs = $ this -> db -> fetchAll ( $ sql ) ; $ batch = $ this -> getBatch ( ) ; if ( $ jobs ) { foreach ( $ jobs as $ job ) { $ batch -> addTask ( 'Mail\\ExecuteMailJobTask' , $ job [ 'gcj_id_job' ] , $ respondentId , $ organizationId ) ; } } else { $ this -> getBatch ( ) -> addMessage ( $ this -> _ ( 'Nothing to do, please create a mail job first.' ) ) ; } // When manually running the jobs, we do not start the monitortask if ( $ batch -> getId ( ) == 'cron' ) { $ batch -> addTask ( 'Mail\\CronMailMonitorTask' ) ; } }
Adds all jobs to the queue

@param $respondentId Optional, execute for just one respondent
@param $organizationId Optional, execute for just one organization
Adds all jobs to the queue