73 'account'=>array(
'0'=>array(
'1'),
'1'=>array(
'2')),
74 'activitypointer'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3'),
'3'=>array(
'4')),
75 'appointment'=>array(
'0'=>array(
'1',
'2',
'3',
'4'),
'1'=>array(
'1',
'2',
'3',
'4'),
'2'=>array(
'1',
'2',
'3',
'4'),
'3'=>array(
'1',
'2',
'3',
'4')),
76 'kbarticle'=>array(
'1'=>array(
'1'),
'2'=>array(
'2'),
'2'=>array(
'3')),
77 'campaign'=>array(
'0'=>array(
'1',
'2',
'3',
'4',
'5')),
78 'campaignactivity'=>array(
'0'=>array(
'0',
'0',
'4',
'5',
'6'),
'1'=>array(
'2'),
'2'=>array(
'3')),
79 'campaignresponse'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3')),
80 'incident'=>array(
'0'=>array(
'1',
'2',
'3',
'4'),
'1'=>array(
'5'),
'2'=>array(
'6')),
81 'incidentresolution'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3')),
82 'notcustomizable'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3')),
83 'contact'=>array(
'0'=>array(
'1'),
'1'=>array(
'2')),
84 'contract'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3'),
'3'=>array(
'4'),
'4'=>array(
'5'),
'5'=>array(
'6')),
85 'contractdetail'=>array(
'0'=>array(
'1'),
'1'=>array(
'2'),
'2'=>array(
'3'),
'3'=>array(
'4')),
86 'transactioncurrency'=>array(
'0'=>array(
'0'),
'1'=>array(
'1')),
87 'discounttype'=>array(
'0'=>array(
'100001'),
'1'=>array(
'100002')),
88 'email'=>array(
'0'=>array(
'1',
'8'),
'1'=>array(
'2',
'3',
'4',
'6',
'7'),
'2'=>array(
'5')),
89 'fax'=>array(
'0'=>array(
'1'),
'1'=>array(
'2',
'3',
'4'),
'2'=>array(
'5')),
90 'invoice'=>array(
'0'=>array(
'1',
'2',
'4',
'5',
'6'),
'1'=>array(
'3',
'7'),
'2'=>array(
'100001',
'100002'),
'2'=>array(
'100003')),
91 'lead'=>array(
'0'=>array(
'1',
'2'),
'1'=>array(
'3'),
'2'=>array(
'4',
'5',
'6',
'7')),
92 'letter'=>array(
'0'=>array(
'1',
'2'),
'1'=>array(
'3',
'4'),
'2'=>array(
'5')),
93 'list'=>array(
'0'=>array(
'0'),
'1'=>array(
'1')),
94 'opportunity'=>array(
'0'=>array(
'1',
'2'),
'1'=>array(
'3'),
'2'=>array(
'4',
'5')),
95 'salesorder'=>array(
'0'=>array(
'1',
'2'),
'1'=>array(
'3'),
'2'=>array(
'4'),
'3'=>array(
'100001',
'100002'),
'4'=>array(
'100003')),
96 'phonecall'=>array(
'0'=>array(
'1'),
'1'=>array(
'2',
'4'),
'2'=>array(
'3')),
97 'pricelevel'=>array(
'0'=>array(
'100001'),
'1'=>array(
'100002')),
98 'product'=>array(
'0'=>array(
'1'),
'1'=>array(
'2')),
99 'quote'=>array(
'0'=>array(
'1'),
'1'=>array(
'2',
'2'),
'2'=>array(
'4',
'5'),
'3'=>array(
'5',
'6',
'7')),
100 'serviceappointment'=>array(
'0'=>array(
'1',
'2'),
'1'=>array(
'8'),
'2'=>array(
'9',
'10'),
'3'=>array(
'3',
'4',
'6',
'7')),
101 'task'=>array(
'0'=>array(
'2',
'3',
'4',
'7'),
'1'=>array(
'5'),
'2'=>array(
'6'))
103 private $Aggregate = array (
'avg',
'max',
'min',
'sum',
'count',
'countcolumn',
'countdistinct');
105 '0'=>array(
'eq-userid',
'ne-userid',
'eq-bysinessid',
'ne-bysinessid',
106 'eq-userteams',
'last-seven-days',
'last-fiscal-period',
'last-fiscal-year',
'last-month',
107 'last-week',
'last-year',
'next-seven-days',
'next-fiscal-period',
'next-fiscal-year',
'next-month',
'next-week',
108 'next-year',
'null',
'this-fiscal-period',
'this-fiscal-year',
'this-month',
'this-week',
'this-year',
'today',
'not-null',
'tomorrow',
'yesterday') ,
109 '1'=>array(
'like',
'not-like',
'eq',
'ge',
'gt',
'le',
'lt',
'ne',
'on',
'on-or-after',
'on-or-before',
110 'in-fiscal-period',
'in-fiscal-year',
'last-x-days',
'last-x-fiscal-periods',
'last-x-fiscal-years',
'last-x-hours',
111 'last-x-months',
'last-x-weeks',
'last-x-years',
'next-x-days',
'next-x-fiscal-periods',
'next-x-fiscal-years',
112 'next-x-hours',
'next-x-months',
'next-x-weeks',
'next-x-years',
'olderthan-x-months') ,
113 '2'=> array(
'not-in',
'in'),
114 '3'=> array(
'between',
'not-between',
'in-fiscal-period-and-year',
'in-or-after-fiscal-period-and-year',
'in-or-before-fiscal-period-and-year')
210 $SoapEnvelope =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:con="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
213 <ser:entityName>' . $Table .
'</ser:entityName>
214 <ser:id>' . $Id .
'</ser:id>';
216 $SoapEnvelope .=
'</ser:Retrieve>
221 Return $this->
call (
'Retrieve', $SoapEnvelope );
249 public function RetrieveMultiple($Table, $Where, $Columns=
false, $Join =
false, $Order =
false) {
251 if (is_array ( $Columns )) {
263 $Filter = $this->formatFetchFilter ( $Where );
264 if ($Join !==
false){
267 }
catch ( Exception $e ) {
271 $SoapEnvelope =
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
273 <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
274 <query i:type="a:FetchExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
276 <fetch version=\'1.0\' output-format=\'xml-platform\' mapping=\'logical\' aggregate=\'' .
$Aggregate .
'\' distinct=\
'false\'>';
277 $SoapEnvelope.=$Entity.$Attributes.$Order.$Filter.$Join;
280 $SoapEnvelope .=
'</entity>
290 Return $this->
call (
'RetrieveMultiple', $SoapEnvelope );
312 $SoapEnvelope =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
316 <ser:entityName>' . $Table .
'</ser:entityName>
317 <ser:id>' . $Id .
'</ser:id>
322 Return $this->
call (
'Delete', $SoapEnvelope );
352 }
catch ( Exception $e ) {
356 $SoapEnvelope =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
357 <soap:Body><Update xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
358 <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
359 <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
362 <b:EntityState i:nil="true"/>
363 <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
364 <b:Id>' . $Id .
'</b:Id>
365 <b:LogicalName>' . $Table .
'</b:LogicalName>
366 <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
371 return $this->
call (
'Update', $SoapEnvelope );
406 public function Create($Table, $Params) {
409 }
catch ( Exception $e ) {
412 $SoapEnvelope =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
414 <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
415 <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
416 <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
419 <b:EntityState i:nil="true"/>
420 <b:FormattedValues />
421 <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
422 <b:LogicalName>' . $Table .
'</b:LogicalName>
423 <b:RelatedEntities />
424 </entity></Create></soap:Body>
426 return $this->
call (
'Create', $SoapEnvelope );
443 public function SetState($Id, $Table, $StateCode, $StatusCode) {
444 if (isset ( $this->StateCheck [$Table] [$StateCode] ) && in_array ( $StatusCode, $this->StateCheck [$Table] [$StateCode] )) {
446 $Request =
'<request i:type="b:SetStateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
447 <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
448 <a:KeyValuePairOfstringanyType>
449 <c:key>EntityMoniker</c:key>
450 <c:value i:type="a:EntityReference">
451 <a:Id>' . $Id .
'</a:Id>
452 <a:LogicalName>' . $Table .
'</a:LogicalName>
453 <a:Name i:nil="true" />
455 </a:KeyValuePairOfstringanyType>
456 <a:KeyValuePairOfstringanyType>
458 <c:value i:type="a:OptionSetValue">
459 <a:Value>' . $StateCode .
'</a:Value>
461 </a:KeyValuePairOfstringanyType>
462 <a:KeyValuePairOfstringanyType>
463 <c:key>Status</c:key>
464 <c:value i:type="a:OptionSetValue">
465 <a:Value>' . $StatusCode .
'</a:Value>
467 </a:KeyValuePairOfstringanyType></a:Parameters>
468 <a:RequestId i:nil="true" />
469 <a:RequestName>SetState</a:RequestName>
473 $strPair = print_r ( $this->StateCheck [$Table],
true );
474 return $this->
GetErrorObject (
'Pair State and status not avaible for ' . $Table .
' should be in State => array( avaible status) : ' . $strPair );
485 $Request =
'<request i:type="a:RetrieveAllEntitiesRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
486 <a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
487 <a:KeyValuePairOfstringanyType>
488 <b:key>EntityFilters</b:key>
489 <b:value i:type="c:EntityFilters" xmlns:c="http://schemas.microsoft.com/xrm/2011/Metadata">Privileges</b:value>
490 </a:KeyValuePairOfstringanyType>
491 <a:KeyValuePairOfstringanyType>
492 <b:key>RetrieveAsIfPublished</b:key>
493 <b:value i:type="c:boolean" xmlns:c="http://www.w3.org/2001/XMLSchema">true</b:value>
494 </a:KeyValuePairOfstringanyType>
496 <a:RequestId i:nil="true" />
497 <a:RequestName>RetrieveAllEntities</a:RequestName>
516 $Request =
'<request i:type="b:ExecuteWorkflowRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
517 <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
518 <a:KeyValuePairOfstringanyType>
519 <c:key>EntityId</c:key>
520 <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">$EntityId</c:value>
521 </a:KeyValuePairOfstringanyType>
522 <a:KeyValuePairOfstringanyType>
523 <c:key>WorkflowId</c:key>
524 <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">$WorkflowId</c:value>
525 </a:KeyValuePairOfstringanyType>
527 <a:RequestId i:nil="true" />
528 <a:RequestName>ExecuteWorkflow</a:RequestName>
531 $Return = $this->
ParseDatas ( $Return->Result->Body->ExecuteResponse->ExecuteResult->Results, $Return );
540 $SoapEnvelope =
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
542 <Associate xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
547 <parentObjectType>10095</parentObjectType>
548 <objectId>568B31F9-8AEE-E211-8830-005056B74E4F</objectId>
549 <parentId>A5DF8846-3BF0-E211-8830-005056B74E4F</parentId>
550 <associationName>classification_occupation</associationName>
551 </Associate></soap:Body>
553 return $this->
call (
'Associate', $SoapEnvelope );
574 public function Assign($Table,$Id,$IdAssign,$TypeAssign=
'systemuser'){
575 $Request =
'<request i:type="b:AssignRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
576 <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
577 <a:KeyValuePairOfstringanyType>
578 <c:key>Target</c:key>
579 <c:value i:type="a:EntityReference">
581 <a:LogicalName>'.$Table.
'</a:LogicalName>
582 <a:Name i:nil="true" />
584 </a:KeyValuePairOfstringanyType>
585 <a:KeyValuePairOfstringanyType>
586 <c:key>Assignee</c:key>
587 <c:value i:type="a:EntityReference">
588 <a:Id>'.$IdAssign.
'</a:Id>
589 <a:LogicalName>'.$TypeAssign.
'</a:LogicalName>
590 <a:Name i:nil="true" />
592 </a:KeyValuePairOfstringanyType>
594 <a:RequestId i:nil="true" />
595 <a:RequestName>Assign</a:RequestName>
599 if(isset( $Response->Error) && $Response->Error===
true){
603 $Return->Error =
false;
604 $Return->ErrorCode =
false;
605 $Return->ErrorMessage =
'';
606 $Return->NbResult =1 ;
607 $Return->Result=
true;
617 $Request =
'<request i:type="b:WhoAmIRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
618 <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
619 <a:RequestId i:nil="true" />
620 <a:RequestName>WhoAmI</a:RequestName>
624 $Return = $this->
ParseDatas ( $Return->Result->Body->ExecuteResponse->ExecuteResult->Results, $Return );
636 $SoapEnvelope =
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
638 <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
643 return $this->
call (
'Execute', $SoapEnvelope );
655 private function call($operation, $soapBody) {
659 curl_setopt ( $ch, CURLOPT_URL, $this->serv_adress );
660 curl_setopt ( $ch, CURLOPT_RETURNTRANSFER,
true );
661 curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
662 curl_setopt ( $ch, CURLOPT_UNRESTRICTED_AUTH,
true);
663 curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION,
true);
664 curl_setopt ( $ch, CURLOPT_POST,
true );
665 curl_setopt ( $ch, CURLOPT_POSTFIELDS, $soapBody );
666 curl_setopt ( $ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM );
667 curl_setopt ( $ch, CURLOPT_USERPWD, $this->user .
':' . $this->password );
668 $response = curl_exec ( $ch );
670 if ($response ===
false) {
671 $Return->Error = True;
672 $Return->ErrorCode = 0;
673 $Return->ErrorMessage = curl_error ( $ch );
674 $Return->Result = False;
677 $response = str_replace (
'<a:',
'<', $response );
678 $response = str_replace (
'<b:',
'<', $response );
679 $response = str_replace (
'<c:',
'<', $response );
680 $response = str_replace (
'<s:',
'<', $response );
681 $response = str_replace (
'</a:',
'</', $response );
682 $response = str_replace (
'</b:',
'</', $response );
683 $response = str_replace (
'</c:',
'</', $response );
684 $response = str_replace (
'</s:',
'</', $response );
685 $xml = simplexml_load_string ( $response );
686 if (isset ( $xml->Body->Fault )) {
687 $Return->Error = True;
688 $Return->ErrorCode = ( string ) $xml->Body->Fault->faultcode;
689 $Return->ErrorMessage = (
string ) $xml->Body->Fault->faultstring;
690 $Return->Result = False;
692 switch ($operation) {
693 case 'RetrieveMultiple' :
700 $Return->NbResult = 1;
701 $Return->Result = ( string ) $xml->Body->CreateResponse->CreateResult;
704 if (isset ( $xml->Body->UpdateResponse )) {
705 $Return->NbResult = 1;
706 $Return->Result =
true;
708 $Return->Error = True;
709 $Return->ErrorCode =
'Unknown Error';
710 $Return->ErrorMessage =
'Unknown Error';
714 $Return->NbResult = 1;
715 $Return->Result = $xml;
718 die ( print_r ( $xml ) );
721 if (isset ( $xml->Body->DeleteResponse )) {
722 $Return->NbResult = 1;
723 $Return->Result =
true;
725 $Return->Error = True;
726 $Return->ErrorCode =
'Unknown Error';
727 $Return->ErrorMessage =
'Unknown Error';
744 return " <entity name='" . $EntityName .
"'>";
777 if (is_array ( $Columns )) {
778 foreach ( $Columns as $column ) {
779 if (is_array ( $column )) {
782 if (isset ( $column [
'name'] )) {
783 if (empty ( $column [
'alias'] )) {
784 $column [
'alias'] = $column [
'name'];
787 if (! empty ( $column [
'aggregate'] )) {
789 if ($column [
'aggregate'] ==
'countdistinct') {
790 $Attributes .=
"<attribute name='" . $column [
'name'] .
"' alias='" . $column [
'alias'] .
"' aggregate='countcolumn' distinct='true' />";
792 $Attributes .=
"<attribute name='" . $column [
'name'] .
"' alias='" . $column [
'alias'] .
"' aggregate='" . $column [
'aggregate'] .
"' />";
795 }
else if (isset ( $column [
'groupby'] )) {
797 if (isset ( $column [
'alias'] )) {
798 if ($column [
'groupby'] !==
true) {
799 $Attributes .=
"<attribute name='" . $column [
'name'] .
"' alias='" . $column [
'alias'] .
"' dategrouping='" . $column [
'groupby'] .
"' groupby='true' />";
801 $Attributes .=
"<attribute name='" . $column [
'name'] .
"' alias='" . $column [
'alias'] .
"' groupby='true' />";
808 $Attributes .=
"<attribute name='" . $column .
"' />";
859 if (is_array ( $Params )) {
860 foreach ( $Params as $Param ) {
864 return $TxtAttribute;
892 if (isset ( $Param [
'field'] ) && isset ( $Param [
'type'] )) {
893 $TxtAttribute .=
'<b:KeyValuePairOfstringanyType>
894 <c:key>' . $Param [
'field'] .
'</c:key>';
895 switch ($Param [
'type']) {
896 case 'OptionSetValue' :
897 case 'optionsetvalue' :
901 $TxtAttribute .=
'<c:value i:type="b:OptionSetValue"><b:Value>' . $Param [
'value'] .
'</b:Value></c:value>';
906 $TxtAttribute .=
'<c:value i:type="b:Money"><b:value>' . $Param [
'value'] .
'</b:value></c:value>';
913 $TxtAttribute .=
'<c:value i:type="d:boolean" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $Param [
'value'] .
'</c:value>';
920 $TxtAttribute .=
'<c:value i:type="d:int" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $Param [
'value'] .
'</c:value>';
925 $TxtAttribute .=
'<c:value i:type="d:dateTime" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $Param [
'value'] .
'</c:value>';
931 $TxtAttribute .=
'<c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">' . $Param [
'value'] .
'</c:value>';
933 case 'EntityReference' :
934 case 'entityreference' :
938 $TxtAttribute .=
'<c:value i:type="b:EntityReference">
939 <b:Id>' . $Param [
'id'] .
'</b:Id>
940 <b:LogicalName>' . $Param [
'name'] .
'</b:LogicalName>
941 <b:Name i:nil="true" />
944 case 'ActivityParty' :
946 case 'activityparty' :
948 case 'ArrayOfEntity' :
949 case 'arrayofentity' :
952 $TxtAttribute .=
'<c:value i:type="b:ArrayOfEntity">';
954 foreach ( $Param [
'value'] as $entity ) {
955 $TxtAttribute .=
' <b:Entity>
958 $TxtAttribute .=
'</b:Attributes><b:Entitystate i:nil="true" />
959 <b:FormattedValues />
960 <b:Id>00000000-0000-0000-0000-000000000000</b:Id>
961 <b:LogicalName>activityparty</b:LogicalName>
962 <b:RelatedEntities />
970 $TxtAttribute .=
'</b:KeyValuePairOfstringanyType>';
973 return $TxtAttribute;
980 foreach ( $Fields as $Field ) {
991 if (! isset ( $Param [$field] )) {
992 $strArray = print_r ( $Param,
true );
993 throw new \InvalidArgumentException ( sprintf (
"Missing Parameter $field for array : $strArray" ) );
1002 if (! in_array ( $Param, $this->Aggregate )) {
1003 $AggregateValue = print_r ( $this->Aggregate,
true );
1004 throw new \InvalidArgumentException ( sprintf (
"Aggregate Invalid should be in : $AggregateValue" ) );
1014 $Return->Error = True;
1015 $Return->ErrorCode = 0;
1016 $Return->ErrorMessage = $message;
1017 $Return->Result = False;
1033 if ($Columns !==
false && ! is_array ( $Columns )) {
1034 throw new \InvalidArgumentException ( sprintf (
"Column Parameter invalid : $Columns" ) );
1036 $AllCol = ($Columns ==
false) ?
'true' :
'false';
1037 $TxtColumn =
'<ser:columnSet><con:AllColumns>' . $AllCol .
'</con:AllColumns><con:Columns>';
1038 if ($Columns !=
false) {
1039 foreach ( $Columns as $Column ) {
1040 $TxtColumn .=
'<arr:string>' . $Column .
'</arr:string>';
1043 $TxtColumn .=
'</con:Columns></ser:columnSet>';
1066 if (is_array ( $Orders )) {
1067 foreach ( $Orders as $Order ) {
1069 if (isset ( $Order [
'Column'] ) && isset ( $Order [
'Order'] )) {
1070 $TxtOrder .=
"<order attribute='" . $Order [
'Column'] .
"' descending='";
1071 $TxtOrder .= ($Order [
'Order'] ==
'Asc') ?
'false' :
'true';
1072 $TxtOrder .=
"' />";
1123 if (is_array ( $Filters )) {
1124 if (isset ( $Filters [
'Type'] )) {
1125 $TxtHead =
"<filter type='" . $Filters [
'Type'] .
"' >";
1127 $TxtHead =
'<filter >';
1129 foreach ( $Filters as $Filter ) {
1130 if (isset ( $Filter [
'Type'] )) {
1133 if (isset ( $Filter [
'Op'] )) {
1139 $TxtFilter=$TxtHead.$TxtFilter.
'</filter >';
1174 if (isset ( $Joins [
'name'] )) {
1179 foreach ( $Joins as $Join ) {
1180 $this->
TestParameters($Join,array(
'name',
'from',
'to',
'type',
'columns',
'where'));
1181 $TxtJoin .=
"<link-entity name='" . $Join [
'name'] .
"' from='" . $Join [
'from'] .
"' to='" . $Join [
'to'] .
"' ";
1182 if (! empty ( $Join [
'alias'] )){
1183 $TxtJoin .=
" alias='" . $Join [
'alias'] .
"' ";
1185 $TxtJoin .=
" link-type='" . $Join [
'type'] .
"' >";
1187 if (! empty ( $Join [
'nested'] ))
1189 $TxtJoin .= $this->formatFetchFilter ( $Join [
'where'] );
1190 $TxtJoin .=
"</link-entity>";
1214 if (in_array ( $Filter [
'Op'], $this->Operator [
'0'] )) {
1215 $Condition =
"<condition attribute='" . $Filter [
'Column'] .
"' operator='" . $Filter [
'Op'] .
"' />";
1220 }
else if (in_array ( $Filter [
'Op'], $this->Operator [
'1'] )) {
1225 $Condition =
"<condition attribute='" . $Filter [
'Column'] .
"' operator='" . $Filter [
'Op'] .
"' value='" . $Filter [
'Value'] .
"' />";
1230 }
else if (in_array ( $Filter [
'Op'], $this->Operator [
'2'] )) {
1235 $Condition =
"<condition attribute='" . $Filter [
'Column'] .
"' operator='" . $Filter [
'Op'] .
"' >";
1236 if (! is_array ( $Filter [
'Value'] )) {
1237 $TxtFilter = print_r ( $Filter,
true );
1238 throw new \InvalidArgumentException ( sprintf (
"Filter Incorrect [Value] for this kind of operator should be an array : $TxtFilter" ) );
1240 foreach ( $Filter [
'Value'] as $Value ) {
1241 $Condition .=
'<value>' . $Value .
'</value>';
1243 $Condition .=
'</condition >';
1248 }
else if (in_array ( $Filter [
'Op'], $this->Operator [
'3'] )) {
1253 $Condition =
"<condition attribute='" . $Filter [
'Column'] .
"' operator='" . $Filter [
'Op'] .
"' >";
1254 $Condition .=
'<value>' . $Filter [
'Value'] .
'</value> <value>' . $Filter[
1256 ] .
'</value>';
1257 $Condition .=
'</condition >';
1259 $ListOperator = print_r ( $this->Operator,
true );
1260 throw new \InvalidArgumentException ( sprintf (
"Condition '" . $Filter [
'Op'] .
"' Invalid should be in : $ListOperator" ) );
1276 $Datas = $xml->Body->RetrieveMultipleResponse->RetrieveMultipleResult->Entities->Entity;
1277 $Return = $this->
ParseDatas ( $Datas, $Return );
1292 $Results = array ();
1293 foreach ( $Datas as $Data ) {
1295 $Results [$NbResults] = $ResultLine;
1298 $Return->NbResult = $NbResults;
1299 $Return->Result = $Results;
1312 $ResultLine = new \stdClass ();
1313 if (isset ( $Data->Attributes )) {
1314 foreach ( $Data->Attributes as $keypair ) {
1315 foreach ( $keypair->KeyValuePairOfstringanyType as $data ) {
1316 $key = str_ireplace (
'.',
'_', $data->key );
1322 foreach ( $Data as $data ) {
1323 if (isset ( $data->key )) {
1324 $key = str_ireplace (
'.',
'_', $data->key );
1338 if (isset ( $data->value->Value )) {
1339 $value = ( string ) $data->value->Value;
1341 }
else if (isset ( $data->value->LogicalName )) {
1343 'id' => (
string ) $data->value->Id,
1344 'logicalname' => (
string ) $data->value->LogicalName,
1345 'name' => (
string ) $data->value->Name
1347 }
else if (isset ( $data->value->Entities )) {
1348 $Entities = array ();
1349 foreach ( $data->value->Entities as $entity ) {
1350 if (isset ( $entity->Entity->Attributes )) {
1357 $value = ( string ) $data->value;
1359 if (! is_array ( $value )) {
1360 if (ctype_digit ( $value )) {
1361 return (
int ) $value;
1362 }
else if (is_float ( $value )) {
1363 return (
float ) $value;
1364 }
else if (is_bool ( $value )) {
1365 return (
bool ) $value;
1382 $Datas = $xml->Body->RetrieveResponse->RetrieveResult;
1383 $Return = $this->
ParseDatas ( $Datas, $Return );
1384 $Return->Result = $Return->Result [0];
1396 $soap_action =
'http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/' . $operation;
1400 'Connection: Keep-Alive',
1401 'User-Agent: PHP-SOAP-CURL',
1402 'Content-Type: text/xml; charset=utf-8',
1403 'SOAPAction: "' . $soap_action .
'"'
1418 $result = array_key_exists ( $needle, $haystack );
1421 foreach ( $haystack as $v ) {
1422 if (is_array ( $v ) || is_object ( $v ))
array_key_exists_r($needle, $haystack)
ParseDatas($Datas, $Return)
FormatFetchAttribute($Columns)
call($operation, $soapBody)
Assign($Table, $Id, $IdAssign, $TypeAssign='systemuser')
__construct($serv_adress, $user, $password)
RetrieveMultiple($Table, $Where, $Columns=false, $Join=false, $Order=false)
SetState($Id, $Table, $StateCode, $StatusCode)
ParseRetrieve($xml, $Return)
setServAdress($serv_adress)
ParseRetrieveMultiple($xml, $Return)
TestParameter($Param, $field)
GenerateSoapHeader($operation)
FormatFetchOrder($Orders)
Retrieve($Table, $Id, $Columns)
TestParameters($Param, $Fields)
Workflow($EntityId, $WorkflowId)
FormatAttributes($Params)
Result object for DynamicCRM.
FormatFetchFilter($Filters)
Update($Table, $Params, $Id)
FormatFetchEntity($EntityName)