Example #1
0
 function ajax_approve_deal($deal_id)
 {
     $deal_info = $this->Deals_model->get_draft_deal($deal_id);
     $data = array('id' => $deal_id, 'deal_type_id' => $deal_info->deal_type_id, 'is_approved' => 1);
     $this->Deals_model->save($data);
     unset($data);
     //get deal code
     $this->load->model(array('Dealsign_model'));
     $codes = $this->Dealsign_model->get_deal_codes(array('is_used' => 0), 1, '', 'id', 'asc');
     if ($codes) {
         foreach ($codes as $code) {
             $arr_codes[] = $code->deal_code;
         }
     }
     $str_codes = "'" . implode("','", $arr_codes) . "'";
     $str_codes_payment = implode(",", $arr_codes);
     //update payment table
     $payment['deal_id'] = $deal_info->id;
     $payment['deal_id_approved'] = $str_codes_payment;
     $this->Payment_model->update_deal_id($payment);
     unset($payment);
     //add deal from draft deal to approved deal table
     $deal_dates = explode(",", $deal_info->dealDates);
     $cnt_dates = count($deal_dates);
     $str_dates = arr_date_to_str_date($deal_dates);
     $deal_start_date = $deal_dates[0];
     //$no_of_coupons=$deal_info->no_of_coupons*$cnt_dates;
     $image = $deal_info->image;
     if (!empty($image)) {
         // for each deal there is a unique image
         $source = $image = $deal_info->image;
         $ext = substr($image, strpos($image, "."));
         $image = md5(uniqid(mt_rand())) . $ext;
         $this->load->library('image_lib');
         //cropped thumbnail
         $config['image_library'] = 'gd2';
         $config['source_image'] = 'uploads/images/thumbnails/' . $source;
         $config['new_image'] = 'uploads/images/thumbnails/' . $image;
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 250;
         $config['height'] = 180;
         $this->image_lib->initialize($config);
         $this->image_lib->resize();
         $this->image_lib->clear();
     }
     $save['id'] = '';
     $save['deal_id'] = $arr_codes[0];
     $save['merchant_id'] = $deal_info->merchant_id;
     $save['deal_type_id'] = $deal_info->deal_type_id;
     $save['company_name'] = $deal_info->business_name;
     $save['deal_city'] = $deal_info->deal_city;
     $save['title'] = $deal_info->title;
     $save['description'] = $deal_info->description;
     $save['image'] = $image;
     $save['actual_price'] = $deal_info->actual_price;
     $save['list_price'] = $deal_info->list_price;
     $save['discount_pct'] = $deal_info->discount_pct;
     $save['start_date'] = $deal_start_date;
     $save['coupon_exist'] = $deal_info->coupon_exist;
     $save['no_of_coupons'] = $deal_info->no_of_coupons;
     $save['coupon_expiration_date'] = $deal_info->coupon_expiration_date;
     $save['terms_and_conditions'] = $deal_info->terms_and_conditions;
     $save['deal_note'] = $deal_info->deal_note;
     $lats_id = $this->Deals_model->save_approved($save);
     $this->Dealsign_model->makeUsed(array('deal_id' => $lats_id, 'deal_code' => $arr_codes[0]));
     //insert dates to approved_deal_dates
     $i = 0;
     foreach ($deal_dates as $date) {
         $data['deal_id'] = $lats_id;
         $data['deal_code'] = $save['deal_id'];
         $data['deal_type_id'] = $save['deal_type_id'];
         $data['deal_date'] = $date;
         $this->Deals_model->save_approved_dealDate($data);
         $i++;
     }
     //send deal approval by admin mail to merchant
     $this->load->helper('string');
     $email = $deal_info->email_id;
     $res = $this->db->where('id', '20')->get('messages');
     $row = $res->row_array();
     // set replacement values for subject & body
     // {customer_name}
     $row['subject'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['subject']);
     $row['content'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['content']);
     $row['content'] = str_replace('{deal_name}', $deal_info->title, $row['content']);
     $row['content'] = str_replace('{deal_dates}', $str_dates, $row['content']);
     // {url}
     $row['subject'] = str_replace('{url}', $this->config->item('base_url'), $row['subject']);
     $row['content'] = str_replace('{url}', $this->config->item('base_url'), $row['content']);
     // {site_name}
     $row['subject'] = str_replace('{site_name}', $this->config->item('company_name'), $row['subject']);
     $row['content'] = str_replace('{site_name}', $this->config->item('company_name'), $row['content']);
     $this->load->library('email');
     $config['mailtype'] = 'html';
     $this->email->initialize($config);
     $this->email->from($this->setting->admin_email, $this->setting->website_name);
     $this->email->to($email);
     $this->email->subject($row['subject']);
     $this->email->message(html_entity_decode($row['content']));
     $this->email->send();
     $this->session->set_flashdata('message', 'Deal approved successfully and moved to upcoming deals');
     echo 'success';
     die;
 }
