Original Source
https://pdocrud.com/demo/pages/file-image-uploading
https://pdocrud.com/demo/pages/set-search-cols
https://pdocrud.com/demo/pages/multiple-file-uploading
New File Uploading Control
This file control is modified version of default file control that allows you to add/remove files. It also helps to check files upload status in edit/update operation.
$pdocrud = new PDOCrud();
$pdocrud->fieldTypes("user_image", "FILE_NEW");//change type to image
$pdocrud->formFields(array("username","user_image"));
echo $pdocrud->dbTable("jm_users")->render();
File (Image) uploading
$pdocrud = new PDOCrud();
$pdocrud->fieldTypes("user_image", "image");//change type to image
$pdocrud->formFields(array("username","user_image"));
echo $pdocrud->dbTable("jm_users")->render("insertform");
Multiple file uploading
$pdocrud = new PDOCrud();
$pdocrud->fieldTypes("user_image", "FILE_MULTI");//change type to file multi
$pdocrud->formFields(array("username","user_image"));
echo $pdocrud->dbTable("jm_users")->render("insertform");
Import Bulk Data
You can import bulk data from csv/xml/excel file directly in database table using the bulk import function. You need to specify the filename and table name only. Your file must have header as the column name of the table.
Please note xml file must have simple column-value... structure. Apart from these, three more functions are added (csvToArray, xmlToArray and excelToArray), that converts csv/xml/excel To Array.
$pdocrud = new PDOCrud();
echo "Records Imported: ". $pdocrud->bulkImport("upload/advertisement.csv", "advertisement");
echo $pdocrud->dbTable("advertisement")->render();
Date range wise report
You can directly add month wise, day wise, year wise (calendar as well day duration wise) report buttons to generate the table data based on the date range. Please note it work for the CRUD table not for SQL as sql statement can be of anytype.
$pdocrud = new PDOCrud();
/**
* Add date range report buttons (eg daily ,monthly ,yearly report button)
* @param string $text Name/Text of the button
* @param string $type Type of the report to be generated.
* return object Object of class
*/
$pdocrud->addDateRangeReport("This Year", "calendar_year", "order_date");
$pdocrud->addDateRangeReport("This Month", "calendar_month", "order_date");
$pdocrud->addDateRangeReport("Last 365 days", "year", "order_date");
$pdocrud->addDateRangeReport("Last 30 days", "month", "order_date");
$pdocrud->addDateRangeReport("1 Day", "Last 1 day", "order_date");
$pdocrud->addDateRangeReport("Today", "today", "order_date");
echo $pdocrud->dbTable("orders")->render();
Set Search Col Data Type
You can set search col data type to date/datetime/time etc to make search more friendly. Default type is text. For example When you set search column data type to date-range, it will show date range options.
$pdocrud = new PDOCrud();
//set the search column data type
$pdocrud->setSearchColumnDataType("order_date", "date-range");// other options are time-range, datetime-range
echo $pdocrud->dbTable("orders")->render();
SQL Operation
Render sql helps to display the data in grid/table format. You can write sql select statement to display data in the grid format. Please note that since sql statement can be of any type so the default grid function will not work with this sql render. From version 2.4, the pagination, records per page and display of total records is also removed. A better option to use the sql render with the jquery datatable plugin. You can see example here
$pdocrud = new PDOCrud();
$pdocrud->setQuery("select * from orders");
echo $pdocrud->render("SQL");
Subselect SQL
You can use the subselect query to generate columns dynamically. You can get data from other tables using the query. It accepts two parameters, first one is column name/alias and second is query.
$pdocrud = new PDOCrud();
$pdocrud->crudTableCol(array("first_name","last_name"));
/**
* Allows you to add the dynamic column based on sub query
* @param string $columnName Alias column name to be used for the query
* @param string $query Sub Query to be used
* return object Object of class
*/
$pdocrud->subQueryColumn("order_id", "select sum(id) from orders where customer_name = {user_name}");
echo $pdocrud->dbTable("users")->render()