diff --git a/application/controllers/api.php b/application/controllers/api.php index f0fbf17..bb5eaa9 100644 --- a/application/controllers/api.php +++ b/application/controllers/api.php @@ -814,7 +814,9 @@ public function saverecords() { 'file' => $data ['upload_data'] ['file_name'] ); $imgName = NFS_IMAGE_PATH.'/app_id_'.$app_id.'/'.$data ['upload_data'] ['file_name']; - //$imgName = base_url() . 'assets/images/data/form-data/' . $data ['upload_data'] ['file_name']; + //$imgName = base_url() + // . 'assets/images/data/form-data/' + // . $data ['upload_data'] ['file_name']; $temp_array = array( 'image' => $imgName, 'title' => $image_title @@ -826,7 +828,10 @@ public function saverecords() { $cap_id++; } - $this->form_results_model->update_mobile_activity($activity_inserted_id,array('form_images'=> json_encode($images_array))); + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id,array('form_images'=> json_encode($images_array)) + ); $err_msg=''; $uc_name = ''; @@ -848,7 +853,8 @@ public function saverecords() { $err_msg.="TOWN api return null, "; } - $district = $this->getDistrictName($location); // Get Town name against location + $district = $this-> + getDistrictName($location); // Get Town name against location if ($district) { $district_name = strip_tags($district); }else{ @@ -897,7 +903,8 @@ public function saverecords() { $fields_count = $this->db->list_fields('zform_' . $form_id); $fields_count = array_map('strtolower', $fields_count); if(count($fields_count) < 90){ - $field = array($element => array('type' => 'VARCHAR', 'constraint' => 200, 'NULL' => TRUE)); + $field = array($element => + array('type' => 'VARCHAR', 'constraint' => 200, 'NULL' => TRUE)); $this->dbforge->add_column('zform_' . $form_id, $field, $after_field); }else { @@ -920,7 +927,9 @@ public function saverecords() { ///////////////////////// HASSAN ANWAR //////////////////////////// /////////////////////////////////////////////////////////////////////// - $multiChoices = $this->db->query("Select * from form_multiselectFieldLabels where formId='$form_id'"); + $multiChoices = $this->db-> + query("Select * from form_multiselectFieldLabels + where formId='$form_id'"); foreach($multiChoices->result() as $row) { $fd=(array) $dataresultnew1; @@ -943,7 +952,11 @@ public function saverecords() { /////////////////////////////////////////////////////////////////////// } - $this->form_results_model->update_mobile_activity($activity_inserted_id,array('form_data_decoded'=> json_encode($dataresultnew1))); + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id, + array('form_data_decoded'=> json_encode($dataresultnew1)) + ); $final_array = array(); foreach ($dataresultnew1 as $key => $value) { @@ -963,7 +976,10 @@ public function saverecords() { if(!$ret_ins){ $err_msg .= $this->db->_error_message(); - $this->form_results_model->update_mobile_activity($activity_inserted_id,array('error'=>$err_msg)); + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id,array('error'=>$err_msg) + ); // $jsone_array = array ( // 'error' => $err_msg // ); @@ -972,7 +988,10 @@ public function saverecords() { } $form_result_id_new = $this->db->insert_id(); }catch (Exception $e) { - $this->form_results_model->update_mobile_activity($activity_inserted_id,array('error'=>$e->message())); + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id,array('error'=>$e->message()) + ); echo json_encode($jsone_array); exit; } @@ -1010,7 +1029,14 @@ public function saverecords() { 'image' => $image_path ['image'] ); if(strpos($image_path['title'], $form_info['security_key']) !== FALSE){ - $add_images ['title'] = urldecode(base64_decode(str_replace($form_info ['security_key'], '', $image_path['title']))); + $add_images ['title'] = + urldecode( + base64_decode( + str_replace( + $form_info ['security_key'], '', $image_path['title'] + ) + ) + ); } else { $add_images ['title'] = urldecode($image_path ['title']); } @@ -1035,7 +1061,8 @@ public function saverecords() { // this code is used for sending record to other domain if ($post_url) { - if ($form_id == '4575' && strpos($_SERVER ['SERVER_NAME'], 'dataplug.itu') !== false) { + if ($form_id == '4575' && + strpos($_SERVER ['SERVER_NAME'], 'dataplug.itu') !== false) { $tempary = array( 'imei_no' => $imei_no, 'image_url' => $add_images ['image'], @@ -1100,7 +1127,8 @@ public function saverecords() { // app3883($app_id,$imei_no,$dataresultnew1); } } - //$this->form_results_model->update_mobile_activity($activity_inserted_id,array('error'=>'submitted')); + //$this->form_results_model->update_mobile_activity( + // $activity_inserted_id,array('error'=>'submitted')); $this->form_results_model->remove_mobile_activity($activity_inserted_id); $jsone_array = array( 'success' => 'Record submitted successfully!.' @@ -1112,7 +1140,9 @@ public function saverecordscron() { //ob_get_level(); //ob_start(); ini_set ( 'memory_limit', '-1' ); - $unsent_activity_array = $this->db->order_by('id', 'ASC')->get_where('mobile_activity_log',array(),100)->result_array(); + $unsent_activity_array = $this->db-> + order_by('id', 'ASC')-> + get_where('mobile_activity_log',array(),100)->result_array(); //echo count($unsent_activity_array); //exit; $i = 0; @@ -1194,12 +1224,16 @@ public function saverecordscron() { $key => $v ); $captions_images = array_merge($captions_images, $tempary_cap); - } elseif ($key == 'form_id' || $key == 'security_key' || $key == "dateTime" || $key == "landing_page" || $key == "is_take_picture" || $key == 'form_icon_name') { + } elseif ($key == 'form_id' || $key == 'security_key' + || $key == "dateTime" || $key == "landing_page" + || $key == "is_take_picture" || $key == 'form_icon_name') { } else { if(strpos($v, $form_info['security_key']) !== FALSE){ - $vdcode = urldecode(base64_decode(str_replace($form_info['security_key'], '', $v))); + $vdcode = urldecode( + base64_decode(str_replace($form_info['security_key'], '', $v)) + ); } else { $vdcode = urldecode($v); @@ -1234,7 +1268,8 @@ public function saverecordscron() { $err_msg.="TOWN api return null, "; } - $district = $this->getDistrictName($location); // Get Town name against location + $district = $this-> + getDistrictName($location); // Get Town name against location if ($district) { $district_name = strip_tags($district); } else { @@ -1272,7 +1307,12 @@ public function saverecordscron() { $fields_count = $this->db->list_fields('zform_' . $form_id); $fields_count = array_map('strtolower', $fields_count); if (count($fields_count) < 90) { - $field = array($element => array('type' => 'VARCHAR', 'constraint' => 200, 'NULL' => TRUE)); + $field = + array( + $element => array( + 'type' => 'VARCHAR', 'constraint' => 200, 'NULL' => TRUE + ) + ); $this->dbforge->add_column('zform_' . $form_id, $field, $after_field); } else { $field = array($element => array('type' => 'TEXT', 'NULL' => TRUE)); @@ -1284,12 +1324,23 @@ public function saverecordscron() { } - $this->form_results_model->update_mobile_activity($activity_inserted_id, array('form_data_decoded' => json_encode($dataresultnew1))); + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id, + array('form_data_decoded' => json_encode($dataresultnew1)) + ); $ret_ins = $this->db->insert('zform_' . $form_id, $dataresultnew1); $form_result_id_new = $this->db->insert_id(); if (!$ret_ins) { - $err_msg .= 'Record Not Submitted. ' . $this->db->_error_message() . '. "Please Refresh your application"'; - $this->form_results_model->update_mobile_activity($activity_inserted_id, array('error' => $err_msg)); + $err_msg .= + 'Record Not Submitted. ' + . $this->db->_error_message() + . '. "Please Refresh your application"'; + $this->form_results_model-> + update_mobile_activity( + $activity_inserted_id, + array('error' => $err_msg) + ); continue; } @@ -1325,7 +1376,14 @@ public function saverecordscron() { 'image' => $image_path['image'] ); if(strpos($image_path ['title'], $form_info['security_key']) !== FALSE){ - $add_images ['title'] = urldecode(base64_decode(str_replace($form_info ['security_key'], '', $image_path ['title']))); + $add_images ['title'] = + urldecode( + base64_decode( + str_replace( + $form_info ['security_key'], '', $image_path ['title'] + ) + ) + ); } else { $add_images ['title'] = urldecode($image_path ['title']); } @@ -1434,7 +1492,15 @@ public function saverecordsharzindagi() { } //Stop activity saving if already saved - $activity_aready_exist = $this->db->get_where('zform_'.$form_id, array('form_id' => $form_id, 'imei_no' => $imei_no,'activity_datetime' => $activity_datetime))->row_array(); + $activity_aready_exist = $this->db-> + get_where( + 'zform_'.$form_id, + array( + 'form_id' => $form_id, + 'imei_no' => $imei_no, + 'activity_datetime' => $activity_datetime + ) + )->row_array(); if ($activity_aready_exist) { $jsone_array = array( 'success' => 'This activity already submitted.' @@ -1455,8 +1521,10 @@ public function saverecordsharzindagi() { $app_id = $form_info ['app_id']; // Temprary block the record sending $app_general_setting = get_app_general_settings($app_id); - if (isset($app_general_setting->record_stop_sending) && $app_general_setting->record_stop_sending == 1) { - $error_message = "Record receiving service currently not available. Please Try later"; + if (isset($app_general_setting->record_stop_sending) + && $app_general_setting->record_stop_sending == 1) { + $error_message = "Record receiving service currently not available. + Please Try later"; if ($app_general_setting->message_stop_sending_record != '') { $error_message = $app_general_setting->message_stop_sending_record; } @@ -1508,7 +1576,10 @@ public function saverecordsharzindagi() { // move the file - if ($s3->putObjectFile($fileTempName, $bucket_name, $imgName, S3::ACL_PUBLIC_READ)) { + if ($s3-> + putObjectFile( + $fileTempName, $bucket_name, $imgName, S3::ACL_PUBLIC_READ) + ) { $imgName = 'http://' . $bucket_name . '.s3.amazonaws.com/' . $imgName; $temp_array = array( 'image' => $imgName, @@ -1539,7 +1610,10 @@ public function saverecordsharzindagi() { $error_before = array( 'file' => $data ['upload_data'] ['file_name'] ); - $imgName = base_url() . 'assets/images/data/form-data/' . $data ['upload_data'] ['file_name']; + $imgName = + base_url() + . 'assets/images/data/form-data/' + . $data ['upload_data'] ['file_name']; $temp_array = array( 'image' => $imgName, 'title' => $image_title @@ -1575,7 +1649,10 @@ public function saverecordsharzindagi() { $error_before = array( 'file' => $data ['upload_data'] ['file_name'] ); - $imgName = base_url() . 'assets/images/data/form-data/' . $data ['upload_data'] ['file_name']; + $imgName = + base_url() + . 'assets/images/data/form-data/' + . $data ['upload_data'] ['file_name']; $temp_array = array( 'image' => $imgName, 'title' => $image_title @@ -1611,7 +1688,8 @@ public function saverecordsharzindagi() { } /** - * This function is used for saving the record which sent from android application + * This function is used for saving the record + * which sent from android application * * @return json * @author Zahid Nadeem @@ -1650,7 +1728,15 @@ public function saverecordsweb() { } //Stop activity saving if already saved - $activity_aready_exist = $this->db->get_where('zform_'.$form_id, array('form_id' => $form_id, 'imei_no' => $imei_no,'activity_datetime' => $activity_datetime))->row_array(); + $activity_aready_exist = $this->db-> + get_where( + 'zform_'.$form_id, + array( + 'form_id' => $form_id, + 'imei_no' => $imei_no, + 'activity_datetime' => $activity_datetime + ) + )->row_array(); if ($activity_aready_exist) { $jsone_array = array( 'success' => 'This activity already submitted.' @@ -1671,8 +1757,10 @@ public function saverecordsweb() { $app_id = $form_info ['app_id']; // Temprary block the record sending $app_general_setting = get_app_general_settings($app_id); - if (isset($app_general_setting->record_stop_sending) && $app_general_setting->record_stop_sending == 1) { - $error_message = "Record receiving service currently not available. Please Try later"; + if (isset($app_general_setting->record_stop_sending) + && $app_general_setting->record_stop_sending == 1) { + $error_message = "Record receiving service currently not available. + Please Try later"; if ($app_general_setting->message_stop_sending_record != '') { $error_message = $app_general_setting->message_stop_sending_record; } @@ -1692,7 +1780,8 @@ public function saverecordsweb() { exit(); } -/* $authorized = $this->app_model->appuser_imei_already_exist($imei_no, $app_id); +/* $authorized = $this->app_model-> + appuser_imei_already_exist($imei_no, $app_id); if ($app_general_setting->only_authorized == 1 && !$authorized) { $jsone_array = array( 'error' => 'You are not authorized' @@ -1727,12 +1816,22 @@ public function saverecordsweb() { $key => $v ); $captions_images = array_merge($captions_images, $tempary_cap); - } elseif ($key == 'form_id' || $key == 'security_key' || $key == "dateTime" || $key == "landing_page" || $key == "is_take_picture" || $key == 'form_icon_name') { + } elseif ($key == 'form_id' || $key == 'security_key' || $key == "dateTime" + || $key == "landing_page" || $key == "is_take_picture" + || $key == 'form_icon_name') { } else { if ($security_key) { - $vdcode = urldecode(base64_decode(str_replace($form_info ['security_key'], '', $v))); + $vdcode = urldecode( + base64_decode( + str_replace( + $form_info ['security_key'], + '', + $v + ) + ) + ); } else { $vdcode = urldecode($v); } @@ -1744,18 +1843,36 @@ public function saverecordsweb() { } $warning_message = ''; $app_map_view_setting = get_map_view_settings($app_id); - if(isset($app_map_view_setting->map_distance_mapping) && $app_map_view_setting->map_distance_mapping)//if Distance maping on then call this block + //if Distance maping on then call this block + if(isset($app_map_view_setting->map_distance_mapping) + && $app_map_view_setting->map_distance_mapping) { $saved_distance=500; - if($app_map_view_setting->distance !== ''){//if distance not given then default distance will assign as 500 + if($app_map_view_setting->distance !== ''){ + //if distance not given then default distance will assign as 500 $saved_distance=$app_map_view_setting->distance; } - $matching_value = $record[$app_map_view_setting->matching_field]; //this field name getting from setting and getting value from received json - $kml_poligon_rec = $this->db->get_where('kml_poligon', array('app_id' => $app_id, 'type' => 'distence','matching_value' => $matching_value))->row_array(); + + // this field name getting from setting and getting value from received json + $matching_value = $record[$app_map_view_setting->matching_field]; + $kml_poligon_rec = $this->db-> + get_where( + 'kml_poligon', + array('app_id' => $app_id, + 'type' => 'distence', + 'matching_value' => $matching_value + ) + )->row_array(); if(!empty($kml_poligon_rec)){ $lat_long = explode(',', $location);//Received location from mobile device - $distance_from_center = lan_lng_distance($kml_poligon_rec['latitude'], $kml_poligon_rec['longitude'],$lat_long[0], $lat_long[1]); + $distance_from_center = + lan_lng_distance( + $kml_poligon_rec['latitude'], + $kml_poligon_rec['longitude'], + $lat_long[0], + $lat_long[1] + ); if($distance_from_center > $saved_distance) { $warning_message = 'Your location mismatched. '; @@ -1793,7 +1910,13 @@ public function saverecordsweb() { } } // move the file - if ($s3->putObjectFile($fileTempName, $bucket_name, $imgName, S3::ACL_PUBLIC_READ)) { + if ($s3->putObjectFile( + $fileTempName, + $bucket_name, + $imgName, + S3::ACL_PUBLIC_READ + ) + ) { $imgName = 'http://' . $bucket_name . '.s3.amazonaws.com/' . $imgName; $temp_array = array( 'image' => $imgName, @@ -1838,7 +1961,9 @@ public function saverecordsweb() { $error_before = array( 'file' => $data ['upload_data'] ['file_name'] ); - $imgName = NFS_IMAGE_PATH.'/app_id_'.$app_id .'/'. $data ['upload_data'] ['file_name']; + $imgName = + NFS_IMAGE_PATH.'/app_id_'.$app_id .'/'. + $data ['upload_data'] ['file_name']; $temp_array = array( 'image' => $imgName, 'title' => $image_title @@ -1864,7 +1989,9 @@ public function saverecordsweb() { $town_name = strip_tags($town); } - $district = $this->getDistrictName($location); // Get Town name against location + $district = + $this-> + getDistrictName($location); // Get Town name against location if ($district) { $district_name = strip_tags($district); } @@ -1892,7 +2019,12 @@ public function saverecordsweb() { ///////////////////////// HASSAN ANWAR //////////////////////////// /////////////////////////////////////////////////////////////////////// - $multiChoices = $this->db->query("Select * from form_multiselectFieldLabels where formId='$form_id'"); + $multiChoices = + $this->db-> + query( + "Select * from form_multiselectFieldLabels + where formId='$form_id'" + ); foreach($multiChoices->result() as $row) { $fd=(array) $dataresultnew1; @@ -1926,7 +2058,8 @@ public function saverecordsweb() { ); $this->db->insert( 'mobile_activity_log', $mobile_log); //Mobile activity log - End - $err_msg = 'Record Not Submitted. '.$this->db->_error_message().'. "Please Refresh your application"'; + $err_msg = 'Record Not Submitted. '.$this->db-> + _error_message().'. "Please Refresh your application"'; $jsone_array = array ( 'error' => $err_msg ); @@ -1967,7 +2100,15 @@ public function saverecordsweb() { 'image' => $image_path ['image'] ); if ($security_key) { - $add_images ['title'] = urldecode(base64_decode(str_replace($form_info ['security_key'], '', $image_path ['title']))); + $add_images ['title'] = urldecode( + base64_decode( + str_replace( + $form_info ['security_key'], + '', + $image_path ['title'] + ) + ) + ); } else { $add_images ['title'] = urldecode($image_path ['title']); } diff --git a/application/controllers/tracking.php b/application/controllers/tracking.php index 3da9899..c30961a 100644 --- a/application/controllers/tracking.php +++ b/application/controllers/tracking.php @@ -27,8 +27,8 @@ public function savetracking() { $altitude = $_REQUEST ['altitude']; $speed = $_REQUEST ['speed']; $route_id = $_REQUEST ['routeId']; - $gpsTime = date('Y-m-d H:i:s', strtotime($_REQUEST ['gpsTime'])); - $deviceTS = date('Y-m-d H:i:s', strtotime($_REQUEST ['deviceTS'])); + $gps_time = date('Y-m-d H:i:s', strtotime($_REQUEST ['gpsTime'])); + $device_ts = date('Y-m-d H:i:s', strtotime($_REQUEST ['deviceTS'])); $created_datetime = date('Y-m-d H:i:s'); $dataresultnew = array( 'app_id' => $app_id, @@ -36,8 +36,8 @@ public function savetracking() { 'location' => $location, 'lat' => $lat, 'lng' => $lng, - 'gpsTime' => $gpsTime, - 'deviceTS' => $deviceTS, + 'gps_time' => $gps_time, + 'device_ts' => $device_ts, 'accuracy' => $accuracy, 'altitude' => $altitude, 'speed' => $speed,