snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Custom "Print All Assigned" page

Open ppestime opened this issue 8 years ago • 9 comments

Is it possible to customize my "Print All Assigned" page to include a header with company logo and name, and additional place for supervisor signature and inventory keeper signature?

Thanks for such a great software!

ppestime avatar Jan 26 '18 19:01 ppestime

Yes would like this as well and perhaps if possible to use a template file perhaps a Word document set by the admin?

And follow the rules set by Snipe-IT like <<ASSET_TABLE>> and <> so that the print out can be like

[Logo] [Text] [Text] <<ASSET_TABLE>> [Text] <<ACCESSORIESETC_TABLE>> [Text] <>

Thank you always for the great software.

smksar avatar Apr 21 '18 04:04 smksar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

stale[bot] avatar Jun 20 '18 04:06 stale[bot]

I would love to open this feature request back up. Would be a huge help to implement Snipe at my company, as we don't use individual Asset Names and want to display the asset cost (and possibly a total user cost) on this page. Having the ability to customize what the page looks like would cover a ton of use cases and give more customization.

Please let me know if you'd like any extra info!

ghost avatar Oct 31 '18 19:10 ghost

perhaps if possible to use a template file perhaps a Word document set by the admin

That's unlikely to happen to be honest. It would require additional libraries to import the Word template, and that road is fraught with peril.

snipe avatar Nov 01 '18 01:11 snipe

For anyone else looking to customize their page, it can be done right now with a couple of caveats:

  • You have to understand a bit of PHP, and edit this file directly: ./resources/views/users/print.blade.php
  • If you don't keep track of it, updating your instance will revert your changes

I can't give any tutorials or examples for what your situation may be, but if you know HTML and PHP, then you can dig in and add/remove variables and columns as you need until a decision is made on this feature. To avoid it getting overwritten on future releases, since I run Docker, I have bind mounted the individual file so it is persistent on container upgrades.

Here's an example of what I have put together, including a cost print out for assets, and a monthly cost for licenses.

Added this to the top to define 0 for each cost variable:

@php
    $cost = 0;
    $monthly = 0;
@endphp

I adjusted my assets table like this (note the cost variable in front of the counter):

@if ($snipeSettings->logo_print_assets=='1')
    @if ($snipeSettings->brand == '3')

        <h3>
        @if ($snipeSettings->logo!='')
            <img class="print-logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
        @endif
        {{ $snipeSettings->site_name }}
        </h3>
    @elseif ($snipeSettings->brand == '2')
        @if ($snipeSettings->logo!='')
            <img class="print-logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
        @endif
    @else
      <h3>{{ $snipeSettings->site_name }}</h3>
    @endif
@endif

<h4>Assigned to {{ $show_user->present()->fullName() }}</h4>

@if ($assets->count() > 0)
    @php
        $counter = 1;
    @endphp
    <table class="inventory">
        <thead>
        <tr>
            <th colspan="8">{{ trans('general.assets') }}</th>
        </tr>
        </thead>
        <thead>
            <tr>
                <th style="width: 5%;"></th>
                <th style="width: 5%;">Asset Tag</th>
                <th style="width: 20%;">Model</th>
                <th style="width: 10%;">Category</th>
                <th style="width: 30%;">Serial</th>
                <th style="width: 10%;">Supplier</th>
                <th style="width: 10%;">Cost</th>
                <!-- <th style="width: 10%;">Checked Out</th> -->
            </tr>
        </thead>

    @foreach ($assets as $asset)

        <tr>
            <td>{{ $counter }}</td>
            <td>{{ $asset->asset_tag }}</td>
            <td>{{ $asset->model->manufacturer->name }} {{ $asset->model->name }} {{ $asset->model->model_number }}</td>
            <td>{{ $asset->model->category->name }}</td>
            <td>{{ $asset->serial }}</td>
            <td>{{ $asset->supplier->name }}</td>
            <td>{{ $asset->purchase_cost }}</td>
            <!-- <td>{{ $asset->last_checkout }}</td> -->
        </tr>
            @php
                $cost = $cost + $asset->purchase_cost;
                $counter++
            @endphp
    @endforeach
    </table>
@endif

And adjusted my license table like this (note the monthly variable before the lcounter):

@if ($licenses->count() > 0)
    <br><br>
    <table class="inventory">
        <thead>
        <tr>
            <th colspan="4">{{ trans('general.licenses') }}</th>
        </tr>
        </thead>
        <thead>
            <tr>
                <th style="width: 5%;"></th>
                <th style="width: 70%;">Software</th>
                <th style="width: 25%;">Monthly Cost</th>
                <!-- <th style="width: 10%;">Checked Out</th> -->
            </tr>
        </thead>
        @php
        $lcounter = 1;
        @endphp

        @foreach ($licenses as $license)

            <tr>
                <td>{{ $lcounter }}</td>
                <td>{{ $license->name }}</td>
                <td>{{ $license->purchase_cost }}</td>
                <!-- <td>{{  $license->assetlog->first()->created_at }}</td> -->
            </tr>
            @php
                $monthly = $monthly + $license->purchase_cost;
                $lcounter++
            @endphp
        @endforeach
    </table>
@endif

Then I removed the signed off portion (my company doesn't care, we like the email system as a confirmation) and added the cost calculations:

<h3 style="text-align: right; margin-right: 50px;">Total Asset Cost - ${{ $cost }} USD</h3>
<h3 style="text-align: right; margin-right: 50px;">Total Monthly Cost - ${{ $monthly }} USD</h3>

Here's what it looks like when I use the button, now:

snipe

ghost avatar Nov 02 '18 15:11 ghost

@snipe using blade shouldn't this be possible using childs and sections?

CoMPaTech avatar May 07 '19 11:05 CoMPaTech

Thank you sk33z3r, your work helps me a lot. it would be a great thing to have a small form editor or a possibility to assign a form editor.

kaeser49 avatar Jun 19 '22 04:06 kaeser49

Hi,

Do you know how I can edit the header and footer? When I save the file to PDF I have a visible header and footer where I would like to put other data.

Zrzut ekranu 2022-11-16 o 10 27 31 Zrzut ekranu 2022-11-16 o 10 27 22

kruzikruz avatar Nov 16 '22 09:11 kruzikruz

@sk33z3r I customized the template to suit our needs, but there is an important issue we are facing. The report does not include any child assets. For instance, in cases where we have a parent asset with three child assets assigned to it, the report only shows the parent asset. Could you please provide assistance with this matter?

JMH-Jarbydev avatar Aug 16 '23 16:08 JMH-Jarbydev