function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new productgenspec(); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } } return parent::save($object, $related_field); }
function editGenSpec($id) { $productGenSpec = new productgenspec($id); $productGenSpec->name = $this->input->post("specName"); $productGenSpec->description = $this->input->post("specDescription"); $productGenSpec->type = $this->input->post('specElementType'); if ($this->input->post("specType") == "1") { $productGenSpec->parentcat_id = $this->input->post("specGroupId"); $productGenSpec->isGroup = 0; } else { $productGenSpec->parentcat_id = ""; $productGenSpec->isGroup = 1; } if (!$productGenSpec->save()) { return "Lỗi khi lưu product general spect"; } }
function productSpecdialog() { $productGenSpec = new productgenspec(); $dis['searchKey'] = ""; if ($_SERVER['REQUEST_METHOD'] == "POST") { $searchKey = $this->input->post('searchName'); $productGenSpec->like("name", $searchKey); $dis['searchKey'] = $searchKey; $dis['isSearch'] = true; } $productGenSpec->order_by("parentcat_id", "asc"); $productGenSpec->order_by("name", "asc"); $productGenSpec->get_iterated(); $dis['base_url'] = base_url(); $dis['Spec'] = $productGenSpec; $this->load->view("admin/layout/dialogContent/productSpecDialogContent", $dis); }
<td class="a-center"><div align="center"><?php echo $count; ?> </div></td> <td> <a href="javascript:void(0)" onclick="productDialog_editGenSpec(<?php echo $row->id; ?> )"><?php echo $row->name; ?> </a> </td> <td> <?php $parent = new productgenspec($row->parentcat_id); if ($parent->exists()) { echo $parent->name; } ?> </td> <td><?php if ($row->isGroup == "1") { echo "Nhóm"; } else { echo "Thuộc tính"; } ?> </td> <td><div align="center">
function addSpec($cat_id) { $productcat = new Productcat($cat_id); //check the product GenSpecID $specNewType = $this->input->post("specNewType"); if ($specNewType == "1") { $productCatSpecId = $this->input->post("productSpecId"); $catSpecCheck = new productcatspec(); $catSpecCheck->where_related_productgenspec("id", $productCatSpecId); $catSpecCheck->where_related_productcat("id", $cat_id); $catSpecCheck->get(); if (!$catSpecCheck->exists()) { $productGenSpec = new productgenspec($productCatSpecId); $productCatSpec = new productcatspec(); $productCatSpec->productcat_id = $cat_id; if (!$productCatSpec->save(array("productgenspec" => $productGenSpec))) { return "Có lỗi khi lưu productcatspec"; } } } else { $productGenSpec = new productgenspec(); $productGenSpec->name = $this->input->post("specName"); $productGenSpec->description = $this->input->post("specDescription"); $productGenSpec->type = $this->input->post('specElementType'); if ($this->input->post("specType") == "1") { $productGenSpec->parentcat_id = $this->input->post("specGroupId"); $productGenSpec->isGroup = 0; } else { $productGenSpec->isGroup = 1; } if ($productGenSpec->save()) { $productCatSpec = new productcatspec(); $productCatSpec->productcat_id = $cat_id; if (!$productCatSpec->save(array("productgenspec" => $productGenSpec))) { return "Có lỗi khi lưu productcatspec"; } } else { return "Lỗi khi lưu product general spect"; } } }