ts................
save(data) {
const temp = data.value;
const uploadData = new FormData();
for (let key in temp) {
let value = temp[key];
uploadData.append(key, value);
}
if (this.selectedFile !== undefined) {
uploadData.append('attachment1', this.selectedFile, this.selectedFile.name);
}
this.service.post('qa/all.php?type=saveReceivComplaintform', uploadData).subscribe(response => {
if (response['status'] == 'success') {
alert('Saved Successfully');
// this.router.navigate(['/checklist']);
} else {
console.log(response);
alert('Failed: An error occured, please try again!');
}
});
}
********* Error Detector line *************
error_reporting(E_ALL);
ini_set('display_errors', 1);
*****************************
****************chart code for anguler (php)2-12-23 ************
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Perform a query to fetch data from table1 and table2
$query = "
SELECT label1 AS label, value1 AS value FROM table1
UNION
SELECT label2 AS label, value2 AS value FROM table2
";
$result = $conn->query($query);
// Prepare an array to store the data
$data = array();
// Convert the result set to an associative array
while ($row = $result->fetch_assoc()) {
$data['labels'][] = $row['label'];
$data['totalMonthlyPurchaseData'][] = $row['value'];
}
// Close the database connection
$conn->close();
// Convert the data to JSON format and output
header('Content-Type: application/json');
echo json_encode($data);
?>
*********************************
// ...
// Inside your `onCreate` method
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Create a new "Select PDF" button
Button pdfButton = new Button(CustomerMaster.this);
pdfButton.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
pdfButton.setText("Select PDF");
// Create a new EditText for PDF name
final EditText pdfNameEditText = new EditText(CustomerMaster.this);
pdfNameEditText.setLayoutParams(new LinearLayout.LayoutParams(
0, // Set width to 0 to make it take remaining space
ViewGroup.LayoutParams.WRAP_CONTENT,
1 // Set layout_weight to 1 for the EditText to take the remaining space
));
pdfNameEditText.setHint("PDF Name");
// Create a new LinearLayout for the PDF pair
LinearLayout pdfPairLayout = new LinearLayout(CustomerMaster.this);
pdfPairLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
));
pdfPairLayout.setOrientation(LinearLayout.HORIZONTAL);
// Add the "Select PDF" button and PDF name EditText to the PDF pair layout
pdfPairLayout.addView(pdfButton);
pdfPairLayout.addView(pdfNameEditText);
// Add the PDF pair layout to the container layout
containerLayout.addView(pdfPairLayout);
// Set a click listener for the "Select PDF" button
pdfButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Create an intent to pick a PDF file
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
intent.addCategory(Intent.CATEGORY_OPENABLE);
// Start the activity to pick a PDF
startActivityForResult(Intent.createChooser(intent, "Select a PDF"), PICK_PDF_REQUEST);
}
});
}
});
// ...
// Modify the onActivityResult method to handle the selected PDF file
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_PDF_REQUEST && resultCode == Activity.RESULT_OK && data != null) {
pdfUri = data.getData();
// Get the PDF file name
String pdfName = getFileNameFromUri(pdfUri);
// Display the PDF name in the corresponding EditText
pdfNameEditText.setText(pdfName);
} else if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK && data != null) {
// Handle photo capture
// ...
}
}
// Helper method to extract the file name from a URI
private String getFileNameFromUri(Uri uri) {
String result = null;
if (uri.getScheme().equals("content")) {
try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
int index = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
if (index != -1) {
result = cursor.getString(index);
}
}
}
}
if (result == null) {
result = uri.getLastPathSegment();
}
return result;
}
ffffsdfag