Can't make carousel work in php: CodeIgniter - codeigniter

I have added a carousel in a container but it remains static showing the first pic. Though the carousel buttons are visible but not active. The code is:
<div class="col-xl-8 col-lg-8 col-md-7 mb-5 mb-md-0">
<div id="" class="pt-0 pt-md-4 pt-lg-5">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php if (!empty($event)) {
foreach ($event as $key => $value) {
?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?= $key ?>" <?php if ($key == 0) { ?> class="active" <?php } ?>></li>
<?php }
} ?>
</ol>
<div class="carousel-inner">
<?php if (!empty($event)) {
foreach ($event as $key => $value) {
$date = date('d', strtotime($value['datetime']));
$month = date('F', strtotime($value['datetime']));
$year = date('Y', strtotime($value['datetime']));
$seconds = strtotime($value['datetime']) - time();
$days = floor($seconds / 86400);
$seconds %= 86400;
$hours = floor($seconds / 3600);
$seconds %= 3600;
$minutes = floor($seconds / 60);
$seconds %= 60;
$cdate = date("Y-m-d H:i:s", strtotime($value['datetime']));
if ($cdate > date("Y-m-d H:i:s")) {
?>
<div class="carousel-item <?php if ($key == 0) { ?>active<?php } ?>">
<div class="row">
<div class="col-md-12 col-lg-6 mb-4 mb-md-0">
<div class="d-flex align-items-center justify-content-between w-100">
<!--<div class="images-craus">-->
<!-- <img src="<?= base_url() ?>/images/upcomingevents/<?= $value['image1'] ?>">-->
<!--</div>-->
<div class="dates">
<h3 class="months"><?= $month ?> <?= $date ?><br><?= $year ?></h3>
<h3 class="team"><?= $cdate ?> <br><?= $value['team1'] ?> vs <?= $value['team2'] ?></h3>
</div>
<!--<div class="images-craus">-->
<!-- <img src="<?= base_url() ?>/images/upcomingevents/<?= $value['image2'] ?>">-->
<!--</div>-->
</div>
</div>
<div class="col-md-12 col-lg-6 mb-4 mb-md-0">
<div class="details1">
<div class="pt-0 pt-md-4 pb-3">
<h5 class="text-white text-center">Next Match<br><?= $value['team1'] ?> vs <?= $value['team2'] ?></h5>
</div>
<div class="button-20 d-flex">
<button type="button" class="btn btn-danger"><?= $days ?> day</button>
<button type="button" class="btn btn-danger"><?= $hours ?> hr</button>
<button type="button" class="btn btn-danger"><?= $minutes ?>min</button>
</div>
</div>
</div>
</div>
</div>
<?php }
}
} ?>
</div>
I tried looking at bootstrap feature but couldn't really work it out. Mind you this carousel also have a table list which shows on the right side of the container. I am not sharing it code as table is working fine.

Related

how to add show data on modal for individual id?

