I am trying to print a bootstrap modal in chrome but I see always I press the print button and preview the print, the preview shows this vertical bar.
How can I remove this vertical bar in print preview. I don't know why this is showing. There is no vertical bar in the actual bootstrap modal which I am printing.
Any help is appreciated. Thanks
Here is the html coding:
<style>
.str td{
padding-top:1px !important;
padding-bottom:1px !important;
}
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{padding: 5px;}
</style>
<div class="modal-dialog modal-lg no-modal-header">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="fa fa-2x">×</i>
</button>
<button type="button" class="btn btn-xs btn-default no-print pull-right" style="margin-right:15px;" onclick="window.print();">
<i class="fa fa-print"></i> <?= lang('print'); ?></button>
<?php if ($logo) {
?>
<div class="text-cente no-print" style="margin-bottom:20px;">
<img src="<?= base_url() . 'assets/uploads/logos/' . $biller->logo; ?>"
alt="<?= $biller->company && $biller->company != '-' ? $biller->company : $biller->name; ?>">
</div>
<?php
} ?>
<div class="well well-sm no-print">
<div class="row bold">
<div class="col-xs-5">
<p class="bold">
<?= lang('date'); ?>: <?= $this->sma->hrld($inv->date); ?><br>
<?= lang('ref'); ?>: <?= $inv->reference_no; ?><br>
<?php if (!empty($inv->return_sale_ref)) {
echo lang('return_ref') . ': ' . $inv->return_sale_ref;
if ($inv->return_id) {
echo ' <a data-target="#myModal2" data-toggle="modal" href="' . admin_url('sales/modal_view/' . $inv->return_id) . '"><i class="fa fa-external-link no-print"></i></a><br>';
} else {
echo '<br>';
}
} ?>
<?= lang('sale_status'); ?>: <?= lang($inv->sale_status); ?><br>
<?= lang('payment_status'); ?>: <?= lang($inv->payment_status); ?><br>
<?= $inv->payment_method ? lang('payment_method') . ': ' . lang($inv->payment_method) : ''; ?>
<?php
if ($inv->payment_method == 'cod' || $inv->payment_method == 'bank' && $inv->attachment) {
?>
<a href="<?= admin_url('welcome/download/' . $inv->attachment) ?>"
title="<?= lang('attachment') ?>" class="tip">
<i class="fa fa-chain"></i>
</a>
<?php
}
?>
<?php if ($inv->payment_status != 'paid' && $inv->due_date) {
echo '<br>' . lang('due_date') . ': ' . $this->sma->hrsd($inv->due_date);
} ?>
</p>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
<div class="row" style="margin-bottom:15px;">
<?php if ($Settings->invoice_view == 1) {
?>
<div class="col-xs-12 text-center">
<h1><?= lang('tax_invoice'); ?></h1>
</div>
<?php
} ?>
</div>
<?php
$col = $Settings->indian_gst ? 5 : 4;
if ($Settings->product_discount && $inv->product_discount != 0) {
$col++;
}
if ($Settings->tax1 && $inv->product_tax > 0) {
$col++;
}
if ($Settings->product_discount && $inv->product_discount != 0 && $Settings->tax1 && $inv->product_tax > 0) {
$tcol = $col - 2;
} elseif ($Settings->product_discount && $inv->product_discount != 0) {
$tcol = $col - 1;
} elseif ($Settings->tax1 && $inv->product_tax > 0) {
$tcol = $col - 1;
} else {
$tcol = $col;
}
?>
<div class="row" style="margin-bottom:10px;">
<?php if ($Settings->invoice_view == 1) {
?>
<div class="col-xs-12 text-center">
<h1><?= lang('tax_invoice'); ?></h1>
</div>
<?php
} ?>
<div class="col-xs-4">
<div class="row">
<div class="col-xs-2" style="padding-right: 0px;">
<?php echo $this->lang->line('to'); ?>:
</div>
<div class="col-xs-10 pull-left" style="padding-left: 10px;">
<strong>
<p><small><?= $customer->company && $customer->company != '-' ? $customer->company : $customer->name; ?></small></p>
<?= $customer->company && $customer->company != '-' ? '' : 'Attn: ' . $customer->name ?></strong></p>
</strong>
</div>
<div class="col-xs-10" style="padding-right: 0px;">
<small>
<?php if ($customer->vat_no != '-' && $customer->vat_no != '') {
echo '<br>' . lang('vat_no') . ': ' . $customer->vat_no;
}
if ($customer->gst_no != '-' && $customer->gst_no != '') {
echo '<br>' . lang('gst_no') . ': ' . $customer->gst_no;
}
if ($customer->cf1 != '-' && $customer->cf1 != '') {
echo lang('ccf1') . ': ' . $customer->cf1;
}
if ($customer->cf2 != '-' && $customer->cf2 != '') {
echo '<br>' . lang('ccf2') . ': ' . $customer->cf2;
}
if ($customer->cf3 != '-' && $customer->cf3 != '') {
echo '<br>' . lang('ccf3') . ': ' . $customer->cf3;
}
if ($customer->cf4 != '-' && $customer->cf4 != '') {
echo '<br>' . lang('ccf4') . ': ' . $customer->cf4;
}
if ($customer->cf5 != '-' && $customer->cf5 != '') {
echo '<br>' . lang('ccf5') . ': ' . $customer->cf5;
}
if ($customer->cf6 != '-' && $customer->cf6 != '') {
echo '<br>' . lang('ccf6') . ': ' . $customer->cf6;
}
?>
</small>
</div>
</div>
</div>
<div class="col-xs-4">
<?php
echo '<small>'.$customer->address . '<br>' . $customer->city . ' ' . $customer->postal_code . ' ' . $customer->state . '<br>' . $customer->country;
?>
</div>
<div class="col-xs-4">
<small><?php echo lang('tel') . ': ' . $customer->phone . '<br>' . lang('email') . ': ' . $customer->email;
?></small>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped print-table order-table" style="page-break-inside:auto">
<tbody>
<tr>
<th colspan="2"><small>SALES PERSON</small></th>
<th colspan="2"><small>REFERENCE NO</small></th>
<th colspan="2"><small>INVOICE DATE</small></th>
<th colspan="2"><small>PAID BY</small></th>
</tr>
<tr>
<td colspan="2"><small><?=$created_by->first_name?></small></td>
<td colspan="2"><small><?=$inv->reference_no?></small></td>
<td colspan="2"><small><?=$this->sma->hrld($inv->date)?></small></td>
<td colspan="2"><small><?=$payments?></small></td>
</tr>
<tr>
<th><small>NO</small></th>
<th><small>DESCRIPTION</small></th>
<th><small>QTY</small></th>
<th><small>UNIT</small></th>
<th><small>SUB TOTAL</small></th>
<th><small>%</small></th>
<th class="text-right"><small>TOTAL</small></th>
</tr>
<?php $r = 1;
if($rows){
foreach ($rows as $row):
?>
<tr class="str" style="<?php if($r == 9){ echo 'page-break-inside:avoid; page-break-after:auto;'; } ?>" >
<td class="std"><small><?=$r?></small></td>
<td class="std"><small><?=$row->product_name?></small></td>
<td class="std"><small><?=$this->sma->formatQuantity($row->unit_quantity)?></small></td>
<td class="std"><small><?=number_format((float)$row->unit_price + $row->item_discount, 2, '.', '')?></small>
</td>
<td class="std"><small><?=number_format((float)($row->unit_price)*($row->unit_quantity), 2, '.', '')?></small>
</td>
<td class="std"><small><?=number_format((float)$row->item_discount, 2, '.', '')?></small></td>
<td class="text-right"><small><?=$this->sma->formatMoney($row->subtotal)?></small></td>
</tr>
<?php
$r++;
endforeach;
}
if ($return_rows) {
echo '<tr class="warning"><td colspan="100%" class="no-border"><strong>' . lang('returned_items') . '</strong></td></tr>';
foreach ($return_rows as $row):
?>
<tr>
<td><small><?=$r?></small></td>
<td><small><?=$row->product_name?></small></td>
<td><small><?=$this->sma->formatQuantity($row->unit_quantity)?></small></td>
<td><small><?=number_format((float)$row->unit_price + $row->item_discount, 2, '.', '')?></small>
</td>
<td><small><?=number_format((float)($row->unit_price)*($row->unit_quantity), 2, '.', '')?></small>
</td>
<td><small><?=number_format((float)$row->item_discount, 2, '.', '')?></small></td>
<td class="text-right"><small><?=$this->sma->formatMoney($row->subtotal)?></small></td>
</tr>
<?php
$r++;
endforeach;
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="6" class="text-right"><small><?=lang('total');?></small></th>
<th colspan="2" class="text-right">
<small><?=$this->sma->formatMoney($return_sale ? (($inv->total + $inv->product_tax) + ($return_sale->total + $return_sale->product_tax)) : ($inv->total + $inv->product_tax));?></small>
</th>
</tr>
<?php
if ($inv->order_tax != 0) {
echo '<tr><th colspan="6><small>' . lang('tax') . '</th><th class="text-right"colspan="2"><small>' . $this->sma->formatMoney($return_sale ? ($inv->order_tax + $return_sale->order_tax) : $inv->order_tax) . '</small></th></tr>';
}
if ($inv->order_discount != 0) {
echo '<tr><th colspan="6" class="text-right"><small>' . lang('order_discount') . '</small></th><th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($return_sale ? ($inv->order_discount + $return_sale->order_discount) : $inv->order_discount) . '</small></th></tr>';
}
if ($inv->shipping != 0) {
echo '<tr><th colspan="6" class="text-right"><small>' . lang('shipping') . '</th><th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($inv->shipping) . '</small></th></tr>';
}
if ($return_sale) {
if ($return_sale->surcharge != 0) {
echo '<tr><th colspan="6" class="text-right"><small>' . lang('return_surcharge') . '</small></th><th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($return_sale->surcharge) . '</small></th></tr>';
}
}
if ($Settings->indian_gst) {
if ($inv->cgst > 0) {
$cgst = $return_sale ? $inv->cgst + $return_sale->cgst : $inv->cgst;
echo '<tr><td colspan="6"><small>' . lang('cgst') . '</small></td><td class="text-right" colspan="2"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($cgst) : $cgst) . '</small></td></tr>';
}
if ($inv->sgst > 0) {
$sgst = $return_sale ? $inv->sgst + $return_sale->sgst : $inv->sgst;
echo '<tr><td colspan="6"><small>' . lang('sgst') . '</small></td><td class="text-right" colspan="2"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($sgst) : $sgst) . '</small></td></tr>';
}
if ($inv->igst > 0) {
$igst = $return_sale ? $inv->igst + $return_sale->igst : $inv->igst;
echo '<tr><td colspan="6"><small>' . lang('igst') . '</small></td><td class="text-right" colspan="6"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($igst) : $igst) . '</small></td></tr>';
}
}
if ($pos_settings->rounding || $inv->rounding != 0) {
?>
<tr>
<th colspan="6" class="text-right"><small><?=lang('rounding'); ?></small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney($inv->rounding); ?></small></th>
</tr>
<tr>
<th colspan="6" class="text-right"><small><?=lang('grand_total'); ?></small></th>
<th colspan="2" class="text-right">
<small><?=$this->sma->formatMoney($return_sale ? (($inv->grand_total + $inv->rounding) + $return_sale->grand_total) : ($inv->grand_total + $inv->rounding)); ?></small>
</th>
</tr>
<?php
} else {
?>
<tr>
<th colspan="6" class="text-right"><small><?=lang('grand_total'); ?></small></th>
<th colspan="2" class="text-right">
<small><?=$this->sma->formatMoney($return_sale ? ($inv->grand_total + $return_sale->grand_total) : $inv->grand_total); ?></small>
</th>
</tr>
<?php
}
if ($inv->paid < ($inv->grand_total + $inv->rounding)) {
?>
<tr>
<th colspan="6" class="text-right"><small><?=lang('paid_amount'); ?></small></th>
<th colspan="2" class="text-right">
<small><?=$this->sma->formatMoney($return_sale ? ($inv->paid + $return_sale->paid) : $inv->paid); ?></small>
</th>
</tr>
<tr>
<th colspan="6" class="text-right"><small>Due Amount</small></th>
<th colspan="2" class="text-right">
<small><?=$this->sma->formatMoney(($return_sale ? (($inv->grand_total + $inv->rounding) + $return_sale->grand_total) : ($inv->grand_total + $inv->rounding)) - ($return_sale ? ($inv->paid + $return_sale->paid) : $inv->paid)); ?></small>
</th>
</tr>
<?php
} ?>
<td colspan='8'>
<strong><small>Please Note : Any deposit balances are due prior to the above Confirmed
Product Delivery Date</small></strong>
<br>
<small>All goods remain the property of Arcadia Traders untill paid in full.</small>
<br>
<small>- Please use invoice number as reference for all payments.</small>
</td>
</tr>
</tfoot>
</table>
</div>
<?= $Settings->invoice_view > 0 ? $this->gst->summary($rows, $return_rows, ($return_sale ? $inv->product_tax + $return_sale->product_tax : $inv->product_tax)) : ''; ?>
<div class="row">
<div class="col-xs-12">
<?php
if ($inv->note || $inv->note != '') {
?>
<div class="well well-sm">
<p class="bold"><?= lang('note'); ?>:</p>
<div><?= $this->sma->decode_html($inv->note); ?></div>
</div>
<?php
}
if ($inv->staff_note || $inv->staff_note != '') {
?>
<div class="well well-sm staff_note">
<p class="bold"><?= lang('staff_note'); ?>:</p>
<div><?= $this->sma->decode_html($inv->staff_note); ?></div>
</div>
<?php
} ?>
</div>
<?php if ($customer->award_points != 0 && $Settings->each_spent > 0) {
?>
<div class="col-xs-5 pull-left">
<div class="well well-sm">
<?=
'<p>' . lang('this_sale') . ': ' . floor(($inv->grand_total / $Settings->each_spent) * $Settings->ca_point)
. '<br>' .
lang('total') . ' ' . lang('award_points') . ': ' . $customer->award_points . '</p>'; ?>
</div>
</div>
<?php
} ?>
<div class="order_barcodes no-print">
<table class="table">
<tbody>
<tr>
<td>
<div style="max-width:200px; padding-top:7px;">
<img src="<?= admin_url('misc/barcode/' . $this->sma->base64url_encode($inv->reference_no) . '/code128/74/0/1'); ?>"
alt="<?= $inv->reference_no; ?>" class="bcimg">
</div>
</td>
<td class="text-right">
<div style="max-width:70px">
<?= $this->sma->qrcode('link', urlencode(admin_url('sales/view/' . $inv->id)), 2); ?>
</div>
</td>
</tr>
</tbody>
</table>
<br>
</div>
<div class="col-xs-5 pull-right no-print">
<div class="well well-sm">
<p>
<?= lang('created_by'); ?>:
<?= $inv->created_by ? $created_by->first_name . ' ' . $created_by->last_name : $customer->name; ?>
<br>
<?= lang('date'); ?>: <?= $this->sma->hrld($inv->date); ?>
</p>
<?php if ($inv->updated_by) {
?>
<p>
<?= lang('updated_by'); ?>:
<?= $updated_by->first_name . ' ' . $updated_by->last_name; ?><br>
<?= lang('update_at'); ?>: <?= $this->sma->hrld($inv->updated_at); ?>
</p>
<?php
} ?>
</div>
</div>
</div>
<?php if (!$Supplier || !$Customer) {
?>
<div class="buttons">
<div class="btn-group btn-group-justified">
<div class="btn-group">
<a href="<?= admin_url('sales/add_payment/' . $inv->id) ?>" class="tip btn btn-primary"
title="<?= lang('add_payment') ?>" data-toggle="modal" data-target="#myModal2">
<i class="fa fa-dollar"></i>
<span class="hidden-sm hidden-xs"><?= lang('payment') ?></span>
</a>
</div>
<div class="btn-group">
<a href="<?= admin_url('sales/add_delivery/' . $inv->id) ?>" class="tip btn btn-primary"
title="<?= lang('add_delivery') ?>" data-toggle="modal" data-target="#myModal2">
<i class="fa fa-truck"></i>
<span class="hidden-sm hidden-xs"><?= lang('delivery') ?></span>
</a>
</div>
<?php if ($inv->attachment) {
?>
<div class="btn-group">
<a href="<?= admin_url('welcome/download/' . $inv->attachment) ?>" class="tip btn btn-primary"
title="<?= lang('attachment') ?>">
<i class="fa fa-chain"></i>
<span class="hidden-sm hidden-xs"><?= lang('attachment') ?></span>
</a>
</div>
<?php
} ?>
<div class="btn-group">
<a href="<?= admin_url('sales/email/' . $inv->id) ?>" data-toggle="modal"
data-target="#myModal2" class="tip btn btn-primary" title="<?= lang('email') ?>">
<i class="fa fa-envelope-o"></i>
<span class="hidden-sm hidden-xs"><?= lang('email') ?></span>
</a>
</div>
<div class="btn-group">
<a href="<?= admin_url('sales/pdf/' . $inv->id) ?>" class="tip btn btn-primary"
title="<?= lang('download_pdf') ?>">
<i class="fa fa-download"></i>
<span class="hidden-sm hidden-xs"><?= lang('pdf') ?></span>
</a>
</div>
<?php if (!$inv->sale_id) {
?>
<div class="btn-group">
<a href="<?= admin_url('sales/edit/' . $inv->id) ?>" class="tip btn btn-warning sledit"
title="<?= lang('edit') ?>">
<i class="fa fa-edit"></i>
<span class="hidden-sm hidden-xs"><?= lang('edit') ?></span>
</a>
</div>
<div class="btn-group">
<a href="#" class="tip btn btn-danger bpo"
title="<b><?= $this->lang->line('delete_sale') ?></b>"
data-content="<div style='width:150px;'><p><?= lang('r_u_sure') ?></p><a class='btn btn-danger' href='<?= admin_url('sales/delete/' . $inv->id) ?>'><?= lang('i_m_sure') ?></a> <button class='btn bpo-close'><?= lang('no') ?></button></div>"
data-html="true" data-placement="top">
<i class="fa fa-trash-o"></i>
<span class="hidden-sm hidden-xs"><?= lang('delete') ?></span>
</a>
</div>
<?php
} ?>
</div>
</div>
<?php
} ?>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.tip').tooltip();
});
</script>
I'm no sure of what exactly your problem is, but you can try adding style="overflow: hidden;" at the beginning (at str) and maybe that solves the problem.
You can simply hide this scroll bar by adding this css property in your style tag only if your website do not have scrolling behaviour
html { overflow: hidden; }
But if you website does have scrolling behaviour and you just want to remove this scroll bar from printing document then you can use add these css proeprties in your style tag
::-webkit-scrollbar {
width: 0px;
background: transparent;
/* make scrollbar transparent */
actual answer
Try using window.print() and hide everything except the modal. The scroll bars won’t be there using this method.
Related
Hi I am trying to print a webpage. In the web print preview, it is showing properly, but when I actually print it on paper, the text doesn't show properly.
Some float:right properties are not working and similarly bootstrap grid too.
You can see the issue in picture.
See at the top "To" section. The text is properly aligned. Also the text at the bottom "Total", "Grand total" etc are float:right in actual page, but when I print they are not float:right.
html and css:
#media print {
#page {
size: auto;
}
.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12 {
float: left;
}
.col-xs-12 {
width: 100%;
}
.col-xs-11 {
width: 91.66666666666666%;
}
.col-xs-10 {
width: 83.33333333333334%;
}
.col-xs-9 {
width: 75%;
}
.col-xs-8 {
width: 66.66666666666666%;
}
.col-xs-7 {
width: 58.333333333333336%;
}
.col-xs-6 {
width: 50%;
}
.col-xs-5 {
width: 41.66666666666667%;
}
.col-xs-4 {
width: 33.33333333333333%;
}
.col-xs-3 {
width: 25%;
}
.col-xs-2 {
width: 16.666666666666664%;
}
.col-xs-1 {
width: 8.333333333333332%;
}
}
}
.table>thead>tr>th,
.table>tbody>tr>th,
.table>tfoot>tr>th,
.table>thead>tr>td,
.table>tbody>tr>td,
.table>tfoot>tr>td {
padding: 5px;
}
<div class="modal-dialog modal-lg no-modal-header">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="fa fa-2x">×</i>
</button>
<button type="button" class="btn btn-xs btn-default no-print pull-right" style="margin-right:15px;" onclick="window.print();">
<i class="fa fa-print"></i> <?= lang('print'); ?></button>
<?php if ($logo) {
?>
<div class="text-cente no-print" style="margin-bottom:20px;">
<img src="<?= base_url() . 'assets/uploads/logos/' . $biller->logo; ?>" alt="<?= $biller->company && $biller->company != '-' ? $biller->company : $biller->name; ?>">
</div>
<?php
} ?>
<div class="well well-sm no-print">
<div class="row bold">
<div class="col-xs-5">
<p class="bold">
<?= lang('date'); ?>:
<?= $this->sma->hrld($inv->date); ?><br>
<?= lang('ref'); ?>:
<?= $inv->reference_no; ?><br>
<?php if (!empty($inv->return_sale_ref)) {
echo lang('return_ref') . ': ' . $inv->return_sale_ref;
if ($inv->return_id) {
echo ' <a data-target="#myModal2" data-toggle="modal" href="' . admin_url('sales/modal_view/' . $inv->return_id) . '"><i class="fa fa-external-link no-print"></i></a><br>';
} else {
echo '<br>';
}
} ?>
<?= lang('sale_status'); ?>:
<?= lang($inv->sale_status); ?><br>
<?= lang('payment_status'); ?>:
<?= lang($inv->payment_status); ?><br>
<?= $inv->payment_method ? lang('payment_method') . ': ' . lang($inv->payment_method) : ''; ?>
<?php
if ($inv->payment_method == 'cod' || $inv->payment_method == 'bank' && $inv->attachment) {
?>
<a href="<?= admin_url('welcome/download/' . $inv->attachment) ?>" title="<?= lang('attachment') ?>" class="tip">
<i class="fa fa-chain"></i>
</a>
<?php
}
?>
<?php if ($inv->payment_status != 'paid' && $inv->due_date) {
echo '<br>' . lang('due_date') . ': ' . $this->sma->hrsd($inv->due_date);
} ?>
</p>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
<div class="row" style="margin-bottom:15px;">
<?php if ($Settings->invoice_view == 1) {
?>
<div class="col-xs-12 text-center">
<h1>
<?= lang('tax_invoice'); ?>
</h1>
</div>
<?php
} ?>
</div>
<?php
$col = $Settings->indian_gst ? 5 : 4;
if ($Settings->product_discount && $inv->product_discount != 0) {
$col++;
}
if ($Settings->tax1 && $inv->product_tax > 0) {
$col++;
}
if ($Settings->product_discount && $inv->product_discount != 0 && $Settings->tax1 && $inv->product_tax > 0) {
$tcol = $col - 2;
} elseif ($Settings->product_discount && $inv->product_discount != 0) {
$tcol = $col - 1;
} elseif ($Settings->tax1 && $inv->product_tax > 0) {
$tcol = $col - 1;
} else {
$tcol = $col;
}
?>
<div class="row" style="margin-bottom:10px;">
<?php if ($Settings->invoice_view == 1) {
?>
<div class="col-xs-12 text-center">
<h1>
<?= lang('tax_invoice'); ?>
</h1>
</div>
<?php
} ?>
<div class="col-xs-4">
<div class="row">
<div class="col-xs-2" style="padding-right: 0px;">
<?php echo $this->lang->line('to'); ?>:
</div>
<div class="col-xs-10 pull-left" style="padding-left: 10px;">
<strong>
<p>
<small><?= $customer->company && $customer->company != '-' ? $customer->company : $customer->name; ?></small>
</p>
<?= $customer->company && $customer->company != '-' ? '' : 'Attn: ' . $customer->name ?>
</strong></p>
</strong>
</div>
<div class="col-xs-10" style="padding-right: 0px;">
<small>
<?php if ($customer->vat_no != '-' && $customer->vat_no != '') {
echo '<br>' . lang('vat_no') . ': ' . $customer->vat_no;
}
if ($customer->gst_no != '-' && $customer->gst_no != '') {
echo '<br>' . lang('gst_no') . ': ' . $customer->gst_no;
}
if ($customer->cf1 != '-' && $customer->cf1 != '') {
echo lang('ccf1') . ': ' . $customer->cf1;
}
if ($customer->cf2 != '-' && $customer->cf2 != '') {
echo '<br>' . lang('ccf2') . ': ' . $customer->cf2;
}
if ($customer->cf3 != '-' && $customer->cf3 != '') {
echo '<br>' . lang('ccf3') . ': ' . $customer->cf3;
}
if ($customer->cf4 != '-' && $customer->cf4 != '') {
echo '<br>' . lang('ccf4') . ': ' . $customer->cf4;
}
if ($customer->cf5 != '-' && $customer->cf5 != '') {
echo '<br>' . lang('ccf5') . ': ' . $customer->cf5;
}
if ($customer->cf6 != '-' && $customer->cf6 != '') {
echo '<br>' . lang('ccf6') . ': ' . $customer->cf6;
}
?>
</small>
</div>
</div>
</div>
<div class="col-xs-4">
<?php
echo '<small>' . $customer->address . '<div>' . $customer->city . ' ' . $customer->postal_code . ' ' . $customer->state . '</div><div>' . $customer->country . '</div>';
?>
</div>
<div class="col-xs-4">
<small><?php echo lang('tel') . ': ' . $customer->phone . '<div>' . lang('email') . ': ' . $customer->email . "</div>";
?></small>
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped print-table order-table" style="page-break-inside:auto">
<tbody>
<tr>
<th colspan="2"><small>SALES PERSON</small></th>
<th colspan="2"><small>REFERENCE NO</small></th>
<th colspan="2"><small>INVOICE DATE</small></th>
<th colspan="2"><small>PAID BY</small></th>
</tr>
<tr>
<td colspan="2"><small><?= $created_by->first_name ?></small></td>
<td colspan="2"><small><?= $inv->reference_no ?></small></td>
<td colspan="2"><small><?= $this->sma->hrld($inv->date) ?></small></td>
<td colspan="2"><small><?= $payments[0]->paid_by ?></small></td>
</tr>
<tr>
<th><small>NO</small></th>
<th><small>DESCRIPTION</small></th>
<th><small>QTY</small></th>
<th><small>UNIT</small></th>
<th><small>SUB TOTAL</small></th>
<th><small>%</small></th>
<th class="text-right"><small>TOTAL</small></th>
</tr>
<?php $r = 1;
if ($rows) {
foreach ($rows as $row):
?>
<tr class="str" style="<?php if ($r == 9) {
echo 'page-break-inside:avoid; page-break-after:auto;';
} ?>">
<td class="std"><small><?= $r ?></small></td>
<td class="std"><small><?= $row->product_name ?></small></td>
<td class="std"><small><?= $this->sma->formatQuantity($row->unit_quantity) ?></small>
</td>
<td class="std">
<small><?= number_format((float)$row->unit_price + $row->item_discount, 2, '.', '') ?></small>
</td>
<td class="std">
<small><?= number_format((float)($row->unit_price) * ($row->unit_quantity), 2, '.', '') ?></small>
</td>
<td class="std">
<small><?= number_format((float)$row->item_discount, 2, '.', '') ?></small></td>
<td class="text-right"><small><?= $this->sma->formatMoney($row->subtotal) ?></small>
</td>
</tr>
<?php
$r++;
endforeach;
}
if ($return_rows) {
echo '<tr class="warning"><td colspan="100%" class="no-border"><strong>' . lang('returned_items') . '</strong></td></tr>';
foreach ($return_rows as $row):
?>
<tr>
<td><small><?= $r ?></small></td>
<td><small><?= $row->product_name ?></small></td>
<td><small><?= $this->sma->formatQuantity($row->unit_quantity) ?></small></td>
<td>
<small><?= number_format((float)$row->unit_price + $row->item_discount, 2, '.', '') ?></small>
</td>
<td>
<small><?= number_format((float)($row->unit_price) * ($row->unit_quantity), 2, '.', '') ?></small>
</td>
<td><small><?= number_format((float)$row->item_discount, 2, '.', '') ?></small></td>
<td class="text-right"><small><?= $this->sma->formatMoney($row->subtotal) ?></small>
</td>
</tr>
<?php
$r++;
endforeach;
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="6" class=""><small style="float: right;"><?= lang('total'); ?></small></th>
<th colspan="2" class="text-right">
<small "><?= $this->sma->formatMoney($return_sale ? (($inv->total + $inv->product_tax) + ($return_sale->total + $return_sale->product_tax)) : ($inv->total + $inv->product_tax)); ?></small>
</th>
</tr>
<?php
if ($inv->order_tax != 0) {
echo '<tr><th colspan="6><small>' . lang('tax') . '</th><th class="text-right"colspan="2"><small>' . $this->sma->formatMoney($return_sale ? ($inv->order_tax + $return_sale->order_tax) : $inv->order_tax) . '</small></th>
</tr>'; } if ($inv->order_discount != 0) { echo '
<tr>
<th colspan="6" class="text-right"><small>' . lang('order_discount') . '</small></th>
<th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($return_sale ? ($inv->order_discount + $return_sale->order_discount) : $inv->order_discount) . '</small></th>
</tr>'; } if ($inv->shipping != 0) { echo '
<tr>
<th colspan="6" class="text-right"><small>' . lang('shipping') . '</th><th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($inv->shipping) . '</small></th>
</tr>'; } if ($return_sale) { if ($return_sale->surcharge != 0) { echo '
<tr>
<th colspan="6" class="text-right"><small>' . lang('return_surcharge') . '</small></th>
<th class="text-right" colspan="2"><small>' . $this->sma->formatMoney($return_sale->surcharge) . '</small></th>
</tr>'; } } if ($Settings->indian_gst) { if ($inv->cgst > 0) { $cgst = $return_sale ? $inv->cgst + $return_sale->cgst : $inv->cgst; echo '
<tr>
<td colspan="6"><small>' . lang('cgst') . '</small></td>
<td class="text-right" colspan="2"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($cgst) : $cgst) . '</small></td>
</tr>'; } if ($inv->sgst > 0) { $sgst = $return_sale ? $inv->sgst + $return_sale->sgst : $inv->sgst; echo '
<tr>
<td colspan="6"><small>' . lang('sgst') . '</small></td>
<td class="text-right" colspan="2"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($sgst) : $sgst) . '</small></td>
</tr>'; } if ($inv->igst > 0) { $igst = $return_sale ? $inv->igst + $return_sale->igst : $inv->igst; echo '
<tr>
<td colspan="6"><small>' . lang('igst') . '</small></td>
<td class="text-right" colspan="6"><small>' . ($Settings->format_gst ? $this->sma->formatMoney($igst) : $igst) . '</small></td>
</tr>'; } } if ($pos_settings->rounding || $inv->rounding != 0) { ?>
<tr>
<th colspan="6" class="text-right"><small><?= lang('rounding'); ?></small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney($inv->rounding); ?></small></th>
</tr>
<tr>
<th colspan="6" class=""><small style="float: right;"><?= lang('grand_total'); ?></small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney($return_sale ? (($inv->grand_total + $inv->rounding) + $return_sale->grand_total) : ($inv->grand_total + $inv->rounding)); ?></small>
</th>
</tr>
<?php
} else {
?>
<tr>
<th colspan="6" class="text-right"><small style="float: right;"><?= lang('grand_total'); ?></small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney($return_sale ? ($inv->grand_total + $return_sale->grand_total) : $inv->grand_total); ?></small>
</th>
</tr>
<?php
}
if ($inv->paid < ($inv->grand_total + $inv->rounding)) {
?>
<tr>
<th colspan="6" class=""><small style="float: right;"><?= lang('paid_amount'); ?></small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney($return_sale ? ($inv->paid + $return_sale->paid) : $inv->paid); ?></small>
</th>
</tr>
<tr>
<th colspan="6" class=""><small style="float: right;">Due Amount</small></th>
<th colspan="2" class="text-right">
<small><?= $this->sma->formatMoney(($return_sale ? (($inv->grand_total + $inv->rounding) + $return_sale->grand_total) : ($inv->grand_total + $inv->rounding)) - ($return_sale ? ($inv->paid + $return_sale->paid) : $inv->paid)); ?></small>
</th>
</tr>
<?php
} ?>
<td colspan='8'>
<strong><small>Please Note : Any deposit balances are due prior to the above Confirmed
Product Delivery Date</small></strong>
<br>
<small>All goods remain the property of Arcadia Traders untill paid in full.</small>
<br>
<small>- Please use invoice number as reference for all payments.</small>
</td>
</tr>
</tfoot>
</table>
</div>
<?= $Settings->invoice_view > 0 ? $this->gst->summary($rows, $return_rows, ($return_sale ? $inv->product_tax + $return_sale->product_tax : $inv->product_tax)) : ''; ?>
<div class="row">
<div class="col-xs-12">
<?php
if ($inv->note || $inv->note != '') {
?>
<div class="well well-sm">
<p class="bold">
<?= lang('note'); ?>:</p>
<div>
<?= $this->sma->decode_html($inv->note); ?>
</div>
</div>
<?php
}
if ($inv->staff_note || $inv->staff_note != '') {
?>
<div class="well well-sm staff_note">
<p class="bold">
<?= lang('staff_note'); ?>:</p>
<div>
<?= $this->sma->decode_html($inv->staff_note); ?>
</div>
</div>
<?php
} ?>
</div>
<?php if ($customer->award_points != 0 && $Settings->each_spent > 0) {
?>
<div class="col-xs-5 pull-left">
<div class="well well-sm">
<?=
'<p>' . lang('this_sale') . ': ' . floor(($inv->grand_total / $Settings->each_spent) * $Settings->ca_point)
. '<br>' .
lang('total') . ' ' . lang('award_points') . ': ' . $customer->award_points . '</p>'; ?>
</div>
</div>
<?php
} ?>
<div class="order_barcodes no-print">
<table class="table">
<tbody>
<tr>
<td>
<div style="max-width:200px; padding-top:7px;">
<img src="<?= admin_url('misc/barcode/' . $this->sma->base64url_encode($inv->reference_no) . '/code128/74/0/1'); ?>" alt="<?= $inv->reference_no; ?>" class="bcimg">
</div>
</td>
<td class="text-right">
<div style="max-width:70px">
<?= $this->sma->qrcode('link', urlencode(admin_url('sales/view/' . $inv->id)), 2); ?>
</div>
</td>
</tr>
</tbody>
</table>
<br>
</div>
<div class="col-xs-5 pull-right no-print">
<div class="well well-sm">
<p>
<?= lang('created_by'); ?>:
<?= $inv->created_by ? $created_by->first_name . ' ' . $created_by->last_name : $customer->name; ?>
<br>
<?= lang('date'); ?>:
<?= $this->sma->hrld($inv->date); ?>
</p>
<?php if ($inv->updated_by) {
?>
<p>
<?= lang('updated_by'); ?>:
<?= $updated_by->first_name . ' ' . $updated_by->last_name; ?><br>
<?= lang('update_at'); ?>:
<?= $this->sma->hrld($inv->updated_at); ?>
</p>
<?php
} ?>
</div>
</div>
</div>
<?php if (!$Supplier || !$Customer) {
?>
You are using colspan="6", remove that, hopefully it will solve your issue.
I have data table with search filed. I am trying to filter table using data range and order status. I want to filter table also using range and status and also want to export into excel sheet. Code is working for only search and simple export (Not filtered data).
Thanks
This is my file (View, Controller and Model)
View:-
<a class="pull-right btn btn-primary btn-xs" href="<?php echo base_url()?>order/createXLS"><i class="fa fa-file-excel-o"></i> Export Data</a>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title" >Custom Filter : </h3>
</div>
<div class="panel-body">
<form id="form-filter" method="POST" action="order/ajax_list" class="form-horizontal">
<div class="form-group">
<label for="FirstName" class="col-sm-2 control-label">From</label>
<div class="col-sm-4">
<input type="date" class="form-control" id="from">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label">To</label>
<div class="col-sm-4">
<input type="date" class="form-control" id="to">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label">Status</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="status">
</div>
</div>
<div class="form-group">
<label for="LastName" class="col-sm-2 control-label"></label>
<div class="col-sm-4">
<button type="button" id="btn-filter" class="btn btn-primary">Filter</button>
<button type="button" id="btn-reset" class="btn btn-default">Reset</button>
</div>
</div>
</form>
</div>
</div>
<table class="table table-bordered table-striped" id="mytable">
<thead>
<tr>
<th width="80px">No</th>
<th>Order Number</th>
<th>Service Date</th>
<th>Service Location</th>
<th>Customer Name</th>
<th>Contact Number</th>
<th>Order Status</th>
<th>Payment Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$start = 0;
foreach ($job_positions_data as $job_positions)
{
?>
<tr>
<td>
<?php echo ++$start ?>
</td>
<td>
<?php echo $job_positions->order_number ?>
</td>
<td>
<?php echo $job_positions->service_date ?>
</td>
<td>
<?php if($job_positions->service_location == 1)
{
echo 'vkool_branch';
}
else
{
echo 'customer_location' ;
}
?>
</td>
<td>
<?php echo $job_positions->firstname ?>
</td>
<td>
<?php echo $job_positions->contact_number ?>
</td>
<td>
<?php if($job_positions->order_status == 0)
{
echo 'Action Pending';
}
elseif($job_positions->order_status == 1)
{
echo 'Under Process' ;
}
elseif($job_positions->order_status == 2)
{
echo 'Cancelled' ;
}
elseif($job_positions->order_status == 3)
{
echo 'Completed' ;
}
elseif($job_positions->order_status == 4)
{
echo 'Refund' ;
}
?>
</td>
<td>
<?php if( $job_positions->payment_status == 1)
{
echo 'Pending (Pay at Store)';
}
elseif($job_positions->payment_status == 0)
{
echo 'Pending (Pay Online)';
}
elseif($job_positions->payment_status == 14)
{
echo 'Paid';
}?>
</td>
<td style="text-align:center" width="200px">
<i class="fa fa-search-plus"></i>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$("#mytable").dataTable();
});
</script>
Controller : -
public function createXLS() {
$fileName = 'data-'.time().'.xlsx';
require_once APPPATH . "/third_party/PHPExcel/Classes/PHPExcel.php";
$orderInfo = $this->Order_model->get_For_Export();
$ordervalue = json_encode($orderInfo, true);
/*echo '<pre>';
print_r($orderInfo);
echo '</pre>';
exit;*/
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
// set Header
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'S.No');
$objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Order Number');
$objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Service Location');
$objPHPExcel->getActiveSheet()->SetCellValue('D1', 'First Name');
$objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Last Name');
$objPHPExcel->getActiveSheet()->SetCellValue('F1', 'Contact_No');
$objPHPExcel->getActiveSheet()->SetCellValue('G1', 'Order Status');
$objPHPExcel->getActiveSheet()->SetCellValue('H1', 'Payment Status');
// Style
$style = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
),
'font' => array(
'bold' => true,
'color' => array('rgb' => '2F4F4F'),
'size' => 20,
),
);
$styleHeading = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
),
'font' => array(
'bold' => true,
'size' => 15,
),
);
// set Row
$rowCount = 2;
foreach ($orderInfo as $element) {
$objPHPExcel->getActiveSheet()->SetCellValue('A' . $rowCount, $element['id']);
$objPHPExcel->getActiveSheet()->SetCellValue('B' . $rowCount, $element['order_number']);
$objPHPExcel->getActiveSheet()->SetCellValue('C' . $rowCount, $element['service_location']);
$objPHPExcel->getActiveSheet()->SetCellValue('D' . $rowCount, $element['firstname']);
$objPHPExcel->getActiveSheet()->SetCellValue('E' . $rowCount, $element['lastname']);
$objPHPExcel->getActiveSheet()->SetCellValue('F' . $rowCount, $element['contact_number']);
$objPHPExcel->getActiveSheet()->SetCellValue('G' . $rowCount, $element['order_status']);
$objPHPExcel->getActiveSheet()->SetCellValue('H' . $rowCount, $element['payment_status']);
$rowCount++;
}
// download file
$filename = "jobSummery". date("Y-m-d-H-i-s").".xls";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
public function list_view()
{
$job_positions = $this->Order_model->get_all();
$data = array(
'job_positions_data' => $job_positions
);
$this->load->view('order/index', $data);
}
Model :-
public function get_all()
{
$this->db->order_by('id', 'DESC');
$this->db->from('tbl_order');
$query = $this->db->get();
$result = $query->result();
return $result;
}
public function get_For_Export()
{
$this->db->order_by('id', 'DESC');
$this->db->from('tbl_order');
$query = $this->db->get();
$result = $query->result_array();
return $result;
}
I have a program to store some financial values using batch process. Main tables are finance_budget & finance_budget_issue. finance_budget.budget_id = finance_budget_issue.budget_id (1 to many join)
I tried to edit some records using following code
Controller
public function editIssues($id)
{
$this->checkPermissions('edit', 'allocationIssues');
$bc = array(array('link' => 'budget/regIssues', 'page' => 'Allocation Issues'), array('link' => '#', 'page' => 'Edit'));
$meta = array('page_title' => 'Allocation Issues', 'bc' => $bc);
$this->form_validation->set_rules('vote_id', 'Vote', 'required');
$this->form_validation->set_rules('budget_date', 'Budget Date', 'required');
if ($this->form_validation->run() == true) {
$ustock = array(
'vote_id' => $this->input->post('vote_id'),
'budget_date' => $this->input->post('budget_date'),
'ref_no' => $this->input->post('ref_no'),
'usr' => $this->session->userdata('id_user'),
'added_time' => date('Y-m-d h:i:s'),
'budget_status' => 'issues',
'transfer_status' => 'Pending'
);
$count = count($this->input->post('office'));
$offices = $this->input->post('office');
$amount = $this->input->post('amount');
$notes = $this->input->post('notes');
for ($x = 0; $x < $count; $x++) {
$details[$x]['budget_id'] = $id;
$details[$x]['office'] = $offices[$x];
$details[$x]['amount'] = $amount[$x];
$details[$x]['notes'] = $notes[$x];
}
}
if ($this->form_validation->run() == true && $this->Budget_model->editIssuedAllocations($ustock, $details, $id)) {
$this->session->set_flashdata('message', 'Successfully Updated ..!!');
redirect('budget/regIssues');
} else {
$this->data['vote'] = $this->Budget_model->getVote(array('office_id'=>$this->session->userdata('office_id')));
$this->data['office'] = $this->Budget_model->getOffice();
$this->data['issues'] = $this->Budget_model->budgetById($id);
$this->render('budget/editIssues', $meta, $this->data);
}
}
Model
function editIssuedAllocations($ustock,$details,$id)
{
if(!empty($id)){
$this->db->trans_start();
$this->db->update('finance_budget',$ustock,array('budget_id'=>$id));
if($id!=1){
$this->db->where('budget_id', $id);
$this->db->delete('finance_budget_issue');
$this->db->insert_batch('finance_budget_issue', $details);
}
$this->db->trans_complete();
return $this->db->trans_status();
}
return false;
}
View
<?php
if (!empty($purchase)) {
$details = $purchase;
$purchase = $purchase[0];
}
?>
<script type="text/javascript">
$(document).ready(function () {
var i = $('#last').val();
$(".add-new").click(function () {
i++;
// $('.tab_logic').append();
$('#addr' + i).html("<td><a href='javascript:void(0);' id='add-post' class='external add-new'><i style='color: #00C853 !important;' class='fa fa-2x fa-plus-circle'></i></a></td>" +
"<td><select name='office[]' id='office" + i + "' class='select2 form-control' required>" +
"<option value=''></option>" +
<?php
if (!empty($office)) {
foreach ($office as $row) {
?>
"<option value='<?= $row->office_id ?>'><?= addslashes($row->office_name) ?></option>" +
<?php
}
}
?>
"</select></td>" +
"<td><input name='amount[]' type='number' step='any' placeholder='Amount' class='form-control input-md' required></td>" +
"<td><input name='notes[]' type='text' placeholder='Notes' class='form-control input-md'></td>" +
"<td><a href='javascript:void(0);' class='external remove'><i style='color: #dd4b39 !important;' class='fa fa-2x fa-minus-circle' id='addIcon'></i></a></td>");
$('#tab_logic').append('<tr id="addr' + (i + 1) + '"></tr>');
$('#i').val(i);
// alert($('#i').val());
$('#item' + i).select2();
});
$(document).on("click", ".remove", function () {
var count = $('#tab_logic>tbody').children().length;
if (count > 0) {
$(this).closest('tr').remove();
}
});
});
</script>
<div class="box box-info">
<div class="box box-info collapsed-box">
<div class="box-header with-border">
<h3 class="box-title">Edit Issued Allocations</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" style="font-size: 16px;" data-widget="collapse"><i
class="fa fa-plus"></i>
</button>
</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div class="box-body" style="display: block">
<form action="<?= site_url('budget/editPurchase/' . $purchase->budget_id) ?>" method="post">
<div class="row">
<div class="col-md-2">
<div class="form-group"><label>Budget ID</label>
<input type="text" name="budget_id" id="budget_id" class="form-control" disabled
value="<?= $purchase->budget_id ?> ">
</div>
</div>
<div class="col-md-4">
<div class="form-group"><label>වැය ශීර්ෂය</label>
<select name="vote_id" id="vote_id" class="form-control select2" required>
<option value="<?= $purchase->vote_id ?>"><?= $purchase->vote ?></option>
<?php
if (!empty($vote)) {
foreach ($vote as $row) {
?>
<option value="<?= $row->vote_id ?>"><?= $row->vote ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group"><label>යොමු / ගොණු අංකය</label>
<input type="text" name="ref_no" id="ref_no" class="form-control"
value="<?= $purchase->ref_no ?>">
</div>
</div>
<div class="col-md-2">
<div class="form-group"><label>දිනය</label>
<input type="date" name="budget_date" id="budget_date" class="form-control"
value="<?= $purchase->budget_date ?>">
</div>
</div>
</div>
<div class="col-md-12 column">
<table class="table table-bordered table-hover" id="tab_logic">
<thead>
<tr>
<th class="text-center">
</th>
<th class="text-center">
Office
</th>
<th class="text-center">
Amount
</th>
<th class="text-center">
Notes
</th>
<th class="text-center">
</th>
</tr>
</thead>
<tbody>
<?php
//dd($details);
$x = 0;
foreach ($details as $i => $values) {
// foreach ($values as $key => $value) {
$x = $i;
?>
<tr id='addr0'>
<td>
<a href="javascript:void(0);" id="add-post" class="external add-new"><i
style="color: #00C853 !important;"
class="fa fa-2x fa-plus-circle"></i></a>
</td>
<td style="width: 50%">
<input type="hidden" name="i" id="i" value="<?= $i ?>">
<select name="office[]" id="<?= "office" . $i ?>" class="form-control select2" required>
<option value="<?= $details[$i]->office_id ?>"><?= $details[$i]->office_name ?></option>
<?php
if (!empty($office)) {
foreach ($office as $row) {
?>
<option value="<?= $row->office_id ?>"><?= $row->office_name ?></option>
<?php
}
}
?>
</select>
</td>
<td>
<input type="number" name='amount[]' placeholder='Amount' class="form-control"
value="<?= (-1) * $details[$i]->amount ?>" required/>
</td>
<td>
<input type="text" name="notes[]" placeholder='Notes'
value="<?= $details[$i]->notes ?>" class="form-control"/>
<input type="hidden" name="table_id"
value="<?= $details[$i]->notes ?>">
</td>
<td><a href='javascript:void(0)' class='external remove'><i
style='color: #dd4b39 !important;'
class='fa fa-2x fa-minus-circle ' id='addIcon'></i></a>
</td>
</tr>
<tr id='addr1'></tr>
<?php
//print " $key => $value\n";
// }
//print "}\n";
}
?>
</tbody>
</table>
</div>
<!--table-->
<div class="row">
<div class="col-md-8"></div>
<div class="col-md-4">
<input type="hidden" value="<?= $x ?>" name="last" id="last">
<input type="submit" value="Update" class="btn btn-primary btn-block">
</div>
</div>
</form>
<!--end of table-->
</div>
</div>
</div>
Desired Output
Should be edit some values in the finance_budget & finance_budget_issue tables that related with same budget_id (Eg:- budget_id =2995)
Error
After editing some values in my view that is working & save properly. When I press the save button in my view without editing any value, the record in finance_budget_issue table that is related to finance_budget table by budget_id is deleted.
I can not understand what I am going wrong ? Can anyone help me ?
You could modify the model to check whether $details are empty or not to leave the finance_budget_issue table intact :
function editIssuedAllocations($ustock,$details,$id)
{
if(!empty($id)){
$this->db->trans_start();
$this->db->update('finance_budget',$ustock,array('budget_id'=>$id));
if($id!=1 && !empty($details[0])){
$this->db->where('budget_id', $id);
$this->db->delete('finance_budget_issue');
$this->db->insert_batch('finance_budget_issue', $details);
}
$this->db->trans_complete();
return $this->db->trans_status();
}
return false;
}
I have modified the for loop as follows in the controller.
$count = count($this->input->post('office'));
$offices = $this->input->post('office');
$votes = $this->input->post('vote_id');
$amount = $this->input->post('amount');
$notes = $this->input->post('notes');
$bdate = $this->input->post('budget_date');
for ($x = 0; $x < $count; $x++) {
$details[$x]['budget_id'] = $id;
$details[$x]['office'] = $offices[$x];
$details[$x]['vote_id'] = $votes[$x];
$details[$x]['amount'] = (-1)*$amount[$x];
$details[$x]['notes'] = $notes[$x];
$details[$x]['budget_date'] = $bdate[$x];
$details[$x]['status'] = 1;
}
Now the issue was fixed partially. But the saving vote_id of finance_budget_issue table is incorrect without editing.
I wonder how I can change the size of bootstrap select tag. It is not responsive as well. Please see attachment, in first picture there is small resolution in second one is bigger.
<div class="col-md-9">
<?php $this->load->view('FlashMessagesView'); ?>
<div class="col-md-12 form-group">
<?php if ($searchTerm)
{ ?>
<h3>Vysledky hladania:
<a href="<?php echo base_url('Product/index/') . $subCategoryId; ?>" style="cursor: pointer; color: red"
class="glyphicon glyphicon-remove" aria-hidden="true"></a>
</h3>
<?php } ?>
<div class="col-md-3" style="float: right">
<?php echo form_open('Product/index/' . $subCategoryId,
['id' => 'form_search', 'class' => 'form-horizontal', 'role' => 'form']); ?>
<div class="input-group">
<input type="hidden" name="subcategory_id"
value="<?php echo $subCategoryId ?>"/>
<input type="text" class="form-control" name="product_description"
placeholder="Hladat velkost RAM, CPU...">
<span class="input-group-btn"><button class="btn btn-default" type="submit"><span
class="glyphicon glyphicon-search"></span></button></span>
<?php echo form_close(); ?>
</div>
</div>
Cena: <span class="glyphicon glyphicon-arrow-down" style="cursor: pointer"
onclick="sortProductByLowestPrice()"></span><span class="glyphicon glyphicon-arrow-up"
style="cursor: pointer"
onclick="sortProductByHighestPrice()"></span><br>
Len skladom <input type="checkbox" id="stock_sort" name="stock_only" onclick="sortProductByStock()">
</div>
<?php
$con = mysqli_connect('localhost', 'root', '');
mysqli_select_db($con, 'test');
$sql = "SELECT * FROM products WHERE subcategory_id = " . $subCategoryId;
$result = mysqli_query($con, $sql);
$numberOfProducts = mysqli_num_rows($result);
$numberOfPages = ceil($numberOfProducts / $resultPerPage);
if ( ! isset($_GET['page']))
{
$page = 1;
} else
{
$page = $_GET['page'];
}
$pageFirstResult = ($page - 1) * $resultPerPage;
if ($searchTerm)
{
$like = implode(' OR ', $searchTerm);
$sql = "SELECT * FROM products WHERE subcategory_id = " . $subCategoryId . " AND " . $like . " LIMIT " . $pageFirstResult . ", " . $resultPerPage;
} else
{
$sql = "SELECT * FROM products WHERE subcategory_id = " . $subCategoryId . " LIMIT " . $pageFirstResult . ", " . $resultPerPage;
}
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) != 0)
{
$productCount = 0;
?>
<div class="col-md-12" style="padding-left: 0">
<ul class="list-unstyled" id="products" data-role="list">
<?php
while ($product = mysqli_fetch_array($result))
{
?>
<li data-sort="<?php echo $product['product_price'] ?>" class="col-md-3">
<div class="thumbnail">
<a href="product_details.html"><img
src="<?php echo base_url('assets/img/') . $product['product_image']; ?>"/></a>
<div class="caption" style="height: 300px; overflow: hidden">
<h5><?php echo $product['product_name']; ?></h5>
<p><?php echo $product['product_description']; ?></p>
</div>
<div class="product_footer caption">
<?php if ($product['product_quantity'] == 0)
{ ?>
<p style="text-align: center"><span
style="color:orange"><b>Na objednavku.</b></span>
</p>
<?php } else
{ ?>
<p style="text-align: center">
<span style="color:green">
<b>Na sklade <?php echo $product['product_quantity'] ?> ks.</b>
</span>
</p>
<?php } ?>
<h3><a type="button" id="<?php echo $product['id'] ?>"
class="btn btn-success buy_button">Kupit</a>
<?php if ($this->encryption->decrypt($this->session->role) == 'Admin')
{ ?>
<button href="" type="button" id="<?php echo $product['id'] ?>"
class="btn btn-warning"
data-toggle="modal" data-target="#modal_<?php echo $productCount; ?>">
Upravit
</button>
<?php } ?>
<span class="pull-right"><?php echo $product['product_price']; ?> €</span></h3>
<div class="modal fade" id="modal_<?php echo $productCount ?>" data-backdrop="static"
data-keyboard="false">
<div class="modal-dialog">
<div class="modal-body"><?php $this->load->view('AdminProductUpdateView', array('product' => $product, 'productCount' => $productCount,
'id' => $product['id'])) ?>
</div>
</div>
</div>
<p style="text-align: center">Cena bez
DPH <?php echo $product['product_price'] - $product['product_price_dph']; ?> €</p>
</div>
</div>
</li>
<?php $productCount++; ?>
<?php
}
?>
</ul>
</div>
<div class="col-md-1">
<select class="form-control" style="min-width: 2cm" onchange="productPerPage(<?php echo $subCategoryId; ?>, this.value)">
<option selected="selected" hidden><?php echo $resultPerPage; ?></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>10</option>
<option>20</option>
<option>50</option>
</select>
</div>
Produkty na stranku
<div class="products_pagination">
<a id="previous_page">←</a>
<?php
for ($i = 1; $i <= $numberOfPages; $i++)
{
?>
<a id="<?php echo $i; ?>"
href="<?php echo base_url('Product/index/') . $subCategoryId . '/' . $resultPerPage . '?page=' . $i; ?>"><?php echo $i . ' '; ?></a>
<?php
}
?>
<a id="next_page">→</a>
</div>
<?php } else
{ ?>
<h3 class="col-md-12">Nenasli sa ziadne produkty.</h3>
<?php } ?>
</div>
<script>
productsPaggination(<?php echo $numberOfPages; ?>);
getSubcategoryForAdminUpdate(<?php echo $isAdmin ? 1 : 0; ?>, <?php echo $numberOfProducts; ?>);
</script>
small resolution
bigger resolution
This works for me to reduce select tag's width;
<select id ="Select1" class="input-sm">
You can use any one of these classes;
class="input-sm"
class="input-md"
class="input-lg"
Since youre using col-md-1, you are giving it 1/12 of your containers space, which is very little.
I would suggest to simply give it more space, eg. col-sm-2
Try specifying the width:
select.form-control {
width:100%;
}
I am not sure if you also realise that the dropdown is in the col-md-1 container. It will appear small on small screens.
I want to update data using php/mysql but beeing a new programmer in PHP.
I am wondering how I could:
1- Use an application form with Sweet Alert so that in my CRUD when I may click on 'Edit', and instead of being redirected to process replacing it with one easy step?
2- Send data coming from this completed form when I click on a button in the PHP's $_POST superglobal so that I'd be able to test the data and update my database.
Can someone help me please? Here is my code from crud.php:
<?php
session_start(); // on a besoin des variables de session
include_once("inc/inc_header.php");
include_once("inc/inc_nav.php");
include_once('connection.php');
include_once('oldconnection.php');
//include_once('../dist/libs/grocery-crud-1.5.8.1/application/libraries/Grocery_CRUD.php');
//include_once('../dist/libs/grocery-crud-1.5.8.1/application/libraries/image_moo.php');
?>
<?php
if(isset($_GET['oneDeleted']) && $_GET['oneDeleted'] == true && isset($_GET['stopUser']))
{
?>
<h2>
<?php
extract($_GET);
echo $stopUser." a bien ete supprime. ";
?>
</h2>
<?php
}
?>
<?php
// on recupere les donnees d'obis.
$cruder = $con->prepare("SELECT * FROM user");
$cruder->execute();
$abonnes = $cruder->fetchAll(); // on met ses donnees personnelles dans $mesInfos, elles serviront en placeholder.
foreach($abonnes as $abonne)
{
$keepId = $abonne['user_id'];
?>
<?php /*if(isset($_GET['oneDeleted'] && $_GET['oneDeleted'] == true) && isset($_GET['stopuser']))
{ ?>
<h2>
<?php
extract($_GET);
echo $stopUser." a bien ete supprime.";
?>
</h2>
<?php }*/ ?>
<br />
<table class="table table-hover table-inverse">
<thead>
<tr>
<th>user_id</th>
<th>Nom</th>
<th>Prenom</th>
<th>Email</th>
<th>Telephone</th>
<th>Statut</th>
<th>Nombre de reservations</th>
<th>Derniere visite</th>
<th>Derniere reservation</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $abonne['user_id']; ?></td>
<td><?php echo $abonne['nom']; ?></td>
<td><?php echo $abonne['prenom']; ?></td>
<td><?php echo $abonne['email']; ?></td>
<td><?php echo $abonne['tel']; ?></td>
<td>
<?php
$status = $abonne['rights'];
if($status == 1)
{
echo "Admin";
}else
{
echo "Visiteur";
}
?>
</td>
<td><?php echo $abonne['last_visit']; ?></td>
<td><?php echo $abonne['nb_reservation']; ?></td>
<td><?php echo $abonne['event_id']; ?></td>
<td>
<a>
<button type="button" class="btn btn-outline-warning" data-toggle="modal" data-target="#editUserModal">
Editer
</button>
</a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-outline-danger btn-outline-warning"
onclick="swal({
title: 'AVERTISSEMENT!',
text: 'CET UTILISATEUR SERA DEFINITIVEMENT SUPPRIME !',
type: 'warning',
showCancelButton: true,
cancelButtonText: 'ANNULER',
confirmButtonColor: '#DD6B55',
confirmButtonText: 'OUI, je le supprime.',
closeOnConfirm: false
},
function(){
timer: 5000;
document.location.href='deleteUser.php?user_id=<?php echo $keepId; ?>';
});
"
>
Supprimer
</button>
</td>
</tr>
</tbody>
</table>
<?php
}
include_once("inc/inc_footer.php");
?>