$accountname, 'bill_street' => $address, 'email1' => $email, 'website' => $website, 'phone' => $phone, 'inn' => $inn, 'cf_1951' => $ogrn ); global $adb, $current_user; $query = "select a.accountid from vtiger_account a left join vtiger_crmentity e on e.crmid = a.accountid where e.deleted = 0 and a.inn = ? limit 1"; $result = $adb->pquery($query, array($inn)); if ($adb->num_rows($result) > 0) { //$params['id'] = '11x'.$adb->query_result($result, 0, 'accountid'); $output = $adb->query_result($result, 0, 'accountid'); $logstring = date('Y-m-d H:i:s').' Найден контрагент с id = '.$output.', просто вернем его наружу'.PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); /* try { $account = vtws_revise($params, $current_user); $output = substr($account['id'], 3); $logstring = date('Y-m-d H:i:s').' обновлен Контрагент с id '.$output.PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); } catch (WebServiceException $ex) { $logstring = date('Y-m-d H:i:s').' '.$ex->getMessage().PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); } */ } else { $params['assigned_user_id'] = vtws_getWebserviceEntityId('Users', $user->id); $logstring = date('Y-m-d H:i:s').' Массив для создания Контрагента: '.json_encode($params).PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); try { $account = vtws_create('Accounts', $params, $user); $output = substr($account['id'], 3); $logstring = date('Y-m-d H:i:s').' создан Контрагент с id '.$output.PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); } catch (WebServiceException $ex) { $logstring = date('Y-m-d H:i:s').' '.$ex->getMessage().PHP_EOL; file_put_contents('logs/CreateAccount.log', $logstring, FILE_APPEND); } } return $output; }