Ejemplo n.º 1
0
    /**
     *
     */
    public function render()
    {
        $content = '<style type="text/css">
td {text-align: center}
</style>';
        $content .= $this->sef->getResponsibleAgencyLabel() . ' &deg; ' . $this->sef->getFunctionalGroupVersion() . '<hr/>';
        $content .= '<div style="background-color: #ddd"><small>Implementation Guideline Description</small><br/>';
        $content .= $this->sef->getImplementationDescription() . '</div>';
        foreach ($this->sef->getSetsSection() as $set => $tables) {
            $content .= '<h1 style="border-bottom: 1px solid #ddd">' . $set . '</h1>';
            foreach ($tables as $tableIndex => $table) {
                $content .= '<h3>Table ' . ($tableIndex + 1) . '</h3>';
                $content .= '<table border="1" style="width: 780px">
<tr>
<th>USER<br/>REQ</th>
<th>REQ.<br/>DES.</th>
<th>MAX<br/>USE</th>
<th>POS<br/>NO.</th>
<th>SEGMENT<br/>ID</th>
<th>SEGMENT<br/>NAME</th>
</tr>';
                $increment = 0;
                $position = 0;
                foreach ($table as $segment) {
                    if (isset($segment['type']) && $segment['type'] == 'loop') {
                        $content .= '<tr><td colspan="6">Loop ...</td></tr>';
                    } else {
                        if (!$increment) {
                            $increment = $segment['ordinal'];
                        }
                        $position += $segment['ordinal'];
                        $content .= '<tr>
<td></td>
<td>' . ($segment['required'] ? $segment['required'] : 'O') . '</td>
<td>' . ($segment['maximum'] ? $segment['maximum'] : 1) . '</td>
<td>' . $position . '</td>
<td>' . $segment['segment'] . '</td>
<td></td>
</tr>';
                        if (!$segment['ordinal']) {
                            $position += $increment;
                        }
                    }
                }
                $content .= '</table>';
            }
        }
        return $content;
    }
Ejemplo n.º 2
0
 /**
  * @param string $content
  * @param bool $checkIntegrity
  * @return \Smalot\Edi\Sef\Sef
  */
 public static function parse($content, $checkIntegrity = true)
 {
     $sections = self::parseSections($content);
     $parser = new self($sections);
     if ($checkIntegrity) {
         $parser->checkIntegrity();
     }
     $schema = new Sef($parser->extractVersion());
     $schema->setIniSection($parser->extractIniSection());
     $schema->setStdSection($parser->extractStdSection());
     $schema->setSetsSection($parser->extractSetsSection());
     $schema->setSegsSection($parser->extractSegsSection());
     return $schema;
 }