public function createAction()
 {
     $auth = $this->session->get('auth');
     $request = $this->request;
     if (!$request->isPost()) {
         return $this->forward("products/index");
     }
     $request = $request->getPost();
     $products = new Products();
     $products->product_types_id = $request['product_types_id'];
     $products->name = $request['name'];
     $products->issuer = $request['issuer'];
     $products->status = $request['status'];
     $products->cycle = $request['cycle'];
     $products->min = $request['min'];
     $products->expected = $request['expected'];
     $products->issuetime = $request['issuetime'];
     $products->telephone = $request['telephone'];
     $products->control = $request['control'];
     $products->description = $request['description'];
     $products->registrar = $auth['name'];
     if ($products->save()) {
         $this->flash->notice("保存成功!");
         return $this->forward('products/new');
     } else {
         foreach ($products->getMessages() as $message) {
             $this->flash->error((string) $message);
         }
     }
 }
 public function addProductAction()
 {
     if (ApiController::access()) {
         $product = new Products();
         $saveArr = $this->request->getPost();
         if (!isset($saveArr['name'])) {
             die('Не передан обязательный параметр name');
         }
         if ($product->save($saveArr) == false) {
             foreach ($product->getMessages() as $message) {
                 $this->response .= (string) $message;
             }
         } else {
             $this->response = array('error_code' => 200, 'error_desc' => 'Create product: ' . $this->request->getPost('name'));
         }
         echo json_encode($this->response);
         $this->view->disable();
     }
 }
Esempio n. 3
0
 public function createAction()
 {
     $request = $this->request;
     if (!$request->isPost()) {
         return $this->forward("products/index");
     }
     $products = new Products();
     $products->id = $request->getPost("id", "int");
     $products->product_types_id = $request->getPost("product_types_id", "int");
     $products->name = $request->getPost("name", "striptags");
     $products->price = $request->getPost("price");
     $products->active = $request->getPost("active");
     if (!$products->save()) {
         foreach ($products->getMessages() as $message) {
             $this->flash->error((string) $message);
         }
         return $this->forward("products/new");
     } else {
         $this->flash->success("products was created successfully");
         return $this->forward("products/index");
     }
 }
Esempio n. 4
0
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->_forward("products/index");
     }
     $products = new Products();
     $products->id = $this->request->getPost("id", "int");
     $products->product_types_id = $this->request->getPost("product_types_id", "int");
     $products->name = $this->request->getPost("name");
     $products->price = $this->request->getPost("price");
     $products->active = $this->request->getPost("active");
     $products->name = strip_tags($products->name);
     if (!$products->save()) {
         foreach ($products->getMessages() as $message) {
             Flash::error((string) $message, "alert alert-error");
         }
         return $this->_forward("products/new");
     } else {
         Flash::success("products was created successfully", "alert alert-success");
         return $this->_forward("products/index");
     }
 }