I am beginner of codeigniter
I want to hide this button action when status is completed.
Check screenshot
<div class="btn-wrapper pull-left">
<a target="__blank" href="<?php echo $burl.'/print_delivery
id='.$value['order_id']; ?>" class="btn btn-success md-trigger">
<i class="fa fa-print"></i> Print
</a>
</div>
and this is my controller
public function print_delivery()
{
$id_order = $this->input->get('id');
$this->load->model('Order');
$this->Order->updatePrintStatus($id_order);
Try this
Here in $value['status'] status stands for field name for your status field in your table
<div class="btn-wrapper pull-left">
<?php if($value['status']!='Completed'){?>
<a target="__blank" href="<?php echo $burl.'/print_delivery
id='.$value['order_id']; ?>" class="btn btn-success md-trigger">
<i class="fa fa-print"></i> Print
</a>
<?php } ?>
</div>
Related
I'm using codeigniter and trying to pass content to the database using the WYSIWYG editor.
I installed the WYSIWYG into my VIEW like the below code.
<div class="blank">
<div class="blank-page">
<!------------- syam bek-------------->
<?php if(!empty($error)): ?>
<div class="alert alert-warning">
<strong>Warning!</strong> <?php echo $error; ?>
</div>
<?php endif;?>
<?php if(!empty($products)):?>
<?php $ver=array('id'=>'try','name'=>'try','class'=>'form-horizontal'); ?>
<?php echo form_open_multipart(base_url().'editproduct/edit',$ver);?>
<label>المنتج
<br>
<select class="selectpicker" data-show-subtext="true" data-live-search="true" name="select_product" onchange="[document.try.action='editproduct/show',document.try.submit()]">
<?php
if (count($products)>1) {
echo '<option selected></option>';
foreach ($products as $p):
echo "<option value ='$p->p_id'>" . $p->p_name . "</option>";
endforeach;
}
elseif(count($products)==1){
foreach ($products as $p):
echo "<option selected value ='$p->p_id'>" . $p->p_name . "</option>";
endforeach;
}
?>
</select>
<?php if(count($products)==1){
$name=$p->p_name;
$details=$p->details;
$price=$p->p_price;
}else{
$name="";
$details="";
$price="";
}
?>
</label>
</br>
<label>اسم المنتج
<input type="text" name="name" value="<?php echo $name;?>" class="form-control"/>
</label>
<br>
<label>تفاصيل للمنتج
<input type="text" name="details" value="<?php echo $details;?>" class="form-control" />
</label>
<br>
<label>سعر المنتج
<input type="text" name="price" value="<?php echo $price;?>" class="form-control" />
</label>
<br>
<br>
<br>
<div class="container">
<div class="hero-unit">
<div id="alerts"></div>
<div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font"><i class="icon-font"></i><b class="caret"></b></a>
<ul class="dropdown-menu">
</ul>
</div>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" title="Font Size"><i class="icon-text-height"></i> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-edit="fontSize 5"><font size="5">Huge</font></a></li>
<li><a data-edit="fontSize 3"><font size="3">Normal</font></a></li>
<li><a data-edit="fontSize 1"><font size="1">Small</font></a></li>
</ul>
</div>
<div class="btn-group">
<a class="btn" data-edit="bold" title="Bold (Ctrl/Cmd+B)"><i class="icon-bold"></i></a>
<a class="btn" data-edit="italic" title="Italic (Ctrl/Cmd+I)"><i class="icon-italic"></i></a>
<a class="btn" data-edit="strikethrough" title="Strikethrough"><i class="icon-strikethrough"></i></a>
<a class="btn" data-edit="underline" title="Underline (Ctrl/Cmd+U)"><i class="icon-underline"></i></a>
</div>
<div class="btn-group">
<a class="btn" data-edit="insertunorderedlist" title="Bullet list"><i class="icon-list-ul"></i></a>
<a class="btn" data-edit="insertorderedlist" title="Number list"><i class="icon-list-ol"></i></a>
<a class="btn" data-edit="outdent" title="Reduce indent (Shift+Tab)"><i class="icon-indent-left"></i></a>
<a class="btn" data-edit="indent" title="Indent (Tab)"><i class="icon-indent-right"></i></a>
</div>
<div class="btn-group">
<a class="btn" data-edit="justifyleft" title="Align Left (Ctrl/Cmd+L)"><i class="icon-align-left"></i></a>
<a class="btn" data-edit="justifycenter" title="Center (Ctrl/Cmd+E)"><i class="icon-align-center"></i></a>
<a class="btn" data-edit="justifyright" title="Align Right (Ctrl/Cmd+R)"><i class="icon-align-right"></i></a>
<a class="btn" data-edit="justifyfull" title="Justify (Ctrl/Cmd+J)"><i class="icon-align-justify"></i></a>
</div>
<div class="btn-group">
<a class="btn" title="Insert picture (or just drag & drop)" id="pictureBtn"><i class="icon-picture"></i></a>
<input type="file" data-role="magic-overlay" data-target="#pictureBtn" data-edit="insertImage" />
</div>
<div class="btn-group">
<a class="btn" data-edit="undo" title="Undo (Ctrl/Cmd+Z)"><i class="icon-undo"></i></a>
<a class="btn" data-edit="redo" title="Redo (Ctrl/Cmd+Y)"><i class="icon-repeat"></i></a>
</div>
<input type="text" data-edit="inserttext" id="voiceBtn" x-webkit-speech="">
</div>
<div id="editor">
</div>
</div>
</div>
<button class="btn btn-warning" name="cancel" >الغاء</button>
<button type="submit" name="save" class="btn btn-primary">حفظ</button>
<button type="submit" name="del" class="btn btn-danger">حذف المنتج</button>
<?php echo form_close();?>
<?php else :?>
<?php echo "لايوجد منتجات ليتم التعديل عليها";?>
<?php endif;?>
</div>
</div>
check i trace the inspector from the broswer i found insertion happens in the <div id="editor">HERE</div>
i don't know to pass the DIV contents to the database, especially the DIV element not identified by name like other elements.
Thanks
You can use javascript and ajax to submit your form, this is rough outline of jquery solution
// listen for submit event on your form
$( "#try" ).submit(function( event ) {
event.preventDefault();
let content = $('#editor').val(); // get the value from the editor
let details = $("input[name='details']").val() // get the value of input with the name of 'details'
... // do the same for all other inputs
// validate inputs if desired
if(content == '') {
// for example do something if content is empty
return;
}
// collect all input data into one object
var data = {
content: content,
details: details,
...
}
// send ajax request to the server
$.ajax({
url : 'urlToYourBackendEndpoint',
type : 'POST',
data : data,
success : function(response) {
// check the response and redirect or show notice after submit here
},
error : function(request,error)
{
alert("Request: "+JSON.stringify(request));
}
});
});
i am using codeigniter.i am trying to convert this bootstrap code into a php variable for HTML table class
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-default pull-right" role="menu">
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_take_payment/<?php echo $row['invoice_id'];?>');">
<i class="entypo-bookmarks"></i>
Take Payment </a>
</li>
<li class="divider"></li>
<!-- VIEWING LINK -->
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_view_invoice/<?php echo $row['invoice_id'];?>');">
<i class="entypo-credit-card"></i>
View Invoice </a>
</li>
<li class="divider"></li>
<!-- EDITING LINK -->
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_edit_invoice/<?php echo $row['invoice_id'];?>');">
<i class="entypo-pencil"></i>
Edit </a>
</li>
<li class="divider"></li>
<!-- DELETION LINK -->
<li>
<a href="#" onclick="confirm_modal('<?php echo base_url();?>index.php?admin/invoice/delete/<?php echo $row['invoice_id'];?>');">
<i class="entypo-trash"></i>
Delete </a>
</li>
</ul>
</div>
result of above HTML code
now i want to convert this complete html code into a php syntax so i can use it in HTML table class and code for this is as below-
[$edit_url =base_url().'index.php?modal/popup/modal_edit_invoice/'. $row\['invoice_id'\];
$url = base_url().'index.php?modal/popup/modal_take_payment/'. $row\['invoice_id'\];
$url_delete= base_url().'index.php?admin/invoice/delete/'. $row\['invoice_id'\];
$url_invoice= base_url().'index.php?modal/popup/modal_view_invoice/'. $row\['invoice_id'\];
$onclick_delete = array('onclick'=>"return confirm_modal('{$url_delete}')" , 'class'=>"btn-default btn-sm dropdown-toggle");
$onclick_edit = array('onclick'=>"return showAjaxModal('{$edit_url}')" , 'class'=>"btn btn-default btn-sm dropdown-toggle");
$onclick_take = array('onclick'=>"return showAjaxModal('{$url}')",'class'=>"btn btn-default btn-sm dropdown-toggle");
$onclick_invoice = array('onclick'=>"return showAjaxModal('{$url_invoice}')",'class'=>"btn btn-default btn-sm dropdown-toggle");
$links = anchor('#', 'Take Payment',$onclick_take);
$links .= anchor('#', 'edit',$onclick_edit);
$links .= anchor('#', 'Invoice',$onclick_invoice);
$links .= anchor('#', 'delete',$onclick_delete);
but this is not giving me the result as above html code. so can you please suggest me the changes in the code.
problem_II
and when i am using above code bootstrap model properties also not working as expected.the problem is Body is not auto scrolling to top when model is popup and for that reason model is not coming properly on my screen. although i didn't made any changes in body.modal-open.
please help me out. thanks in advance
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.
I am using Advanced Custom Posts and Custom Post Types plugin for my WP site.
How can I make a custom post show on the Bootstrap modal depending on the trigger button? I want it to show inside the modal's .modal-body. I found a solution somewhere here but it requires putting the modal syntax inside the while loop and every time there's a new custom post, the modal syntax is repeated which is not nice.
I am still a newbie and studying AJAX / JSON request but can't get it to work. I think it's the best way to do it. From what I know I need to create a separate PHP file but not sure what to code inside.
Can someone please provide an example? I'm stuck for almost a week. Thanks a lot in advance!
Here's my code:
<div class="row">
<?php $sample_query = new WP_Query( array(
'post_type' => 'sample',
'category_name' => 'trending',
'orderby' => 'rand'
) ); ?>
<?php while( $sample_query->have_posts() ) : $sample_query->the_post(); ?>
<?php
$sample_logo = get_field('sample_logo');
$sample_body = get_field('sample_body');
?>
<div class="col-md-3">
<div class="trending-sample">
<div class="thumbnail">
<a href="#">
<img src="<?php echo $sample_logo[url]; ?>" alt="<?php echo $sample_logo[alt]; ?>">
</a>
<div class="caption">
<h3><?php the_title(); ?></h3>
<p><?php echo $sample_body; ?></p>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal">Open Modal</button>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
My Modal:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<h3><?php the_title(); ?></h3>
<img src="<?php echo $sample_logo[url]; ?>" alt="<?php echo $sample_logo[alt]; ?>">
<p class="sample-desc"><?php echo $sample_body; ?></p>
<hr class="dashed">
<p class="lead">Sample Text</p>
<p class="modal-share">
<strong>Share:</strong>
<span class="sharefb"><i class="fa fa-facebook"></i></span>
<span class="sharetwitter"><i class="fa fa-twitter"></i></span>
<span class="sharegplus"><i class="fa fa-google-plus"></i></span>
<span class="sharemail"><i class="fa fa-envelope-o"></i></span>
<button type="button" class="btn btn-danger pull-right" data-dismiss="modal"><strong>Close</strong></button>
</p>
</div>
</div>
</div>
</div>
I am deleting item from cart and after deleting i am displaying fresh result. but all item from cart table is delete i am getting this error
Trying to get property of non-object (View:
D:\xampp\htdocs\avitra\resources\views\ordersummary.blade.php)
for following query. When all item is removed from cart & it display then it can not get any record from cart table so it return null value and getting above error? How can i handle this error in laravel?
$getCartResult=DB::table('product_details')
->join('cart','cart.product_id','=','product_details.product_id')
->join('subcategory','product_details.sub_id','=','subcategory.sub_id')
->select('subcategory.image','subcategory.name_of_subcategory','product_details.*','cart.*')
->where('cart.user_id',$userid)
->get();
blade file:
<?php $getCartResult=DB::table('product_details')
->join('cart','cart.product_id','=','product_details.product_id')
->join('subcategory','product_details.sub_id','=','subcategory.sub_id')
->select('subcategory.image','subcategory.name_of_subcategory','product_details.*','cart.*')
->where('cart.user_id',$userid)
->get();
?>
<?php
if (!empty($getCartResult)) {
?>
<div class="card-body cart_show" style="overflow-y: scroll;height: 300px;display:none;">
#foreach($getCartResult as $v_contents)
<div class="row">
<div class="col-sm-3 mt-3">
<div>
<img src="{{asset('images/'.$v_contents->image)}}" class="img-fluid">
</div>
<center>
<div class="input-group mt-2" style="width:100px">
<button type="button" class="cart-btn btn-default btn-number cart_qtyminus" data-type="minus" data-id="<?php echo $v_contents->cart_id;?>" data-value="<?php echo $v_contents->product_id;?>">
<span class="fa fa-minus cart-fa"></span>
</button>
<!-- <input type="text" name="cart_qty" class="form-control input-number" value="{{$v_contents->qty}}" min="1" max="10"> -->
<span class="cart_quantity " style="border: 1px solid;height: 30px;width:30px;"><?php echo $v_contents->qty; ?></span>
<button type="button" class="cart-btn btn-default btn-number cart_qtyplus" data-type="plus" data-id="<?php echo $v_contents->cart_id;?>" data-value="<?php echo $v_contents->product_id;?>">
<span class="fa fa-plus cart-fa"></span>
</button>
</div>
</center>
</div>
<div class="col-sm-5 mt-3">
<div>
<span><b>{{$v_contents->name_of_subcategory}}</b></span>
</div>
<div class="mt-2">
<span>Seller : Avitra Ayurved</span>
</div>
<?php $subtotal=$v_contents->discount_price*$v_contents->qty; ?>
<div class="mt-2">
Price :<span class="cart_subtotal"><?php echo $subtotal; ?></span>
</div>
<div class="mt-2">
<span><a class="btn btn-sm mt-3 cart_delete" data-id="<?php echo $v_contents->cart_id;?>"><span style="color: #FBA842;"><b>REMOVE</b></span></a></span>
</div>
</div>
<div class="col-sm-4">
<div class="mt-2">
<span>Delivery by Fri Jan 24 | Free</span>
</div>
</div>
</div><hr>
#endforeach
<div>
<span style="float: right;"><button class="btn btn-sm continue cart_payment_show"><span><b>CONTINUE</b></span></button></span>
</div>
</div>
<?php } ?>
You are getting this error because your query is not returning any result and your are trying to access it's property something like $getCartResult->id.
To resolve this you can check if item exists or not using if condition on your blade template for e.g
#if(!empty($getCartResult))
// your code
#endif
I think the problem is that you are trying to access a row that has been deleted. Check the query that you are returning after deleting an item.