コード例 #1
0
 public function execute()
 {
     $service_model = new shopServiceModel();
     $service_product_model = new shopProductServicesModel();
     $id = waRequest::get('id', null, waRequest::TYPE_INT);
     $edit = waRequest::get('edit', null, waRequest::TYPE_STRING_TRIM);
     if ($edit == 'name') {
         $service_model->updateById($id, array('name' => waRequest::post('name', '', waRequest::TYPE_STRING_TRIM)));
         return;
     }
     if ($id) {
         $service = $service_model->getById($id);
         if (!$service) {
             $this->errors[] = _w("Unknown service to update");
             return;
         }
     }
     if ($id) {
         // delete products
         $delete_products = waRequest::post('delete_product', array(), waRequest::TYPE_ARRAY_INT);
         $service_product_model->deleteByProducts($delete_products, $id);
     }
     $id = $service_model->save($this->getData(), $id, true);
     $this->response = array('id' => $id);
 }