I want when user click on "more detail href". they should get this detail on modal the box.
<ul class="list-tickets">
<?php foreach ($searchFlights as $searchFlight) {
//One Way Logic
$stopInfo_O = "";
$stopCount_O = 0;
$AirlineLogo_O = $this->search_model->getAirlinelogo($searchFlight->airline_idO);
$finalDepartdate_O = $searchFlight->departure_dateO;
$DepartAirpot_O = $this->search_model->getAirportCode($searchFlight->depart_airportidO);
$totalFlightTime_O = $searchFlight->total_flighttimeO;
$finalArrivaldate_O = $searchFlight->arrival_dateO;
$totalBaggage_O = $searchFlight->baggageO;
$stopOvertime1 = $searchFlight->stopover1_staydurationO;
$className0 = $searchFlight->classNameO;
$ArrivalAirpot_O = $this->search_model->getAirportCode($searchFlight->arrival_airportidO);
$flightPrice = $searchFlight->flightPrice;
if($searchFlight->operatedby_airlineidO == "0") {
$operatedAirlinename = "";
} else {
$operatedAirlinename = $this->search_model->getAirlinename($searchFlight->operatedby_airlineidO);
}
//Stops Handling Oneway
if(empty($searchFlight->stopover1_airportidO) && empty($searchFlight->stopover2_airportidO)){ $stopInfo_O = "Direct"; }
if($searchFlight->stopover1_airportidO != 0){ $stopCount_O++; }
if($searchFlight->stopover2_airportidO != 0){ $stopCount_O++; }
if($stopCount_O>0){
$stopInfo_O .= $stopCount_O." Stop ";
//Stop oneway 1
$stopInfo_O .= $this->search_model->getAirportCode($searchFlight->stopover1_airportidO);
if($stopCount_O == 2) {
//Stop One Way 2
$stopInfo_O .= ", ".$this->search_model->getAirportCode($searchFlight->stopover2_airportidO);
}
}
?>
<li class="list-item">
<div class="list-item-inner">
<div class="list-item-main">
<!-- Oneway Section -->
<div class="list-item-top">
<div class="list-item-logo">
<img src="<?= base_url(); ?>uploads/<?php echo $AirlineLogo_O; ?>" alt="">
</div>
<div class="list-item-content">
<div class="list-item-content-left">
<!-- Final Departure Dates-->
<div class="text-bold text-base">
<?php echo $finalDepartdate_O; ?>
</div>
<!-- Departure Airport -->
<span class="small reveal-block">
<?php echo $DepartAirpot_O; ?>
</span>
</div>
<div class="list-item-content-line-wrapper small">
<!-- Total Flight Time -->
<div class="list-item-content-line-top">
<?php echo $totalFlightTime_O; ?>
</div>
<div class="list-item-content-line"></div>
<!-- Stops info -->
<div class="list-item-content-line-bottom text-primary">
<p title="<?php echo $stopOvertime1; ?>"><?php echo $stopInfo_O; ?> </p>
</div>
</div>
<div class="list-item-content-right">
<!-- Final Arrival date -->
<div class="text-bold text-base">
<?php echo $finalArrivaldate_O; ?>
</div>
<!-- Arrival Airport -->
<span class="small reveal-block">
<?php echo $ArrivalAirpot_O; ?>
</span>
</div>
</div>
</div>
</div>
<div class="list-item-footer ticket-holder-dt">
<h5 class="text-bold list-item-price"><?php echo COMMON_CurrencySymbol." ".$flightPrice;?></h5>
<span class="ticket-include"></span>
<span class="ticket-type">One way</span>
<a class="btn btn-info btn-xs btn-no-shadow" href="<?= base_url(); ?>searchflights/bookFlight?id=<?php echo $searchFlight->id; ?>">
Book Now
</a>
<br>
<a href="">
More detail <!-- I want when user click on it. they should get this detail on modal the box -->
</a>
<br>
<?php echo $className0; ?> Class
</div>
</div>
<div class="small text-gray-light list-item-subtitle">Operated by <?php echo $operatedAirlinename; ?></div>
<div class="tripbaggage">Baggage: <?php echo $totalBaggage_O; ?></div>
<?php } ?>
You can achieve this by implementing separate modal for each id inside for loop or
by implementing Ajax request to show the detail information of the corresponding id.

How can fixed the codeigniter cart update issue

