How to disable specific value in foreach blade laravel on the table - laravel-5.3

Help me guys, for this picture i want to disable view specific data from blade laravel this is the picture
https://i.stack.imgur.com/CuwB9.jpg
https://i.stack.imgur.com/NQfIc.jpg
this is my blade laravel file
<table class="table table-bordered table-responsive" style="margin-top: 20px">
<thead>
<tr>
<th>NO</th>
<th>NAMA</th>
<th>JABATAN</th>
<th>PROJECT</th>
<th>POSISI DALAM PROJECT</th>
<th>START PROJECT</th>
<th>FINISH PROJECT</th>
<th>DAYS PROJECT</th>
</tr>
</thead>
<tbody>
#php
$no = 1;
#endphp
#foreach ($data as $value)
<tr>
<td>{{ $no ++ }}</td>
<td>{{ $value->EMPLOYEE_NAME }}</td>
<td>{{ $value->EMPLOYEE_TITLE }}</td>
<td>{{ $value->PROJECT_NAME }}</td>
<td>{{ $value->PROJECT_ROLE }}</td>
<td>{{ $value->PROJECT_START }}</td>
<td>{{ $value->PROJECT_END }}</td>
<td>{{ $value->PROJECT_DURATION }}</td>
</tr>
#endforeach
</tbody>
</table>
and then controller to view $data
public function index(){
$data['data'] = DB::table('project')->join('employee','project.EMPLOYEE_ID','=','employee.EMPLOYEE_ID')
->select('EMPLOYEE_NAME' , 'EMPLOYEE_TITLE' , 'PROJECT_NAME' , 'PROJECT_ROLE' ,'PROJECT_START' , 'PROJECT_END' , 'PROJECT_DURATION')
->get();
return view('index',$data);
}
Help me guys... .

Related

Print the table based on the selected option of a radio element

