.
--
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*
* Generic Table Editor
*
* Inspired by http://extjs.com/deploy/dev/examples/writer/writer.html
*
* @author Bernhard Woehrlin
* @copyright (c) 2008-2009, IT.CappuccinoNet.com
* @date 2009-09-01 16:27:36
* @version 1.3
* @class Dates
*
* A simple application controller extension
*/
class Dates extends ApplicationController {
/**
* view
* Retrieves rows from database.
*/
public function view($start = null, $limit = null) {
global $DB;
$res = new Response();
$res->success = true;
$res->message = "Loaded data";
//$res->data =
$result = Date::getAll($start, $limit, null, $DB['table_orderby']);
#print_r($result);
$res->data = $result;
#print_r($res->data);
$res->total = Date::getNumRows();
return $res->to_json();
}
/**
* create
*/
public function create() {
$res = new Response();
$rec = Date::insert($this->params);
if ($rec) {
$res->success = true;
$res->message = 'Added new dataset';
$res->data = $rec;
} else {
$res->message = 'Could not add dataset';
}
return $res->to_json();
}
/**
* update
*/
public function update() {
$res = new Response();
$rec = Date::update($this->id, $this->params);
if ($rec) {
$res->data = $rec;
$res->success = true;
$res->message = 'Updated dataset with ID '.$this->id.'';
} else {
$res->message = 'Could not find dataset';
}
return $res->to_json();
}
/**
* destroy
*/
public function destroy() {
$res = new Response();
if (Date::delete($this->id) === true) {
$res->success = true;
$res->message = 'Removed dataset with ID '.$this->id.'';
$res->data = null;
} else {
$res->message = 'Could not delete dataset';
}
return $res->to_json();
}
}