Laravel: How To Print Ticket Using Laravel After Adding Data? - html

Good day pips. I am struggling on printing after I click create.
the ui for creating and printing
When I click the create button, it will add to the database and print a number or ticket. All I know is dompdf but that one is downloading 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">×</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>
I already code the javascript onclick in my create button. My problem is it prints the current page of the ui. I just want to print the details such as C-1, counter 1. Another problem is that is show the preview but it doesn't add on the database.

Related

How to send data to email through contact form

I'm trying to send a message to an email like in this code, once you click on "Enviar", your message goes to your email with the name, email and message info. I'm using this provider but it's not working: https://formsubmit.co/ this is the code:
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel">Contáctanos</h4>
</div>
<div class="modal-body">
<form>
<form action="https://formsubmit.co/myemaiL#gmail.com" method="POST">
<div class="form-group">
<label for="Name">Nombre</label>
<input type="text" class="form-control" id="Name" placeholder="Name" required>
</div>
<div class="form-group">
<label for="Email">Email</label>
<input type="email" class="form-control" id="Email-1" placeholder="Email" required>
</div>
<div class="form-group">
<label for="Message">Mensaje</label>
<textarea class="form-control" id="Message" placeholder="Ingresa tu mensaje" required></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-success">Enviar</button>
</div>
</div>
</div>
</div>
</div>
</div>```
Hopefully someone can help me out, thanks!
The problem with your code is that submit button is outside <form> open and close tag. However the <form tag immediately after the modal-body class is not necessary
Your code should be like this
<form action="https://formsubmit.co/laide_lawal#yahoo.com" method="POST">
<div class="form-group">
<label for="Name">Nombre</label>
<input type="text" class="form-control" id="Name" placeholder="Name" required>
</div>
<div class="form-group">
<label for="Email">Email</label>
<input type="email" class="form-control" id="Email-1" placeholder="Email" required>
</div>
<div class="form-group">
<label for="Message">Mensaje</label>
<textarea class="form-control" id="Message" placeholder="Ingresa tu mensaje" required></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-success">Enviar</button>
</div>
</form>

Angular - How to style my form to accomodate all the field data

I am working on an application using Angular-7 frontend. In the form that is shown below, the form field elements are truncated and not everything is displayed:
addModal
<div id="addModal" class="modal" style="background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4);">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add New Role</h5>
<button type="button" class="close" (click)='closeAddModal()'>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger" [hidden]="!error.name">
{{ error.name }}
</div>
<form #editRoleForm=ngForm>
<div class="form-group">
<label for="name">Name</label>
<input type="name" name="name" id="inputName" class="form-control" placeholder="Name" [(ngModel)]="form.name" required>
</div>
<div class="form-group">
<label for="name">Permissions</label>
<div *ngFor="let permission of permissions">
<input type="checkbox" name="{{ permission.name }}" value="{{ permission.name }}" (change)="checkboxAdd($event)"> {{ permission.name }}
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)='addModalSubmit()' [disabled]="!editRoleForm.valid">Save changes</button>
<button type="button" class="btn btn-secondary" (click)='closeAddModal()'>Close</button>
</div>
</div>
</div>
</div>
editModal
<div id="editModal" class="modal" style="background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4);">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit Role</h5>
<button type="button" class="close" (click)='closeEditModal()'>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger" [hidden]="!error.name">
{{ error.name }}
</div>
<form #newRoleForm=ngForm>
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter name" required [(ngModel)]="data.name"/>
</div>
<div class="form-group">
<label for="name">Permissions</label>
<div *ngFor="let permission of permissions">
<input type="checkbox" name="{{ permission.name }}" value="{{ permission.name }}" (change)="checkbox($event)" *ngIf="!data.permission.includes(permission.name)">
<input type="checkbox" name="{{ permission.name }}" value="{{ permission.name }}" (change)="checkbox($event)" *ngIf="data.permission.includes(permission.name)" checked> {{ permission.name }}
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" [disabled]="!newRoleForm.valid" (click)='editsubmit()'>Save changes</button>
<button type="button" class="btn btn-secondary" (click)='closeEditModal()'>Close</button>
</div>
</div>
</div>
</div>
How do I style the form, so that all the form elements will be displayed (I can't even see the submit button)? It may even be in three columns.

form.valid on Angular gets false after the 1st submit

I am working on Angular 7 and having the following situation:
.html code (updated):
<form #form="ngForm" (ngSubmit)="addRecord(form)">
<div class="modal-header">
<h5 class="modal-title" id="modalRecordLabel">Add Record</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="resetForm(form)">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<small style="margin-top: 10px;">All fields with asterisk (*) are required.</small>
<div class="container-fluid">
<div class="row">
<div class="col-md-10">
<!-- Name -->
<div class="form-group">
<label for="input1">Name *</label>
<input
type="text"
class="form-control"
id="input1"
name="input1"
[(ngModel)]="myObject.description"
required
#input1=ngModel
[class.field-error]="form.submitted && input1.invalid"
tabindex="11">
<div [hidden]="!form.submitted || input1.valid " class="alert alert-danger">
Name is required.
</div>
</div>
<!-- Date 1-->
<div class="form-group">
<label for="date1">Date 1 *</label>
<div class="input-group">
<input
class="form-control"
placeholder="yyyy-mm-dd"
id="date1"
name="date1"
[ngModel]="date1"
required
#date1=ngModel
[class.field-error]="form.submitted && date1.invalid"
ngbDatepicker #da="ngbDatepicker"
tabindex="12">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="da.toggle()" type="button"></button>
</div>
</div>
<div [hidden]="!form.submitted || date1.valid " class="alert alert-danger">
Date 1 is required.
</div>
</div>
<!-- Date 2 -->
<div class="form-group">
<label for="date2">Date 2 *</label>
<div class="input-group">
<input
class="form-control"
placeholder="yyyy-mm-dd"
id="date2"
name="date2"
[ngModel]="date2"
required
#date2=ngModel
[class.field-error]="form.submitted && date2.invalid"
ngbDatepicker #da2="ngbDatepicker"
tabindex="13">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="da2.toggle()" type="button"></button>
</div>
</div>
<div [hidden]="!form.submitted || date2.valid " class="alert alert-danger">
Date 2 is required.
</div>
</div>
<!--Date 3-->
<div class="form-group">
<label for="date3">Date 3</label>
<div class="input-group">
<input
class="form-control"
placeholder="yyyy-mm-dd"
id="date3"
name="date3"
[ngModel]="date3"
ngbDatepicker #da3="ngbDatepicker"
tabindex="14">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="da3.toggle()" type="button"></button>
</div>
</div>
</div>
<!--Date 4-->
<div class="form-group">
<label for="date4">Date 4</label>
<div class="input-group">
<input
class="form-control"
placeholder="yyyy-mm-dd"
id="date4"
name="date4"
[ngModel]="date4"
ngbDatepicker #da4="ngbDatepicker"
tabindex="15">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="da4.toggle()" type="button"></button>
</div>
</div>
</div>
<!-- Type -->
<div class="form-group">
<label for="input2">Type</label>
<div class="input-group">
<select
class="form-control"
id="input2"
name="input2"
[(ngModel)]="myObject.type.id"
(change)="selectOption($event.target.value)"
#input2="ngModel"
tabindex="16">
<option *ngFor='let input2 of input2List' [value]="input2.id">{{input2.description}}</option>
</select>
</div>
</div>
</div>
</div>
</div> <!-- closing div for class="container-fluid"-->
</div> <!-- closing div for class="modal-body"-->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="resetForm(form)" tabindex="101">Close</button>
<button type="submit" class="btn btn-primary" tabindex="102">Add</button>
</div>
</form>
.ts code:
addRecord(form: NgForm): void {
if(form.valid) {
//do something
}
}
The first time the form is submitted, all the data is saved successfully. However, if I tried to submit a second record using the same form, now form.valid is always false.
So my question is, why is form.valid always false after the first submit?

Element with name not being sent with form data via POST

I am trying to submit my modal title as post data, however it isn't being sent.
I have given the element a name attribute. Elements in the modal body are submitting as I would expect. Trying to submit the element whose name is "editModalTitle" below
HTML:
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<form action="/editItem" method="post" id ="editModalForm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" name="eModalTitle"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Quantity:</label>
<div class="row">
<div class="col">
<select class="form-control" id="qtSelect">
<option>Set to</option>
<option>Add</option>
<option>Subtract</option>
</select>
</div>
<div class="col" id= "qtD">
<input type="text" class="form-control" id="qt" name="quantityTB" placeholder="Quantity">
</div>
</div>
</div>
<div class="form-group" id="prD">
<label>Price:</label>
<input type="text" class="form-control" id="pr" name="priceTB" placeholder="Enter new price here...">
</div>
<div class="form-group">
<label>Notes:</label>
<div class="row">
<div class="col">
<select class="form-control" id="ntSelect">
<option>Set notes to:</option>
<option>Add to notes:</option>
</select>
</div>
<div class="col">
<input type="text" class="form-control" id="ntInput" name="notesTB"placeholder="Enter notes here...">
</div>
</div>
</div>
<div class="form-group">
<label>Location:</label>
<input type="text" class="form-control" id="loc" name="locationTB" placeholder="Enter new location here...">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="eSvBtn" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
Form data here
Edit 1: Added full html for modal.
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<form action="/editItem" method="post" id ="editModalForm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" name="eModalTitle"></h5>
<!-- hidden value for modal title to post -->
<input type="hidden" id="Modal_title_to_post" name="Modal_title_to_post" value="eModalTitle">
<!-- hidden value for modal title to post -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Quantity:</label>
<div class="row">
<div class="col">
<select class="form-control" id="qtSelect">
<option>Set to</option>
<option>Add</option>
<option>Subtract</option>
</select>
</div>
<div class="col" id= "qtD">
<input type="text" class="form-control" id="qt" name="quantityTB" placeholder="Quantity">
</div>
</div>
</div>
<div class="form-group" id="prD">
<label>Price:</label>
<input type="text" class="form-control" id="pr" name="priceTB" placeholder="Enter new price here...">
</div>
<div class="form-group">
<label>Notes:</label>
<div class="row">
<div class="col">
<select class="form-control" id="ntSelect">
<option>Set notes to:</option>
<option>Add to notes:</option>
</select>
</div>
<div class="col">
<input type="text" class="form-control" id="ntInput" name="notesTB"placeholder="Enter notes here...">
</div>
</div>
</div>
<div class="form-group">
<label>Location:</label>
<input type="text" class="form-control" id="loc" name="locationTB" placeholder="Enter new location here...">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="eSvBtn" class="btn btn-primary">Save changes</button>
</div>
</div>
</form>
</div>
</div>
Updated code with hidden value for the modal title :)

Bootstrap modal not working with same code in different pages

I have the following code on 2 pages:
<input class="btn btn-primary" type="button" value="Sign Up" data-toggle="modal" data-target="#myModal"/>
<!-- my modal dialog-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Create New User</h4>
</div>
<div class="modal-body">
<form id="myform" action="add_user.php" method="POST">
<div class="form-group">
<input class="form-control" type="text" id="username" name="username" placeholder="Username"/>
</div>
<div class="form-group">
<input class="form-control" type="password" id="password-input" name="password" placeholder="Password"/>
</div>
<div class="form-group">
<input class="form-control" type="password" id="password-confirm-input" placeholder="Confirm Password" onblur=";"/>
</div>
<div class="form-group">
<input class="form-control" type="text" placeholder="User Type"/>
</div>
<div class="form-group" id="msg">
<input class="form-control" type="text" name=email placeholder="E-mail Address"/>
</div>
<div>
<label id="label" for="male"></label>
</div>
<br>
<div class="form-group pull-right">
<input class="btn btn-success" type="submit" id="create_user2" value="Create User"/>
</div>
</form>
</div>
</div>
</div>
</div>
This code works on the index.php page, a modal dialog pops up.
in another page, dashboard.php, it does not.
I have the exact same button and modal code in the body tags
Be sure you have bootstrap JS references in both pages:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>