diff --git a/web_interface/astpp/application/libraries/Timezone.php b/web_interface/astpp/application/libraries/Timezone.php index 8f7a46323..bcdf58323 100755 --- a/web_interface/astpp/application/libraries/Timezone.php +++ b/web_interface/astpp/application/libraries/Timezone.php @@ -33,9 +33,13 @@ function uset_timezone() { $account_data = $this->CI->session->userdata ( 'accountinfo' ); return $account_data ['timezone_id']; } - function display_GMT($currDate, $fulldate = 1, $timezone_id = "") { + // ASTPPCOM-891 Ashish start + function display_GMT($currDate, $fulldate = 1, $timezone_id = "",$table_key = '') { + // ASTPPCOM-891 Ashish end $number = ($timezone_id == "") ? $this->uset_timezone () : $timezone_id; - $SERVER_GMT = '0'; + // ASTPPCOM-891 Ashish start + $SERVER_GMT = ($table_key == "livecall") ? $this->get_server_timezone(): '0' ; + // ASTPPCOM-891 Ashish end $result = $this->CI->db->query ( "select gmtoffset from timezone where id =" . $number ); $timezone_offset = $result->result (); @@ -63,7 +67,9 @@ function display_GMT($currDate, $fulldate = 1, $timezone_id = "") { } function convert_to_GMT_new($currDate, $fulldate = 1, $timezone_id = '') { $number = ($timezone_id == "") ? $this->uset_timezone () : $timezone_id; - $SERVER_GMT = '0'; + // ASTPPCOM-891 Ashish start + $SERVER_GMT = $this->get_server_timezone(); + // ASTPPCOM-891 Ashish End $result = $this->CI->db->query ( "select gmtoffset,timezone_name from timezone where id =" . $number ); $timezone_offset = $result->result (); $USER_GMT = $timezone_offset ['0']->gmtoffset; @@ -86,7 +92,9 @@ function convert_to_GMT_new($currDate, $fulldate = 1, $timezone_id = '') { function convert_to_GMT($currDate, $fulldate = 1, $timezone_id = '') { $number = ($timezone_id == "") ? $this->uset_timezone () : $timezone_id; - $SERVER_GMT = '0'; + // ASTPPCOM-891 Ashish start + $SERVER_GMT = $this->get_server_timezone(); + // ASTPPCOM-891 Ashish end $result = $this->CI->db->query ( "select gmtoffset from timezone where id =" . $number ); $timezone_offset = $result->result (); $USER_GMT = $timezone_offset ['0']->gmtoffset; @@ -114,6 +122,17 @@ function get_login_type_timezone(){ $date = new DateTime("now", new DateTimeZone($timezone_name)); return $date->format('Y-m-d'); } - + // ASTPPCOM-891 Ashish start + function get_server_timezone(){ + $server_time_zone = exec("timedatectl | grep Time"); + $server_time_zone = explode(":",$server_time_zone); + $server_time_zone = explode(" ",$server_time_zone[1]); + $result = $this->CI->db->query ( "select gmtoffset from timezone where timezone_name = '".$server_time_zone[1]."'" ); + $timezone_offset = $result->result (); + + $SERVER_GMT = $timezone_offset ['0']->gmtoffset; + return $SERVER_GMT; + } + // ASTPPCOM-891 Ashish end } ?> diff --git a/web_interface/astpp/application/libraries/astpp/common.php b/web_interface/astpp/application/libraries/astpp/common.php index 9c225fd45..2670b6b34 100755 --- a/web_interface/astpp/application/libraries/astpp/common.php +++ b/web_interface/astpp/application/libraries/astpp/common.php @@ -1862,14 +1862,15 @@ function emailFunction($from, $to, $subject, $message,$alert_template="",$usermo $last_id=$this->CI->db->insert_id(); return $last_id; } - - function convert_GMT_to($select = "", $table = "", $date, $timezone_id = '') { - + // ASTPPCOM-891 Ashish start + function convert_GMT_to($select = "", $table = "", $date, $timezone_id = '', $table_key = '') { + // ASTPPCOM-891 Ashish end if ($date == '0000-00-00 00:00:00') { return $date; } else { - - return $this->CI->timezone->display_GMT ( $date, 1, $timezone_id ); + // ASTPPCOM-891 Ashish start + return $this->CI->timezone->display_GMT ( $date, 1, $timezone_id , $table_key); + // ASTPPCOM-891 Ashish end } } function convert_GMT($date) { diff --git a/web_interface/astpp/application/modules/dashboard/controllers/dashboard.php b/web_interface/astpp/application/modules/dashboard/controllers/dashboard.php index 28c69fb3a..f21ababed 100755 --- a/web_interface/astpp/application/modules/dashboard/controllers/dashboard.php +++ b/web_interface/astpp/application/modules/dashboard/controllers/dashboard.php @@ -89,26 +89,42 @@ function customerReport_call_statistics_with_profit() { $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); $json_data = array(); if($post['drop_val'] == "t_week"){ - $start_date = (date('D')!='Mon') ? date('Y-m-d ',strtotime('last Monday')) : date('Y-m-d'); - $end_date = date('Y-m-d'); + // ASTPPCOM-891 Ashish start + $start_date = (date('D')!='Mon') ? date('Y-m-d H:i:s',strtotime('last Monday')) : date('Y-m-d H:i:s'); + $end_date = date('Y-m-d H:i:s'); + $start_date_gmt = (date('D')!='Mon') ? date('Y-m-d',strtotime('last Monday')) : date('Y-m-d'); + $end_date_gmt = date('Y-m-d'); + $start_date = $this->common->convert_GMT_new($start_date); + $end_date = $this->common->convert_GMT_new($end_date); + // ASTPPCOM-891 Ashish end }else{ $start_date=date($year.'-'.$month.'-01'); $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); $gmtoffset=$this->common->get_timezone_offset(); - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); + // ASTPPCOM-891 Ashish start + $end_date =date($year."-".$month."-".$end_day.' H:i:s'); + $end_date=date('Y-m-d',strtotime($end_date)); + $start_date_gmt = $start_date; + $end_date_gmt =$end_date; + $start_date = $this->common->convert_GMT_new($start_date); + $end_date = $this->common->convert_GMT_new($end_date); + // ASTPPCOM-891 Ashish end } $current_date=(int)date("d"); $count=0; $i=0; - $begin = new DateTime($start_date); - $end = new DateTime($end_date); + // ASTPPCOM-891 Ashish start + $begin = new DateTime($start_date_gmt); + $end = new DateTime($end_date_gmt); + // ASTPPCOM-891 Ashish end $end=$end->modify('+1 day'); $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end); $records_date=array(); $accountinfo=$this->session->userdata('accountinfo'); $parent_id= ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; - $customerresult = $this->dashboard_model->get_call_statistics('cdrs_day_by_summary',$parent_id,$start_date,$end_date); + // ASTPPCOM-891 Ashish start + $customerresult = $this->dashboard_model->get_call_statistics('cdrs_day_by_summary',$parent_id,$start_date_gmt,$end_date_gmt); + // ASTPPCOM-891 Ashish end $acc_arr = array(); $customer_total_result = array(); $customer_total_result['sum'] = '0'; @@ -125,6 +141,9 @@ function customerReport_call_statistics_with_profit() { $res_mcd = 0; if($customerresult -> num_rows > 0){ foreach ($customerresult->result_array() as $data) { + // ASTPPCOM-891 Ashish start + $data['day'] = date('d',strtotime($data['day'])); + // ASTPPCOM-891 Ashish end $acc_arr[$data['day']] = $data; $customer_total_result['sum'] += $data['sum']; $customer_total_result['answered'] += $data['answered']; @@ -357,10 +376,18 @@ function customerReport_maximum_countryminutes() { function customerReport_calculation(){ - $today_start_date = date("Y-m-d 00:00:00"); - $today_end_date = date("Y-m-d 23:59:59"); + // ASTPPCOM-891 Ashish start + $current_date = $this->common->get_current_login_type_timezone(); + $today_start_date = date($current_date." 00:00:00"); + $today_end_date = date($current_date." 23:59:59"); + $today_start_date=$this->common->convert_GMT_new ($today_start_date); + $today_end_date=$this->common->convert_GMT_new ($today_end_date); + // ASTPPCOM-891 Ashish End $start_date = date('Y-m-01 00:00:00'); $end_date = date('Y-m-d H:i:s'); + // ASTPPCOM-891 Ashish start + $end_date=$this->common->convert_GMT_new ($end_date); + // ASTPPCOM-891 Ashish End $accountinfo = $this->session->userdata ( 'accountinfo' ); if($accountinfo['type'] == '1'){ $reseller_id = $accountinfo['id']; @@ -546,12 +573,18 @@ function getrefill_value(){ function get_today_result(){ $accountinfo = $this->session->userdata ( 'accountinfo' ); + // ASTPPCOM-891 Ashish start + $start_date = $this->common->convert_GMT_new (date("Y-m-d") . " 00:00:00"); + $end_date = $this->common->convert_GMT_new (date("Y-m-d") . " 23:59:59"); + // ASTPPCOM-891 Ashish end if($accountinfo['type'] == '1'){ $reseller_id = $accountinfo['id']; }else{ $reseller_id = "0"; } - $query_refill = 'Select sum(amount) as today_refill_amount from payment_transaction where date >= "'.date("Y-m-d 00:00:00").'" and date <= "'.date("Y-m-d 23:59:59").'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish start + $query_refill = 'Select sum(amount) as today_refill_amount from payment_transaction where date >= "'.$start_date.'" and date <= "'.$end_date.'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish end $result_refill = $this->db->query($query_refill); $result_refill = (array) $result_refill->first_row(); if($result_refill['today_refill_amount'] == "" OR $result_refill['today_refill_amount'] == NULL){ @@ -559,8 +592,9 @@ function get_today_result(){ }else{ $result_array['today_refill_amount'] = $this->common_model->calculate_currency( $result_refill['today_refill_amount'] ) ; } - - $query_order = 'Select count(*) as order_count from orders where order_date <= "'.date("Y-m-d 23:59:59").'" and order_date >= "'.date("Y-m-d 00:00:00").'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish start + $query_order = 'Select count(*) as order_count from orders where order_date <= "'.$end_date.'" and order_date >= "'.$start_date.'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish end $result_order = $this->db->query($query_order); $count = (array) $result_order->first_row(); if($count['order_count'] == "" OR $count['order_count'] == NULL){ @@ -568,8 +602,9 @@ function get_today_result(){ }else{ $result_array['today_order_count'] = $count['order_count']; } - - $query = 'Select count(*) as account_count from accounts where creation <= "'.date("Y-m-d 23:59:59").'" and creation >= "'.date("Y-m-d 00:00:00").'" and reseller_id="'.$reseller_id.'" and status="0" and deleted="0"'; + // ASTPPCOM-891 Ashish start + $query = 'Select count(*) as account_count from accounts where creation <= "'.$end_date.'" and creation >= "'.$start_date.'" and reseller_id="'.$reseller_id.'" and status="0" and deleted="0"'; + // ASTPPCOM-891 Ashish end $result = $this->db->query($query); $count = (array) $result->first_row(); if($count['account_count'] == "" OR $count['account_count'] == NULL){ @@ -577,8 +612,9 @@ function get_today_result(){ }else{ $result_array['today_account_count'] = $count['account_count']; } - - $query = 'Select SUM(total_calls) as total_calls from cdrs_day_by_summary where calldate <= "'.date("Y-m-d 23:59:59").'" and calldate >= "'.date("Y-m-d 00:00:00").'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish start + $query = 'Select SUM(total_calls) as total_calls from cdrs_day_by_summary where calldate <= "'.$end_date.'" and calldate >= "'.$start_date.'" and reseller_id="'.$reseller_id.'"'; + // ASTPPCOM-891 Ashish end $result = $this->db->query($query); $count = (array) $result->first_row(); if($count['total_calls'] == "" OR $count['total_calls'] == NULL){ diff --git a/web_interface/astpp/application/modules/dashboard/models/dashboard_model.php b/web_interface/astpp/application/modules/dashboard/models/dashboard_model.php index 73f1bd16b..7b8ec7d4d 100755 --- a/web_interface/astpp/application/modules/dashboard/models/dashboard_model.php +++ b/web_interface/astpp/application/modules/dashboard/models/dashboard_model.php @@ -49,6 +49,7 @@ function get_recent_recharge() { return $this->db->get ( 'payments' ); } function get_call_statistics($table, $parent_id, $start_date = '', $end_date = '', $group_flag = true) { + // ASTPPCOM-891 Ashish start $this->db->select ( "sum(total_calls) as sum, SUM(total_answered_call) as answered, MAX(mcd) AS mcd, @@ -59,7 +60,8 @@ function get_call_statistics($table, $parent_id, $start_date = '', $end_date = ' sum(debit) as debit, sum(cost) as cost, SUM(total_answered_call) as completed, - DAY(calldate) as day", false ); + calldate as day", false ); + // ASTPPCOM-891 Ashish end $this->db->where ( 'calldate >=', $start_date . " 00:00:00" ); $this->db->where ( 'calldate <=', $end_date . " 23:59:59" ); $this->db->where ( 'reseller_id', $parent_id ); diff --git a/web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php b/web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php index 8b34606ac..48b193807 100755 --- a/web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php +++ b/web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php @@ -613,7 +613,9 @@ function livecall_report_json() 'cell' => array( " Hang Up ", // Ashish ASTPPCOM-752 - $this->common->convert_GMT_to('', '', $value['created']), + // ASTPPCOM-891 Ashish start + $this->common->convert_GMT_to('', '', $value['created'],'','livecall'), + // ASTPPCOM-891 Ashish end // Ashish 752 End $value['cid_name'] . " " . $value['cid_num'], $value['ip_addr'], diff --git a/web_interface/astpp/application/modules/reports/models/reports_model.php b/web_interface/astpp/application/modules/reports/models/reports_model.php index 2d9079b6f..60df2c778 100755 --- a/web_interface/astpp/application/modules/reports/models/reports_model.php +++ b/web_interface/astpp/application/modules/reports/models/reports_model.php @@ -40,8 +40,11 @@ function getcustomer_cdrs($flag, $start, $limit, $export = false) // ASTPPCOM-825 end $table_name = 'cdrs'; if ($this->session->userdata('advance_search_date') == 1) { - $where['callstart >= '] = date("Y-m-d") . " 00:00:00"; - $where['callstart <='] = date("Y-m-d") . " 23:59:59"; + // ASTPPCOM-891 Ashish start + $timezone = $this->common->get_current_login_type_timezone(); + $where['callstart >= '] =$this->common->convert_GMT_new ( $timezone . " 00:00:00"); + $where['callstart <='] =$this->common->convert_GMT_new ( $timezone . " 23:59:59"); + // ASTPPENT-891 Ashish end } else { if ($this->session->userdata('customerReport_cdrs_year') != '' and $this->session->userdata('customerReport_cdrs_year') != '0') { $table_name = $this->session->userdata('customerReport_cdrs_year'); @@ -110,14 +113,19 @@ function getreseller_cdrs($flag, $start, $limit, $export = false) "accountid <>" => $account_data['id'] ); if ($this->session->userdata('advance_search_date') == 1) { - $where['callstart >= '] = date("Y-m-d") . " 00:00:00"; - $where['callstart <='] = date("Y-m-d") . " 23:59:59"; + // ASTPPENT-891 Ashish start + $timezone = $this->common->get_current_login_type_timezone(); + $where['callstart >= '] =$this->common->convert_GMT_new ( $timezone . " 00:00:00"); + $where['callstart <='] =$this->common->convert_GMT_new ( $timezone . " 23:59:59"); + // ASTPPENT-891 Ashish end } } else { if ($this->session->userdata('advance_search_date') == 1) { $where = array( - 'callstart >= ' => date("Y-m-d") . " 00:00:00", - 'callstart <=' => date("Y-m-d") . " 23:59:59" + // ASTPPENT-891 Ashish start + 'callstart >= ' =>$this->common->convert_GMT_new ( date("Y-m-d") . " 00:00:00"), + 'callstart <=' => $this->common->convert_GMT_new (date("Y-m-d") . " 23:59:59") + // ASTPPENT-891 Ashish end ); } } @@ -165,8 +173,11 @@ function getprovider_cdrs($flag, $start, $limit, $export = false) if ($this->session->userdata('advance_search') != 1) { if ($this->session->userdata('advance_search_date') == 1) { - $where['callstart >= '] = date("Y-m-d") . " 00:00:00"; - $where['callstart <='] = date("Y-m-d") . " 23:59:59"; + // ASTPPENT-891 Ashish start + $timezone = $this->common->get_current_login_type_timezone(); + $where['callstart >= '] =$this->common->convert_GMT_new ( $timezone . " 00:00:00"); + $where['callstart <='] =$this->common->convert_GMT_new ( $timezone . " 23:59:59"); + // ASTPPENT-891 Ashish end } } else { if ($this->session->userdata('providerreport_cdrs_year') != '' and $this->session->userdata('providerreport_cdrs_year') != '0') { diff --git a/web_interface/astpp/application/modules/user/controllers/user.php b/web_interface/astpp/application/modules/user/controllers/user.php index 87afeb8a2..a6cf4a268 100755 --- a/web_interface/astpp/application/modules/user/controllers/user.php +++ b/web_interface/astpp/application/modules/user/controllers/user.php @@ -2814,6 +2814,10 @@ function user_invoice_unpaid_pay() function user_get_current_info() { $account_data = $this->session->userdata("accountinfo"); + // ASTPPCOM-891 Ashish start + $start_date = $this->common->convert_GMT_new (date("Y-m-d") . " 00:00:01"); + $end_date = $this->common->convert_GMT_new (date("Y-m-d H:i:s")); + // ASTPPCOM-891 Ashish end $where = array( "accountid" => $account_data['id'], "order_date >=" => date("Y-m-d 00:00:01"), @@ -2823,8 +2827,10 @@ function user_get_current_info() $result_array['product_count'] = $count_all; $where_cdr = array( "accountid" => $account_data['id'], - "callstart >=" => date("Y-m-d 00:00:01"), - "callstart <=" => date("Y-m-d H:i:s") + // ASTPPCOM-891 Ashish start + "callstart >=" => $start_date, + "callstart <=" => $end_date + // ASTPPCOM-891 Ashish end ); $count_cdrs = $this->db_model->countQuery("*", "cdrs", $where_cdr); $result_array['call_count'] = $count_cdrs; diff --git a/web_interface/astpp/application/modules/user/models/user_model.php b/web_interface/astpp/application/modules/user/models/user_model.php index 3b52a2187..be23f073c 100755 --- a/web_interface/astpp/application/modules/user/models/user_model.php +++ b/web_interface/astpp/application/modules/user/models/user_model.php @@ -380,8 +380,11 @@ function getuser_cdrs_list($flag, $start, $limit, $export = true) } $table_name = $account_data['type'] != 1 ? 'cdrs' : 'reseller_cdrs'; if ($this->session->userdata('advance_search_date') == 1) { - $where['callstart >= '] = date("Y-m-d") . " 00:00:00"; - $where['callstart <='] = date("Y-m-d") . " 23:59:59"; + // ASTPPCOM-891 Ashish start + $timezone = $this->common->get_current_login_type_timezone(); + $where['callstart >= '] = $this->common->convert_GMT_new ( $timezone . " 00:00:00"); + $where['callstart <='] = $this->common->convert_GMT_new ( $timezone . " 23:59:59"); + // ASTPPCOM-891 Ashish end } else { if ($this->session->userdata('cdrs_year') != '' and $this->session->userdata('cdrs_year') != '0') { $table_name = $this->session->userdata('cdrs_year');