diff --git a/CHANGELOG.md b/CHANGELOG.md index 089037189..b769492b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Imports: contacts take Primary, Important, Billing, Technical, Tags and Notes, and keep a phone's country code; locations take Country, On-site Contact, Primary, Tags and Notes; credentials take URI 2, Favorite, Asset, Contact, Tags and Notes; networks take Site, Provider, Tags and Notes. A credential whose 2FA secret isn't one is not imported, rather than imported without its 2FA. - Imports: vendors, domains, certificates, licenses and services import too, from Import under the arrow beside each list's New button. Vendors go to the client whose vendors it's opened from, or are your own when it's opened from your vendors. A new domain is looked up, and a certificate with a host is checked, on its refresher's next run. A license's Assets and Contacts give it seats, and a service's Runs On, Vendors, People and Domains link it to them - by name, added to what it has. A license Type that isn't a software type yet is added. - Pictures: your picture, a user's and a contact's, and the photos of assets, locations and racks, show on their form as the picture itself with a camera on it - the person's initials, or a camera, when there isn't one. Click it to open the Picture window: drop, paste or choose a picture, crop it to fit the shape it's shown in - a circle for a person - by dragging and zooming, turn it a quarter at a time, and Use this picture, or Remove the one there is. Photos of assets, locations and racks can also be square, 4:3, 3:4 or the whole photo. What's kept is what's in the frame, at up to 512 pixels across for a person and 2048 for a photo, so a big phone photo goes in at a sensible size, the right way up, without its location or camera details. A person's initials follow their name as it's typed. +- Receipts and logos open in the Picture window too: an expense's receipt (on its form, and on its quick look, where it's saved as soon as it's used) and your company's logo (Admin > Settings > Company details, and the setup wizard, where your own picture works the same way). They have no set shape - drag the frame's corners and edges in to just the receipt or logo. Trim the edges cuts the empty or plain-coloured space round a logo, and a PNG logo keeps its see-through background. A receipt can still be a PDF, which goes in as it is. A receipt is kept at up to 2400 pixels, so it stays readable, and a logo at up to 1200. ### Bug Fixes @@ -104,7 +105,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - `Virtual Machine` in `ASSET_TYPES` (`functions/asset_type.php`) has the `purchase` fields - Vendor, Order / invoice reference and Purchased. - Imports run through one window, `agent/modals/import/import.php?kind=&client_id=`, and one handler, `agent/post/import.php`: `import_check` and `import_run` (both JSON, the file sent each time with the column map) and `import_template`. Each kind is an entry in `importKinds()` (`functions/import_kinds.php`) - its permission module, whether it is a client's, its fields (template and export heading, other headings taken for it, required, help, example), `find` (the record already here), `key` (what makes two rows the same record), `legacy` (the old fixed columns, by position) and `row`, which adds or updates one record from the fields the file has. Adding a kind is an entry and its `row` function. `importProcess()` (`functions/import.php`) runs the rows in a transaction, each behind a savepoint so a row that fails is undone whole, commits it for `import_run` and rolls it back for `import_check` - the check is the import itself, as the email preview is; like it, a check moves `AUTO_INCREMENT` on. `importAutoMap()` matches headings, `importFile()` checks and reads the upload (comma or semicolon, byte-order mark, 10 MB and 5,000 rows at most). The per-kind import windows, their `import_*_csv` and `download_*_csv_template` handlers, `importColumns()`, `importCsvRows()`, `importLegacyColumns()`, `importHeadingsText()`, `importTagIds()`, `importNotesText()` and `NETWORK_CSV_COLUMNS` are gone. Templates need read access to the kind's module - the products template had no check. An asset an import adds or updates gets an `asset_history` row. - Import kinds `vendors`, `domains`, `certificates`, `licenses` and `services` in `importKinds()`, saved through `vendorFormSet()`, `domainFormSet()` with `domainWriteHistory()`, `certificateFormSet()` with `certificateWriteHistory()`, `softwareFormSet()` with `softwareSyncSeats()` and `softwareAddKeys()`, and `serviceFormSet()` with `linkAdd()`. Updating, a kind's row reads the record's current values into the form's fields and lays the file's over them, so it is checked as the form checks it. A kind's `module` can be a callable of the client id (`importModule()`) and its `client` `'optional'` - a vendor is the client's (`module_client`), or with none your own (`module_financial`). `log` names it in the audit log when that isn't its `one` (licenses log as Software). `importClientRecordId()` finds a client's domain, and `importClientRecordIds()` reads a cell of names separated by commas. The Domains and Certificates menus show to an agent who can add, so Import is there on an empty list. -- Picture fields: `pictureField($name, $remove_name, $current, $empty, $opts)` (`functions/picture.php`) renders the picture as a button with a camera badge, a hidden file input named `$name` and a hidden `$remove_name` input; `js/picture_field.js` opens the Picture window over the form's own (the window stacking in `js/app.js`), crops on a canvas and puts the crop in the file input through `DataTransfer` - a JPG for a JPG, else WebP, PNG where the browser can't write WebP - and sets the remove input to 1 on Remove, so the forms post the same fields as before and no handler changed. Options: `round`, `shapes`, `max`, `class` (the new picture's ``), `box` and `name` (the field the initials follow). `picturePhoto()` and `picturePhotoEmpty()` are a photo's two looks. Used on the profile, Admin > Users, contacts, assets, locations and racks, replacing their file inputs, remove boxes and preview scripts. A browser without `DataTransfer` gets the file picker and the file as picked. +- Picture fields: `pictureField($name, $remove_name, $current, $empty, $opts)` (`functions/picture.php`) renders the picture as a button with a camera badge, a hidden file input named `$name` and a hidden `$remove_name` input; `js/picture_field.js` opens the Picture window over the form's own (the window stacking in `js/app.js`), crops on a canvas and puts the crop in the file input through `DataTransfer` - a JPG for a JPG, else WebP, PNG where the browser can't write WebP - and sets the remove input to 1 on Remove, so the forms post the same fields as before and no handler changed. Options: `round`, `shapes`, `max`, `class` (the new picture's ``), `box` and `name` (the field the initials follow). `picturePhoto()` and `picturePhotoEmpty()` are a photo's two looks. Used on the profile, Admin > Users, contacts, assets, locations and racks, replacing their file inputs, remove boxes and preview scripts. A browser without `DataTransfer` gets the file picker and the file as picked. Free crops: `shapes => 'free'` gives a frame with corner and edge handles over the whole picture instead of the fixed-shape crop, `trim` adds Trim the edges (transparent, or within a small distance of the corner colour, found on a downscaled probe), `accept` sets the file types - with `application/pdf` a PDF is used as it is - and `submit` sends the form once a picture is used; `box` adds `tall` (a receipt) and `logo`, and `pictureFile()` is a PDF's look. A PNG source stays PNG when the field doesn't take WebP, so a logo keeps its transparency. Used on the expense form and quick look (`expense_receipt_save` is now posted as a hidden field), Admin > Settings > Company details and the setup wizard's company and account steps; `js/setup.js` loses its `data-setup-image` preview and checks, and `.itflow-setup-preview` is gone. ## [26.11.8] diff --git a/admin/settings_company.php b/admin/settings_company.php index 372de586c..d62b536f3 100644 --- a/admin/settings_company.php +++ b/admin/settings_company.php @@ -75,23 +75,16 @@ echo settingsPageStart('company'); -
-
-
- Your logo> - - No logo yet - -
-
-
- 'fa-image', 'type' => 'file', 'label' => $logo_url !== '' ? 'Replace it' : 'Add one', 'accept' => 'image/png,image/jpeg', - 'data' => ['settings-preview' => 'settingsLogoPreview'], 'help' => 'A PNG or JPG, up to 5 MB. A wide one prints best.']) ?> - - Take the logo off - -
-
+ ' : picturePhotoEmpty('Add your logo', 'fa-image'); + echo settingsField('company_logo', '', pictureField('company_logo', '', $logo_shows, picturePhotoEmpty('Add your logo', 'fa-image'), + ['title' => 'Logo', 'shapes' => 'free', 'box' => 'logo', 'max' => 1200, 'trim' => true, 'accept' => 'image/png,image/jpeg', 'class' => 'itflow-picture-logo', 'id' => 'settings_company_logo']), + 'Click it to ' . ($logo_url !== '' ? 'change it' : 'add one') . ' - a PNG or JPG. A wide one prints best, and a PNG keeps a see-through background.'); + ?> + + Take the logo off + diff --git a/agent/modals/expense/expense.php b/agent/modals/expense/expense.php index 1447a76d1..c9477d718 100644 --- a/agent/modals/expense/expense.php +++ b/agent/modals/expense/expense.php @@ -104,18 +104,18 @@ ob_start();
- -
-
+ -
- - - -
+ + 'Receipt', 'shapes' => 'free', 'box' => 'tall', 'max' => 2400, 'accept' => 'image/*,application/pdf', 'submit' => true]) ?>
+
+ + +
diff --git a/agent/modals/expense/expense_form.php b/agent/modals/expense/expense_form.php index 0e5e66e46..3054e4fee 100644 --- a/agent/modals/expense/expense_form.php +++ b/agent/modals/expense/expense_form.php @@ -292,22 +292,23 @@ $form_markup = $form_row && !$form_refund ? floatval($form_row['expense_markup']
- - -
- - -
- - -
+ + +
+ 'Receipt', 'shapes' => 'free', 'box' => 'tall', 'max' => 2400, 'accept' => 'image/*,application/pdf']) ?> +
+ +
+ + Click it to - on a phone, take the picture right there.
- -
- -
-
A photo or a PDF - on a phone, take the picture right here.
diff --git a/css/itflow_custom.css b/css/itflow_custom.css index f3cee3d76..ffe4f4316 100644 --- a/css/itflow_custom.css +++ b/css/itflow_custom.css @@ -8334,39 +8334,6 @@ a.itflow-portal-request:focus-visible { .itflow-setup-checks .list-group-item { background: transparent; } -/* The picture picked for the avatar or logo, before it is sent */ -.itflow-setup-preview { - flex: 0 0 auto; - width: 3.5rem; - height: 3.5rem; - display: flex; - align-items: center; - justify-content: center; - border: 1px dashed var(--bs-border-color); - border-radius: .5rem; - background: var(--bs-tertiary-bg); - color: var(--bs-secondary-color); - font-size: 1.25rem; - overflow: hidden; -} -.itflow-setup-preview.is-round { - border-radius: 50%; -} -.itflow-setup-preview.has-image { - border-style: solid; -} -.itflow-setup-preview.has-image > i { - display: none; -} -.itflow-setup-preview > img { - width: 100%; - height: 100%; - object-fit: cover; -} -.itflow-setup-preview:not(.is-round) > img { - object-fit: contain; - padding: .2rem; -} /* Finish - what to do once signed in, numbered */ .itflow-setup-next { counter-reset: itflow-setup-next; @@ -9468,6 +9435,28 @@ a.itflow-portal-request:focus-visible { width: 10rem; height: 7.5rem; } +.itflow-picture-field.is-tall .itflow-picture-preview { + width: 7.5rem; + height: 10rem; +} +.itflow-picture-field.is-logo .itflow-picture-preview { + width: 16rem; + max-width: 100%; + height: 6rem; + border: 1px solid var(--bs-border-color); + background-color: var(--bs-tertiary-bg); +} +.itflow-picture-field.is-logo { + max-width: 100%; +} +/* A logo fitted whole in its box, with room round it */ +.itflow-picture-logo { + display: block; + width: 100%; + height: 100%; + padding: .5rem; + object-fit: contain; +} .itflow-picture-photo { display: block; width: 100%; @@ -9492,6 +9481,21 @@ a.itflow-portal-request:focus-visible { .itflow-picture-none i { font-size: 1.4rem; } +/* A file that isn't a picture - a PDF receipt */ +.itflow-picture-none.is-file { + border-style: solid; + color: var(--bs-body-color); +} +.itflow-picture-none.is-file i { + color: var(--bs-danger); +} +.itflow-picture-doc .itflow-picture-none { + height: 12rem; + font-size: .9rem; +} +.itflow-picture-doc .itflow-picture-none i { + font-size: 3rem; +} /* Darker on hover, with the camera to say it can be changed */ .itflow-picture-button::after { position: absolute; @@ -9601,6 +9605,43 @@ a.itflow-portal-request:focus-visible { .itflow-crop-frame.is-round { border-radius: 50%; } +/* The free crop - a frame dragged by its corners and edges, or moved by its middle */ +.itflow-crop-stage.is-free { + cursor: default; +} +.itflow-free-frame { + cursor: move; + pointer-events: auto; +} +.itflow-free-frame:focus-visible { + outline: 2px solid var(--bs-primary); + outline-offset: 2px; +} +.itflow-free-handle { + position: absolute; + width: 14px; + height: 14px; + margin: -7px 0 0 -7px; + border: 2px solid var(--bs-primary); + border-radius: 3px; + background-color: #fff; + touch-action: none; +} +.itflow-free-handle.is-nw { top: 0; left: 0; cursor: nwse-resize; } +.itflow-free-handle.is-n { top: 0; left: 50%; cursor: ns-resize; } +.itflow-free-handle.is-ne { top: 0; left: 100%; cursor: nesw-resize; } +.itflow-free-handle.is-e { top: 50%; left: 100%; cursor: ew-resize; } +.itflow-free-handle.is-se { top: 100%; left: 100%; cursor: nwse-resize; } +.itflow-free-handle.is-s { top: 100%; left: 50%; cursor: ns-resize; } +.itflow-free-handle.is-sw { top: 100%; left: 0; cursor: nesw-resize; } +.itflow-free-handle.is-w { top: 50%; left: 0; cursor: ew-resize; } +@media (pointer: coarse) { + .itflow-free-handle { + width: 22px; + height: 22px; + margin: -11px 0 0 -11px; + } +} /* Thirds, while it's moved */ .itflow-crop-stage.is-moving .itflow-crop-frame { background: diff --git a/functions/picture.php b/functions/picture.php index aaafbafe9..bbf376c10 100644 --- a/functions/picture.php +++ b/functions/picture.php @@ -18,12 +18,19 @@ * 'round' a person's picture - shown and cropped as a circle * 'title' the window's title ('Picture', or 'Photo') * 'shapes' the shapes a photo can be cropped to, the first to start with - - * square, 4:3, 3:4, 16:9 and whole ('square') + * square, 4:3, 3:4, 16:9 and whole ('square') - or 'free', any + * shape, by dragging the frame's corners and edges * 'max' the longest side kept, in pixels (512 for a person, 2048) * 'class' the classes of the a new picture shows as - for a person * the avatar's ('itflow-picture-photo' for a photo) - * 'box' a photo's box - 'square' or 'wide' (4:3) + * 'box' a photo's box - 'square', 'wide' (4:3), 'tall' (3:4, a receipt) + * or 'logo' (wide, the picture fitted in it) * 'name' the form field with the person's name - their initials follow it + * 'accept' the file types it takes (JPG, PNG, GIF and WebP) - with + * application/pdf a PDF is taken as it is + * 'trim' a Trim the edges button for a free crop - a logo + * 'submit' send the form once a picture is used - a form that is only it + * 'id' the button's id, for a
- -
-
-
- - -
- Optional - JPG or PNG, up to 5 MB.
' ?> -
-
-
+ + 'Logo', 'shapes' => 'free', 'box' => 'logo', 'max' => 1200, 'trim' => true, 'accept' => 'image/png,image/jpeg', 'class' => 'itflow-picture-logo', 'id' => 'setupCompanyLogo']) ?> + Optional - click it to add a PNG or JPG.' ?>
diff --git a/setup/steps/user.php b/setup/steps/user.php index 0902033cb..d592c7554 100644 --- a/setup/steps/user.php +++ b/setup/steps/user.php @@ -71,13 +71,10 @@ $first_error = array_key_first($user_errors);
-
+ true, 'title' => 'Your picture', 'class' => 'itflow-contact-avatar itflow-contact-avatar-lg', 'name' => 'name', 'id' => 'setupUserAvatar']) ?>
-
- - -
- Optional - JPG, PNG, GIF or WebP, up to 5 MB.
' ?> + Optional - click it to add a picture.
' ?>