Add form to add/update warranty. #236

This commit is contained in:
Korina Cordero 2019-07-29 04:38:00 +00:00
parent 2d1a91842a
commit 2deea2ea8e
2 changed files with 110 additions and 15 deletions

View file

@ -3,6 +3,8 @@
namespace App\Controller;
use App\Entity\Warranty;
use App\Entity\SAPBattery;
use App\Entity\BatteryManufacturer;
use App\Ramcar\WarrantyClass;
@ -123,9 +125,8 @@ class WarrantyController extends Controller
$params['obj'] = new Warranty();
$params['mode'] = 'create';
// get batteries (models and sizes)
// get SAP batteries
// get warranty class
// get dropdown parameters
$this->fillDropdownParameters($params);
// response
return $this->render('warranty/form.html.twig', $params);
@ -181,13 +182,11 @@ class WarrantyController extends Controller
if (empty($obj))
throw $this->createNotFoundException('The item does not exist');
// get batteries (models and sizes)
// get SAP batteries
// get warranty class
// get status
$params['obj'] = $obj;
// get dropdown parameters
$this->fillDropdownParameters($params);
// response
return $this->render('warranty/form.html.twig', $params);
}
@ -210,14 +209,8 @@ class WarrantyController extends Controller
{
$em = $this->getDoctrine()->getManager();
// db loaded
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
// need to add battery model and sizes
// need to add SAP battery
// name values
$params['sap_batts'] = $em->getRepository(SAPBattery::class)->findAll();
$params['warranty_classes'] = WarrantyClass::getCollection();
}

View file

@ -0,0 +1,102 @@
{% extends 'base.html.twig' %}
{% block body %}
<!-- BEGIN: Subheader -->
<div class="m-subheader">
<div class="d-flex align-items-center">
<div class="mr-auto">
<h3 class="m-subheader__title">Warranties</h3>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
<div class="m-portlet m-portlet--mobile">
<div class="m-portlet__head">
<div class="m-portlet__head-caption">
<div class="m-portlet__head-title">
<span class="m-portlet__head-icon">
<i class="la la-industry"></i>
</span>
<h3 class="m-portlet__head-text">
{% if mode == 'update' %}
Edit Warranty
{% else %}
New Warranty
{% endif %}
</h3>
</div>
</div>
</div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ mode == 'update' ? url('warranty_update_submit', {'id': obj.getId()}) : url('warranty_create_submit') }}">
<div class="m-portlet__body">
<div class="m-form__section m-form__section--first">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Warranty Info
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="serial">
Serial
</label>
<input type="text" name="serial" class="form-control m-input" value="{{ obj.getSerial }}" data-name="serial">
<div class="form-control-feedback hide" data-field="serial"></div>
</div>
<div class="col-lg-4">
<label data-field="warranty_class">
Warranty Classification
</label>
<select name="warranty_class" class="form-control m-input">
{% for key, warranty_class in warranty_classes %}
<option value="{{ key }}"{{ obj.getWarrantyClass == key ? ' selected' }}>{{ warranty_class }}</option>
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="warranty_class"></div>
</div>
<div class="col-lg-4">
<label data-field="plate_number">
Plate Number
</label>
<input type="text" name="plate_number" class="form-control m-input" value="{{ obj.getPlateNumber }}" data-name="plate_number">
<div class="form-control-feedback hide" data-field="plate_number"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="first_name">
First Name
</label>
<input type="text" name="first_name" class="form-control m-input" value="{{ obj.getFirstName }}" data-name="first_name">
<div class="form-control-feedback hide" data-field="first_name"></div>
</div>
<div class="col-lg-4">
<label data-field="last_name">
Last Name
</label>
<input type="text" name="last_name" class="form-control m-input" value="{{ obj.getLastName }}" data-name="last_name">
<div class="form-control-feedback hide" data-field="last_name"></div>
</div>
<div class="col-lg-4">
<label data-field="mobile_number">
Mobile Phone
</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<input type="text" name="mobile_number" class="form-control m-input" value="{{ obj.getMobileNumber|default('') }}" data-name="mobile_number">
<div class="form-control-feedback hide" data-field="mobile_number"></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}