public function deliverReport()
 {
     $this->_logger->log(__METHOD__);
     if (count($this->data) == 0) {
         return false;
     }
     ini_set('memory_limit', '-1');
     $this->_logger->log(__METHOD__, array('ex_schedule_id' => $this->schedule_type_report->ex_schedule_id));
     $this->_logger->log(__METHOD__ . ' :' . print_r($this->schedule_type_report, 1));
     $destinations = ScheduleTypeReportDestination::getList($this->schedule_type_report->ex_schedule_id);
     $total = count($destinations);
     $this->_logger->log(__METHOD__, array('destination_count' => $total));
     //$this->_logger->log(__METHOD__ . ' :'. print_r($destinations,1));
     $file_path = $this->schedule_type_report_processed->full_file_name;
     //        $report_type = strtoupper($this->schedule_info->report_type);
     $file_name = $this->schedule_type_report_processed->check_period_start . '-' . $this->schedule_type_report_processed->check_period_end . '.' . $this->schedule_type_report->report_format;
     //$this->schedule_type_report->report_format;
     $report_type = $this->schedule_type_report->report_type;
     //$this->schedule_type_report_processed->file_content;
     if (count($destinations) > 0) {
         foreach ($destinations as $i => $destination) {
             if ($destination->method === 'mail') {
                 $this->_logger->log(__METHOD__, array('destination' => $i + 1, 'report_type' => $report_type, 'method' => $destination->method, 'email' => $destination->destination_email));
                 $mail_params = array('station_id_code' => $this->schedule_type_report->station_type, 'actuality_time' => $this->schedule_type_report->created, 'schedule_period' => Yii::app()->params['schedule_generation_period'][$this->schedule_type_report->period], 'report_file_name' => $file_name, 'link' => '', 'report_type' => $report_type);
                 $subject = Yii::t('letter', 'scheduled_report_mail_subject', $mail_params, null, 'en');
                 $settings = Settings::model()->findByPk(1);
                 $mailSender = new mailSender('odss_reports', $mail_params);
                 $sendResult = $mailSender->setAttachments(array(array('file_path' => $file_path, 'file_name' => $file_name)))->setRecipient($destination->destination_email)->setFrom($settings->mail__sender_address, $settings->mail__sender_name)->setSubject($subject)->setHtmlBody()->send();
                 $this->_logger->log(__METHOD__ . ' $sendResult: ' . $sendResult);
                 $this->_logger->log(__METHOD__ . ' Message send with attached file');
                 $this->_logger->log(__METHOD__ . ' Deliver via mail DONE.');
             } else {
                 if ($destination->method === 'ftp') {
                     // use it if you have some superstition about "../"
                     //                    $fileCopier = new FileCopier;
                     //                    $file_path = $fileCopier->rmPathSteps($file_path);
                     $ftpClient = new FtpClient();
                     $errors = $ftpClient->connect($destination->destination_ip, $destination->destination_ip_port)->login($destination->destination_ip_user, $destination->destination_ip_password)->setFolder($destination->destination_ip_folder)->openLocalFile($file_path)->upload($file_name)->closeLocalFile()->getErrors();
                     $this->_logger->log(__METHOD__ . " ftp errors:" . print_r($errors, 1));
                     $this->_logger->log(__METHOD__ . ' Deliver via ftp DONE.');
                 } else {
                     if ($destination->method === 'local_folder') {
                         $this->_logger->log(__METHOD__, array('destination' => $i + 1, 'report_type' => $report_type, 'method' => $destination->method, 'destination_folder' => $destination->destination_local_folder));
                         $destinationPath = $this->schedule_type_report_processed->getFileDir() . DIRECTORY_SEPARATOR . $destination->destination_local_folder;
                         $this->_logger->log(__METHOD__ . ' $file_path: ' . $file_path);
                         $this->_logger->log(__METHOD__ . ' $destinationPath: ' . $destinationPath);
                         $this->_logger->log(__METHOD__ . ' $file_name: ' . $file_name);
                         $fileCopier = new FileCopier();
                         $errors = $fileCopier->copy($file_path, $destinationPath . DIRECTORY_SEPARATOR . $file_name)->getErrors();
                         $this->_logger->log(__METHOD__ . print_r($errors, 1));
                         $this->_logger->log(__METHOD__ . ' Deliver to local folder DONE.');
                     }
                 }
             }
         }
     }
     $this->_logger->log(__METHOD__ . ' Delivery completed.');
 }