Example #1
0
 public function action_test_log()
 {
     $lead_details = array('title' => 'Mr', 'first_name' => 'Simon', 'surname' => 'Skinner', 'address' => '115 Argosy Avenue', 'area' => 'Layton', 'town' => 'Blackpool', 'postcode' => 'FY37NG', 'telephone' => '7515879426', 'list_id' => '145');
     $dupe_check = GAB\Debtsolv::check_for_duplicate($lead_details['surname'], $lead_details['address'], $lead_details['postcode'], $lead_details['telephone']);
     if (!$dupe_check['found'] || $dupe_check['found'] && $dupe_check['location'] == 'leadpool') {
         // No client found in debtsolv or the client was found in leadpool
         // Create the lead
         $lead_creation = GAB\Debtsolv::create_lead($lead_details['title'], $lead_details['first_name'], $lead_details['surname'], $lead_details['address'], $lead_details['area'], $lead_details['town'], $lead_details['postcode']);
         if ($lead_creation['created']) {
             // Lead was created
             $campaign_contact = GAB\Debtsolv::create_campaign_contact_id($lead_creation['client_id'], "Test Comment");
             if ($campaign_contact['created']) {
                 $insert_lead_details = GAB\Debtsolv::insert_lead_details($lead_creation['client_id'], $lead_details['list_id'], "GAB");
                 print_r($insert_lead_details);
             } else {
                 // Campaign Contact was not created
                 $this->response(array('result' => 'fail', 'code' => 103, 'message' => "Campaign Contact ID was not created!"));
             }
         } else {
             // Lead was not created
             $this->response(array('result' => 'fail', 'code' => 102, 'message' => "Lead was not created!"));
         }
     } else {
         // Client already in Debtsolv
         $this->response(array('result' => 'fail', 'code' => 101, 'message' => "This client is already in Debtsolv!"));
     }
 }
Example #2
0
 public function get_wallboard_past_stats($center = "GAB")
 {
     $last_month = GAB\Debtsolv::get_referral_count($center, date("01-m-Y", strtotime("Last Month")), date("t-m-Y", strtotime("Last Month")));
     $this_month = GAB\Debtsolv::get_referral_count($center, date("01-m-Y"), date("t-m-Y"), 3600);
     $this_week = GAB\Debtsolv::get_referral_count($center, date("d-m-Y", strtotime("monday this week")), date("d-m-Y"), 300);
     // Return the array
     $this->response(array('last_month' => array('referrals' => $last_month['referrals'], 'pack_out' => $last_month['pack_outs'], 'pack_out_percentage' => $last_month['referrals'] == 0 ? 0 : number_format($last_month['pack_outs'] / $last_month['referrals'] * 100, 2), 'pack_out_value' => number_format($last_month['pack_outs_value'], 2)), 'this_month' => array('referrals' => $this_month['referrals'], 'pack_out' => $this_month['pack_outs'], 'pack_out_percentage' => $this_month['referrals'] == 0 ? 0 : number_format($this_month['pack_outs'] / $this_month['referrals'] * 100, 2), 'pack_out_value' => number_format($this_month['pack_outs_value'], 2)), 'this_week' => array('referrals' => $this_week['referrals'], 'pack_out' => $this_week['pack_outs'], 'pack_out_percentage' => $this_week['referrals'] == 0 ? 0 : number_format($this_week['pack_outs'] / $this_week['referrals'] * 100, 2), 'pack_out_value' => number_format($this_week['pack_outs_value'], 2))));
 }
