Esempio n. 1
0
$queueCount = count($sendReportsTo);
$sendCount = 0;
// Log our counts
logWrite("Number of persons to whom report will be sent: {$queueCount}\nBegin send loop:");
if (is_array($sendReportsTo)) {
    if (!empty($sendReportsTo)) {
        foreach ($sendReportsTo as $ars => $user) {
            $mail = new Zend_Mail();
            $mail->setFrom('*****@*****.**', 'Textmunication.com');
            $mail->addTo($user['email']);
            //            $mail->addCc('*****@*****.**', 'Wais Asefi');
            $mail->setSubject('Keyword Activity Report');
            $excelFile = "";
            if ($weeklyreport->checkAdminUser($user['id']) and $user['id'] != 187) {
                if ($user['edituser'] != '0') {
                    $excelDataArray = $weeklyreport->getWeeklyReportService();
                    $enddate = date("Ymd");
                    $startdate = date('Ymd', strtotime('-7 days'));
                    $excelFileName = "KeywordActivity_" . $startdate . '_' . $enddate;
                    logWrite("Creating the Excel spreadsheets");
                    $excel = new Application_Model_Excel();
                    if (isset($excelDataArray)) {
                        $excelFile = $excel->create($excelDataArray, $excelFileName);
                        logWrite("Attaching the spreadsheets");
                        $at = $mail->createAttachment(file_get_contents($excelFile['path']));
                        $at->filename = $excelFile['name'];
                    } else {
                        continue;
                    }
                }
            }