首页 > 解决方案 > Laravel:添加数据后如何使用 Laravel 打印票?

问题描述

好日子点子。单击创建后,我正在努力打印。

用于创建和打印的用户界面

当我单击创建按钮时,它将添加到数据库并打印一个号码或票。我只知道 dompdf 但那个正在下载 pdf

<div class="modal fade" id="callModal" tabindex="-1" role="dialog" aria-labelledby="callModalLabel" aria-hidden="true">

  <div class="modal-dialog" role="document">

    <div class="modal-content">

      <div class="modal-header">

        <h5 class="modal-title" id="callModalLabel">New Call</h5>

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">            
          <span aria-hidden="true">&times;</span>
        </button>

      </div>
      <div class="modal-body">

        <div class="row">

            <div class="col-md-12">

                <!--start of the form-->
                <form id="form-data" class="form-horizontal" method="POST" action="{{ route('call.store') }}"> 
                    {{ csrf_field() }}
                    <div class="row form-group">    

                        <div class="col-md-12">  
                            <input type="hidden" class="form-control" id="trans-id" name="trans_id" readonly>
                        </div>

                        <div class="col-md-12"> 
                            <label>Transaction Type:</label>
                            <input type="text" class="form-control" id="trans-name" readonly>
                        </div>

                        <div class="col-md-12"> 
                            <input type="hidden" id="called" name="called" value="NO">
                        </div>

                        <div class="col-md-12"> 

                            <label>Department:</label>

                            <select class="form-control" id="dept_id" name="dept_id" required>
                                        <option value="" data-hidden="true"  
                                                selected="selected">-- Select Department --
                                        </option>
                                            @foreach($departments as $department)
                                                <option value= "{{ $department->id }}">
                                                      {{ $department->dept_name }} 
                                                </option>
                                            @endforeach
                            </select>

                        </div>

                        <div class="col-md-12">    
                            <label>RFID</label>
                            <input type="text" id="rfid" class="form-control" name="rfid" required> 
                        </div>

                        <div class="col-md-12">    
                            <label>Student First Name</label>
                            <input type="text" id="firstname" class="form-control" name="firstname" required=""> 
                        </div>

                        <div class="col-md-12">    
                            <label>Student Last Name</label>
                            <input type="text" id="lastname" class="form-control" name="lastname" required> 
                        </div>

                        <div class="col-md-12">    
                            <label>Amount</label>
                            <input type="number" id="amount" class="form-control" name="amount" step=".01" required> 
                        </div>

                    </div>



            </div>

        </div>

      </div>

      <div class="modal-footer">

            <button type="submit" class="btn btn-success btn-fill pull-right" id="form-button-add" name="form-button-add" onclick="window.print()">
                CREATE <!--CREATE, SAVE AND PRINT THE TICKET-->
            </button>

            <button  data-dismiss="modal" aria-hidden="true" class="btn btn-basic pull-right" style="margin-right: 2%">
                CANCEL
            </button>             

            <div class="clearfix"></div>    

        </form>
        <!-- end of the form -->
      </div>

    </div>

  </div>

</div>

我已经在我的创建按钮中编写了 javascript onclick 代码。我的问题是它打印 ui 的当前页面。我只想打印详细信息,例如 C-1,计数器 1。另一个问题是显示预览但它没有添加到数据库中。

标签: htmllaravel-5.8

解决方案


推荐阅读