I have a radio element with three options (Normal, Time Sensitive, and Hold For Pick-Up). Every time an user clicks an option, an unique table element for the option (for user to fill information) will pop up automatically. Finally, I would like to print all the submitted data to PDF attachment.
As I write the twig code for it, I am stuck in the part where I want to print the table that belongs to the selected option
{# choose_your_shipping_option: radio's key #}
{# Normal: option text #}
{% if webform_token('[webform_submission:values:choose_your_shipping_option]') == "Normal" %}
<table>
<tr>
<th>Shipping Address:</th>
<th>Acct #</th>
</tr>
<tr>
<td rowspan="3">[webform_submission:values:shipping_address]</td>
<td>[webform_submission:values:id_num]</td>
</tr>
<tr>
<th>Phone</th>
</tr>
<tr>
<td>
[webform_submission:values:phone]
</td>
</tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Time Sensitive" %}
<table>
<tr>
<th>Delivery Date</th>
<td>[webform_submission:values:time_sensitive_01_delivery_date]</td>
<th>Must Have Street Address (No PO Box)</th>
</tr>
<tr>
<th colspan="2">Shipping Address:</th>
<th>Acct #</th>
</tr>
<tr>
<td colspan="2" rowspan="3" style="text-align: center;">[webform_submission:values:shipping_address_2]</td>
<td>[webform_submission:values:id_num]</td>
</tr>
<tr>
<th>Phone</th>
</tr>
<tr>
<td>
[webform_submission:values:phone_2]
</td>
</tr>
</table>
{% elseif webform_token('[webform_submission:values:choose_your_shipping_option]') == "Hold For Pick-Up" %}
<table>
<tr>
<th>Will be picked up by</th>
<th>Pick-up Date:</th>
</tr>
<tr>
<td>[webform_submission:values:pick_up_01_picked_up_by]</td>
<td>[webform_submission:values:pick_up_01_pick_up_date]</td>
</tr>
<tr>
<th>Pick-up Location</th>
<th>Pick-up Time</th>
</tr>
<tr>
<td>[webform_submission:values:location]</td>
<td>[webform_submission:values:time]</td>
</tr>
</table>
{% endif %}
It would ruin the pdf template when I use webform_token. Is there a correct way to print only the one that's filled by the user?

Get checked values of checkboxes from a table and use them in controller

I'm using Symfony 3.4. I'd like to get checked values of checkboxes from a table and get these values in the controller for another process.
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Agent</th>
<th>Sélectionner</th>
</tr>
</thead>
<tbody>
{% for agent in agents %}
<tr>
<td>{{ agent.id }}</td>
<td>{{ agent.fullname }}</td>
<td>
<input type="checkbox" name="idagent[{{agent.id}}]" value={{agent.id}}" />
</td>
</tr>
{% endfor %}
</tbody>
In the controller
public function newinterneAction(Request $request)
{
...
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$ids=$request->get('idagent');
die(dump($ids));
}
}
But this return null. How can I make it with Symfony?
Any help will be appreciated.
Use $request->getContent();
Anyway, you should use https://symfony.com/doc/current/forms.html for creating forms

Can't show data dataGrid when using datasource JSON [DEVEXTREME ANGULARJS]

When I'm bind using angularjs it's work properly but when using DevExtreme it's not work
This is function getAll
//To Get All Records
function GetAllEntry() {
var promiseGet = GetAllEntryService.GetAllEntry();
promiseGet.then(function (pl) { $scope.GetAllEntry = pl.data },
function (errorPl) {
console.log('Some Error in Getting Records.', errorPl);
});
}
this table bind using angularJS
<tbody ng-repeat="entry in GetAllEntry">
<tr>
<td>
<input type="checkbox" value="">
</td>
<td>{{ entry.TICKET_NUMBER }}</td>
<td>{{ entry.REQUESTER }}</td>
<td>{{ entry.CATEGORY }}</td>
<td>{{ entry.SUBCATEGORY }}</td>
<td>{{ entry.SUBJECT }}</td>
<td>{{ entry.BODY }}</td>
<td>{{ entry.FILE_NAME }}</td>
<td>{{ entry.ASSIGNED_TO }}</td>
</tr>
</tbody>
That its working properly good!
But When using devExtreme:
$scope.dataGridOptions = {
dataSource: {
store: GetAllEntry()
},
columns: ['TICKET_NUMBER', 'REQUESTER', 'CATEGORY', 'SUBCATEGORY', 'SUBJECT', 'BODY', 'FILE_NAME', 'ASSIGNED_TO']
};
in HTML:
<div>
<div id="gridContainer" dx-data-grid="dataGridOptions"></div>
</div>
It's not showing my data? What code I'm missing add to this project?
reference:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular-sanitize.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/globalize/0.1.1/globalize.min.js"></script>
<script type="text/javascript" src="http://cdn3.devexpress.com/jslib/15.2.4/js/dx.webappjs.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn3.devexpress.com/jslib/15.2.4/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="http://cdn3.devexpress.com/jslib/15.2.4/css/dx.light.css" />

How group item in for TWIG

How I can grouping item in list, if I have different items with one ID?
I want if loop find two or more items with the same id combine them in to list ul > li.
For example:
{% extends 'base.html.twig' %}
{% block wrapper %}
<div class="panel panel-default">
<div class="panel-heading clearfix add">
Заявки
</div>
<table class="table">
<tr>
<th>ID</th>
<th>ID заявки</th>
<th>Склад</th>
<th>Матеріал</th>
<th>Кількість</th>
<th>Сумма</th>
<th>Дата</th>
<th>Час</th>
<th>Користувач</th>
</tr>
{% if itemEntries == null %}
<tr>
<td colspan="6">Елементи для показу відсутні</td>
</tr>
{% endif %}
{% for value in itemEntries %}
<tr>
<td>{{ value.id }}.</td>
<td>{{ value.bid }}</td>
<td>{{ value.storage.name }}</td>
<td>{{ value.item.name }} (ID: {{ value.item }})</td>
<td>{{ value.count }}</td>
<td>-{{ value.count * value.item.price }}</td>
<td>{{ value.date | date('d-m-Y') }}</td>
<td>{{ value.time | date('H:m:i') }}</td>
<td>{{ value.userLogin }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}
Thanks!
The best way is to group the items in a SQL query.
So in you controller you should using groupBy() to grouping the result.
Look at this example:
$itemEntries = $this->em->createQueryBuilder()
->select('e')
->from('AppBundle:Entry', 'e')
->groupBy('e.bidId')
->getQuery()
->getResult();

What's wrong with twig?

This is my first steps in symfony 2.0, so please apologise a basic question. I try to extend automaticaly generated crud code. To postcontroller I've added:
/**
* Prints a Post entity.
*
* #Route("/print", name="post_print")
* #Template()
*/
public function printAction()
{
$em = $this->getDoctrine()->getEntityManager();
$entities = $em->getRepository('AcmeBlogBundle:Post')->findAll();
echo "<pre>";
print_r($entities);
echo "</pre>";
return array('entities' => $entities);
}
created print.html.twig:
<h1>Post list</h1>
<table class="records_list">
<thead>
<tr>
<th>Id</th>
<th>Polish</th>
<th>English</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.polish }}</td>
<td>{{ entity.english }}</td>
<td>{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif%}</td>
<td>
<ul>
<li>
show
</li>
<li>
edit
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('post_new') }}">
Create a new entry
</a>
</li>
<li>
<a href="{{ path('post_print') }}">
Drukuj
</a>
</li>
</ul>
and I'm getting:
Variable "entity" does not exist in AcmeBlogBundle:Post:print.html.twig at line 7
500 Internal Server Error - Twig_Error_Runtime
Any idea what could be wrong?
I've cleared cache ... and now everything seems to be OK.

Resources