Skip to content
Robert edited this page Nov 24, 2015 · 1 revision

Table templae tags

    private function getTableTags(array $data)
    {
        $tags = ['row'  => [['clone' => '${lineRow}', 'rows' => 0]],
                 'tags' => []];

        if (count($data) > 0) {
            $i = 0;

            foreach ($data as $key => $value) {
                $i++;
                $tags['tags']['${lineRow#'.$i.'}']            = '';
                $tags['tags']['${lineCode#'.$i.'}']           =
                    htmlspecialchars($value['code'], ENT_COMPAT, 'UTF-8');
                
                $tags['tags']['photos'][] = [
                    'tag'        => '${linePhoto#'.$i.'}',
                    'replacement' => $value['photo_path']
                ];
                $tags['row'][] = [
                    'clone' => '${lineTestCode#'.$i.'}',
                    'rows' => count($value['sub_data'])
                ];
                $ii = 0;
                foreach ($value['sub_data'] as $subKey => $subData) {
                    $ii++;
                    $tags['tags']['${lineTestCode#'.$i.'#'.$ii.'}'] =
                            htmlspecialchars($subData['sub_test_code'], ENT_COMPAT, 'UTF-8');
                    $tags['tags']['${lineTestDesc#'.$i.'#'.$ii.'}'] =
                            htmlspecialchars($remedyData['sub_test_desc'], ENT_COMPAT, 'UTF-8');   
                }
            }
            $tags['row'][0]['rows'] = $i;
        }
        

        return $tags;
    }
Clone this wiki locally