// Pastèque is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Pastèque. If not, see <http://www.gnu.org/licenses/>. // tax_edit action namespace ProductAttributes; $message = null; $error = null; // Check saves if (isset($_POST['id'])) { // Update attribute $attr = \Pasteque\Attribute::__build($_POST['id'], $_POST['label'], null); \Pasteque\AttributesService::updateAttribute($attr); // edit values $taxValues = array(); foreach ($_POST as $key => $value) { if (strpos($key, "label-") === 0 && $key != "label-new") { $id = substr($key, 6); $val = \Pasteque\AttributeValue::__build($id, $value); \Pasteque\AttributesService::updateValue($val); } } if (isset($_POST['delete'])) { foreach ($_POST['delete'] as $del) { \Pasteque\AttributesService::deleteValue($del); } }
// Update attribute $set = \Pasteque\AttributeSet::__build($_POST['id'], $_POST['label']); foreach ($_POST['id-attr'] as $attrId) { if ($attrId !== null && $attrId !== "") { $attr = \Pasteque\Attribute::__build($attrId, "unused", null); $set->addAttribute($attr, null); } } \Pasteque\AttributesService::updateSet($set); } else { if (isset($_POST['label'])) { // Create attribute $set = new \Pasteque\AttributeSet($_POST['label']); foreach ($_POST['id-attr'] as $attrId) { if ($attrId !== null && $attrId !== "") { $attr = \Pasteque\Attribute::__build($attrId, "unused", null); $set->addAttribute($attr, null); } } \Pasteque\AttributesService::createSet($set); } } $set = null; if (isset($_GET['id'])) { $set = \Pasteque\AttributesService::get($_GET['id']); } ?> <h1><?php \pi18n("Edit attribute set", PLUGIN_NAME); ?> </h1>