Example #1
0
function LogicBoxes_Contract_Register($Settings, $PepsonID, $Person, $DomainZone)
{
    /****************************************************************************/
    $__args_types = array('array', 'string', 'array', 'string');
    #-----------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /****************************************************************************/
    $Wsdl = System_Element('config/Wsdl/Customer.wsdl');
    if (Is_Error($Wsdl)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    $AddCustomer = new SoapClient($Wsdl, array('exceptions' => 0));
    #-----------------------------------------------------------------------------
    $Params = array('SERVICE_USERNAME' => $Settings['Login'], 'SERVICE_PASSWORD' => $Settings['Password'], 'SERVICE_ROLE' => 'reseller', 'SERVICE_LANGPREF' => 'ru', 'SERVICE_PARENTID' => $Settings['ParentID'], 'customerUserName' => $Person['Email'], 'customerPassword' => UniqID());
    #-----------------------------------------------------------------------------
    switch ($PepsonID) {
        case 'Natural':
            #-------------------------------------------------------------------------
            $Params['name'] = SPrintF('%s %s %s', Translit($Person['Name']), Mb_SubStr(Translit($Person['Lastname']), 0, 1), Translit($Person['Sourname']));
            $Params['company'] = 'N/A';
            $Params['address1'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']));
            $Params['address2'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']));
            $Params['address3'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']));
            $Params['city'] = Translit($Person['pCity']);
            $Params['state'] = Translit($Person['pState']);
            $Params['country'] = isset($Person['PasportCountry']) ? $Person['PasportCountry'] : $Person['pCountry'];
            $Params['zip'] = $Person['pIndex'];
            break;
        case 'Juridical':
            #-------------------------------------------------------------------------
            $Params['name'] = SPrintF('%s %s %s', Translit($Person['dName']), Translit($Person['dLastname']), Translit($Person['dSourname']));
            $Params['company'] = SPrintF('%s %s', Translit($Person['CompanyName']), Translit($Person['CompanyFormFull']));
            $Params['address1'] = Translit(SPrintF('%s %s', $Person['jType'], $Person['jAddress']));
            $Params['address2'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']));
            $Params['address3'] = Translit(SPrintF('%s %s', $Person['pType'], $Person['pAddress']));
            $Params['city'] = Translit($Person['jCity']);
            $Params['state'] = Translit($Person['jState']);
            $Params['country'] = Translit($Person['jCountry']);
            $Params['zip'] = $Person['jIndex'];
            break;
        default:
            return ERROR | @Trigger_Error(400);
    }
    #-----------------------------------------------------------------------------
    $Phone = $Person['Phone'];
    #-----------------------------------------------------------------------------
    if ($Phone) {
        #---------------------------------------------------------------------------
        $Phone = Preg_Split('/\\s+/', $Phone);
        #---------------------------------------------------------------------------
        $Params['telNoCc'] = Trim(Current($Phone), '+');
        $Params['telNo'] = SPrintF('%s%s', Next($Phone), Next($Phone));
        #---------------------------------------------------------------------------
        Reset($Phone);
        #---------------------------------------------------------------------------
        $Params['altTelNoCc'] = Trim(Current($Phone), '+');
        $Params['altTelNo'] = SPrintF('%s%s', Next($Phone), Next($Phone));
    } else {
        #---------------------------------------------------------------------------
        $Params['telNoCc'] = '';
        $Params['telNo'] = '';
        $Params['altTelNoCc'] = '';
        $Params['altTelNo'] = '';
    }
    #-----------------------------------------------------------------------------
    $Fax = $Person['Fax'];
    #-----------------------------------------------------------------------------
    if ($Fax) {
        #---------------------------------------------------------------------------
        $Fax = Preg_Split('/\\s+/', $Fax);
        #---------------------------------------------------------------------------
        $Params['faxNoCc'] = Trim(Current($Fax), '+');
        $Params['faxNo'] = SPrintF('%s%s', Next($Fax), Next($Fax));
    } else {
        #---------------------------------------------------------------------------
        $Params['faxNoCc'] = '';
        $Params['faxNo'] = '';
    }
    #-----------------------------------------------------------------------------
    $Params['customerLangPref'] = 'ru';
    #-----------------------------------------------------------------------------
    Debug(Print_R($Params, TRUE));
    #-----------------------------------------------------------------------------
    $Response = $AddCustomer->__SoapCall('addCustomer', $Params);
    #-----------------------------------------------------------------------------
    if (Is_SOAP_Fault($Response)) {
        #---------------------------------------------------------------------------
        Debug($Response->faultstring);
        #---------------------------------------------------------------------------
        return new gException('ANSWER_ERROR', 'Ошибка обращения к регистратору');
    }
    #-----------------------------------------------------------------------------
    $CustomerID = $Response;
    #-----------------------------------------------------------------------------
    $Wsdl = System_Element('config/Wsdl/DomContact.wsdl');
    if (Is_Error($Wsdl)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    $DefaultContact = new SoapClient($Wsdl, array('exceptions' => 0));
    #-----------------------------------------------------------------------------
    $Response = $DefaultContact->addDefaultContact($Settings['Login'], $Settings['Password'], 'reseller', 'ru', $Settings['ParentID'], $CustomerID);
    #-----------------------------------------------------------------------------
    if (Is_SOAP_Fault($Response)) {
        #---------------------------------------------------------------------------
        Debug($Response->faultstring);
        #---------------------------------------------------------------------------
        return new gException('ANSWER_ERROR', 'Ошибка обращения к регистратору');
    }
    #-----------------------------------------------------------------------------
    return array('TicketID' => $CustomerID);
}