I am unable to update cart on checkout page. I do not know what is Happen.
Here is my code.
function update_cart()
{
$rowid =$this->input->post('rowid');
$price =$this->input->post('price');
$qty = $this->input->post('qty');
$pr = preg_replace( '/,/', '', $price);
$amount = $pr * $qty;
$data = array(
'rowid' => $rowid,
'price' => $price,
'amount' => $amount,
'qty' => $qty
);
$this->cart->update($data);
redirect('checkout');
}
Here is my car view code .I am trying to update cart value here.No error showing. I unable to solve .Any help .Only update cart is not working . Other functionality is working good .add to cart delete to cart but update to cart does not working . I create session table and also try other suggestion and solution form stack overflow.
<form action="<?=base_url()?>cart/update_cart" method="post">
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">
<div class="row">
<div class="col-xs-6">
<h5><span class="glyphicon glyphicon-shopping-cart"></span> Shopping Cart</h5>
</div>
<div class="col-xs-6">
<a href="<?=base_url()?>">
<button type="button" class="btn btn-primary btn-sm btn-block">
<span class="glyphicon glyphicon-share-alt"></span> Continue shopping
</button>
</a>
</div>
</div>
</div>
</div>
<div class="panel-body">
<?php $i = 1; ?>
<?php
//print_r($this->cart->contents() );
//die;
foreach ($this->cart->contents() as $items): ?>
<?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
<div class="row">
<div class="col-xs-2">
<img class="img-responsive" src="<?=base_url()?>uploads/product/<?=$items['image'];?>" />
</div>
<div class="col-xs-4">
<h5 class="product-name">
<strong><?php echo $items['name']; ?>
</strong>
<?=$items['options'];?>
</h5>
</div>
<div class="col-xs-6">
<div class="col-xs-6 text-right">
<h6><strong><?= $this->cart->format_number($items['price']); ?>
<span class="text-muted">x</span></strong></h6>
</div>
<div class="col-xs-4">
<?php //echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'size' => '1')); ?>
<input type="text" name="qty" min="1" value="<?=$items['qty'] ?>" maxlength="1" style="width: 50%;">
<input type="hidden" name="price" value="<?=$items['price'] ?>">
<input type="hidden" name="name" value="<?=$items['name'] ?>">
<input type="hidden" name="description" value="<?=$items['description'] ?>">
</div>
<div class="col-xs-2">
<a href="<?=base_url()?>cart/remove/<?=$items['rowid']?>">
<button type="button" class="btn btn-link btn-xs">
<span class="glyphicon glyphicon-trash" onclick="confirm('Are you sure want to delete')";> </span>
</button>
</a>
</div>
</div>
</div>
<hr>
<?php $i++; ?>
<?php endforeach; ?>
at view .... use only two input
<input type="text" name="qty[]" min="1" value="<?=$items['qty'] ?>" maxlength="1" style="width: 50%;">
<input type="hidden" name="rowid[]" value="<?=$items['rowid'] ?>">
at controller
you only need to change qty if you are going to update a cart
function update_cart()
{
for ($i=0; $i < count($_POST) - 1; $i++) {
$data = array(
'rowid' => $_POST['rowid'][$i],
'qty' => $_POST['qty'][$i]
);
$this->cart->update($data);
}
redirect('checkout');
}

Banner Images not being reinserted correct to database

