%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php class Reports extends MY_Controller { function __construct() { parent::__construct(); not_logged_res(); ini_set('memory_limit', '2048M'); set_time_limit(3000); $this->load->model("reports_model", "report"); $this->load->model("dataset_model", "dataset"); $this->load->model("user_model", "user"); $this->load->model("leads_model", "leads"); } function dashboard($limit){ $data['data']=$this->report->dashboard($limit); $this->json_data($data); } function dashboard_top_leads($limit){ $data['data']=$this->report->dashboard_top_leads($limit); $this->json_data($data); } function leadGroupWise(){ $data['result']=$this->report->leadGroupWise(); $this->json_data($data, true); } function leadSourceWise(){ $data['result']=$this->report->leadSourceWise(); $this->json_data($data, true); } function leadStateWise(){ $data['result']=$this->report->leadStateWise(); $this->json_data($data, true); } function leadProgrammeWise(){ $data['result']=$this->report->leadProgrammeWise(); $this->json_data($data, true); } function leadLandingPageWise(){ $data['result']=$this->report->leadLandingPageWise(); $this->json_data($data, true); } /** Other Reports */ function callers_disp(){ $this->checkAccess(['callers_report', 'callers_report_byyou']); $data['result']=$this->report->callers_disp(FALSE, $this->is_access('callers_report')?false:true); $this->json_data($data); } function init_callers_disp(){ $this->checkAccess(['callers_report', 'callers_report_byyou']); $data['users']=$this->user->active_users($this->is_access('callers_report')?false:true); $data['summary']=$this->report->callers_disp_summary($this->is_access('callers_report')?false:true); $this->json_data($data); } /** Campaign Messages */ function init_campaigns(){ $this->checkAccess('manage_campaigns'); $list=$this->report->lists_leads_login_url(); $data['result_lu']=$list['result']; $data['page_lu']=$list['page']; $list=$this->report->campaigns(); $data['result']=$list['result']; $data['page']=$list['page']; $data['data_sets']=$this->dataset->all_lists(true); $data['templates']=$this->report->campaign_templates(); $data['tags']=campaign_temp_tags(); $this->json_data($data); } function campaigns(){ $this->checkAccess('manage_campaigns'); $data=$this->report->campaigns(); $this->json_data($data); } function save_campaign(){ $this->checkAccess('manage_campaigns'); $inf=array('success'=>false, 'msg'=>'Error!'); $post=trim_array($this->input->post()); $id=$post['id']=intval($post['id']); if($post['test']!='T'){ $this->form_validation->set_rules('title', 'Campaign Name', "required|is_unique[campaign_templates.title.id!='$id']", $this->req); $this->form_validation->set_rules('data_set_id', 'Data Set', "required", $this->req); }else{ $this->form_validation->set_rules('test_usr', 'Email ids or mobile numbers for testing', "required", $this->req); } if(!$post['template_id']){ if($post['type']=='EMAIL'){ $this->form_validation->set_rules('subject', 'Subject', "required", $this->req); $this->form_validation->set_rules('email_msg', 'Message', "required", $this->req); $post['msg']=$post['email_msg']; }else{ $post['subject']=''; $this->form_validation->set_rules('msg', 'Message', "required", $this->req); } } if(@$this->form_validation->run() == FALSE){ $inf['errors']=$this->form_validation->get_errors(); $inf['msg']=reset($inf['errors']); }else{ if($post['test']=='T'){ $this->test_campaign($post); die; } $post['schedule_time'] = $post['schedule_time'].' '.$post['schedule_time']; $data=filter_value($post, array('id', 'title', 'template_id', 'data_set_id','from_name','from_email','reply_to_email','schedule_time')); if(!$data['template_id']){ $data['template_id']=$this->create_hidden_template($id, $post); } if($campaign_id=$this->common->save($data, "campaigns")){ $inf['success']=true; if($post['status']=='PUBLISHED'){ $inf=$this->report->publish_campaign($campaign_id); }else{ $inf['msg']='Campaign '.($id?'updated':'added').' successfully'; } } } $this->json_data($inf); } function campaign_detail($id){ $this->checkAccess('manage_campaigns'); $data['dtl']=$this->report->campaign_detail($id); $data['dtl']['schedule_date']=get_date($data['dtl']['schedule_time']); $data['dtl']['schedule_time']=date('H:i:s',strtotime($data['dtl']['schedule_time'])); $this->json_data($data); } function delete_campaign(){ $this->checkAccess('manage_campaigns'); $inf=array('success'=>false, 'msg'=>'Can not deleted!'); $id=intval($this->input->post('id')); if($this->report->delete_campaign($id)){ $inf['success']=true; $inf['msg']="Campaign deleted successfully"; } $this->json_data($inf); } function test_campaign($post){ $inf=array('success'=>false, 'msg'=>'Error!'); //$post=trim_array($this->input->post()); if(!$post['test_usr']){ $inf['msg']="Enter email ids or mobile numbers for testing"; $this->json_data($inf); } if($post['template_id']){ $tdtl=$this->report->campaign_template_detail($post['template_id']); $post['subject']=$tdtl['subject']; $post['msg']=$tdtl['msg']; }elseif($post['id']){ $dtl=$this->report->campaign_detail($post['id']); if($dtl['status']=='PUBLISHED'){ $tdtl=$this->report->campaign_template_detail($dtl['template_id']); $post['type']=$tdtl['type']; $post['subject']=$tdtl['subject']; $post['msg']=$tdtl['msg']; } } $inf=$this->report->test_campaign($post); $this->json_data($inf); } function create_hidden_template($campaign_id, $post){ $d=['type'=>$post['type'], 'subject'=>$post['subject'], 'msg'=>$post['msg'], 'is_hidden'=>1]; $dtl=$this->report->campaign_detail($campaign_id); if($dtl){ if($dtl['is_hidden_temp']){ $d['id']=$dtl['template_id']; } } return $this->common->save($d, "campaign_templates"); } function campaign_templates(){ $this->checkAccess('manage_campaigns'); $data['templates']=$this->report->campaign_templates(); $this->json_data($data); } function save_campaign_template(){ $this->checkAccess('manage_campaigns'); $inf=array('success'=>false, 'msg'=>'Error!'); $post=trim_array($this->input->post()); $id=$post['id']=intval($post['id']); $this->form_validation->set_rules('title', 'Template Name', "required|is_unique[campaign_templates.title.id!='$id']", $this->req); $this->form_validation->set_rules('type', 'type', "required", $this->req); if($post['type']=='EMAIL'){ $this->form_validation->set_rules('subject', 'Subject', "required", $this->req); $this->form_validation->set_rules('email_msg', 'Message', "required", $this->req); $post['msg']=$post['email_msg']; }else{ $post['subject']=''; $this->form_validation->set_rules('msg', 'Message', "required", $this->req); } if(@$this->form_validation->run() == FALSE){ $inf['errors']=$this->form_validation->get_errors(); $inf['msg']=reset($inf['errors']); }else{ $data=filter_value($post, array('id', 'title', 'type', 'subject', 'msg')); if($this->common->save($data, "campaign_templates")){ $inf['success']=true; $inf['msg']='Template '.($id?'updated':'added').' successfully'; } } $this->json_data($inf); } function campaign_template_detail($id){ $this->checkAccess('manage_campaigns'); $data['dtl']=$this->report->campaign_template_detail($id); $this->json_data($data); } function delete_campaign_template(){ $this->checkAccess('manage_campaigns'); $inf=array('success'=>false, 'msg'=>'Can not deleted!'); $id=intval($this->input->post('id')); if($this->report->delete_campaign_template($id)){ $inf['success']=true; $inf['msg']="Template deleted successfully"; } $this->json_data($inf); } function lists_leads_login_url(){ $data=$this->report->lists_leads_login_url(); $this->json_data($data); } function export_lists_leads_login_url(){ $data=$this->report->lists_leads_login_url(true); download_leads_login_url_csv($data['result']); } /** DB Backup */ function db_backups(){ $this->checkAccess('db_backup'); $list=get_dir_file_info(UP_PATHF.'db_backups/'); if(!$list){ $list=[]; } usort($list, function($a, $b) { return $b['date']-$a['date']; }); $res=[]; foreach($list as $r){ if($r['name']=='index.html') continue; $res[]=['name'=>$r['name'], 'size'=>round($r['size']/1024/1024, 2), 'date'=>get_date($r['date'], true), 'download_path'=>URL.'common/downloadFile/'.encode($r['server_path'])]; } $this->json_data(['result'=>$res]); } function take_db_backup(){ $this->checkAccess('db_backup'); if(!is_dir(UP_PATHF.'db_backups/')){ mkdir(UP_PATHF.'db_backups/', 777, true); write_file(UP_PATHF.'db_backups/index.html', "Directory access is forbidden."); } $this->load->model("dbbackup"); $fname="db_backup_".date('Y_m_d_h_i_s_A').".sql"; $this->dbbackup->takebackup($fname, UP_PATHF.'db_backups/', FALSE); $this->db_backups(); die; /** */ // $db="lms"; // $backup_dir=UP_PATHF.'db_backups/'; // $file_name="db_backup_".date('Y_m_d_h_i_s_A').".sql"; // $file_name="test.sql"; // if(ENVIRONMENT=='development'){ // $dumpvar=""; // $cmd = 'F:\\xampp\\mysql\\bin\\mysqldump.exe -h' . $this->db->hostname . ' -u' . $this->db->username . ' ' . $db . ' > ' . $backup_dir . $file_name; // }else{ // $cmd = 'mysqldump -h' . $this->db->hostname . ' -u' . $this->db->username . ' -p'.$this->db->password.' '. $db . ' > ' . $backup_dir . $file_name; // } // exec($cmd); // echo $cmd; // die; /** \ */ $this->load->dbutil(); $config=array( 'format'=>'txt', 'foreign_key_checks'=>FALSE, 'tables'=>[], 'ignore'=>['old_leads'] ); $backup = $this->dbutil->backup($config); $fname="db_backup_".date('Y_m_d_h_i_s_A').".sql"; write_file(UP_PATHF.'db_backups/'.$fname, $backup); $this->db_backups(); //$this->load->helper('download'); //force_download($fname, $backup); } } //EOF