Example #2
0
 function request_approval_mail_admin($deal_id)
 {
     $deal_info = $this->CI->Deals_model->get_draft_deal($deal_id);
     $deal_dates = explode(",", $deal_info->dealDates);
     $str_dates = arr_date_to_str_date($deal_dates);
     $this->CI->load->helper('string');
     $email = $deal_info->email_id;
     $res = $this->CI->db->where('id', '21')->get('messages');
     $row = $res->row_array();
     // set replacement values for subject & body
     // {customer_name}
     $row['subject'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['subject']);
     $row['subject'] = str_replace('{deal_city}', $deal_info->deal_city, $row['subject']);
     $row['content'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['content']);
     $row['content'] = str_replace('{deal_name}', $deal_info->title, $row['content']);
     $row['content'] = str_replace('{deal_dates}', $str_dates, $row['content']);
     $row['content'] = str_replace('{deal_city}', $deal_info->deal_city, $row['content']);
     // {url}
     $row['subject'] = str_replace('{url}', $this->CI->config->item('base_url'), $row['subject']);
     $row['content'] = str_replace('{url}', $this->CI->config->item('base_url'), $row['content']);
     // {site_name}
     $row['subject'] = str_replace('{site_name}', $this->setting->website_name, $row['subject']);
     $row['content'] = str_replace('{site_name}', $this->setting->website_name, $row['content']);
     $this->CI->load->library('email');
     $config['mailtype'] = 'html';
     $this->CI->email->initialize($config);
     $this->CI->email->from($email, $this->setting->website_name);
     $this->CI->email->to($this->setting->admin_email);
     $this->CI->email->subject($row['subject']);
     $this->CI->email->message(html_entity_decode($row['content']));
     $this->CI->email->send();
 }
Example #3
0
 function ajax_approve_deal($deal_id)
 {
     $deal_info = $this->Deals_model->get_draft_deal($deal_id);
     $data = array('id' => $deal_id, 'deal_type_id' => $deal_info->deal_type_id, 'is_approved' => 1);
     $this->Deals_model->save($data);
     $deal_dates = explode(",", $deal_info->dealDates);
     $str_dates = arr_date_to_str_date($deal_dates);
     foreach ($deal_dates as $date) {
         $save['id'] = '';
         $save['deal_id'] = $deal_info->id;
         $save['merchant_id'] = $deal_info->merchant_id;
         $save['deal_type_id'] = $deal_info->deal_type_id;
         $save['company_name'] = $deal_info->business_name;
         $save['display_date'] = $date;
         $save['deal_city'] = '';
         $save['title'] = $deal_info->title;
         $save['description'] = $deal_info->description;
         $save['image'] = $deal_info->image;
         $save['actual_price'] = $deal_info->actual_price;
         $save['list_price'] = $deal_info->list_price;
         $save['discount_pct'] = $deal_info->discount_pct;
         $save['coupon_exist'] = $deal_info->coupon_exist;
         $save['no_of_coupons'] = $deal_info->no_of_coupons;
         $save['terms_and_conditions'] = $deal_info->terms_and_conditions;
         $this->Deals_model->save_approved($save);
     }
     $this->load->helper('string');
     $email = $deal_info->email_id;
     $res = $this->db->where('id', '20')->get('messages');
     $row = $res->row_array();
     // set replacement values for subject & body
     // {customer_name}
     $row['subject'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['subject']);
     $row['content'] = str_replace('{merchant_name}', $deal_info->contact_name, $row['content']);
     $row['content'] = str_replace('{deal_name}', $deal_info->title, $row['content']);
     $row['content'] = str_replace('{deal_dates}', $str_dates, $row['content']);
     // {url}
     $row['subject'] = str_replace('{url}', $this->config->item('base_url'), $row['subject']);
     $row['content'] = str_replace('{url}', $this->config->item('base_url'), $row['content']);
     // {site_name}
     $row['subject'] = str_replace('{site_name}', $this->config->item('company_name'), $row['subject']);
     $row['content'] = str_replace('{site_name}', $this->config->item('company_name'), $row['content']);
     $this->load->library('email');
     $config['mailtype'] = 'html';
     $this->email->initialize($config);
     $this->email->from($this->setting->admin_email, $this->setting->website_name);
     $this->email->to($email);
     $this->email->subject($row['subject']);
     $this->email->message(html_entity_decode($row['content']));
     $this->email->send();
     $this->session->set_flashdata('message', 'Deal approved successfully and moved to upcoming deals');
     echo 'success';
     die;
 }