When i try to send this request then i get error "id: 0 500 Internal Server Error - SoapFault".
My request:
$client = new SoapClient( 'xxx', array('trace' => 1));
$client -> soap_defencoding = 'utf-8';
$client -> decode_utf8 = FALSE;
$a = array( 'user_name' => 'xx', 'user_password' => 'xx' );
$response = $client->__soapCall( 'adeLogin', $a );
$session = get_object_vars($response)['session'];
$aCPrep = array(
'rname1' => 'Pan',
'rname2' => 'Jan',
'rname3' => 'test',
'rcountry' => 'PL',
'rzipcode' => '00-950',
'rcity' => 'Warszawa',
'rstreet' => 'ul. Kwieciska 15',
'quantity' => '1',
'rphone' => '1500-100-900',
'rcontact' => 'Antoni',
'weight' => '100',
'date' => '2012-01-01',
'references' => 'by WebAPI ',
'notes' => 'by Thomi (thest 4)',
'srv_ade' => 'asd',
'pfc' => 'Magazyn',
'sendaddr' => array( 'name1' => 'Firma z Francji', 'name2' => 'firma', 'name3' => 'firma2','country' => 'FR', 'zipcode' => '14117', 'city' => 'Arromanches', 'street' => 'Pl. du Six Juin 1944' ),
'srv_daw' => array( 'name' => '','building' => '','floor' => '','room' => '','phone' => '','altrec' => ''),
'srv_ident' => array( 'name' => '','country' => '','zipcode' => '','city' => '','street' => '','nation' => '','date_birth' => '','identity' => '','ident_doctype' => '','spages' => '','ssign' => '','sdealsend' => '','sdealrec' => ''),
'srv_ppe' => array( 'sname1' => '','sname2' => '','sname3' => '','scountry' => '','szipcode' => '','scity' => '','sstreet' => '','sphone' => '','scontact' => '','rname1' => '','rname2' => '','rname3' => '','rcountry' => '','rzipcode' => '','rcity' => '','rstreet' => '','rphone' => '','rcontact' => '','references' => '','weight' => ''),
'srv_bool' => array( 'cod' => '1', 'cod_amount' => '200', 'exw' => '0', 'rod' => '0', 'pod' => '0', 'exc' => '0','ident' => '0','daw' => '0','ps' => '0','pr' => '0','s10' => '0','s12' => '0','sat' => '0','ow' => '0','srs' => '0',),
'parcels' => array( '0' => array( 'weight' => '15', 'reference' => 'paczka duza','number' => '','srv_ade' => '', 'srv_bool' => array( 'cod' => '1', 'cod_amount' => '200', 'exw' => '0', 'rod' => '0', 'pod' => '0', 'exc' => '0','ident' => '0','daw' => '0','ps' => '0','pr' => '0','s10' => '0','s12' => '0','sat' => '0','ow' => '0','srs' => '0')))
);
$aCMsg = array( 'session' => $session, 'consign_prep_data' => $aCPrep );
$aClient = $client->__soapCall( 'adePreparingBox_Insert', $aCMsg );
It is error from my soap server or from symfony ? Anybody know what is wrong ?
How can i show the XML ?
it's response from SOAP server
Try
echo "REQUEST:\n".$client->__getLastRequest()."\n";
echo "RESPONSE:\n".$client->__getLastResponse()."\n";
Related
I have Freeswitch server sending CDR information (A leg only) in JSON to PHP script and I need to parse extension and phone number in every scenario possible:
Incoming call from PSTN to: user, group, callcenter app (answered, un-answered)
Outgoing call to PSTN from user (answered, un-answered)
Each scenario have to use different variable in the JSON - depends if was bridged or not, if it's incoming (destination_number), if it's outgoing (caller_id_number), etc.
I was using bridge_uuid to detect if the call was bridged, but still got calls where bridge_uuid is missing and last_app is bridge (with status ORIGINATOR_CANCEL).
I put together 7 scenarios, but still there are calls, where phone number appear in extension for some reason and vice-versa.
Is there any simple way to get this information from CDR?
SCENARIO 1:
outbound
bridge_uuid = exists
extension = callflow.0.caller_profile.caller_id_number
number = callflow.0.caller_profile.destination_number
SCENARIO 2:
outbound
bridge_uuid = not exists
extension = callflow.0.caller_profile.destination_number
number = callflow.0.caller_profile.caller_id_number
SCENARIO 3:
outbound
bridge_uuid = not exists
last_app = bridge
extension = callflow.0.caller_profile.caller_id_number
number = callflow.0.caller_profile.destination_number
SCENARIO 4:
inbound
bridge_uuid = exists
cc_agent_bridged = exists
extension = callflow.0.caller_profile.originatee.originatee_caller_profiles.0.destination_number
number = callflow.0.caller_profile.caller_id_number
SCENARIO 5:
inbound
bridge_uuid = exists
cc_agent_bridged = not exists
extension = callflow.0.caller_profile.caller_id_number
number = callflow.0.caller_profile.destination_number
SCENARIO 6:
inbound
bridge_uuid = not exists
extension = NULL
number = callflow.0.caller_profile.caller_id_number
SCENARIO 7:
inbound
bridge_uuid = exists
cc_agent_bridged = not exists
extension = ???
number = ???
JSON CDR
'core-uuid' => 'bf6eef3c-16b7-4f61-8cc2-1cd73460268e',
'switchname' => 'freeswitch',
'channel_data' =>
array (
'state' => 'CS_REPORTING',
'direction' => 'outbound',
'state_number' => '11',
'flags' => '0=1;2=1;22=1;40=1;42=1;45=1;116=1;117=1',
'caps' => '1=1;2=1;3=1;4=1;5=1;6=1;8=1;9=1;10=1',
),
'callStats' =>
array (
),
'variables' =>
array (
'direction' => 'outbound',
'is_outbound' => 'true',
'uuid' => 'c9aa9f5f-7afd-46af-8cca-2af25b758aec',
'call_uuid' => 'c9aa9f5f-7afd-46af-8cca-2af25b758aec',
'session_id' => '4755',
'sip_profile_name' => 'homeoffice',
'video_media_flow' => 'disabled',
'text_media_flow' => 'disabled',
'channel_name' => 'sofia/homeoffice/4012%40XXX.XXX.XXX.XXX%3A56955',
'sip_destination_url' => 'sip%3A4012%40XXX.XXX.XXX.XXX%3A56955%3Btransport%3DUDP%3Brinstance%3D845ce1bf3f9efbf1%3Bfs_nat%3Dyes%3Bfs_path%3Dsip%3A4012%40XXX.XXX.XXX.XXX%3A56955%3Btransport%3DUDP%3Brinstance%3D845ce1bf3f9efbf1',
'origination_caller_id_name' => 'Name%20Surname',
'origination_caller_id_number' => '1829XXXXXXX',
'EXT_ID' => '163748',
'USER_ID' => '793',
'ID_TYPE' => 'application',
'callgroup' => 'local',
'dialed_user' => '4012',
'dialed_domain' => 'pbx.domain.com',
'sip_invite_domain' => 'pbx.domain.com',
'presence_id' => '4012%40pbx.domain.com',
'originate_early_media' => 'true',
'rtp_use_codec_string' => 'OPUS,G729,PCMU,PCMA,GSM',
'local_media_ip' => 'XXX.XXX.XXX.XXX',
'local_media_port' => '17432',
'advertised_media_ip' => 'XXX.XXX.XXX.XXX',
'audio_media_flow' => 'sendrecv',
'rtp_local_sdp_str' => 'v%3D0%0D%0Ao%3DFreeSWITCH%201646156158%201646156159%20IN%20IP4%20XXX.XXX.XXX.XXX%0D%0As%3DFreeSWITCH%0D%0Ac%3DIN%20IP4%20XXX.XXX.XXX.XXX%0D%0At%3D0%200%0D%0Am%3Daudio%2017432%20RTP/AVP%20102%2018%200%208%203%20103%20101%0D%0Aa%3Drtpmap%3A102%20opus/48000/2%0D%0Aa%3Dfmtp%3A102%20useinbandf
ec%3D1%3B%20maxaveragebitrate%3D30000%3B%20maxplaybackrate%3D48000%3B%20ptime%3D20%3B%20minptime%3D10%3B%20maxptime%3D40%0D%0Aa%3Drtpmap%3A18%20G729/8000%0D%0Aa%3Dfmtp%3A18%20annexb%3Dno%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A8%20PCMA/8000%0D%0Aa%3Drtpmap%3A3%20GSM/8000%0D%0Aa%3Drtpmap%3A103%20telephone-e
vent/48000%0D%0Aa%3Dfmtp%3A103%200-15%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dfmtp%3A101%200-15%0D%0Aa%3Dptime%3A20%0D%0Aa%3Dsendrecv%0D%0A',
'sip_outgoing_contact_uri' => '%3Csip%3Amod_sofia%40XXX.XXX.XXX.XXX%3A5090%3E',
'sip_req_uri' => '4012%40XXX.XXX.XXX.XXX%3A56955%3Btransport%3DUDP%3Brinstance%3D845ce1bf3f9efbf1',
'sip_nat_detected' => 'true',
'sofia_profile_name' => 'office',
'recovery_profile_name' => 'office',
'sofia_profile_url' => 'sip%3Amod_sofia%40XXX.XXX.XXX.XXX%3A5090',
'sip_local_network_addr' => 'XXX.XXX.XXX.XXX',
'sip_reply_host' => 'XXX.XXX.XXX.XXX',
'sip_reply_port' => '56955',
'sip_network_ip' => 'XXX.XXX.XXX.XXX',
'sip_network_port' => '56955',
'sip_user_agent' => 'Z%205.5.9%20v2.10.17.3',
'sip_allow' => 'INVITE,%20ACK,%20CANCEL,%20BYE,%20NOTIFY,%20REFER,%20MESSAGE,%20OPTIONS,%20INFO,%20SUBSCRIBE',
'sip_recover_contact' => '%3Csip%3A4012%40XXX.XXX.XXX.XXX%3A56955%3Btransport%3DUDP%3E',
'sip_full_via' => 'SIP/2.0/UDP%20XXX.XXX.XXX.XXX%3A5090%3Brport%3D5090%3Bbranch%3Dz9hG4bKS6tvm613tKgpg',
'sip_recover_via' => 'SIP/2.0/UDP%20XXX.XXX.XXX.XXX%3A5090%3Brport%3D5090%3Bbranch%3Dz9hG4bKS6tvm613tKgpg',
'sip_from_display' => 'Name%20Surname',
'sip_full_from' => '%22Name%20Surname%22%20%3Csip%3A1829XXXXXXX%40pbx.domain.com%3E%3Btag%3DDc8U2HQFrDQ4D',
'sip_full_to' => '%3Csip%3A4012%40XXX.XXX.XXX.XXX%3A56955%3Btransport%3DUDP%3Brinstance%3D845ce1bf3f9efbf1%3E%3Btag%3De4ab0722',
'sip_from_user' => '1829XXXXXXX',
'sip_from_uri' => '1829XXXXXXX%40pbx.domain.com',
'sip_from_host' => 'pbx.domain.com',
'sip_to_params' => 'transport%3DUDP%3Brinstance%3D845ce1bf3f9efbf1',
'sip_to_user' => '4012',
'sip_to_port' => '56955',
'sip_to_uri' => '4012%40XXX.XXX.XXX.XXX%3A56955',
'sip_to_host' => 'XXX.XXX.XXX.XXX',
'sip_contact_params' => 'transport%3DUDP',
'sip_contact_user' => '4012',
'sip_contact_port' => '56955',
'sip_contact_uri' => '4012%40XXX.XXX.XXX.XXX%3A56955',
'sip_contact_host' => 'XXX.XXX.XXX.XXX',
'sip_to_tag' => 'e4ab0722',
'sip_from_tag' => 'Dc8U2HQFrDQ4D',
'sip_cseq' => '48533003',
'sip_call_id' => '7ba03d12-1451-123b-ff84-ac1f6b94e36c',
'hangup_cause' => 'NO_ANSWER',
'hangup_cause_q850' => '19',
'digits_dialed' => 'none',
'start_stamp' => '2022-03-01%2018%3A26%3A30',
'profile_start_stamp' => '2022-03-01%2018%3A26%3A30',
'progress_stamp' => '2022-03-01%2018%3A26%3A30',
'end_stamp' => '2022-03-01%2018%3A27%3A30',
'start_epoch' => '1646173590',
'start_uepoch' => '1646173590060292',
'profile_start_epoch' => '1646173590',
'profile_start_uepoch' => '1646173590060292',
'answer_epoch' => '0',
'answer_uepoch' => '0',
'bridge_epoch' => '0',
'bridge_uepoch' => '0',
'last_hold_epoch' => '0',
'last_hold_uepoch' => '0',
'hold_accum_seconds' => '0',
'hold_accum_usec' => '0',
'hold_accum_ms' => '0',
'resurrect_epoch' => '0',
'resurrect_uepoch' => '0',
'progress_epoch' => '1646173590',
'progress_uepoch' => '1646173590620111',
'progress_media_epoch' => '0',
'progress_media_uepoch' => '0',
'end_epoch' => '1646173650',
'end_uepoch' => '1646173650000174',
'caller_id' => '%22Name%20Surname%22%20%3C1829XXXXXXX%3E',
'duration' => '60',
'billsec' => '0',
'progresssec' => '0',
'answersec' => '0',
'waitsec' => '0',
'progress_mediasec' => '0',
'flow_billsec' => '0',
'mduration' => '59940',
'billmsec' => '0',
'progressmsec' => '560',
'answermsec' => '0',
'waitmsec' => '0',
'progress_mediamsec' => '0',
'flow_billmsec' => '0',
'uduration' => '59939882',
'billusec' => '0',
'progressusec' => '559819',
'answerusec' => '0',
'waitusec' => '0',
'progress_mediausec' => '0',
'flow_billusec' => '0',
'sip_hangup_disposition' => 'send_cancel',
'sip_invite_failure_status' => '487',
'sip_invite_failure_phrase' => 'CANCEL',
),
'callflow' =>
array (
0 =>
array (
'profile_index' => '1',
'caller_profile' =>
array (
'username' => '',
'dialplan' => '',
'caller_id_name' => 'Name Surname',
'ani' => '1829XXXXXXX',
'aniii' => '',
'caller_id_number' => '1829XXXXXXX',
'network_addr' => 'XXX.XXX.XXX.XXX',
'rdnis' => '',
'destination_number' => '4012',
'uuid' => 'c9aa9f5f-7afd-46af-8cca-2af25b758aec',
'source' => 'src/switch_ivr_originate.c',
'context' => 'default',
'chan_name' => 'sofia/office/4012#XXX.XXX.XXX.XXX:56955',
),
'times' =>
array (
'created_time' => '1646173590060292',
'profile_created_time' => '1646173590060292',
'progress_time' => '1646173590620111',
'progress_media_time' => '0',
'answered_time' => '0',
'bridged_time' => '0',
'last_hold_time' => '0',
'hold_accum_time' => '0',
'hangup_time' => '1646173650000174',
'resurrect_time' => '0',
'transfer_time' => '0',
),
),
),
)
PHP SCRIPT
$data = json_decode($data_above, true);
$bridged = isset($data['variables']['bridge_uuid']);
$callcenter = isset($data['variables']['cc_agent_bridged']);
$direction = $data['variables']['direction'];
$extension = $data['callflow'][0]['caller_profile'];
$extension = match($direction)
{
'inbound'=>match($bridged)
{
true => match($callcenter)
{
true => $extension['originatee']['originatee_caller_profiles'][0]['destination_number'],
false => 'caller_id_number'
},
false => ''
},
'outbound'=>match($bridged)
{
true => 'caller_id_number',
false => $data['variables']['last_app'] == 'bridge' ? 'caller_id_number' : 'destination_number'
}
};
I am facing a problem in PHP OOPS code.
My code is:
class Settings
{
private $client_addr = array(
'ClientID' => array('maxlength'=>'10','IsNull'=>'n'),
'ClientAddressType' => array('maxlength'=>'12','IsNull'=>'y'),
'ClientAddressLine1' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientAddressLine2' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientCounty' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientCity' => array('maxlength'=>'30','IsNull'=>'y'),
'ClientState' => array('maxlength'=>'2','IsNull'=>'y'),
'ClientZip' => array('maxlength'=>'9','IsNull'=>'y'),
);
private $client_general = array(
'PayerID' => array('maxlength'=>'64','IsNull'=>'n'),
'ProviderID' => array('maxlength'=>'50','IsNull'=>'n'),
'ClientID' => array('maxlength'=>'10','IsNull'=>'n'),
'ClientFirstName' => array('maxlength'=>'30','IsNull'=>'n'),
'ClientMiddleInitial' => array('maxlength'=>'1','IsNull'=>'y'),
'ClientLastName' => array('maxlength'=>'30','IsNull'=>'n'),
);
function getSelectedArrayData($setlected_arr)
{
$setlected_arr = '$this->'."$setlected_arr";
print_r($setlected_arr); //it prints a string '$this->client_general'
print_r($this->client_general);//it prints $client_general array data
}
}
$settings = new Settings();
$settings->getSelectedArrayData('client_general');
My problem is:
When I print print_r($this->client_general); it's printed $client_general array that is okay.
Array
(
[PayerID] => Array
(
[maxlength] => 64
[IsNull] => n
)
[ProviderID] => Array
(
[maxlength] => 50
[IsNull] => n
)
[ClientID] => Array
(
[maxlength] => 10
[IsNull] => n
)
[ClientFirstName] => Array
(
[maxlength] => 30
[IsNull] => n
)
[ClientMiddleInitial] => Array
(
[maxlength] => 1
[IsNull] => y
)
[ClientLastName] => Array
(
[maxlength] => 30
[IsNull] => n
)
)
When I print print_r($setlected_arr); It's printed
$this->client_general
I wnat that it should also point to the $client_general array.
How I can do it?
print_r($this->$setlected_arr);
Try this, Its for you.
class Settings {
private $client_addr = array(
'ClientID' => array('maxlength' => '10', 'IsNull' => 'n'),
'ClientAddressType' => array('maxlength' => '12', 'IsNull' => 'y'),
'ClientAddressLine1' => array('maxlength' => '30', 'IsNull' => 'y'),
'ClientAddressLine2' => array('maxlength' => '30', 'IsNull' => 'y'),
'ClientCounty' => array('maxlength' => '30', 'IsNull' => 'y'),
'ClientCity' => array('maxlength' => '30', 'IsNull' => 'y'),
'ClientState' => array('maxlength' => '2', 'IsNull' => 'y'),
'ClientZip' => array('maxlength' => '9', 'IsNull' => 'y'),
);
private $client_general = array(
'PayerID' => array('maxlength' => '64', 'IsNull' => 'n'),
'ProviderID' => array('maxlength' => '50', 'IsNull' => 'n'),
'ClientID' => array('maxlength' => '10', 'IsNull' => 'n'),
'ClientFirstName' => array('maxlength' => '30', 'IsNull' => 'n'),
'ClientMiddleInitial' => array('maxlength' => '1', 'IsNull' => 'y'),
'ClientLastName' => array('maxlength' => '30', 'IsNull' => 'n'),
);
function getSelectedArrayData($setlected_arr) {
$setlected_arr = ${'this'}->${'setlected_arr'};
print_r($setlected_arr); //it prints a string '$this->client_general'
echo '<br/>';
echo '<br/>';
print_r($this->client_general); //it prints $client_general array data
}
}
$settings = new Settings();
$settings->getSelectedArrayData('client_general');
Example for you is to create dynamic variable by string is here:
${'a' . 'b'} = 'hello there';
echo $ab; // hello there
My compiled output:
All data in array like this
<?php
$sub_arr = array();
$sub_arr[] = array(
'sr_nm' => 1,
'recept_number' => 3019,
'adm_number' => 3434,
'student_name' => 'amit',
'class' => 'LKG',
'pay' => 'online',
'cheq_nm' => '',
'adm_fee' => '',
'consolidated' => '',
'sec.fee' => '',
'dev.charge' => 5000,
'school_fee' => 1300,
'subling' => '-3400',
'transport' => 2300,
'late_fee' =>'total' => 35006
);
$sub_arr[] = array('sr_nm' => 1,
'recept_number' => 3019,
'adm_number' => 3434,
'student_name' => 'amit',
'class' => 'LKG',
'pay' => 'online',
'cheq_nm' => '',
'adm_fee' => '',
'consolidated' => '',
'sec.fee' => '',
'dev.charge' => 5000,
'school_fee' => 1300,
'subling' => '-3400',
'transport' => 2300,
'late_fee' => '',
'total' => 35006
);
And my excel file:
I want to insert new data from A4 shell after loading the file.
I have a relationship where a quote habtm applicants. I am trying to get a quote to save with multiple applicants at once. I already have an array of the applicants I need but I don't know how to format that array to get it to save when I insert it into the quote array.
The applicant array looks like this:
array(
(int) 0 => array(
'Applicant' => array(
'id' => '436',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => '2013-09-21 01:41:00',
'title' => '',
'first_name' => 'george',
'middle_name' => 'a',
'surname' => 'summerlane',
'email' => 'email#q.com',
'landline_number' => '88465120.',
'mobile_number' => '',
'applicant_type' => '',
'created' => '2013-09-21 01:43:10',
'modified' => '2013-09-21 01:43:10'
)
),
(int) 1 => array(
'Applicant' => array(
'id' => '435',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => '2013-09-21 01:41:00',
'title' => '',
'first_name' => 'mary',
'middle_name' => 's',
'surname' => 'amnn',
'email' => 'some#this.cin',
'landline_number' => '465132',
'mobile_number' => '',
'applicant_type' => '',
'created' => '2013-09-21 01:41:48',
'modified' => '2013-09-21 01:41:48'
)
),
(int) 2 => array(
'Applicant' => array(
'id' => '66',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => null,
'title' => null,
'first_name' => 'Tania',
'middle_name' => '',
'surname' => 'Humphreys',
'email' => 'purple67#me.com',
'landline_number' => null,
'mobile_number' => '0438854355',
'applicant_type' => 'Main applicant',
'created' => '2012-10-29 00:00:00',
'modified' => '2012-10-21 00:00:00'
)
)
)
I need one that looks like this:
array(
'Applicants' => array(
'id' => 435,
'id' => 436,
'id' => 66
)
)
How might I go about doing this?
Or is there a better way?
When I save a quote the array looks like this:
array(
'QuoteButton' => 'Submit',
'Quote' => array(
'date' => array(
'day' => '13',
'month' => '10',
'year' => '2013'
),
'description' => '',
'quote_accepted' => '0',
'research_accepted' => '0',
'cc_accepted' => '0',
'pesel_accepted' => '0',
'setfees_accepted' => '0',
'total' => '0'
),
'Applicant' => array(
'id' => '66'
),
How do I insert more than one applicant into the array?
An array can't have the same id, but can crate another array like this:
$datas = array(
(int) 0 => array(
'Applicant' => array(
'id' => '436',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => '2013-09-21 01:41:00',
'title' => '',
'first_name' => 'george',
'middle_name' => 'a',
'surname' => 'summerlane',
'email' => 'email#q.com',
'landline_number' => '88465120.',
'mobile_number' => '',
'applicant_type' => '',
'created' => '2013-09-21 01:43:10',
'modified' => '2013-09-21 01:43:10'
)
),
(int) 1 => array(
'Applicant' => array(
'id' => '435',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => '2013-09-21 01:41:00',
'title' => '',
'first_name' => 'mary',
'middle_name' => 's',
'surname' => 'amnn',
'email' => 'some#this.cin',
'landline_number' => '465132',
'mobile_number' => '',
'applicant_type' => '',
'created' => '2013-09-21 01:41:48',
'modified' => '2013-09-21 01:41:48'
)
),
(int) 2 => array(
'Applicant' => array(
'id' => '66',
'clientcase_id' => '66',
'archive_id' => '1',
'birthdate' => null,
'title' => null,
'first_name' => 'Tania',
'middle_name' => '',
'surname' => 'Humphreys',
'email' => 'purple67#me.com',
'landline_number' => null,
'mobile_number' => '0438854355',
'applicant_type' => 'Main applicant',
'created' => '2012-10-29 00:00:00',
'modified' => '2012-10-21 00:00:00'
)
)
);
$ids = array();
foreach($datas as $data => $applicants) {
$ids[] = $applicants['Applicant']['id'];
}
print_r($ids);
Output:
Array ( [0] => 436 [1] => 435 [2] => 66 )
How to use the ids? Like this:
foreach($ids as $key => $id) {
// do whatever you want with the applicant id
}
like tttony pointed out, array indexes need to be unique so i would:
$ids = array();
foreach($array as $applicant)
$ids[$applicant['Applicant']['id']] = null;
which will output:
Array
(
[436] =>
[435] =>
[66] =>
)
now id is key to $ids array...you could add something else as value rather than null
I have this code: http://pastebin.com/iFwyKM7G
Inside an event-observer class which executes after the customer registered. It creates an order automatically and it works for simple products. However I cannot figure out for the life of me how to make it work with Bundled product!
How can I make this work with a bundled product?
I DID IT!
I changed my code to the following:
$customer = Mage::getSingleton('customer/customer')->load($observer->getCustomer()->getId());
$session = Mage::getSingleton('adminhtml/session_quote');
$order_create_model = Mage::getSingleton('adminhtml/sales_order_create');
Mage::log($customer->debug(), null, 'toszodj_meg.log');
//$transaction = Mage::getModel('core/resource_transaction');
$storeId = $customer->getStoreId();
Mage::log($customer->getDefaultBillingAddress()->debug(), null, 'toszodj_meg.log');
$reservedOrderId = Mage::getSingleton('eav/config')->getEntityType('order')->fetchNewIncrementId($storeId);
$session->setCustomerId((int) $customer->getId());
$session->setStoreId((int) $storeId);
$orderData = array(
'session' => array(
'customer_id' => $customer->getId(),
'store_id' => $storeId,
),
'payment' => array(
'method' => 'banktransfer',
'po_number' => (string) '-',
),
// 123456 denotes the product's ID value
'add_products' =>array(
'2' => array(
'qty' => 1,
'bundle_option' => array(
2 => 2,
1 => 1,
),
'bundle_option_qty' => array(
2 => 1,
1 => 1,
),
),
),
'order' => array(
'currency' => 'EUR',
'account' => array(
'group_id' => $customer->getGroupId(),
'email' => (string) $customer->getEmail(),
),
'comment' => array('customer_note' => 'API ORDER'),
'send_confirmation' => 1,
'shipping_method' => 'flatrate_flatrate',
'billing_address' => array(
'customer_address_id' => $customer->getDefaultBillingAddress()->getEntityId(),
'prefix' => $customer->getDefaultBillingAddress()->getPrefix(),
'firstname' => $customer->getDefaultBillingAddress()->getFirstname(),
'middlename' => $customer->getDefaultBillingAddress()->getMiddlename(),
'lastname' => $customer->getDefaultBillingAddress()->getLastname(),
'suffix' => $customer->getDefaultBillingAddress()->getSuffix(),
'company' => $customer->getDefaultBillingAddress()->getCompany(),
'street' => $customer->getDefaultBillingAddress()->getStreet(),
'city' => $customer->getDefaultBillingAddress()->getCity(),
'country_id' => $customer->getDefaultBillingAddress()->getCountryId(),
'region' => $customer->getDefaultBillingAddress()->getRegion(),
'region_id' => $customer->getDefaultBillingAddress()->getRegionId(),
'postcode' => $customer->getDefaultBillingAddress()->getPostcode(),
'telephone' => $customer->getDefaultBillingAddress()->getTelephone(),
'fax' => $customer->getDefaultBillingAddress()->getFax(),
),
'shipping_address' => array(
'customer_address_id' => $customer->getDefaultShippingAddress()->getEntityId(),
'prefix' => $customer->getDefaultShippingAddress()->getPrefix(),
'firstname' => $customer->getDefaultShippingAddress()->getFirstname(),
'middlename' => $customer->getDefaultShippingAddress()->getMiddlename(),
'lastname' => $customer->getDefaultShippingAddress()->getLastname(),
'suffix' => $customer->getDefaultShippingAddress()->getSuffix(),
'company' => $customer->getDefaultShippingAddress()->getCompany(),
'street' => $customer->getDefaultShippingAddress()->getStreet(),
'city' => $customer->getDefaultShippingAddress()->getCity(),
'country_id' => $customer->getDefaultShippingAddress()->getCountryId(),
'region' => $customer->getDefaultShippingAddress()->getRegion(),
'region_id' => $customer->getDefaultShippingAddress()->getRegionId(),
'postcode' => $customer->getDefaultShippingAddress()->getPostcode(),
'telephone' => $customer->getDefaultShippingAddress()->getTelephone(),
'fax' => $customer->getDefaultShippingAddress()->getFax(),
),
),
);
$order_create_model->importPostData($orderData['order']);
$order_create_model->getBillingAddress();
$order_create_model->setShippingAsBilling(true);
$order_create_model->addProducts($orderData['add_products']);
$order_create_model->collectShippingRates();
$order_create_model->getQuote()->getPayment()->addData($orderData['payment']);
$order_create_model
->initRuleData()
->saveQuote();
$order_create_model->getQuote()->getPayment()->addData($orderData['payment']);
$order_create_model->setPaymentData($orderData['payment']);
$order_create_model
->importPostData($orderData['order'])
->createOrder();
$session->clear();
Mage::unregister('rule_data');
Mage::log('Order Successfull', null, 'siker_bammer.log');
And it works! thought the customer doesn't get notified. which iam trying to figure out now.