-
sanditheresia
Newbie
-
Posts: 3
Threads: 1
Joined: Jul 2017
Reputation:
0
07-17-2017, 01:41 AM
I am beginner of codeigniter
I want to hide this button action when status is completed
this is my code on admin order
Code: <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
Code: public function print_delivery()
{
$id_order = $this->input->get('id');
$this->load->model('Order');
$this->Order->updatePrintStatus($id_order);
please help me
-
Wouter60
Posting Freak
-
Posts: 851
Threads: 38
Joined: Feb 2015
Reputation:
77
In your view:
Code: <?php if ($order->status != 'Completed' ) : ?>
//put your existing code for showing the button here; as result of the if .. endif the button will only show up if the order status is not 'Completed'
<?php endif; ?>
The $order->status variable is just my guess. Rename it to what you are using to determine the Order Status.
-
sanditheresia
Newbie
-
Posts: 3
Threads: 1
Joined: Jul 2017
Reputation:
0
like this
Code: <?php if ($order->status != 'Completed' ) : ?>
thats not working
btw this is my order status
Quote:$data['order_status'] = ['wc-processing'=>'Processing', 'wc-on-hold'=>'On Hold', 'wc-completed'=>'Completed', 'wc-pending'=>'Pending'];
-
Wouter60
Posting Freak
-
Posts: 851
Threads: 38
Joined: Feb 2015
Reputation:
77
(07-17-2017, 05:12 AM)sanditheresia Wrote: btw this is my order status
$data['order_status'] = ['wc-processing'=>'Processing', 'wc-on-hold'=>'On Hold', 'wc-completed'=>'Completed', 'wc-pending'=>'Pending'];
You are passing that from the controller to the view, aren't you?
It's an array of possible order statuses, right?
The table with orders is built up by a foreach {} loop, I guess.
In every iteration you should check the order status of the current record.
If that is 'Completed', don't show the button or disable it.
-
my_RZ
Newbie
-
Posts: 9
Threads: 0
Joined: Apr 2017
Reputation:
0
@ sanditheresia
please provide us with full code of your view file..
-
sanditheresia
Newbie
-
Posts: 3
Threads: 1
Joined: Jul 2017
Reputation:
0
(07-17-2017, 07:24 AM)my_RZ Wrote: @sanditheresia
please provide us with full code of your view file..
this is code from my Admin.php controller
Code: $this->load->model('Order');
$jumlah_data = $this->Order->getTotalOrders($filter_data);
$results = $this->Order->getOrders($filter_data);
$this->load->library('pagination');
$config['base_url'] = $data['burl'].'/order?'.$url;
$config['total_rows'] = $jumlah_data;
$config['per_page'] = $limit;
$config['uri_segment'] = $page;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['data_order'] = $results;
$data['filter_id_order'] = $filter_id_order;
$data['filter_order_date'] = $filter_order_date;
$data['filter_order_status'] = $order_status;
$data['order_status'] = ['wc-processing'=>'Processing', 'wc-on-hold'=>'On Hold', 'wc-completed'=>'Completed', 'wc-pending'=>'Pending'];
$this->load->view('header', $data);
$this->load->view('order', $data);
$this->load->view('footer', $data);
}
public function print_delivery()
{
$id_order = $this->input->get('id');
$this->load->model('Order');
$this->Order->updatePrintStatus($id_order);
and this is one Order.php from my controller
Code: function updatePrintStatus($id_order)
{
$data = ['printing_status' => 1];
$this->db->where('ID', $id_order);
$this->db->update('wpt8_posts', $data);
}
function orderPending()
{
$sql = "select ID from wpt8_posts as p where
p.post_status = 'wc-processing' and printing_status = 1";
$query = $this->db->query($sql);
return $query->result_array();
}
function updateResi($id_order, $tracking_number)
{
$data = [
'tracking_number' => $tracking_number,
'post_status' => 'wc-completed'
];
$this->db->where('ID', $id_order);
$this->db->update('wpt8_posts', $data);
}
}
?>
and this is from view
Code: <div class="btn-wrapper pull-left">
<?php if($value['order_status'] == 'wc-processing'){?>
<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 } ?>
-
my_RZ
Newbie
-
Posts: 9
Threads: 0
Joined: Apr 2017
Reputation:
0
(07-17-2017, 07:37 AM)sanditheresia Wrote: (07-17-2017, 07:24 AM)my_RZ Wrote: @sanditheresia
please provide us with full code of your view file..
this is code from my Admin.php controller
Code: $this->load->model('Order');
$jumlah_data = $this->Order->getTotalOrders($filter_data);
$results = $this->Order->getOrders($filter_data);
$this->load->library('pagination');
$config['base_url'] = $data['burl'].'/order?'.$url;
$config['total_rows'] = $jumlah_data;
$config['per_page'] = $limit;
$config['uri_segment'] = $page;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['data_order'] = $results;
$data['filter_id_order'] = $filter_id_order;
$data['filter_order_date'] = $filter_order_date;
$data['filter_order_status'] = $order_status;
$data['order_status'] = ['wc-processing'=>'Processing', 'wc-on-hold'=>'On Hold', 'wc-completed'=>'Completed', 'wc-pending'=>'Pending'];
$this->load->view('header', $data);
$this->load->view('order', $data);
$this->load->view('footer', $data);
}
public function print_delivery()
{
$id_order = $this->input->get('id');
$this->load->model('Order');
$this->Order->updatePrintStatus($id_order);
and this is one Order.php from my controller
Code: function updatePrintStatus($id_order)
{
$data = ['printing_status' => 1];
$this->db->where('ID', $id_order);
$this->db->update('wpt8_posts', $data);
}
function orderPending()
{
$sql = "select ID from wpt8_posts as p where
p.post_status = 'wc-processing' and printing_status = 1";
$query = $this->db->query($sql);
return $query->result_array();
}
function updateResi($id_order, $tracking_number)
{
$data = [
'tracking_number' => $tracking_number,
'post_status' => 'wc-completed'
];
$this->db->where('ID', $id_order);
$this->db->update('wpt8_posts', $data);
}
}
?>
and this is from view
Code: <div class="btn-wrapper pull-left">
<?php if($value['order_status'] == 'wc-processing'){?>
<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 } ?>
Code: <div class="btn-wrapper pull-left">
<?php if($value['order_status'] == 'wc-completed'){?>
<!---JUST BLANK-->
<?php } ?>
-
Wouter60
Posting Freak
-
Posts: 851
Threads: 38
Joined: Feb 2015
Reputation:
77
-
my_RZ
Newbie
-
Posts: 9
Threads: 0
Joined: Apr 2017
Reputation:
0
|