Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //----
- function chickin_sync_node_insert($node) {
- $result=array();
- if ($node->type == 'hatching') {
- //dpm($node, '$node update');
- if (!empty($node->field_hatching_distribution)) {
- api_load('layerfarm');
- $jumlah = 0;
- foreach ($node->field_hatching_distribution[LANGUAGE_NONE] as $entity_id) {
- $entity = entity_load('field_collection_item', array($entity_id['value']));
- //dpm($entity, '$entity');
- if (!empty($entity)) {
- $entity = array_shift($entity);
- //dpm($entity, '$entity 2');
- $flock_nid = $entity->field_hatching_house[LANGUAGE_NONE][0]['target_id'];
- $number_of_bird = $entity->field_hatching_number_of_bird[LANGUAGE_NONE][0]['value'];
- dpm($flock_nid, '$flock_nid');
- dpm($number_of_bird, '$number_of_bird');
- $houses = node_load($flock_nid);
- //dpm($houses,'houses');
- $farm_nid = $houses->field_house_farm[LANGUAGE_NONE][0]['target_id'];
- dpm($farm_nid,'location');
- $arrays = array();
- $arrays[] = array('farm_id' => $farm_nid, 'quantity' => $number_of_bird);
- dpm($arrays,'jumlah');
- $result[$farm_nid] = (isset($result[$farm_nid])?$result[$farm_nid]:0)+$number_of_bird;
- }
- }
- }
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment