public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Phalcon_Model_Query::fromInput("ProductTypes", $_POST); $this->session->conditions = $query->getConditions(); } else { $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } } $parameters = array(); if ($this->session->conditions) { $parameters["conditions"] = $this->session->conditions; } $parameters["order"] = "id"; $producttypes = ProductTypes::find($parameters); if (count($producttypes) == 0) { Flash::notice("The search did not find any product types", "alert alert-info"); return $this->_forward("producttypes/index"); } $paginator = Phalcon_Paginator::factory("Model", array("data" => $producttypes, "limit" => 10, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("page", $page); $this->view->setVar("producttypes", $producttypes); }
public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, "ProductTypes", $_POST); $this->persistent->searchParams = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } } $parameters = array(); if ($this->persistent->searchParams) { $parameters = $this->persistent->searchParams; } $productTypes = ProductTypes::find($parameters); if (count($productTypes) == 0) { $this->flash->notice("The search did not find any product types"); return $this->forward("producttypes/index"); } $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $productTypes, "limit" => 10, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("page", $page); $this->view->setVar("productTypes", $productTypes); }
/** * Initialize the products form */ public function initialize($entity = null, $options = array()) { /*======================= usuario_id ================================*/ if (!isset($options['edit'])) { $element = new Text("usuario_id"); $this->add($element->setLabel("Id")); } else { $this->add(new Hidden("usuario_id")); } /*======================= usuario_nick ================================*/ $name = new Text("name"); $name->setLabel("Name"); $name->setFilters(array('striptags', 'string')); $name->addValidators(array(new PresenceOf(array('message' => 'Name is required')))); $this->add($name); /*======================= usuario_nombreCompleto ================================*/ $type = new Select('product_types_id', ProductTypes::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '')); $type->setLabel('Type'); $this->add($type); /*======================= usuario_contrasenia ================================*/ $price = new Text("price"); $price->setLabel("Price"); $price->setFilters(array('float')); $price->addValidators(array(new PresenceOf(array('message' => 'Price is required')), new Numericality(array('message' => 'Price is required')))); $this->add($price); /*======================= usuario_sector ================================*/ /*======================= usuario_email ================================*/ /*======================= usuario_activo ================================*/ /*======================= usuario_fechaCreacion ================================*/ /*======================= usuario_imagen ================================*/ }
public function editAction($id) { $request = $this->request; if (!$request->isPost()) { $id = $this->filter->sanitize($id, array("int")); $products = Products::findFirst('id="' . $id . '"'); if (!$products) { $this->flash->error("products was not found"); return $this->forward("products/index"); } $this->view->setVar("id", $products->id); Tag::displayTo("id", $products->id); Tag::displayTo("product_types_id", $products->product_types_id); Tag::displayTo("name", $products->name); Tag::displayTo("price", $products->price); Tag::displayTo("active", $products->active); $this->view->setVar("productTypes", ProductTypes::find()); } }
/** * Initialize the products form */ public function initialize($entity = null, $options = array()) { if (!isset($options['edit'])) { $element = new Text("id"); $this->add($element->setLabel("Id")); } else { $this->add(new Hidden("id")); } $name = new Text("name"); $name->setLabel("Name"); $name->setFilters(array('striptags', 'string')); $name->addValidators(array(new PresenceOf(array('message' => 'Name is required')))); $this->add($name); $type = new Select('product_types_id', ProductTypes::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '')); $type->setLabel('Type'); $this->add($type); $price = new Text("price"); $price->setLabel("Price"); $price->setFilters(array('float')); $price->addValidators(array(new PresenceOf(array('message' => 'Price is required')), new Numericality(array('message' => 'Price is required')))); $this->add($price); }
public function newAction() { $this->view->setVar("productTypes", ProductTypes::find()); }
public function indexAction() { $this->persistent->searchParams = null; $types = Types::find(); $this->view->setVar("productTypes", ProductTypes::find()); }