Exemplo n.º 1
0
     $errorMessage .= GetMessage('ERROR_NO_NAME') . "\n";
 }
 if (empty($locationId)) {
     $errorMessage .= GetMessage('ERROR_NO_LOCATION_ID') . "\n";
 }
 if (empty($errorMessage)) {
     $uFields = array();
     $USER_FIELD_MANAGER->EditFormAddFields(CompanyTable::getUfId(), $uFields);
     $fields = array('NAME' => $name, 'LOCATION_ID' => $locationId, 'ADDRESS' => $location, 'CODE' => $code, 'ACTIVE' => $active);
     $fields = array_merge($fields, $uFields);
     $result = null;
     $conn->startTransaction();
     if ($id > 0) {
         $fields['DATE_MODIFY'] = new \Bitrix\Main\Type\DateTime();
         $fields['MODIFIED_BY'] = $USER->GetID();
         $result = CompanyTable::update($id, $fields);
     } else {
         $fields['XML_ID'] = $request->getPost('XML_ID');
         $fields['DATE_CREATE'] = new \Bitrix\Main\Type\DateTime();
         $fields['CREATED_BY'] = $USER->GetID();
         $result = CompanyTable::add($fields);
     }
     if ($result && $result->isSuccess()) {
         $conn->commitTransaction();
         $id = $result->getId();
         if (strlen($request->getPost("apply")) == 0) {
             LocalRedirect("/bitrix/admin/sale_company.php?lang=" . $lang . "&" . GetFilterParams("filter_", false));
         } else {
             LocalRedirect("/bitrix/admin/sale_company_edit.php?lang=" . $lang . "&ID=" . $id . "&" . GetFilterParams("filter_", false));
         }
     } else {
Exemplo n.º 2
0
        if ($id <= 0 || !$lAdmin->IsUpdated($id)) {
            continue;
        }
        $reqFields = array('NAME');
        // , 'LOCATION_ID'
        foreach ($reqFields as $reqField) {
            if (empty($arFields[$reqField])) {
                $error = true;
                $lAdmin->AddUpdateError('#' . $id . ' : ' . Loc::getMessage('SALE_COMPANY_ERROR_NO_' . $reqField), $id);
            }
        }
        if (!$error) {
            $arFields['DATE_MODIFY'] = new \Bitrix\Main\Type\DateTime();
            $arFields['MODIFIED_BY'] = $USER->GetID();
            $conn->startTransaction();
            $res = CompanyTable::update($id, $arFields);
            if (!$res->isSuccess()) {
                $conn->rollbackTransaction();
                $lAdmin->AddUpdateError(join("\n", $res->getErrorMessages()), $id);
                continue;
            }
            $conn->commitTransaction();
        }
    }
}
if (($ids = $lAdmin->GroupAction()) && $saleModulePermissions >= "W") {
    if ($_REQUEST['action_target'] == 'selected') {
        $ids = array();
        $params = array('select' => array('ID'), 'filter' => $filter);
        $dbResultList = CompanyTable::getList($params);
        while ($result = $dbResultList->Fetch()) {