Esempio n. 1
0
 /**
  * Email a report to emails entered into export modal form.
  * 
  * @author unknown
  * @param string $imageName
  */
 public function email($imageName = '')
 {
     $this->_response_type('json');
     // Get the request info
     $this->data->report_where = json_decode(html_entity_decode($this->input->post('report_where')), true);
     $this->data->report_where['fromDate'] = isset($this->data->report_where['date_from']) ? $this->data->report_where['date_from'] : strtotime(date('Y-m-d 00:00:00'));
     $this->data->report_where['toDate'] = isset($this->data->report_where['date_to']) ? $this->data->report_where['date_to'] : strtotime(date('Y-m-d 23:59:59'));
     $this->data->report_where['time_frame'] = isset($this->data->report_where['time_frame']) ? $this->data->report_where['time_frame'] : '24';
     $moreInfo = $this->Store->get_store_track($this->store_id);
     $this->data->merchant_logo = get_merchant_logo_url($moreInfo->brand_logo);
     $this->data->file_name = $this->input->post('file_name');
     $this->data->title = $this->data->headerDate = '';
     $this->data->time_frame = $this->data->report_where['time_frame'];
     $this->data->product_ids = isset($this->data->report_where['product_ids']) ? $this->data->report_where['product_ids'] : array();
     $this->data->retailer = (int) $this->input->post('is_retailer');
     $rptInfo = getTitleReporting($this->data->report_where, 'Y');
     $this->data->reportType = $this->input->post('report_type');
     switch ($this->data->reportType) {
         case 'productpricing':
             $this->data->title = $emailSubject = 'Price Over Time';
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'dns_list':
             $this->data->title = $emailSubject = 'Do Not Sell List Report';
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'pricingoverview':
             $emailSubject = 'Pricing Overview';
             $this->data->title = 'Today\'s Pricing';
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'marketviolator':
             $emailSubject = 'Violations Detail';
             $this->data->title = $this->data->file_name;
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'violationoverview':
             $emailSubject = 'Violations Overview';
             $this->data->title = $this->data->file_name;
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'violator':
             $emailSubject = 'Price Violator';
             $this->data->title = $this->data->file_name;
             $this->data->headerDate = $rptInfo['date'];
             break;
         case 'whois':
             $emailSubject = $this->data->file_name;
             $this->data->title = $this->data->file_name;
             $this->data->headerDate = $rptInfo['date'];
             break;
         default:
             $emailSubject = 'Price Violations';
             $this->data->title = $rptInfo['title'];
             if (!empty($this->data->report_where['group_id'])) {
                 $group = $this->Product->getGroupByID($this->data->report_where['group_id']);
                 if (!empty($group['name'])) {
                     $this->data->title = $group['name'];
                 }
             }
             $this->data->headerDate = 'Dates: ' . $rptInfo['date'];
     }
     if (isset($_POST['report_name'])) {
         $this->data->title = $this->input->post('report_name') . ' - ' . $this->data->title;
     }
     // Get the images used
     $graphData = $this->input->post('graph_data');
     if ($imageName == '' and $graphData) {
         $imageName = $this->generateImage($graphData, $this->store_id);
     }
     $this->data->graph_image_name = empty($imageName) ? '' : $imageName;
     // Generate the content
     require_once APPPATH . 'libraries/mvexport.php';
     $content = $this->input->post('export_content');
     $this->mvexport = new mvexport($content);
     $this->data->report = $this->mvexport->getReport('.reportTable');
     // Create the email
     $template = 'general';
     $email_addresses = $this->input->post('email_addresses');
     if (is_array($email_addresses)) {
         $receivers = implode(',', array_flip(array_flip($this->input->post('email_addresses'))));
     } else {
         $receivers = $email_addresses;
     }
     $htmlContent = $this->load->view('reports/_email', $this->data, TRUE);
     $textContent = $this->load->view('reports/_email_txt', $this->data, TRUE);
     $this->data = template_email_send($template, $this->user_id, $emailSubject, $receivers, $htmlContent, $textContent);
 }
Esempio n. 2
-1
 function bad_upc()
 {
     $store_list = $this->Store->get_all_store_with_users();
     foreach ($store_list as $store) {
         $upc_list = $this->Product->getBadUpcByStoreId($store['store_id']);
         $number_bad = count($upc_list);
         if ($number_bad > 0) {
             $report_data = get24ReportTitleAndDate(array('time_frame' => 24, 'title' => "Bad UPC List", 'fromDate' => strtotime('-24 hours'), 'toDate' => time()));
             $data = array('upc_list' => $upc_list, 'merchant_logo' => get_merchant_logo_url($store['brand_logo']), 'headerDate' => $report_data['date'], 'title' => $number_bad . ' Invalid UPC' . ($number_bad > 1 ? 's' : ''), 'brand_name' => $this->Store->get_brand_by_store($store['store_id']), 'store_id' => $store['store_id']);
             $html = $this->load->view($this->_controller . '/_bad_upc', $data, true);
             $text = $this->load->view($this->_controller . '/_bad_upc_txt', $data, true);
             $template = 'general';
             template_email_send($template, $store['id'], 'Bad UPC Notification', $store['email'], $html, $text);
         }
     }
     exit;
 }