public function install() { $models = Shared\Markup::models(); foreach ($models as $key => $value) { $this->sync($value); } }
/** * Searchs for data and returns result from db * @param type $model the data model * @param type $property the property of modal * @param type $val the value of property * @before _secure, changeLayout, _admin */ public function search($model = NULL, $property = NULL, $val = 0, $page = 1, $limit = 10) { $this->seo(array("title" => "Search", "keywords" => "admin", "description" => "admin", "view" => $this->getLayoutView())); $view = $this->getActionView(); $model = RequestMethods::get("model", $model); $property = RequestMethods::get("key", $property); $val = RequestMethods::get("value", $val); $page = RequestMethods::get("page", $page); $limit = RequestMethods::get("limit", $limit); $sign = RequestMethods::get("sign", "equal"); $view->set("items", array()); $view->set("values", array()); $view->set("models", Shared\Markup::models()); $view->set("page", $page); $view->set("limit", $limit); $view->set("property", $property); $view->set("val", $val); $view->set("sign", $sign); if ($model) { if ($sign == "like") { $where = array("{$property} LIKE ?" => "%{$val}%"); } else { $where = array("{$property} = ?" => $val); } $objects = $model::all($where, array("*"), "created", "desc", $limit, $page); $count = $model::count($where); $i = 0; if ($objects) { foreach ($objects as $object) { $properties = $object->getJsonData(); foreach ($properties as $key => $property) { $key = substr($key, 1); $items[$i][$key] = $property; $values[$i][] = $key; } $i++; } $view->set("items", $items); $view->set("values", $values[0]); $view->set("count", $count); //echo '<pre>', print_r($values[0]), '</pre>'; $view->set("success", "Total Results : {$count}"); } else { $view->set("success", "No Results Found"); } } }
/** * @before _secure, changeLayout, _admin */ public function dataAnalysis() { $this->seo(array("title" => "Data Analysis", "keywords" => "admin", "description" => "admin", "view" => $this->getLayoutView())); $view = $this->getActionView(); if (RequestMethods::get("action") == "dataAnalysis") { $startdate = RequestMethods::get("startdate"); $enddate = RequestMethods::get("enddate"); $model = ucfirst(RequestMethods::get("model")); $diff = date_diff(date_create($startdate), date_create($enddate)); for ($i = 0; $i < $diff->format("%a"); $i++) { $date = date('Y-m-d', strtotime($startdate . " +{$i} day")); $count = $model::count(array("created LIKE ?" => "%{$date}%")); $obj[] = array('y' => $date, 'a' => $count); } $view->set("data", \Framework\ArrayMethods::toObject($obj)); } $view->set("models", Shared\Markup::models()); }