<?php defined('BASEPATH') OR exit('No direct script access allowed');

if ( ! function_exists('view_action'))
{
	function view_action($url='',$id='',$showicon = true,$text='')
	{
		$html ='<form action="'.$url.'/view" method="post" style="display:inline">';
		$html .= '<input type="hidden" name="view_id" value="'.$id.'">';
		$html .= '<button type="submit" class="btn btn-success btn-sm" data-toggle="tooltip" data-placement="bottom" title="View">';
		if($showicon) {
			$html .= ' <span class="glyphicon glyphicon-eye-open"></span>';	
		}
        $html .= ' '.$text.'</button>';
        $html .= '</form>';
        return $html;
	}
}

if ( ! function_exists('edit_action'))
{
	function edit_action($url='',$id='',$showicon = true,$text='')
	{
		$html ='<form action="'.$url.'/edit" method="post" style="display:inline">';
		$html .= '<input type="hidden" name="edit_id" value="'.$id.'">';
		$html .= '<button type="submit" class="btn btn-warning btn-sm" data-toggle="tooltip" data-placement="bottom" title="Edit">';
		if($showicon) {
			$html .= ' <span class="glyphicon glyphicon-edit"></span>';	
		}
        $html .= ' '.$text.'</button>';
        $html .= '</form>';
        return $html;
	}
}

if ( ! function_exists('delete_action'))
{
	function delete_action($url='',$id='',$delete = NULL,$showicon = true,$text='')
	{
		$delete = ($delete!=NULL)?$delete:'Are you sure you want to delete this record?';

        $html ='<form action="'.$url.'/delete" method="post" style="display:inline" onsubmit="return confirm(\''.$delete.'\'); " >';
		$html .= '<input type="hidden" name="delete_id" value="'.$id.'">';
		$html .= '<button type="submit" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="bottom" title="Delete">';
		if($showicon) {
			$html .= ' <span class="glyphicon glyphicon-trash"></span>';	
		}
        $html .= ' '.$text.'</button>';
        $html .= '</form>';
        return $html;
	}
}