Пример #1
0
            if ($fields) {
                list($data, $error, $messages, $errorFields) = iaField::parsePost($fields, $ad, true);
            }
            $data['status'] = iaUtil::checkPostParam('status', iaCore::STATUS_ACTIVE);
            if (!$error) {
                if (iaCore::ACTION_ADD == $pageAction) {
                    $data['id'] = $iaAd->insert($data);
                    $messages[] = iaLanguage::get('ad_added');
                } else {
                    $data['id'] = $ad['id'];
                    $iaAd->update($data);
                    $messages[] = iaLanguage::get('saved');
                }
                $ad = $iaAd->getById($data['id']);
                $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
                $goto = array('add' => $baseUrl . 'add/', 'list' => $baseUrl, 'stay' => $baseUrl . 'edit/?id=' . $data['id']);
                iaUtil::post_goto($goto);
            }
            $iaView->setMessages($messages, $error ? iaView::ERROR : iaView::SUCCESS);
        }
        $fieldGroups = $iaFields->getFieldsGroups(true, false, $iaAd->getItemName());
        $iaView->assign('fields_groups', $fieldGroups);
        // get products
        $iaProduct = $iaCore->factoryPackage('product', IA_CURRENT_PACKAGE, iaCore::ADMIN);
        $products = $iaProduct->iaDb->all(iaDb::ALL_COLUMNS_SELECTION, '', null, null, iaProduct::getTable());
        $iaView->assign('products', $products);
        $iaView->assign('item', $ad);
        $iaView->display('ads');
    }
}
$iaDb->resetTable();