PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.4
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.4
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
easy-invoice / templates / admin / import-page.php

import-page.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.4, at templates/admin/import-page.php

116 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Import screen.
4 *
5 * Receives: $sources, $previews, $result
6 *
7 * @package Easy_Invoice
8 */
9
10 use EasyInvoice\Controllers\ImportController;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 $labels = [
17 'clients' => __( 'clients', 'easy-invoice' ),
18 'clients_matched' => __( 'clients already here (reused)', 'easy-invoice' ),
19 'invoices' => __( 'invoices', 'easy-invoice' ),
20 'quotes' => __( 'quotes', 'easy-invoice' ),
21 'payments' => __( 'payments', 'easy-invoice' ),
22 'skipped' => __( 'skipped (imported earlier)', 'easy-invoice' ),
23 'already' => __( 'imported earlier', 'easy-invoice' ),
24 ];
25 ?>
26 <div class="p-8">
27 <div class="ei-app-page-header bg-white border-b border-gray-200 px-6 easy-invoice-admin-page-header">
28 <h1 class="text-2xl font-bold text-gray-900"><?php esc_html_e( 'Import', 'easy-invoice' ); ?></h1>
29 <p class="mt-1 text-sm text-gray-500">
30 <?php esc_html_e( 'Bring clients, quotes, invoices and payments in from another product. Nothing is renumbered, running an import twice adds nothing, and a client who already exists here is reused.', 'easy-invoice' ); ?>
31 </p>
32 </div>
33
34 <?php if ( is_array( $result ) ) : ?>
35 <?php if ( ! empty( $result['error'] ) ) : ?>
36 <div class="mt-6 rounded-md bg-red-50 border border-red-200 p-4"><p class="text-sm text-red-800"><?php echo esc_html( $result['error'] ); ?></p></div>
37 <?php else : ?>
38 <div class="mt-6 rounded-md bg-emerald-50 border border-emerald-200 p-4">
39 <p class="text-sm font-medium text-emerald-900">
40 <?php
41 /* translators: %s: source name. */
42 printf( esc_html__( 'Import from %s finished.', 'easy-invoice' ), esc_html( (string) ( $result['label'] ?? '' ) ) );
43 ?>
44 </p>
45 <ul class="mt-2 text-sm text-emerald-900 grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-1">
46 <?php foreach ( (array) ( $result['counts'] ?? [] ) as $key => $n ) : ?>
47 <li><strong><?php echo (int) $n; ?></strong> <?php echo esc_html( $labels[ $key ] ?? $key ); ?></li>
48 <?php endforeach; ?>
49 </ul>
50 <?php if ( ! empty( $result['notes'] ) ) : ?>
51 <ul class="mt-3 text-xs text-emerald-800 list-disc pl-5">
52 <?php foreach ( array_slice( (array) $result['notes'], 0, 20 ) as $note ) : ?>
53 <li><?php echo esc_html( $note ); ?></li>
54 <?php endforeach; ?>
55 </ul>
56 <?php endif; ?>
57 <p class="mt-3 text-sm"><a class="text-indigo-600 font-medium" href="<?php echo esc_url( admin_url( 'admin.php?page=easy-invoice-all' ) ); ?>"><?php esc_html_e( 'Open the invoice list', 'easy-invoice' ); ?></a></p>
58 </div>
59 <?php endif; ?>
60 <?php endif; ?>
61
62 <div class="mt-6 grid grid-cols-1 lg:grid-cols-2 gap-6 items-start">
63 <?php foreach ( $sources as $key => $importer ) : ?>
64 <div class="bg-white rounded-lg border border-gray-200 p-6">
65 <h2 class="text-lg font-semibold text-gray-900"><?php echo esc_html( $importer->label() ); ?></h2>
66 <?php if ( isset( $previews[ $key ] ) ) : ?>
67 <p class="mt-1 text-sm text-gray-600"><?php esc_html_e( 'Found on this site. Reads the data directly; the other plugin does not need to be active.', 'easy-invoice' ); ?></p>
68 <dl class="mt-4 grid grid-cols-2 gap-x-6 gap-y-1 text-sm">
69 <?php foreach ( $previews[ $key ] as $k => $n ) : ?>
70 <div class="flex justify-between border-b border-gray-100 py-1"><dt class="text-gray-500"><?php echo esc_html( $labels[ $k ] ?? $k ); ?></dt><dd class="font-medium text-gray-900" style="font-variant-numeric: tabular-nums;"><?php echo (int) $n; ?></dd></div>
71 <?php endforeach; ?>
72 </dl>
73 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="mt-4">
74 <input type="hidden" name="action" value="<?php echo esc_attr( ImportController::ACTION_RUN ); ?>">
75 <input type="hidden" name="source" value="<?php echo esc_attr( $key ); ?>">
76 <?php wp_nonce_field( ImportController::ACTION_RUN ); ?>
77 <button type="submit" class="inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md bg-indigo-600 text-white hover:bg-indigo-700">
78 <?php
79 /* translators: %s: source name. */
80 printf( esc_html__( 'Import from %s', 'easy-invoice' ), esc_html( $importer->label() ) );
81 ?>
82 </button>
83 </form>
84 <?php else : ?>
85 <p class="mt-1 text-sm text-gray-500"><?php esc_html_e( 'Nothing from this plugin was found on this site.', 'easy-invoice' ); ?></p>
86 <?php endif; ?>
87 </div>
88 <?php endforeach; ?>
89
90 <div class="bg-white rounded-lg border border-gray-200 p-6 lg:col-span-2">
91 <h2 class="text-lg font-semibold text-gray-900"><?php esc_html_e( 'CSV files', 'easy-invoice' ); ?></h2>
92 <p class="mt-1 text-sm text-gray-600">
93 <?php esc_html_e( 'For FreshBooks, Wave, Zoho, Invoice Ninja or a spreadsheet. Columns are matched by their header names, so most exports work unchanged; the templates show the names that are recognised. Invoices with several lines repeat the number on each row.', 'easy-invoice' ); ?>
94 </p>
95 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" enctype="multipart/form-data" class="mt-4 grid grid-cols-1 sm:grid-cols-2 gap-4">
96 <input type="hidden" name="action" value="<?php echo esc_attr( ImportController::ACTION_RUN ); ?>">
97 <input type="hidden" name="source" value="csv">
98 <?php wp_nonce_field( ImportController::ACTION_RUN ); ?>
99 <div>
100 <label for="ei-import-clients" class="block text-sm font-medium text-gray-700"><?php esc_html_e( 'Clients CSV', 'easy-invoice' ); ?></label>
101 <input type="file" id="ei-import-clients" name="clients_csv" accept=".csv,text/csv" class="mt-1 block w-full text-sm">
102 <a class="text-xs text-indigo-600" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . ImportController::ACTION_TPL . '&which=clients' ), ImportController::ACTION_TPL ) ); ?>"><?php esc_html_e( 'Download template', 'easy-invoice' ); ?></a>
103 </div>
104 <div>
105 <label for="ei-import-invoices" class="block text-sm font-medium text-gray-700"><?php esc_html_e( 'Invoices CSV', 'easy-invoice' ); ?></label>
106 <input type="file" id="ei-import-invoices" name="invoices_csv" accept=".csv,text/csv" class="mt-1 block w-full text-sm">
107 <a class="text-xs text-indigo-600" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=' . ImportController::ACTION_TPL . '&which=invoices' ), ImportController::ACTION_TPL ) ); ?>"><?php esc_html_e( 'Download template', 'easy-invoice' ); ?></a>
108 </div>
109 <div class="sm:col-span-2">
110 <button type="submit" class="inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md bg-indigo-600 text-white hover:bg-indigo-700"><?php esc_html_e( 'Import CSV', 'easy-invoice' ); ?></button>
111 </div>
112 </form>
113 </div>
114 </div>
115 </div>
116