public function action_newList() { PermissionHelper::Verification('Editor'); $name = $_POST['inputName']; $attributeGroupName = $_POST['inputGroup']; $attributeUnitName = $_POST['inputUnit']; $attributeValue = explode("\r\n", $_POST['inputValue']); $attribute = new Attribute(); $attribute->attributegroup_id = AttributeGroupService::GetByName($attributeGroupName)->attributegroup_id; $attribute->name = $name; $attribute->type = 2; $attribute->status = "1"; if ($attributeUnitName != "-") { $attribute->unit_id = UnitService::GetByName($attributeUnitName)->unit_id; } AttributeService::Create($attribute); $id = AttributeService::GetByName($name)->attribute_id; for ($i = 0; $i < count($attributeValue); $i++) { $attributeList = new AttributeList(); $attributeList->attribute_id = $id; $attributeList->name = $attributeValue[$i]; AttributeListService::Create($attributeList); } header("Location: /Attribute/Item"); }
function action_new() { PermissionHelper::Verification('Editor'); $name = $_POST['inputName']; $sectionName = $_POST['inputSection']; $attribute = $_POST['attributes']; $catalogue = new Catalogue(); $catalogue->name = $name; $catalogue->section_id = SectionService::GetByName($sectionName)->section_id; CatalogueService::Create($catalogue); $catalogue = CatalogueService::GetByName($name); for ($i = 0; $i < count($attribute); $i++) { $value = new CatalogueAttribute(); $value->catalogue_id = $catalogue->catalogue_id; $value->attribute_id = AttributeService::GetByName(trim($attribute[$i]))->attribute_id; CatalogueAttributeService::Create($value); } header("Location: /Catalog/Item"); }
function action_new() { PermissionHelper::Verification('Editor'); $name = $_POST['inputName']; $price = $_POST['inputPrice']; $Description = $_POST['inputDescription']; $names = explode(',', $_POST['names']); $values = explode(',', $_POST['values']); $catalog = $_POST['catalog']; $product = new Product(); $product->name = $name; $product->price = $price; $product->catalogue_id = CatalogueService::GetByName($catalog)->catalogue_id; $product->description = $Description; ProductService::Create($product); $product_id = ProductService::GetByName($name)->product_id; for ($i = 0; $i < count($names); $i++) { $attribute = AttributeService::GetByName($names[$i]); if ($attribute->type == 1) { $attributeFloat = new AttributeValueFloat(); $attributeFloat->attribute_id = $attribute->attribute_id; $attributeFloat->product_id = $product_id; $attributeFloat->value = $values[$i]; AttributeValueFloatService::Create($attributeFloat); } else { $attributeList = new AttributeValueList(); $attributeList->product_id = $product_id; $attributeList->attribute_id = $attribute->attribute_id; $attributeList->value = AttributeListService::GetByAttributeIdAndName($attribute->attribute_id, $values[$i])->attributelist_id; AttributeValueListService::Create($attributeList); } } $fr = fopen($_FILES['file-0']['tmp_name'], 'r'); $fw = fopen(__ROOT__ . '/images/items/item_' . $product_id . '.jpg', "w"); while (!feof($fr)) { $buff = fread($fr, 1000); fwrite($fw, $buff); } fclose($fr); fclose($fw); header("Location: /Product/itemAdmin"); }