When I update my banner_image it should delete the ones from the database Then re insert the ones that are set.
Currently what it does is deletes the banner image but then re inserts blank banner_image
But should remove that enitre row.
Question How to make sure when I update it that will remove the images rows that are no longer selected and not re insert them
public function update($bid = NULL, $data = array()) {
$banner_update = array('banner_title' => $data['banner_title'], 'banner_status' => $data['banner_status']);
$this->db->where('bid', $bid);
$this->db->update('banner', $banner_update);
$this->db->where('bid', $bid)->delete('banner_image');
if (isset($data['banner_image'])) {
$banner_images = array();
$i = 0;
foreach ($data['banner_image'] as $image) {
$banner_images[$i] = array(
'bid' => $bid,
'banner_image' => $image['image'],
);
$i++;
}
$this->db->insert_batch('banner_image', $banner_images);
}
}
View
<?php echo form_open($action);?>
<div class="container">
<div class="card mt-3">
<div class="card-body">
<?php if (validation_errors()) {?>
<?php unset($_POST);?>
<div class="bg-error-warning">
<ul>
<?php echo validation_errors('<li>', '</li>');?>
</ul>
</div>
<?php }?>
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">
<p>Banner Title</p>
<div class="form-group">
<input type="text" name="banner_title" value="<?php echo $banner_title;?>" placeholder="Enter Banner Title" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">
<table id="images" class="table table-striped table-bordered">
<tbody>
<tr>
<td>
<button type="button" onclick="addImage();" data-toggle="tooltip" title="Add Banner!" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button>
</td>
</tr>
<?php $image_row = 0; ?>
<?php foreach ($banner_images as $banner_image) { ?>
<tr id="image-row<?php echo $image_row; ?>">
<td>
<a href="" id="thumb-image<?php echo $image_row; ?>" data-toggle="image">
<img src="<?php echo $banner_image['thumb']; ?>" alt="" title="" data-placeholder="<?php echo $placeholder; ?>" class="img-thumbnail"/></a>
<input type="hidden" name="banner_image[<?php echo $image_row; ?>][image]" value="<?php echo $banner_image['image']; ?>" id="input-image<?php echo $image_row; ?>" />
</td>
</tr>
<?php $image_row++; ?>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">
<p>Banner Status</p>
<div class="form-group">
<?php $options = array('0' => 'Disabled', '1' => 'Enabled'); echo form_dropdown('banner_status', $options, $banner_status, array('class' => 'form-control'));?>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<button type="submit" class="btn btn-block btn-dark">Create Banner</button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php echo form_close();?>
<script type="text/javascript">
var image_row = <?php echo $image_row; ?>;
function addImage() {
html = '<tr id="image-row' + image_row + '">';
html += '<td class="text-left">';
html += '<a href="" id="thumb-image' + image_row + '" data-toggle="image" >';
html += '<img src="<?php echo $placeholder; ?>" width="100" height="100" class="img-thumbnail" data-placeholder="<?php echo $placeholder; ?>"/>';
html += '<input type="hidden" name="banner_image[' + image_row + '][image]" value="" id="input-image' + image_row + '" />'
html += '</a>';
html += '</td>';
html += '<td class="text-left">';
html += '<button type="button" onclick="$(\'#image-row' + image_row + '\').remove();" data-toggle="tooltip" title="Remove Banner!" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button>'
html += '</td>';
html += '<script>';
html += '$(document).ready(function(){';
html += '$(\'[data-toggle="tooltip"]\').tooltip();';
html += '});';
html += '<\/script>';
$('#images tbody').append(html);
image_row++;
}
</script>
Have got it working just had to put empty in the foreach loop
public function update($bid = NULL, $data = array()) {
$banner_update = array('banner_title' => $data['banner_title'], 'banner_status' => $data['banner_status']);
// Updates the main banner table
$this->db->where('bid', $bid);
$this->db->update('banner', $banner_update);
// Removes banners so can have clean insert of new banners selected
$this->db->where('bid', $bid);
$this->db->delete('banner_image');
// Inserts new banner images & saved ones.
if ($this->input->post('banner_image')) {
foreach ($this->input->post('banner_image') as $image) {
if (!empty($image['image'])) {
$this->db->insert('banner_image', array('bid' => $bid, 'banner_image' => $image['image']));
}
}
}
}

why does $this->form_validation->run() always return false in codeigniter 3.0.0 with php7.1 on ubuntu 16.04?

This is part of the code, it made me cannot login, i don't know where is the problem. When i tried to log in, it has no effect. Sorry for my bad english.
public function login()
{
if ($this->identity->is_admin())
redirect('admin/dashboard');
if ($this->identity->is_contestant())
redirect('contestant/dashboard');
$this->form_validation->set_rules('form[username]', $this->lang->line('username'), 'trim|required|max_length[50]');
$this->form_validation->set_rules('form[password]', $this->lang->line('password'), 'trim|required|max_length[50]');
if ($this->form_validation->run())
{
$credentials = $this->input->post('form');
if ($this->identity->login($credentials))
{
if ($this->identity->is_admin())
redirect('admin/dashboard');
else
redirect('contestant/dashboard');
}
else
{
$this->session->set_flashdata('error', $this->lang->line('wrong_credentials'));
redirect('site/login');
}
}
else
{
$this->ui['header']['title'] = $this->lang->line('login');
$this->ui['header']['page'] = 'login';
$this->load->view('site/header', $this->ui['header']);
$this->load->view('site/login', $this->ui['content']);
$this->load->view('footer', $this->ui['footer']);
}
}
Here are the login site source code.
<div class="container">
<div class="row">
<div class="col-md-12">
<ul class="breadcrumb">
<li>
<i class="glyphicon glyphicon-off"></i> <?php echo $this->lang->line('please_login'); ?>
</li>
</ul>
</div>
</div>
<?php if ($this->session->flashdata('error')) : ?>
<div class="row">
<div class="col-md-5">
<div class="alert alert-danger">
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
<form class="form-horizontal" action="" method="post">
<div class="form-group<?php echo form_error('form[username]') ? ' has-error' : ''; ?>">
<label class="col-sm-1 control-label"><?php echo $this->lang->line('username'); ?>:</label>
<div class="col-sm-4">
<input name="form[username]" type="text" maxlength="30" class="form-control" value="<?php echo set_value('form[username]'); ?>" autofocus="on"/>
<span class="help-block"><?php echo form_error('form[username]'); ?></span>
</div>
</div>
<div class="form-group<?php echo form_error('form[password]') ? ' has-error' : ''; ?>">
<label class="col-sm-1 control-label"><?php echo $this->lang->line('password'); ?>:</label>
<div class="col-sm-4">
<input name="form[password]" type="password" maxlength="30" class="form-control"/>
<span class="help-block"><?php echo form_error('form[password]'); ?></span>
</div>
</div>
<div class="form-actions col-sm-offset-1">
<button type="submit" class="btn btn-danger col-sm-3"><i class="glyphicon glyphicon-user"></i> <?php echo $this->lang->line('login'); ?></button>
</div>
</form>
</div>
</div>
is it true that php7.1 is not supported by CI 3.0.0 so the error happened by this?

How to create pagination with letters using codeigniter

Agent controller:
public function index() {
if (!empty($_SESSION['admin'])) {
$data = array(
'page_title' => 'Agent',
'page_name' => 'agent/index',
'result' => $this->agent_model->list_all()
);
$this->load->view('template', $data);
} else {
redirect('login');
}
}
Agent model:
public function list_all() {
$data = 'agent.id,agent.name,agent.mobile,agent.vehicle,agent.address,agent.img_url,agent.category,agent.status,agent.login_status,vehicle.id AS vehicle_id,vehicle.name AS vehicle_name';
$this->db->select($data);
$this->db->from('agent');
$this->db->join('vehicle', 'agent.vehicle=vehicle.id');
return $this->db->get()->result_array();
}
View:
<?php foreach ($result as $value): ?>
<div class="col-md-4 col-sm-4 col-xs-12 profile_details">
<div class="well profile_view">
<div class="col-sm-12">
<h4 class="brief"><i>Digital Strategist</i></h4>
<div class="left col-xs-7">
<p><i class="fa fa-user"></i> Name: <?= $value['name']; ?></p>
<ul class="list-unstyled">
<li><i class="fa fa-building"></i> Vehicle: <?= $value['vehicle_name']; ?></li>
<li><i class="fa fa-phone"></i> Mobile: <?= $value['mobile']; ?> </li><br/>
<div class="onoffswitch">
<input type="hidden" value="<?= $value["id"]; ?>"/>
<input type="checkbox" class="js-switch"
<?php if ($value['status'] == 1) {
echo "checked";
} ?>>
</div>
</ul>
</div>
<div class="right col-xs-5 text-center">
<img src="/<?= $value['img_url']; ?>" alt="" class="img-circle img-responsive" style="height: 120px; width: 120px;">
</div>
</div>
<div class="col-xs-12 bottom text-center">
<div class="col-xs-12 col-sm-6 emphasis">
<p class="ratings">
<a>4.0</a>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star-o"></span>
</p>
</div>
<div class="col-xs-12 col-sm-6 emphasis btn-group">
<?php if ($value['status'] == 1): ?>
<i class="glyphicon glyphicon-pencil"> </i> Edit
<?php else: ?>
<i class="glyphicon glyphicon-pencil"> </i> Edit
<?php endif; ?>
<a href="<?= base_url("agent/detail/{$value['id']}"); ?>" class="btn btn-primary btn-xs">
<i class="fa fa-user"> </i> View Profile </a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
Below Screenshot:
Screenshot
MY Question: How to create pagination with letters in codeigniter.
MY Question: I create agent module and i apply pagination with letters in above Screenshot. so how to apply pagination with letters in above view.

Resources