Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import CSV - Check file uploaded #1105

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client_asset_import_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<p><strong>Format csv file with headings & data:</strong><br>Name, Description, Type, Make, Model, Serial, OS, Assigned To, Location</p>
<hr>
<div class="form-group my-4">
<input type="file" class="form-control-file" name="file" accept=".csv">
<input type="file" class="form-control-file" name="file" accept=".csv" required>
</div>
<hr>
<div>Download <a href="post.php?download_client_assets_csv_template=<?php echo $client_id; ?>">sample csv template</a></div>
Expand Down
2 changes: 1 addition & 1 deletion client_contact_import_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p><strong>Format csv file with headings & data:</strong><br>Name, Title, Department, Email, Phone, Extension, Mobile, Location</p>
<hr>
<div class="form-group my-4">
<input type="file" class="form-control-file" name="file" accept=".csv">
<input type="file" class="form-control-file" name="file" accept=".csv" required>
</div>
<hr>
<div>Download: <a class="text-bold" href="post.php?download_client_contacts_csv_template=<?php echo $client_id; ?>">sample csv template</a></div>
Expand Down
3 changes: 1 addition & 2 deletions client_import_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
</button>
</div>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white">
<p><strong>Format csv file with headings & data:</strong><br>Client Name, Industry, Referral, Website, Location Name, Location Phone, Location Address, City, State, Postal Code, Country, Contact Name, Title, Contact Phone, Extension, Contact Mobile, Contact Email, Hourly Rate, Currency, Payment Terms, Tax ID, Abbreviation</p>
<hr>
<div class="form-group my-4">
<input type="file" class="form-control-file" name="file" accept=".csv">
<input type="file" class="form-control-file" name="file" accept=".csv" required>
</div>
<hr>
<div>Download: <a class="text-bold" href="post.php?download_clients_csv_template">sample csv template</a></div>
Expand Down
2 changes: 1 addition & 1 deletion client_location_import_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p><strong>Format csv file with headings & data:</strong><br>Name, Description, Address, City, State, Postal Code, Phone, Hours</p>
<hr>
<div class="form-group my-4">
<input type="file" class="form-control-file" name="file" accept=".csv">
<input type="file" class="form-control-file" name="file" accept=".csv" required>
</div>
<hr>
<div>Download: <a class="text-bold" href="post.php?download_client_locations_csv_template=<?php echo $client_id; ?>">sample csv template</a></div>
Expand Down
2 changes: 1 addition & 1 deletion client_login_import_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p><strong>Format csv file with headings & data:</strong><br>Name, Description, Username, Password, URL</p>
<hr>
<div class="form-group my-4">
<input type="file" class="form-control-file" name="file" accept=".csv">
<input type="file" class="form-control-file" name="file" accept=".csv" required>
</div>
<hr>
<div>Download <a class="text-bold" href="post.php?download_client_logins_csv_template=<?php echo $client_id; ?>">sample csv template</a></div>
Expand Down
10 changes: 10 additions & 0 deletions post/user/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,18 @@

$client_id = intval($_POST['client_id']);
$file_name = $_FILES["file"]["tmp_name"];

$error = false;

if (!empty($_FILES["file"]["tmp_name"])) {
$file_name = $_FILES["file"]["tmp_name"];
} else {
$_SESSION['alert_message'] = "Please select a file to upload.";
$_SESSION['alert_type'] = "error";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}

//Check file is CSV
$file_extension = strtolower(end(explode('.',$_FILES['file']['name'])));
$allowed_file_extensions = array('csv');
Expand Down
13 changes: 10 additions & 3 deletions post/user/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,17 @@
if (isset($_POST["import_clients_csv"])) {

enforceUserPermission('module_client', 2);

$file_name = $_FILES["file"]["tmp_name"];
$error = false;

if (!empty($_FILES["file"]["tmp_name"])) {
$file_name = $_FILES["file"]["tmp_name"];
} else {
$_SESSION['alert_message'] = "Please select a file to upload.";
$_SESSION['alert_type'] = "error";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}

//Check file is CSV
$file_extension = strtolower(end(explode('.',$_FILES['file']['name'])));
$allowed_file_extensions = array('csv');
Expand Down Expand Up @@ -589,7 +596,7 @@
if (isset($_GET['download_clients_csv_template'])) {

$delimiter = ",";
$filename = strtoAZaz09($client_name) . "-Clients-Template.csv";
$filename = "Clients-Template.csv";

//create a file pointer
$f = fopen('php://memory', 'w');
Expand Down
10 changes: 9 additions & 1 deletion post/user/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,17 @@
enforceUserPermission('module_client', 2);

$client_id = intval($_POST['client_id']);
$file_name = $_FILES["file"]["tmp_name"];
$error = false;

if (!empty($_FILES["file"]["tmp_name"])) {
$file_name = $_FILES["file"]["tmp_name"];
} else {
$_SESSION['alert_message'] = "Please select a file to upload.";
$_SESSION['alert_type'] = "error";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}

//Check file is CSV
$file_extension = strtolower(end(explode('.',$_FILES['file']['name'])));
$allowed_file_extensions = array('csv');
Expand Down
10 changes: 9 additions & 1 deletion post/user/credential.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,17 @@
enforceUserPermission('module_credential', 2);

$client_id = intval($_POST['client_id']);
$file_name = $_FILES["file"]["tmp_name"];
$error = false;

if (!empty($_FILES["file"]["tmp_name"])) {
$file_name = $_FILES["file"]["tmp_name"];
} else {
$_SESSION['alert_message'] = "Please select a file to upload.";
$_SESSION['alert_type'] = "error";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}

//Check file is CSV
$file_extension = strtolower(end(explode('.',$_FILES['file']['name'])));
$allowed_file_extensions = array('csv');
Expand Down
10 changes: 9 additions & 1 deletion post/user/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,17 @@
enforceUserPermission('module_client', 2);

$client_id = intval($_POST['client_id']);
$file_name = $_FILES["file"]["tmp_name"];
$error = false;

if (!empty($_FILES["file"]["tmp_name"])) {
$file_name = $_FILES["file"]["tmp_name"];
} else {
$_SESSION['alert_message'] = "Please select a file to upload.";
$_SESSION['alert_type'] = "error";
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit();
}

//Check file is CSV
$file_extension = strtolower(end(explode('.',$_FILES['file']['name'])));
$allowed_file_extensions = array('csv');
Expand Down
Loading