Original Source
https://pdocrud.com/demo/pages/action-switch
https://pdocrud.com/demo/pages/action-buttons
https://pdocrud.com/demo/pages/action-button-top
https://pdocrud.com/demo/pages/clone-rows
https://pdocrud.com/demo/pages/add-sidebar
Column Action Button
You can make any column to action switch or url with primary key as query parameter. For example, if you want to change the value from approve to reject or reject to approve, you can use this feature to switch values. Also, if you want to make a column to url with primary key as query paramater then you can also do this using function for example you can make firstname to firstname. You can pass extra data attributes in 4th parameter of function.
$pdocrud = new PDOCrud();
$pdocrud->crudTableCol(array("first_name","last_name","no_of_adult","no_of_child","booking_amount","booking_status"));
//action type switch - on click on column, value will be changed and saved
$action = array("1"=>"0","0"=>"1");//action to be performed, like when value is 1 set it to 0
$text = array("1" => "approved","0"=>"unapproved");
$pdocrud->enqueueActions($action,"switch",$text,"booking_status",array());
//action type url - redirect to another page with primary key
$action = "http://www.google.com?url={pk}";//{another example of adding url {} text will be replaced by the primary key value
$pdocrud->enqueueActions($action,"url","","first_name",array());
echo $pdocrud->dbTable("bookroom")->render();
Side Action Buttons
You can add extra action buttons to perform many operations like switch, url redirection etc. Below are example of how to add url action button and switch. URL action is for redirecting to another website with some value and switch can be used for on/off operation (like approve/disapprove, publish/unpublish).
$pdocrud = new PDOCrud();
$pdocrud->crudTableCol(array("first_name","last_name","no_of_adult","no_of_child","booking_amount","booking_status"));
$action = "http://google.com/?id={pk}";//pk will be replaced by primary key value
$text = '';
$attr = array("title"=>"Redirect URL");
$pdocrud->enqueueBtnActions("url", $action, "url",$text,"booking_status", $attr);
$action = "http://yahoo.com/?id={pk}";
$text = '';
$attr = array("title"=>"Redirect URL");
$pdocrud->enqueueBtnActions("url2", $action, "url",$text,"booking_status", $attr);
$action = array("1"=>"0","0"=>"1");//action to be performed, like when value is 1 set it to 0
$text = array("1" => '',"0"=>'');
$attr = array("title"=>"Switch Button");
$pdocrud->enqueueBtnActions("btnswitch", $action, "btnswitch",$text,"booking_status", $attr);
echo $pdocrud->dbTable("bookroom")->render();
Left Position Action Butotns
You can display action buttons on left side i.e. in first column. Please note that inline edit won't work with this.
$pdocrud = new PDOCrud();
$pdocrud->enqueueBtnTopActions("Report", "View Report", "http://www.google.com", array(), "btn-report");
echo $pdocrud->dbTable("orders")->render();
Add Side Bar
You can add side bar similar to profile page view of many admin template now easily using the addSidebar function. You can add it in both view as well as edit forms. You can add your custom css also to adjust it as per your template. click on edit/view action button to check sidebar.
$pdocrud = new PDOCrud();
//list of urls to displayed below the sidebar
$urls[] = array("url"=>"#profile","text" => "Profile", "icon" =>"fa fa-user", "data"=>"", "attr" =>array("data-profile"=>"user_id"),"class" => array("parent-sidebar"));
$urls[] = array("url"=>"#recent-activity","text" => "Recent Activity", "icon" =>"fa fa-history", "data"=>"12/12/2017", "attr" =>array(),"class" => array("parent-sidebar"));
/**
* Add sidebar to existing data in edit/view form
* @param string $sidebarImage column name of image or url of image
* @param string $sidebarHeading1 column name for sidebar heading 1 or some text
* @param string $sidebarHeading2 column name for sidebar heading 2 or some text
* @param array $sidebarURLs sidebar urls
* @param string $position Position of the sidebar (either left or right)
* return object Object of class
*/
$pdocrud->addSidebar("parent_profile_img","name","email",$urls,"left");
echo $pdocrud->dbTable("parent")->render();