Example #3
0
 public function action_supplier($campaign_id = null)
 {
     if (Auth::has_access('reports.supplier')) {
         // Start Auth If
         if (is_null($campaign_id) && is_null($this->param('listid'))) {
             $data['data_supplier_campaigns'] = Model_Data_Supplier_Campaign::find('all');
             $this->template->title = "Data_supplier_campaigns";
             $this->template->content = View::forge('data/supplier/campaign/index', $data);
         } else {
             $list_data = array();
             $campaign_title = null;
             $column_headings = null;
             $stats = null;
             if (!is_null($this->param('listid'))) {
                 $list_data = array('1' => array((int) $this->param('listid')), '2' => array((int) $this->param('listid') + 30000), '3' => array((int) $this->param('listid') + 50000));
                 $all_lists = array($list_data[1][0], $list_data[2][0], $list_data[3][0]);
                 $stats = GAB\Dialler::full_list($list_data);
             } else {
                 $campaign = Model_Data_Supplier_Campaign::find($campaign_id);
                 $campaign_title = $campaign->title;
                 $all_lists = array();
                 foreach ($campaign->data_supplier_campaign_lists as $list) {
                     $list_data[$list->database_server_id][] = $list->list_id;
                     $all_lists[] = $list->list_id;
                 }
                 ksort($list_data);
                 $stats = GAB\Dialler::list_stats($list_data);
                 $conversions = GAB\Dialler::conversion_chart($list_data);
             }
             if (is_null($all_lists)) {
                 Session::set_flash('fail', 'We currently have no data for that campaign!');
             } else {
                 $list_dispositions = GAB\Debtsolv::get_dialler_list_disposition_report($all_lists)->as_array();
                 // Split Disposition list into referrals and pack outs
                 $pack_outs = array();
                 $pack_ins = array();
                 $referrals = array();
                 $total_values = array('pack_outs' => 0, 'pack_ins' => 0, 'payments' => 0);
                 $pack_out_clients = array();
                 foreach ($list_dispositions as $single_result) {
                     if ($single_result['Description'] == "Lead Completed") {
                         $pack_outs[] = $single_result;
                         $total_values['pack_outs'] = isset($total_values['pack_outs']) ? $total_values['pack_outs'] + $single_result['DI'] : $single_result['DI'];
                         if ($single_result['Pack In Date'] != '30-12-1899') {
                             $pack_ins[] = $single_result;
                             $pack_out_clients[] = $single_result['ClientID'];
                             $total_values['pack_ins'] = isset($total_values['pack_ins']) ? $total_values['pack_ins'] + $single_result['DI'] : $single_result['DI'];
                         }
                     }
                     $referrals[] = $single_result;
                 }
                 $payments = GAB\Debtsolv::get_paid_in_report($all_lists)->as_array();
                 foreach ($payments as $payment) {
                     $total_values['payments'] = isset($total_values['payments']) ? $total_values['payments'] + $payment['Total Payments'] : $payment['Total Payments'];
                 }
                 $column_headings = array();
                 if (count($stats) > 0) {
                     $col1 = reset($stats);
                     foreach ($col1 as $column_head => $column_text) {
                         $column_headings[] = $column_head;
                     }
                 }
                 $referrals_headings = array();
                 $exclude_headings = array('Pack In Date', 'DI', 'Product');
                 if (count($referrals) > 0) {
                     $col1 = reset($referrals);
                     foreach ($col1 as $column_head => $column_text) {
                         if (!in_array($column_head, $exclude_headings)) {
                             $referrals_headings[] = $column_head;
                         }
                     }
                 }
                 $pack_outs_headings = array();
                 $exclude_headings = array('Pack In Date', 'Referred Date', 'Call Back Date');
                 if (count($pack_outs) > 0) {
                     $col1 = reset($pack_outs);
                     foreach ($col1 as $column_head => $column_text) {
                         if (!in_array($column_head, $exclude_headings)) {
                             $pack_outs_headings[] = $column_head;
                         }
                     }
                 }
                 $pack_ins_headings = array();
                 $exclude_headings = array('Description', 'Referred Date', 'Last Contact Date', 'Call Back Date');
                 if (count($pack_ins) > 0) {
                     $col1 = reset($pack_ins);
                     foreach ($col1 as $column_head => $column_text) {
                         if (!in_array($column_head, $exclude_headings)) {
                             $pack_ins_headings[] = $column_head;
                         }
                     }
                 }
                 $payment_headings = array();
                 $exclude_headings = array('Reference');
                 if (count($payments) > 0) {
                     $col1 = reset($payments);
                     foreach ($col1 as $column_head => $column_text) {
                         if (!in_array($column_head, $exclude_headings)) {
                             $payment_headings[] = $column_head;
                         }
                     }
                 }
             }
             $this->template->title = 'Supplier Reports » ' . $campaign_title;
             $this->template->content = View::forge('reports/supplier', array('campaign_id' => $campaign_id, 'total_values' => $total_values, 'payment_headings' => $payment_headings, 'payments' => $payments, 'pack_in_headings' => $pack_ins_headings, 'pack_ins' => $pack_ins, 'pack_out_headings' => $pack_outs_headings, 'pack_outs' => $pack_outs, 'list_dispositions_headings' => $referrals_headings, 'list_dispositions' => $referrals, 'list_title' => $campaign_title, 'list_stats_headings' => $column_headings, 'list_stats' => $stats, 'conversions' => $conversions));
             // End Given Choices If
         }
         // End Auth If
     } else {
         Session::set_flash('fail', 'You do not have access to that section: This has been logged!');
         Response::redirect('/');
     }
 }