public function childAction($id) { $numberPage = 1; $numberPage = $this->request->getQuery("page", "int"); if ($numberPage <= 0) { $numberPage = 1; } $parameters = array(); if ($id) { $parameters = array("fid =" . $id); } $productTypes = Types::find($parameters); if (count($productTypes) == 0) { $this->flash->notice("没有找到对应下级类型"); return $this->forward("producttypes/newtypes/" . $id); } $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $productTypes, "limit" => 10, "page" => $numberPage)); $page = $paginator->getPaginate(); $this->view->setVar("id", $id); $this->view->setVar("page", $page); $this->view->setVar("productTypes", $productTypes); }
public function indexAction() { $this->persistent->searchParams = null; $types = Types::find(); $this->view->setVar("productTypes", ProductTypes::find()); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (!$id) { return Redirect::route('types.index')->with('error', 'Please provide type id'); } $type = Types::find($id); if (empty($type)) { return Redirect::route('types.index')->with('error', 'Type not found'); } Types::destroy($id); return Redirect::route('types.index')->with('success', 'Type deleted successfully'); }
public function editAction($id) { $request = $this->request; if (!$request->isPost()) { $id = $this->filter->sanitize($id, array("int")); $Finance = Finance::findFirst('id="' . $id . '"'); if (!$Finance) { $this->flash->error("这条记录没有找到!"); return $this->forward("products/list"); } $departments = Department::find(); $this->view->setVar("departments", $departments); Tag::displayTo("company", $Finance->did); $typeArr; $type = Type::find(); foreach ($type as $k => $v) { $types = Types::find("fid = '" . $v->id . "'"); $typeArr[$v->name] = $types->toArray(); } $this->view->setVar("typeArr", $typeArr); $this->view->setVar("id", $Finance->id); $datas = json_decode($Finance->data, true); foreach ($typeArr as $key => $val) { foreach ($val as $k => $v) { if (isset($datas['cost'][$v['name']]) && $datas['cost'][$v['name']] != '') { Tag::displayTo("cost[" . $v['name'] . "]", $datas['cost'][$v['name']]); } if (isset($datas['remark'][$v['name']]) && $datas['remark'][$v['name']] != '') { Tag::displayTo("remark[" . $v['name'] . "]", $datas['remark'][$v['name']]); } if (isset($datas['limit'][$v['name']]) && $datas['limit'][$v['name']] != '') { Tag::displayTo("limit[" . $v['name'] . "]", $datas['limit'][$v['name']]); } } } Tag::displayTo("id", $Finance->id); $auth = $this->session->get("auth"); if ($auth['did'] != 0) { Tag::setDefault("company", $auth['did']); } $this->view->setVar('did', $auth['did']); /* 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()); */ } }