I am trying to show product items when button order detail is pressed, but its not working in any way I tried, it's possible to make it work with bootstrap 5 or I have to do it with javascript ?
Useless information for "It looks like your post is mostly code; please add some more details." : In the first foreach I am displaying information from the order, then the second foreach is retrieving product id and quantity from a different table that contain order id and the third foreach is getting product where id from the second foreach in order to display product details
<table class="table border">
<thead>
<tr>
<th class="h4" style="width: 18%">Order Number</th>
<th class="h4">Date</th>
<th class="h4">Total</th>
<th class="h4">Status</th>
<th class="h4"></th>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($order as $row_order) {
$order_status = intval($row_order->status);
?>
<td class="fw-bold">{{ $row_order->id }}</td>
<td class="fw-bold">{{ $row_order->added_on }}</td>
<td class="fw-bold">{{ $row_order->order_total }} $</td>
<td class="fw-bold"><?php if($order_status == 0){ ?>
Not Paid
<?php }elseif ($order_status == 1) { ?>
Paid
<?php }elseif ($order_status == 2) { ?>
Shipped
<?php }elseif ($order_status == 3) { ?>
Delivered
<?php } ?>
</td>
<td></td>
{{-- <td><a class="btn btn-primary" href="">Order Detail</a></td> --}}
<div class="btn-group">
<td>
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
Order Detail
</button>
</td>
#foreach (\App\Models\Order_product_size_color::where('order_id', '=', $row_order->id)->get() as $order_variant)
#foreach (\App\Models\Product_size_color::where('id', '=', $order_variant->product_size_color_id)->get() as $variant)
<div class="dropdown-menu">
<td class="border-0 p-0 dropdown-item">
<tr>
<td class="border-0"><img class="rounded" src="{{ asset('storage/'. $variant->image1->product_image) }}" alt="" style="width: 80px; height: 90px;"></td>
<td class="fw-bold border-0">{{ $variant->product->product_name }}</td>
<td class="border-0">{{ $order_variant->count }} products</td>
<td class="fw-bold border-0">Size: {{ $variant->size->size_name }}</td>
<td class="fw-bold border-0">Color: {{ $variant->color->color_name }}</td>
<td class="fw-bold border-0">${{ $variant->product->price }}</td>
</tr>
</td>
</div>
#endforeach
#endforeach
</div>
<tr>
<td class="fw-bold">Delivery Address:</td>
<td class="fw-bold">{{ $row_order->address }}</td>
</tr>
</tr>
<?php }//end foreach ?>
</tbody>
</table>
Related
I would like to retrieve each row of a datatable that is dynamically created. I created a form with the post method to get these rows but I don't how what to write in my view function to have these in a panda DataFrame.
<form action="{%url 'livedb_model:validation' property.id roomtype.id %}?normal_price={{normal_price}}&week_day_multi={{week_day_multi}}&week_end_multi={{week_end_multi}}&max_discount={{max_discount}}&max_markup={{max_markup}}&coccCategory={{coccCategory}}&agressiveness={{agressiveness}}" method="post">
{% csrf_token %}
<input class='btn btn-primary btn-large btn-block align-self-center'type='submit' value='submit'>
<div id="datatable" class="table-editable align-self-stretch">
<table class="table table-bordered table-responsive-md table-striped text-center">
<tr>
<th class="text-center">Date</th>
<th class="text-center">Availability</th>
<th class="text-center">Current Price</th>
<th class="text-center">Current Occupancy</th>
<th class="text-center">Advised Price</th>
</tr>
{% for day in invdf.itertuples %}
<tr>
{% if day.availability.room %}
<td class="pt-3-half" id='date'>{{day.date|date:'M d,Y'}}</td>
<td class="pt-3-half">{{day.allotment}}</td>
<td class="pt-3-half">{{day.price|floatformat:2}}</td>
<td class="pt-3-half">{{day.occupancy|floatformat:2}}</td>
<td class="pt-3-half" id='price_advised' contenteditable="true">{{day.price_advised|floatformat:2}}</td>
{% else %}
<td class="pt-3-half" id='date'>{{day.date|date:'M d,Y'}}</td>
<td class="pt-3-half">{{day.allotment}}</td>
<td class="pt-3-half">{{day.price|floatformat:2}}</td>
<td class="pt-3-half">{{day.occupancy|floatformat:2}}</td>
<td class="pt-3-half" id='price_advised' contenteditable="true">{{day.price_advised|floatformat:2}}</td>
{% endif %}
</tr>
{% endfor%}
</div>
</form>
For instance I would like to write something like in my view:
def validation(request,id,rt_id):
if request.method=='POST':
price_advised=request.POST.get(ADVISED PRICE COLUMN)
Could you help me on this?
Thank you
you can use javascript add parameter before submitting form
I want to expand and collapse table row using Bootstrap Accordion.
Currently, if I click on any row, it expands and collapse. But what I want is that, if I click on second row then first row should collapse if it is expanded then and so on.
<div class=" panel-body">
<table class="table">
#foreach (var item in Model)
{
<tr>
<td class="accordion-toggle" data-toggle="collapse" data-target="#AA_#(item.Id)">
<button class="bb" type="button">
#Html.Raw(item.H)
</button>
</td>
<td>
#Html.Raw(item.E)
</td>
</tr>
<tr>
<td id="AA_#(item.Id)" class="accordion-body collapse">
<table>
<tr>
<td>
#Html.Raw(item.D)
</td>
<td>
#Html.Raw(item.B)
</td>
</tr>
</table>
</td>
</tr>
}
</table>
</div>
I researched my problem on SO and found one solution provided by #tmg on here. Many thanks to #tmg. I followed the same in my scenario and it worked for me.
<div class="panel-body">
<table class="table">
#foreach (var item in Model)
{
<tr class="accordion-toggle" data-toggle="collapse" data-target="#AA_#(item.Id)">
<td>
<button class="bb" type="button">
#Html.Raw(item.H)
</button>
</td>
<td>
#Html.Raw(item.E)
</td>
</tr>
<tr>
<td class="hiddenRow">
<div class="accordian-body collapse" id="AA_#(item.Id)">
<table>
<tr>
<td>
#Html.Raw(item.D)
</td>
<td>
#Html.Raw(item.B)
</td>
</tr>
</table>
</div>
</td>
</tr>
}
</table>
</div>
And added JQuery to collapse and toggle table row
$('.table .accordian-body').on('show.bs.collapse', function () {
$(this).closest("table")
.find(".collapse.in")
.not(this)
.collapse('toggle')
})
Added Style for hiddenRow
.hiddenRow {
padding: 0 !important;
}
I want to implement bootstrap accordion in my application. Currently, If I click on any rows, it gives me first #Html.Raw(item.D) and #Html.Raw(item.B).
What i want is that, if i click on 2nd row then its respective #Html.Raw(item.D) and #Html.Raw(item.B) should displayed and so on.
Please suggest me where I am going wrong.
<div class="panel-body">
<table class="table">
#foreach (var item in Model)
{
<tr class="accordion-toggle" data-toggle="collapse" data-target="#12345-cores">
<td align="left">
#Html.Raw(item.H)
</td>
<td align="right">
#Html.Raw(item.E)
</td>
</tr>
<tr>
<td class="accordion-body collapse" id="12345-cores">
<table>
<tbody>
<tr>
<td>
#Html.Raw(item.D)
</td>
<td></td>
<td>
#Html.Raw(item.B)
</td>
</tr>
</tbody>
</table>
</td>
</tr>
}
</table>
You need to specify id uniquely, to do so you need to append raw id(or something unique for each row) to id and data-target attributes,
<div class="panel-body">
<table class="table">
#foreach (var item in Model)
{
<tr class="accordion-toggle" data-toggle="collapse" data-target="#12345-cores#(item.id)">
<td align="left">
#Html.Raw(item.H)
</td>
<td align="right">
#Html.Raw(item.E)
</td>
</tr>
<tr>
<td class="accordion-body collapse" id="12345-cores#(item.id)">
<table>
<tbody>
<tr>
<td>
#Html.Raw(item.D)
</td>
<td></td>
<td>
#Html.Raw(item.B)
</td>
</tr>
</tbody>
</table>
</td>
</tr>
}
</table>
updated : data-target="#12345-cores#(item.id) & id="12345-cores#(item.id)"
So I am trying to make bootstrap table with search and sorting with the data coming from a GET calll
<table id="example" class="table table-bordered table-striped table-hover" data-search="true">
<thead>
<tr class="text-white clickable-row" bgcolor="#578ebe" >
<th id="white-text"> # </th>
<th id="white-text"> Name </th>
<th id="white-text"> DBA </th>
<th id="white-text"> Facility ID </th>
<th id="white-text"> Active </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="hospital in hospital_filtered = hospitals">
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_name }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_dba }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.facility_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.active_flag }} </td>
</tr>
</tbody>
</table>
Here is where I make the GET call from my API. The data is coming in, but the bootstrap table sorting and sort are not working. How do I populate bootstrap table with this call?
$http.get("/hospitals/all", {
params: {authtoken: $rootScope.auth_token}}
)
.then(function(response) {
// Request completed successfully
//console.log(response);
$scope.hospitals=response.data
}, function(x) {
// Request error
console.log("Error");
});
});
You're correctly fetching the data, but the iteration is wrong.
HTML:
<input ng-model="searchKeyword" type="text">
<table id="example" class="table table-bordered table-striped table-hover" data-search="true">
<thead>
<tr class="text-white clickable-row" bgcolor="#578ebe" >
<th id="white-text" ng-click="changeSort('hospital_id')"> # </th>
<th id="white-text" ng-click="changeSort('hospital_name')"> Name </th>
<th id="white-text" ng-click="changeSort('hospital_dba')"> DBA </th>
<th id="white-text" ng-click="changeSort('facility_id')"> Facility ID </th>
<th id="white-text" ng-click="changeSort('active_flag')"> Active </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="hospital in hospitals | filter: searchKeyword | orderBy: orderKeyword">
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_name }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_dba }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.facility_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.active_flag }} </td>
</tr>
</tbody>
</table>
The Javascript part:
$scope.orderKeyword = 'hospital_name';
$scope.changeSort = function(sortAttr) {
$scope.orderKeyword = sortAttr;
};
filter: searchKeyword will use the keyword typed into the additional input-field. This way you can basically "search" the table. The results that are left will then be ordered by (orderBy) the attribute-name that's stored inside $scope.orderKeyword. I initialized it with hospital_name.
You may add additional logic like how strict the filtering and which direction the sorting is supposed to be.
Here's the documentation for the two filters in question:
https://docs.angularjs.org/api/ng/filter/orderBy
https://docs.angularjs.org/api/ng/filter/filter
I created a pdf using TCPDF and I filled it with some php variables and the current date using heredoc syntax
Everything is fine when the pdf is generated and viewed in the browser, but on the saved pdf file the php variable values are not shown, only the date...
I declare my variables at the top like so:
$name = $_POST['name'];
$score = $_POST['percentage'];
$ku_number = $_POST['ku-number'];
$date = Date('d - m - Y');
Only $date is shown on the saved pdf.
Any suggestion?
Thank you
Edit: code to pass the variables to TCPDF
// Print a text
$html = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
table{
text-align:center;
color:#000;
}
</style>
<table id="name" cellpadding="0">
<tr>
<td width="10" height="80"> </td>
<td width="620"> </td>
<td width="10"> </td>
</tr>
<tr>
<td> </td>
<td width="620">$name</td>
<td> </td>
</tr>
<tr>
<td width="10"> </td>
<td> </td>
<td width="10"> </td>
</tr>
</table>
<table id="score" cellpadding="0" >
<tr>
<td width="10" height="180"> </td>
<td width="620"> </td>
<td width="10"> </td>
</tr>
<tr>
<td> </td>
<td width="620">$score</td>
<td> </td>
</tr>
<tr>
<td width="10" height="207"> </td>
<td> </td>
<td width="10"> </td>
</tr>
</table>
<table id="ku-number" cellpadding="0" >
<tr height="2">
<td width="50" height="2"></td>
<td width="620" height="2"></td>
<td width="10" height="2"></td>
</tr>
<tr>
<td> </td>
<td width="620" height="20"></td>
<td> </td>
</tr>
<tr>
<td width="50"> </td>
<td>$ku_number</td>
<td > </td>
</tr>
</table>
<table id="date" cellpadding="0" >
<tr height="2">
<td width="50" height="2"></td>
<td width="620" height="2"></td>
<td width="10" height="2"></td>
</tr>
<tr>
<td> </td>
<td width="420" height="20">$date</td>
<td> </td>
</tr>
<tr>
<td width="50"> </td>
<td></td>
<td > </td>
</tr>
</table>
EOF;
$pdf->writeHTML($html, true, false, true, false, '');
//Close and output PDF document
$pdf->Output('certificate.pdf', 'I');
I had the same problem. I found a solution by experimenting things myself mentioned as follows:
Please use concatenation to break $html string into parts. This will surely solve the problem. e.g. I used something like this:
$html = 'HTML CONTENT BREAKS HERE' . $variable_name . 'HTML CONTENT CONTINUES HERE' ;
Normally, most developers will use PHP variable within $html value,
$html = 'HTML CONTENT echo php variable HTML CONTENT' ;
I hope this will work.
Using $_SESSION to store the variables before outputting the PDF solved the problem
Credits go to Yuri Stuken
For more refined results:
Outputting the final PDF:
When you’ve finished creating all required cells, images, links, text etc. you have to call the Output() method to actually get your hands on your dynamically created PDF. This can take no parameters in which case the PDF is sent to the browser, more commonly though, developers specify the filename and the destination of the generated PDF. The destination can be one of four values, these are:
I: send the file inline to the browser.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name.
S: return the document as a string.
You can see my code sets the destination value as F:
$pdf->Output(”./pdfs/example.pdf”, “F”);
referenced from:this
Have a bAlaNCeD Life !