Пример #1
0
 foreach ($sendReportsTo as $user) {
     $mail = new Zend_Mail();
     $mail->setFrom('*****@*****.**', 'Textmunication.com');
     $mail->addTo($user['email']);
     //            $mail->addCc('*****@*****.**', 'Wais Asefi');
     $mail->setSubject('Weekly Reports');
     // Get the Excel model
     $excelDataArray = array();
     if ($weeklyreport->checkAdminUser($user['id']) and $user['id'] != 187) {
         if ($user['edituser'] != '0') {
             $excelDataArray = $weeklyreport->getWeeklyReportApiuser($user['id']);
             $enddate = date("Ymd");
             $startdate = date('Ymd', strtotime('-7 days'));
             $excelFileName = "prosalon_weekly_report" . $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;
             }
         }
         //                else{
         //                    $excelDataArray = $weeklyreport->getWeeklyReport($user['id'],$user['typeidextra']);
         //                    $date = date('Ymd');
         //                    $excelFileName = "PC_weekly_optin" .$user['id'].'_'. $date;
         //                    logWrite("Creating the Excel spreadsheets");
         //                    $excel = new Application_Model_Excel();
Пример #2
0
 public function customreportAction()
 {
     $weeklyreport = new Application_Model_Report();
     $excel = new Application_Model_Excel();
     $userid = 787;
     $excelDataArray = $weeklyreport->getWeeklyReport($userid);
     $date = date('Ymd');
     $excelFileName = "report_clientid" . $user['id'] . '_' . $date;
     $excel = new Application_Model_Excel();
     $excelFile = $excel->create($excelDataArray, $excelFileName);
 }
Пример #3
0
 /**
  * Creates an Excel file
  * 
  * @param array $data
  * @param string $filename
  * @param string $error
  * @param boolean $overwrite
  * @return array Array of filename and filepath on success or false on failure
  */
 public static function createExcelFile(array $data, $filename, $overwrite = true)
 {
     // Register the excel write stream wrapper
     Application_Model_StreamExcel::registerWrapper('xlsfile');
     // Set us up a filename to create/send
     $file_name = "{$filename}.xls";
     // Get the path to that file
     //$file_path = "/tmp/$file_name";
     $file_path = "/home/textm/textmunication.com/htdocs/public/reportdocs/{$file_name}";
     // If there is no file already, create it first
     if (!file_exists($file_path) || $overwrite) {
         // Set up the stream path - NOTE $real_path begins with a '/'
         $export_file = "xlsfile:/{$file_path}";
         // Open the stream for writing in binary mode
         if (($fp = fopen($export_file, "wb")) === false) {
             $error = "Cannot open {$file_path} for writing.";
         } else {
             // Write the real data
             fwrite($fp, serialize($data));
             error_reporting(1);
             // Close the file handle resource
             fclose($fp);
             return array('name' => $file_name, 'path' => $file_path);
         }
     } else {
         self::$excelError = 'File exists and overwrites are off';
     }
     return false;
 }