$excelFileName = $user['topic'] . "_dailyauto_" . $user['edituser']; echo $excelFileName . '<br>'; 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']; $sendiftrue = TRUE; sleep(3); } } } else { if ($user['edituser'] != '0') { $excelDataArray = $weeklyreport->sendingDailyReportJVlocation($user['continent'], $user['id']); $excelFileName = $user['topic'] . "_dailyauto_report_" . $date; echo $excelFileName . '<br>'; 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']; $sendiftrue = TRUE; sleep(3); } } } // Log the steps