Log Message Added : ps

This commit is contained in:
VE10-Sanjeev 2023-09-27 17:16:16 +05:30
parent a3c5f907af
commit cdf73ab9e1
3 changed files with 53 additions and 29 deletions

View File

@ -20,12 +20,13 @@ class ApiIntegration extends ResourceController
if(count($request_data)>0){
$this->logger->info("Api Integration : Request data count = ".count($request_data));
$this->logger->info("Api Integration : Request data = ".json_encode($request_data));
$i = 0;
$final_response = [];
foreach($request_data as $row_data)
{
$get_response[$i] = $this->call_methods((array)$row_data, $api_request_text);
$final_response[$i] = $get_response[$i]['message'];
$final_response[$i] = isset($get_response[$i]['message'])?$get_response[$i]['message']:$get_response[$i];
$i++;
}
// return $this->respond(['status' => 200, 'message' => $final_response,'references'=>$get_response]);
@ -36,7 +37,8 @@ class ApiIntegration extends ResourceController
}
} catch (\Exception $e) {
$this->logger->error("Api Integration : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api Integration : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api Integration : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
return $this->fail('request failed, An error occurred on line ' . $e->getline() . ' : ' . $e->getMessage());
}
@ -63,36 +65,55 @@ class ApiIntegration extends ResourceController
case "books":
try {
$records = (array)$row_data;
$wordpress_book_id = $records['id'];
$this->logger->info("Api CallMethods : method name = ".$method.", row data count = ".count($records).", wordpress Product Ref ID = ".$wordpress_book_id);
$response = $this->save_book_details($records, $wordpress_book_id);
$this->logger->info("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." response = ".$response['status']);
$this->logger->info("Api CallMethods : method name = ".$method.", data type =".gettype($records));
if (isset($records['id']) && !empty($records['id'])) {
$wordpress_book_id = $records['id'];
$this->logger->info("Api CallMethods : method name = ".$method.", row data count = ".count($records).", wordpress Product Ref ID = ".$wordpress_book_id);
$response = $this->save_book_details($records, $wordpress_book_id);
$this->logger->info("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." response = ".$response['status']);
} else {
throw new \Exception('The "id" field is not set or empty.');
}
} catch (\Exception $e) {
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception} ", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
return $this->fail('request failed, An error occurred on line ' . $e->getline() . ': ' . $e->getMessage());
}
break;
case "customers":
try {
$records = (array)$row_data;
$wordpress_customer_id = $records['id'];
$this->logger->info("Api CallMethods : method name = ".$method.", row data count = ".count($records).", wordpress Customer Ref ID = ".$wordpress_customer_id);
$response = $this->save_customer_details($records, $wordpress_customer_id);
$this->logger->info("Api CallMethods : response = ".$response['status']);
$this->logger->info("Api CallMethods : method name = ".$method.", data type =".gettype($records));
if (isset($records['id']) && !empty($records['id'])) {
$wordpress_customer_id = $records['id'];
$this->logger->info("Api CallMethods : method name = ".$method.", row data count = ".count($records).", wordpress Customer Ref ID = ".$wordpress_customer_id);
$response = $this->save_customer_details($records, $wordpress_customer_id);
$this->logger->info("Api CallMethods : response = ".$response['status']);
} else {
throw new \Exception('The "id" field is not set or empty.');
}
} catch (\Exception $e) {
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
return $this->fail('request failed, An error occurred on line ' . $e->getline() . ': ' . $e->getMessage());
}
break;
case "invoice":
try {
$records = (array)$row_data;
$this->logger->info("Api CallMethods : method name = ".$method.", data type =".gettype($records));
if (isset($records['id']) && !empty($records['id'])) {
$wordpress_order_id = $records['id'];
$this->logger->info("Api CallMethods : method name = ".$method.", row data count = ".count($records).", wordpress Order Ref ID = ".$wordpress_order_id);
$response = $this->save_sales_details($records, $wordpress_order_id);
$this->logger->info("Api CallMethods : response = ".$response['status']);
} else {
throw new \Exception('The "id" field is not set or empty.');
}
} catch (\Exception $e) {
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
return $this->fail('request failed, An error occurred on line ' . $e->getline() . ': ' . $e->getMessage());
}
break;
@ -103,7 +124,8 @@ class ApiIntegration extends ResourceController
} catch (\Exception $e) {
$exception_ends_with = $e->getline() ? 'on line ' . $e->getline() . ': ' . $e->getMessage() : $e->getMessage();
return $this->fail(ucwords($method).' request failed, An error occurred ' .$exception_ends_with);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
}
break;
case 'delete':
@ -135,7 +157,8 @@ class ApiIntegration extends ResourceController
$response = ['status' => 200, 'message' => $basic_message];
} catch (\Exception $e) {
$exception_ends_with = $e->getline() ? 'on line ' . $e->getline() . ': ' . $e->getMessage() : $e->getMessage();
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." Exception Message: " . $e->getMessage() . "<br> File: " . $e->getFile() . "<br> Line: " . $e->getLine() . "<br>");
return $this->fail('DELETE request failed, An error occurred' . $exception_ends_with);
}
break;
@ -149,7 +172,8 @@ class ApiIntegration extends ResourceController
} catch (\Exception $e) {
// Handle the exception, you can log it or return an error response
$exception_ends_with = $e->getline() ? 'on line ' . $e->getline() . ': ' . $e->getMessage() : $e->getMessage();
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
// $this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text))." {exception}", ['exception' => $e]);
$this->logger->error("Api CallMethods : ".str_replace("_", " ",ucwords($api_request_text)).$exception_ends_with);
return $this->fail('An error occurred ' . $exception_ends_with);
}
}
@ -291,7 +315,7 @@ class ApiIntegration extends ResourceController
$this->logger->info("Api SaveBookDetails : Image Data = $i ");
$i++;
} // image loop closed
$extensive_correspondence .= (!empty($book_image_data) ? $api_model->insertAndUpdateChildDetails($book_image_data, 'book_images', 'book_img_id') : []);
$extensive_correspondence .= (!empty($book_image_data) ? $api_model->insertAndUpdateChildDetails($book_image_data, 'book_images', 'book_img_id') : "");
$this->logger->info("Api SaveBookDetails : ".$extensive_correspondence);
} //image count closed
else{
@ -444,7 +468,7 @@ class ApiIntegration extends ResourceController
// echo "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; Keys are available but Billing address has no value; <br/>";
}
}
$extensive_correspondence .= (!empty($customer_billing_address_data) ? $api_model->insertAndUpdateChildDetails($customer_billing_address_data, 'customer_addresses', 'customer_address_id') : []);
$extensive_correspondence .= (!empty($customer_billing_address_data) ? $api_model->insertAndUpdateChildDetails($customer_billing_address_data, 'customer_addresses', 'customer_address_id') : "");
$this->logger->info("Api SaveCustomerDetails : ".$extensive_correspondence);
}
@ -528,7 +552,7 @@ class ApiIntegration extends ResourceController
// echo "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; Keys are available but Shipping address has no value <br/>";
}
}
$extensive_correspondence .= (!empty($customer_shipping_address_data) ? $api_model->insertAndUpdateChildDetails($customer_shipping_address_data, 'customer_addresses', 'customer_address_id') : []);
$extensive_correspondence .= (!empty($customer_shipping_address_data) ? $api_model->insertAndUpdateChildDetails($customer_shipping_address_data, 'customer_addresses', 'customer_address_id') : "");
$this->logger->info("Api SaveCustomerDetails : ".$extensive_correspondence);
}else{
$this->logger->error("Api SaveCustomerDetails : Err = Address Data Not Found");
@ -710,7 +734,7 @@ class ApiIntegration extends ResourceController
$this->logger->info("Api SaveSalesDetails : Invoiceitem Data inx = $i ");
$i++;
} // line item loop closed
$extensive_correspondence .= (!empty($line_item_data) ? $api_model->insertAndUpdateChildDetails($line_item_data, 'invoiceitems', 'invoice_child_id') : []);
$extensive_correspondence .= (!empty($line_item_data) ? $api_model->insertAndUpdateChildDetails($line_item_data, 'invoiceitems', 'invoice_child_id') : "");
$this->logger->info("Api SaveSalesDetails : ".$extensive_correspondence);
}
@ -794,7 +818,7 @@ class ApiIntegration extends ResourceController
$this->logger->info("Api SaveSalesDetails : Invoiceitem Data For Shipping inx = $j ");
$j++;
} // line item loop closed
$extensive_correspondence .= (!empty($shipping_line_item_data) ? $api_model->insertAndUpdateChildDetails($shipping_line_item_data, 'invoiceitems', 'invoice_child_id') : []);
$extensive_correspondence .= (!empty($shipping_line_item_data) ? $api_model->insertAndUpdateChildDetails($shipping_line_item_data, 'invoiceitems', 'invoice_child_id') : "");
$this->logger->info("Api SaveSalesDetails : ".$extensive_correspondence);
}
else{

View File

@ -265,10 +265,10 @@ class Authentication extends BaseController
$details = $auth_model->getheringDetailsForHeader($session_uid);
$data['loggedin_person'] = $session_uname;
$data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
$data['company_logo_small'] = file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
$data['company_logo_small'] = !empty($details[0]['company_logo_small']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = !empty($details[0]['company_logo_large']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$successMessage = session()->getFlashdata('success');
$validationErrors = session()->getFlashdata('error');
// Load and display the form view with the above data

View File

@ -74,10 +74,10 @@ abstract class BaseController extends Controller
$data['loggedin_person'] = $session_uname;
$data['loggedin_person_id'] = $session_uid;
$data['loggedin_person_role'] = $details[0]['role'];
$data['favicon'] = file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
$data['company_logo_small'] = file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
$data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
$data['company_logo_small'] = !empty($details[0]['company_logo_small']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_small']) ? base_url("public/uploads/" . $details[0]['company_logo_small']) : base_url("public/uploads/default_logo.png");
$data['company_logo_large'] = !empty($details[0]['company_logo_large']) && file_exists(FCPATH."public/uploads/".$details[0]['company_logo_large']) ? base_url("public/uploads/" . $details[0]['company_logo_large']) : base_url("public/uploads/default.png");
$data['browser_title'] = $data['company_name'] . ' | ' . $data['company_short_name'] . ' ' . $data['page_name'];
$data['heading'] = $data['page_name'] == "Dashboard" ? 'Welcome to ' . $data['company_name'] : "";
echo view('template/header.php', $data);