diff --git a/admin/post/users.php b/admin/post/user.php similarity index 98% rename from admin/post/users.php rename to admin/post/user.php index 1ca98279..7fce39cb 100644 --- a/admin/post/users.php +++ b/admin/post/user.php @@ -266,6 +266,8 @@ if (isset($_POST['export_users_csv'])) { if ($count > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Users-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -273,7 +275,7 @@ if (isset($_POST['export_users_csv'])) { //set column headers $fields = array('Name', 'Email', 'Role', 'Status', 'Creation Date'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { @@ -288,7 +290,7 @@ if (isset($_POST['export_users_csv'])) { } $lineData = array($row['user_name'], $row['user_email'], $row['role_name'], $user_status_display, $row['user_created_at']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/asset.php b/user/post/asset.php index 1dd57c29..98e310ae 100644 --- a/user/post/asset.php +++ b/user/post/asset.php @@ -973,6 +973,8 @@ if (isset($_POST['export_assets_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = strtoAZaz09($client_name) . "-Assets-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -980,12 +982,12 @@ if (isset($_POST['export_assets_csv'])) { //set column headers $fields = array('Name', 'Description', 'Type', 'Make', 'Model', 'Serial Number', 'Operating System', 'Purchase Date', 'Warranty Expire', 'Install Date', 'Assigned To', 'Location', 'Physical Location', 'Notes'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while ($row = mysqli_fetch_array($sql)) { $lineData = array($row['asset_name'], $row['asset_description'], $row['asset_type'], $row['asset_make'], $row['asset_model'], $row['asset_serial'], $row['asset_os'], $row['asset_purchase_date'], $row['asset_warranty_expire'], $row['asset_install_date'], $row['contact_name'], $row['location_name'], $row['asset_physical_location'], $row['asset_notes']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/certificate.php b/user/post/certificate.php index b460062e..3d6b0e24 100644 --- a/user/post/certificate.php +++ b/user/post/certificate.php @@ -228,6 +228,8 @@ if (isset($_POST['export_certificates_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Certificates-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -235,12 +237,12 @@ if (isset($_POST['export_certificates_csv'])) { //set column headers $fields = array('Name', 'Description', 'Domain', 'Issuer', 'Expiration Date'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { $lineData = array($row['certificate_name'], $row['certificate_description'], $row['certificate_domain'], $row['certificate_issued_by'], $row['certificate_expire']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/contact.php b/user/post/contact.php index 4e6c08d3..9ddd754a 100644 --- a/user/post/contact.php +++ b/user/post/contact.php @@ -1164,6 +1164,8 @@ if (isset($_POST['export_contacts_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Contacts-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -1171,12 +1173,12 @@ if (isset($_POST['export_contacts_csv'])) { //set column headers $fields = array('Name', 'Title', 'Department', 'Email', 'Phone', 'Ext', 'Mobile', 'Location'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { $lineData = array($row['contact_name'], $row['contact_title'], $row['contact_department'], $row['contact_email'], formatPhoneNumber($row['contact_phone']), $row['contact_extension'], formatPhoneNumber($row['contact_mobile']), $row['location_name']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/credential.php b/user/post/credential.php index 38279349..c2ec8c09 100644 --- a/user/post/credential.php +++ b/user/post/credential.php @@ -320,6 +320,8 @@ if (isset($_POST['export_credentials_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Credentials-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -327,14 +329,14 @@ if (isset($_POST['export_credentials_csv'])) { //set column headers $fields = array('Name', 'Description', 'Username', 'Password', 'URI'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = mysqli_fetch_assoc($sql)){ $credential_username = decryptCredentialEntry($row['credential_username']); $credential_password = decryptCredentialEntry($row['credential_password']); $lineData = array($row['credential_name'], $row['credential_description'], $credential_username, $credential_password, $row['credential_uri']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/domain.php b/user/post/domain.php index 2ca4fdcf..093bf524 100644 --- a/user/post/domain.php +++ b/user/post/domain.php @@ -341,6 +341,8 @@ if (isset($_POST['export_domains_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Domains-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -348,12 +350,12 @@ if (isset($_POST['export_domains_csv'])) { //set column headers $fields = array('Domain', 'Description', 'Registrar', 'Web Host', 'Expiration Date'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { $lineData = array($row['domain_name'], $row['domain_description'], $row['domain_registrar'], $row['domain_webhost'], $row['domain_expire']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/expense.php b/user/post/expense.php index 89fd1c75..5e809428 100644 --- a/user/post/expense.php +++ b/user/post/expense.php @@ -303,6 +303,8 @@ if (isset($_POST['export_expenses_csv'])) { $num_rows = mysqli_num_rows($sql); if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "$session_company_name-Expenses-$file_name_date.csv"; //create a file pointer @@ -310,12 +312,12 @@ if (isset($_POST['export_expenses_csv'])) { //set column headers $fields = array('Date', 'Amount', 'Vendor', 'Description', 'Category', 'Account'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = mysqli_fetch_assoc($sql)) { $lineData = array($row['expense_date'], $row['expense_amount'], $row['vendor_name'], $row['expense_description'], $row['category_name'], $row['account_name']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/invoice.php b/user/post/invoice.php index 8c630c27..9daae9ce 100644 --- a/user/post/invoice.php +++ b/user/post/invoice.php @@ -1958,6 +1958,8 @@ if (isset($_POST['export_invoices_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "$session_company_name-Invoices-$file_name_date.csv"; //create a file pointer @@ -1965,12 +1967,12 @@ if (isset($_POST['export_invoices_csv'])) { //set column headers $fields = array('Invoice Number', 'Scope', 'Amount', 'Issued Date', 'Due Date', 'Status'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { $lineData = array($row['invoice_prefix'] . $row['invoice_number'], $row['invoice_scope'], $row['invoice_amount'], $row['invoice_date'], $row['invoice_due'], $row['invoice_status'], $row['client_name']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file @@ -2053,6 +2055,8 @@ if (isset($_POST['export_payments_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Payments-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -2060,12 +2064,12 @@ if (isset($_POST['export_payments_csv'])) { //set column headers $fields = array('Payment Date', 'Invoice Date', 'Invoice Number', 'Invoice Amount', 'Payment Amount', 'Payment Method', 'Referrence'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()){ $lineData = array($row['payment_date'], $row['invoice_date'], $row['invoice_prefix'] . $row['invoice_number'], $row['invoice_amount'], $row['payment_amount'], $row['payment_method'], $row['payment_reference']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/location.php b/user/post/location.php index ef6eb552..4f3616b8 100644 --- a/user/post/location.php +++ b/user/post/location.php @@ -371,6 +371,8 @@ if(isset($_POST['export_locations_csv'])){ if($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Locations-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -378,12 +380,12 @@ if(isset($_POST['export_locations_csv'])){ //set column headers $fields = array('Name', 'Description', 'Address', 'City', 'State', 'Postal Code', 'Phone', 'Hours'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()){ $lineData = array($row['location_name'], $row['location_description'], $row['location_address'], $row['location_city'], $row['location_state'], $row['location_zip'], $row['location_phone'], $row['location_hours']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/network.php b/user/post/network.php index a8128aa5..b04fc25f 100644 --- a/user/post/network.php +++ b/user/post/network.php @@ -163,6 +163,8 @@ if (isset($_POST['export_networks_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Networks-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -170,12 +172,12 @@ if (isset($_POST['export_networks_csv'])) { //set column headers $fields = array('Name', 'Description', 'vLAN', 'IP/Network', 'Subnet Mask', 'Gateway', 'Primary DNS', 'Secondary DNS', 'DHCP Range'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while ($row = $sql->fetch_assoc()) { $lineData = array($row['network_name'], $row['network_description'], $row['network_vlan'], $row['network'], $row['network_subnet'], $row['network_gateway'], $row['network_primary_dns'], $row['network_secondary_dns'], $row['network_dhcp_range']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/product.php b/user/post/product.php index 9ef7f7cb..e76e1aa2 100644 --- a/user/post/product.php +++ b/user/post/product.php @@ -246,6 +246,8 @@ if (isset($_POST['export_products_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "$session_company_name-Products.csv"; //create a file pointer @@ -253,12 +255,12 @@ if (isset($_POST['export_products_csv'])) { //set column headers $fields = array('Product', 'Description', 'Price', 'Currency', 'Category', 'Tax'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = mysqli_fetch_assoc($sql)) { $lineData = array($row['product_name'], $row['product_description'], $row['product_price'], $row['product_currency_code'], $row['category_name'], $row['tax_name']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/software.php b/user/post/software.php index 8d9d42e8..73e384b0 100644 --- a/user/post/software.php +++ b/user/post/software.php @@ -222,6 +222,8 @@ if (isset($_POST['export_client_software_csv'])) { if ($num_rows > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Software-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -229,7 +231,7 @@ if (isset($_POST['export_client_software_csv'])) { //set column headers $fields = array('Name', 'Version', 'Description', 'Type', 'License Type', 'Seats', 'Key', 'Assets', 'Contacts', 'Purchased', 'Expires', 'Notes'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { @@ -262,7 +264,7 @@ if (isset($_POST['export_client_software_csv'])) { } $lineData = array($row['software_name'], $row['software_version'], $row['software_description'], $row['software_type'], $row['software_license_type'], $row['software_seats'], $row['software_key'], $assigned_to_assets, $assigned_to_contacts, $row['software_purchase'], $row['software_expire'], $row['software_notes']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/trip.php b/user/post/trip.php index 951e4c49..c9faef80 100644 --- a/user/post/trip.php +++ b/user/post/trip.php @@ -89,6 +89,8 @@ if (isset($_POST['export_trips_csv'])) { if ($count > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Trips-$file_name_date.csv"; //create a file pointer @@ -96,12 +98,12 @@ if (isset($_POST['export_trips_csv'])) { //set column headers $fields = array('Date', 'Purpose', 'Source', 'Destination', 'Miles'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = mysqli_fetch_assoc($sql)){ $lineData = array($row['trip_date'], $row['trip_purpose'], $row['trip_source'], $row['trip_destination'], $row['trip_miles']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file diff --git a/user/post/vendor.php b/user/post/vendor.php index 9fbc7df4..8d737d6d 100644 --- a/user/post/vendor.php +++ b/user/post/vendor.php @@ -284,6 +284,8 @@ if (isset($_POST['export_vendors_csv'])) { if ($count > 0) { $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash $filename = "Vendors-" . date('Y-m-d') . ".csv"; //create a file pointer @@ -291,12 +293,12 @@ if (isset($_POST['export_vendors_csv'])) { //set column headers $fields = array('Name', 'Description', 'Contact Name', 'Phone', 'Website', 'Account Number', 'Notes'); - fputcsv($f, $fields, $delimiter); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); //output each row of the data, format line as csv and write to file pointer while($row = $sql->fetch_assoc()) { $lineData = array($row['vendor_name'], $row['vendor_description'], $row['vendor_contact_name'], $row['vendor_phone'], $row['vendor_website'], $row['vendor_account_number'], $row['vendor_notes']); - fputcsv($f, $lineData, $delimiter); + fputcsv($f, $lineData, $delimiter, $enclosure, $escape); } //move back to beginning of file