view; $GLOBALS['controller'] =& $this->controller; } // Funciones de servicio web exportadas function createJJOrder($params) { require_once(JPATH_BASE. '/libraries/joomla/utilities/date.php'); switch($_SERVER['SERVER_NAME']) { case 'production.voxelcare.com': $pass = '2001-09-11'; break; default: $pass = '364789328'; } $ret = new stdclass(); $obj = new stdclass(); if ($pass != $params['AccessNumber']) { $obj->ErrorCode = -1; $obj->ErrorString = "Bad access number"; $ret->returnValue = $obj; $GLOBALS['soapSuccess'] = false; return $ret; } $view = ($GLOBALS['view']); $controller = ($GLOBALS['controller']); $modelOrder =& $view->getModel('order'); $modelCustomer =& $view->getModel('customer'); $modelPaymentMethods = & $view->getModel('paymentmethods'); $modelUser =& $view->getModel('user'); $userId = $modelUser->getUserIdByUsername('webshop'); if (!$userId) { $obj->ErrorCode = -1; $obj->ErrorString ="Robot user not found"; $ret->returnValue = $obj; $GLOBALS['soapSuccess'] = false; return $ret; } $dateNow = new JDate(); $orderData = array(); $today = $dateNow->toMySQL(); $orderData['id'] =null; $orderData['creationdate'] = $today; $orderData['user'] = $userId; $modelOrder->store($orderData); $orderId = $orderData['id']; $modelOrder->setAction('START'); $modelOrder->setAction('SAVEDLASTSTEP'); $GLOBALS['soapOrderId'] = $orderId; $order =& $modelOrder->getData(); $ats = array('OrderType', 'FootType', 'ShoeSizeType', 'ShoeSize', 'BrandSoleType', 'BlockColor', 'HasPodotrack','HasFoambox', 'Weight','Activity', 'ShoeType','Cover','CustomerName', 'CustomerStoreId', 'Quantity', 'AddressStreet', 'AddressProvince', 'AddressPCode', 'AddressCountry'); foreach($ats as $at) $modelOrder->setAttribute('JJC_'.$at,$params[$at]); // $modelOrder->setAttribute('InsoleCADProject',1,1); $customerName = $params['CustomerName']; if ($customerName) { $customerData = array(); $customerData['id'] = null; $customerData['localid'] = $params['CustomerStoreId']; $customerData['name'] = $customerName; $customerData['address'] = $params['AddressStreet']; $customerData['province'] = $params['AddressProvince']; $customerData['pcode'] = $params['AddressPCode']; $customerData['country'] = $params['AddressCountry']; $customerData['user'] = $userId; $modelCustomer->store($customerData); $customerId = $customerData['id']; $orderData['customer'] = $customerId; } $pmId = $modelPaymentMethods->getIdFromNameId('BYINVOICE'); // TODO // Aqui se deberia de crear un useraddress y enlazarlo con el pedido $controller->_paymentsuccess(array($orderId),$pmId,0,$userId); if ($params['OrderType']=='wellness') { $modelOrder->_item = null; $modelOrder->setAction('MARKASGOOD'); } $orderData['delegateDesign'] =0; $orderData['currentStep'] = 1; $orderData['completedSteps'] = 5; $modelOrder->store($orderData); $order =& $modelOrder->getData(); $obj->ErrorCode = 0; $obj->ErrorString ="Order created succesfully"; $obj->ProductionOrderId = $order->id ; $obj->OrderStatus = $order->statename; $ret->returnValue = $obj; $GLOBALS['soapSuccess'] = true; return $ret; } // Creamos el servidor SOAP $server = new soap_server(); //$client->soap_defencoding = 'UTF-8'; // $server->decode_utf8 = false; $server->soap_defencoding = 'UTF-8'; // Configuramos el servicio $serviceName = 'JJSystem'; $server->configureWSDL($serviceName, 'urn:jjsystem_wsdl','http://'.$_SERVER['SERVER_NAME'].'/components/com_vxc/views/soapserver/tmpl/default.php'); $server->wsdl->addSimpleType('OrderType_Type','','simpleType','scalar',array('wellness','individual','custom')); // Anyadimos tipos $server->wsdl->addComplexType('Response','complexType','struct','all','', array( 'ProductionOrderId' => array('name' => 'ProductionOrderId', 'type' => 'xsd:unsignedLong'), 'OrderStatus' => array('name' => 'OrderStatus', 'type' => 'xsd:string'), 'ErrorCode' => array('name' => 'ErrorCode', 'type' => 'xsd:integer'), 'ErrorString' => array('name' => 'ErrorString', 'type' => 'xsd:string') ) ); $server->wsdl->addComplexType('Request','complexType','struct','all','', array( 'OrderType' => array('name' => 'OrderType', 'type' => 'tns:OrderType_Type'), // wellness, individual, custom 'FootType' => array('name'=> 'FootType','type' => 'xsd:string'), // not clear what the values are 'ShoeSizeType' => array('name' =>'ShoeSizeType' , 'type' => 'xsd:string'), // EU , UK , US 'ShoeSize' => array('name' => 'ShoeSize', 'type' => 'xsd:float' ), 'BrandSoleType' => array('name' => 'BrandSoleType' , 'type' => 'xsd:string'), 'BlockColor' => array('name' => 'BlockColor' , 'type' => 'xsd:string'), 'HasPodotrack' => array('name' => 'HasPodotrack' , 'type' => 'xsd:boolean'), 'HasFoambox' => array('name' => 'HasFoambox' , 'type' => 'xsd:boolean'), 'Weight' => array('name' => 'Weight', 'type' => 'xsd:nonNegativeInteger'), 'Activity' => array('name' => 'Activity', 'type' => 'xsd:string'), 'ShoeType' => array('name' => 'ShoeType', 'type' => 'xsd:string'), 'Cover' => array('name' => 'Cover', 'type' => 'xsd:string'), 'CustomerName' => array('name' => 'CustomerName', 'type' => 'xsd:string'), 'CustomerStoreId' => array('name' => 'CustomerStoreId', 'type' => 'xsd:string'), 'Quantity' => array('name' => 'Quantity', 'type' => 'xsd:nonNegativeInteger'), 'AddressStreet' => array('name' => 'AddressStreet', 'type' => 'xsd:string'), 'AddressProvince' => array('name' => 'AddressProvince', 'type' => 'xsd:string'), 'AddressPCode' => array('name' => 'AddressPCode', 'type' => 'xsd:string'), 'AddressCountry' => array('name' => 'AddressCountry', 'type' => 'xsd:string'), 'AccessNumber' => array('name' => 'AccessNumber', 'type' => 'xsd:string') ) ); // Registramos las funciones publicas de SOAP $server->register('createJJOrder', array('request' => 'tns:Request'), array('returnValue' => 'tns:Response'), $serviceName, $serviceName .'#createJJOrder', 'document', 'literal', 'Returns the data for a newly created order' ); // Obtenemos la peticion $POST raw $rawPost = strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0? (isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input")) : NULL; //@file_put_contents($_SERVER['DOCUMENT_ROOT'].'/components/com_vxc/soap.log', $rawPost, FILE_APPEND); // Lanzamos el motor del servidor SOAP $server->service($rawPost); if (isset($_SERVER['QUERY_STRING'])) { $qs = $_SERVER['QUERY_STRING']; } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $qs = $HTTP_SERVER_VARS['QUERY_STRING']; } else { $qs = ''; } if (preg_match('/wsdl/', $qs)===0) { JJCorneSOAPHelper::log("SOAP SERVER REQUEST RECEIVED",$GLOBALS['soapSuccess'],$GLOBALS['soapOrderId'],$server->request, $server->response); } ?>