public function convertSubitems($columnToTake, $keepId = false,
                                    $keepCode = false, $keepAccountig = false)
    {
        $subitemRules = $this->rules[$columnToTake];
        if (self::isAssoc($this->input->data[$columnToTake])) {
            $sourceData = [$this->input->data[$columnToTake]];
        } else {
            $sourceData = $this->input->getDataValue($columnToTake);
        }

        $typUcOp = $this->input->getDataValue('typUcOp');

        foreach ($sourceData as $subItemData) {
            foreach (array_keys($subItemData) as $subitemColumn) {
                if (!array_key_exists($subitemColumn, $subitemRules)) {
                    unset($subItemData[$subitemColumn]);
                }
            }

            if ($keepAccountig && array_key_exists('ucetni', $subItemData) && array_key_exists('ucetni',
                    $this->output->getData())) {
                $subItemData['ucetni'] = $this->output->getDataValue('ucetni');
            } else {
                unset($subItemData['ucetni']);
            }

            if ($typUcOp) {
                $subItemData['typUcOp'] = $typUcOp;
            } else {
                unset($subItemData['typUcOp']);
            }

            if ($keepCode === false) {
                unset($subItemData['kod']);
            }
            if ($keepId === false) {
                unset($subItemData['id']);
                unset($subItemData['external-ids']);
            }
            $this->output->addArrayToBranch($subItemData);
        }
    }
public function convertSubitems($columnToTake, $keepId = false,
                                    $keepCode = false, $keepAccountig = false)
    {
        $subitemRules = $this->rules[$columnToTake];
        if (self::isAssoc($this->input->data[$columnToTake])) {
            $sourceData = [$this->input->data[$columnToTake]];
        } else {
            $sourceData = $this->input->getDataValue($columnToTake);
        }

        $typUcOp = $this->input->getDataValue('typUcOp');

        foreach ($sourceData as $subItemData) {
            foreach (array_keys($subItemData) as $subitemColumn) {
                if (!array_key_exists($subitemColumn, $subitemRules)) {
                    unset($subItemData[$subitemColumn]);
                }
            }

            if ($keepAccountig && array_key_exists('ucetni', $subItemData) && array_key_exists('ucetni',
                    $this->output->getData())) {
                $subItemData['ucetni'] = $this->output->getDataValue('ucetni');
            } else {
                unset($subItemData['ucetni']);
            }

            if ($typUcOp) {
                $subItemData['typUcOp'] = $typUcOp;
            } else {
                unset($subItemData['typUcOp']);
            }

            if ($keepCode === false) {
                unset($subItemData['kod']);
            }
            if ($keepId === false) {
                unset($subItemData['id']);
                unset($subItemData['external-ids']);
            }
            $this->output->addArrayToBranch($subItemData);
        }
    }
public function convertSubitems ( $ columnToTake , $ keepId = false , $ keepCode = false , $ keepAccountig = false ) { $ subitemRules = $ this -> rules [ $ columnToTake ] ; if ( self :: isAssoc ( $ this -> input -> data [ $ columnToTake ] ) ) { $ sourceData = [ $ this -> input -> data [ $ columnToTake ] ] ; } else { $ sourceData = $ this -> input -> getDataValue ( $ columnToTake ) ; } $ typUcOp = $ this -> input -> getDataValue ( 'typUcOp' ) ; foreach ( $ sourceData as $ subItemData ) { foreach ( array_keys ( $ subItemData ) as $ subitemColumn ) { if ( ! array_key_exists ( $ subitemColumn , $ subitemRules ) ) { unset ( $ subItemData [ $ subitemColumn ] ) ; } } if ( $ keepAccountig && array_key_exists ( 'ucetni' , $ subItemData ) && array_key_exists ( 'ucetni' , $ this -> output -> getData ( ) ) ) { $ subItemData [ 'ucetni' ] = $ this -> output -> getDataValue ( 'ucetni' ) ; } else { unset ( $ subItemData [ 'ucetni' ] ) ; } if ( $ typUcOp ) { $ subItemData [ 'typUcOp' ] = $ typUcOp ; } else { unset ( $ subItemData [ 'typUcOp' ] ) ; } if ( $ keepCode === false ) { unset ( $ subItemData [ 'kod' ] ) ; } if ( $ keepId === false ) { unset ( $ subItemData [ 'id' ] ) ; unset ( $ subItemData [ 'external-ids' ] ) ; } $ this -> output -> addArrayToBranch ( $ subItemData ) ; } }
Convert FlexiBee documnet's subitems

@param string  $columnToTake   usually "polozkyDokladu"
@param boolean $keepId         keep item IDs
@param boolean $keepCode       keep items code
@param boolean $keepAccounting set item's "ucetni" like target
Convert FlexiBee documnet s subitems