<?php $start = microtime(true); echo 'START:', $start, PHP_EOL; $plt_schema = 'http://www.xbrl.org/int/gl/plt/2016-12-01'; $cor_schema = 'http://www.xbrl.org/int/gl/cor/2016-12-01'; $bus_schema = 'http://www.xbrl.org/int/gl/bus/2016-12-01'; $muc_schema = 'http://www.xbrl.org/int/gl/muc/2016-12-01'; $xbrlGlStr = '<?xml version="1.0" encoding="UTF-8"?> <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:gl-cor="'.$cor_schema.'" xmlns:gl-bus="'.$bus_schema.'" xmlns:gl-muc="'.$muc_schema.'" xmlns:gl-plt="http://www.xbrl.org/int/gl/plt/2016-12-01" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:iso639="http://www.xbrl.org/2005/iso639" xmlns:xbrll="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="'.$plt_schema.'./gl/plt/case-c-b-m-u-e-t-s/gl-plt-all-2016-12-01.xsd"> <xbrll:schemaRef xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" xlink:href="./gl/plt/case-c-b-m-u-t-s/gl-plt-all-2016-12-01.xsd" xlink:type="simple"/> <xbrli:context id="now"> <xbrli:entity> <xbrli:identifier scheme="http://www.xbrl.org/xbrlgl/sample">SAMPLE</xbrli:identifier> </xbrli:entity> <xbrli:period> <xbrli:instant>'.date("Y-m-d", time()).'</xbrli:instant> </xbrli:period> </xbrli:context> <xbrli:unit id="JPY"> <xbrli:measure>iso4217:JPY</xbrli:measure> </xbrli:unit> <xbrli:unit id="NotUsed"> <xbrli:measure>pure</xbrli:measure> </xbrli:unit> </xbrli:xbrl>'; $fromDate = null; $toDate = null; $enteredDate = null; $bus_fiscalYearEnd = null; $bus_periodIdentifier = null; $xbrlgl = new SimpleXMLElement( $xbrlGlStr ); $xbrlgl->registerXPathNamespace('gl-cor', $cor_schema); $xbrlgl->registerXPathNamespace('gl-bus', $bus_schema); $xbrlgl->registerXPathNamespace('gl-muc', $muc_schema); $accountingEntries = $xbrlgl->addChild('gl-cor:accountingEntries', null, $cor_schema); $documentInfo = $accountingEntries->addChild('gl-cor:documentInfo', null, $cor_schema); $entityInformation = $accountingEntries->addChild('gl-cor:entityInformation', null, $cor_schema); $sqlH = 'SELECT * FROM XBRLGL_GLHeader'; foreach ($pdo->query($sqlH) as $header) { if ($header['bus_fiscalyearend'] !== $bus_fiscalYearEnd || $header['bus_periodidentifier'] !== $bus_periodIdentifier) { if ($bus_fiscalYearEnd && $bus_periodIdentifier) { echo 'bus_fiscalYearEnd=', $bus_fiscalYearEnd, ' bus_periodIdentifier=', $bus_periodIdentifier, ' ', implode("", explode("-", $fromDate)), '_', implode("", explode("-", $enteredDate)), PHP_EOL; // documentInfo $cor_entriestype = $header['cor_entriestype']; $entriesTypeArray = array('account', 'balance', 'entries', 'journal', 'ledger', 'assets', 'trialbalance', 'taxtables', 'mapping', 'versioning', 'master_file', 'trade_documents', 'profile_compliant', 'other'); if (in_array($cor_entriestype, $entriesTypeArray)) { $entriesType = $documentInfo->addChild('gl-cor:entriesType', $cor_entriestype, $cor_schema); } else { $entriesType = $documentInfo->addChild('gl-cor:entriesType', 'other', $cor_schema); } $entriesType->addAttribute('contextRef', 'now'); $language = $documentInfo->addChild('gl-cor:language', 'iso639:en', $cor_schema); $language->addAttribute('contextRef', 'now'); $creationDate= $documentInfo->addChild('gl-cor:creationDate', date("Y-m-d", time()), $cor_schema); $creationDate->addAttribute('contextRef', 'now'); $entriesComment = $documentInfo->addChild('gl-cor:entriesComment', 'ADC GL_Detail', $cor_schema); $entriesComment->addAttribute('contextRef', 'now'); $periodCoveredStart = $documentInfo->addChild('gl-cor:periodCoveredStart', $fromDate, $cor_schema); $periodCoveredStart->addAttribute('contextRef', 'now'); $periodCoveredEnd = $documentInfo->addChild('gl-cor:periodCoveredEnd', $enteredDate, $cor_schema); $periodCoveredEnd->addAttribute('contextRef', 'now'); // entityInformation $os = $entityInformation->addChild('gl-bus:organizationIdentifiers', null, $bus_schema); $oi = $os->addChild('gl-bus:organizationIdentifier', $bus_organizationIdentifier, $bus_schema); $fy = $entityInformation->addChild('gl-bus:fiscalYearEnd', $bus_fiscalYearEnd, $bus_schema); $rc = $entityInformation->addChild('gl-bus:reportingCalendar', null, $bus_schema); $rp = $rc->addChild('gl-bus:reportingCalendarPeriod', null, $bus_schema); $ap = $rp->addChild('gl-bus:periodIdentifier', $bus_periodIdentifier, $bus_schema); $oi->addAttribute('contextRef', 'now'); $fy->addAttribute('contextRef', 'now'); $ap->addAttribute('contextRef', 'now'); $filename = 'gl_detail_'.implode("", explode("-", $fromDate)).'_'.implode("", explode("-", $enteredDate)).'.xml'; $xbrlgl->asXML($filename); $xbrlgl = new SimpleXMLElement( $xbrlGlStr ); $accountingEntries = $xbrlgl->addChild('gl-cor:accountingEntries', null, $cor_schema); $documentInfo = $accountingEntries->addChild('gl-cor:documentInfo', null, $cor_schema); $entityInformation = $accountingEntries->addChild('gl-cor:entityInformation', null, $cor_schema); } $fromDate = $header['cor_entereddate']; } $bus_organizationIdentifier = $header['bus_organizationidentifier']; $bus_fiscalYearEnd = $header['bus_fiscalyearend']; $bus_periodIdentifier = $header['bus_periodidentifier']; $cor_enteredBy = $header['cor_enteredby']; $cor_enteredDate = $header['cor_entereddate']; $cor_sourcejournalID = $header['cor_sourcejournalid']; $cor_entryNumber = $header['cor_entrynumber']; $entryHeader = $accountingEntries->addChild('gl-cor:entryHeader', null, $cor_schema); $enteredBy = $entryHeader->addChild('gl-cor:enteredBy', $cor_enteredBy, $cor_schema); $enteredDate = $entryHeader->addChild('gl-cor:enteredDate', $cor_enteredDate, $cor_schema); $sourceJournalID = $entryHeader->addChild('gl-cor:sourceJournalID', $cor_sourcejournalID, $cor_schema); $entryNumber = $entryHeader->addChild('gl-cor:entryNumber', $cor_entryNumber, $cor_schema); $enteredBy->addAttribute('contextRef', 'now'); $enteredDate->addAttribute('contextRef', 'now'); $sourceJournalID->addAttribute('contextRef', 'now'); $entryNumber->addAttribute('contextRef', 'now'); $sqlD = "SELECT * FROM XBRLGL_GLDetail WHERE cor_entryNumber='$entryNumber'"; foreach ($pdo->query($sqlD) as $detail) { $cor_lineNumber = $detail['cor_linenumber']; $cor_accountMainID = $detail['cor_accountmainid']; $cor_accountMainDescription = $detail['cor_accountmaindescription']; // ); $cor_mainAccountType = $detail['cor_mainaccounttype']; $cor_accountSubID = $detail['cor_accountsubid']; $cor_accountSubType = $detail['cor_accountsubtype']; $cor_accountSubDescription1 = detail['cor_accountsubdescription1']; // ); $cor_accountSubID1 = $detail['cor_accountsubid1']; $cor_accountSubType1 = $detail['cor_accountsubtype1']; $cor_accountSubDescription2 = $detail['cor_accountsubdescription1']; // ); $cor_accountSubID2 = $detail['cor_accountsubid2']; $cor_accountSubType2 = $detail['cor_accountsubtype2']; $cor_accountSubDescription3 = $detail['cor_accountsubdescription2']; // ); $cor_accountSubID3 = $detail['cor_accountsubid3']; $cor_accountSubType3 = $detail['cor_accountsubtype3']; $cor_amount = number_format($detail['cor_amount'], 0, '.', ''); $muc_amountCurrency = $detail['muc_amountcurrency']; $cor_debitCreditCode = $detail['cor_debitcreditcode']; $cor_postingDate = $detail['cor_postingdate']; $cor_detailComment = $detail['cor_detailcomment']; // ); $entryDetail = $entryHeader->addChild('gl-cor:entryDetail', null, $cor_schema); $lineNumber = $entryDetail->addChild('gl-cor:lineNumber', $cor_lineNumber, $cor_schema); $lineNumber->addAttribute('contextRef', 'now'); $account = $entryDetail->addChild('gl-cor:account', null, $cor_schema); $accountMainID = $account->addChild('gl-cor:accountMainID', $cor_accountMainID, $cor_schema); $accountMainDescription = $account->addChild('gl-cor:accountMainDescription', $cor_accountMainDescription, $cor_schema); $mainAccountTypeArray = array('asset', 'liability', 'equity', 'income', 'gain', 'expense', 'loss', 'contr-to-equity', 'distr-from-equity', 'comprehensive-income', 'other'); if (in_array($cor_mainAccountType, $mainAccountTypeArray)) { $mainAccountType = $account->addChild('gl-cor:mainAccountType', $cor_mainAccountType, $cor_schema); } else { $mainAccountType = $account->addChild('gl-cor:mainAccountType', 'other', $cor_schema); } $accountMainID->addAttribute('contextRef', 'now'); $accountMainDescription->addAttribute('contextRef', 'now'); $mainAccountType->addAttribute('contextRef', 'now'); $accountsub = $account->addChild('gl-cor:accountSub', null, $cor_schema); $accountSubID = $accountsub->addChild('gl-cor:accountSubID', $cor_accountSubID, $cor_schema); $accountSubType = $accountsub->addChild('gl-cor:accountSubType', $cor_accountSubType, $cor_schema); $accountSubID->addAttribute('contextRef', 'now'); $accountSubType->addAttribute('contextRef', 'now'); if (isset($cor_accountSubID1)) { $accountsub1 = $account->addChild('gl-cor:accountSub', null, $cor_schema); $accountSubDescription1 = $accountsub1->addChild('gl-cor:accountSubDescription', $cor_accountSubDescription1, $cor_schema); $accountSubID1 = $accountsub1->addChild('gl-cor:accountSubID', $cor_accountSubID1, $cor_schema); $accountSubType1 = $accountsub1->addChild('gl-cor:accountSubType', $cor_accountSubType1, $cor_schema); $accountSubDescription1->addAttribute('contextRef', 'now'); $accountSubID1->addAttribute('contextRef', 'now'); $accountSubType1->addAttribute('contextRef', 'now'); } if (isset($cor_accountSubID2)) { $accountsub2 = $account->addChild('gl-cor:accountSub', null, $cor_schema); $accountSubDescription2 = $accountsub2->addChild('gl-cor:accountSubDescription', $cor_accountSubDescription2, $cor_schema); $accountSubID2 = $accountsub2->addChild('gl-cor:accountSubID', $cor_accountSubID2, $cor_schema); $accountSubType2 = $accountsub2->addChild('gl-cor:accountSubType', $cor_accountSubType2, $cor_schema); $accountSubDescription2->addAttribute('contextRef', 'now'); $accountSubID2->addAttribute('contextRef', 'now'); $accountSubType2->addAttribute('contextRef', 'now'); } if (isset($cor_accountSubID3)) { $accountsub3 = $account->addChild('gl-cor:accountSub', null, $cor_schema); $accountSubDescription3 = $accountsub3->addChild('gl-cor:accountSubDescription', $cor_accountSubDescription3, $cor_schema); $accountSubID3 = $accountsub3->addChild('gl-cor:accountSubID', $cor_accountSubID3, $cor_schema); $accountSubType3 = $accountsub3->addChild('gl-cor:accountSubType', $cor_accountSubType3, $cor_schema); $accountSubDescription3->addAttribute('contextRef', 'now'); $accountSubID3->addAttribute('contextRef', 'now'); $accountSubType3->addAttribute('contextRef', 'now'); } $amount = $entryDetail->addChild('gl-cor:amount', $cor_amount, $cor_schema); $amountCurrency = $entryDetail->addChild('gl-muc:amountCurrency', $muc_amountCurrency, $muc_schema); $debitCreditCode = $entryDetail->addChild('gl-cor:debitCreditCode', $cor_debitCreditCode, $cor_schema); $postingDate = $entryDetail->addChild('gl-cor:postingDate', $cor_postingDate, $cor_schema); $detailComment = $entryDetail->addChild('gl-cor:detailComment', $cor_detailComment, $cor_schema); $amount->addAttribute('contextRef', 'now'); $amount->addAttribute('unitRef', 'NotUsed'); $amountCurrency->addAttribute('contextRef', 'now'); $debitCreditCode->addAttribute('contextRef', 'now'); $postingDate->addAttribute('contextRef', 'now'); $detailComment->addAttribute('contextRef', 'now'); } } echo 'bus_fiscalYearEnd=', $bus_fiscalYearEnd, ' bus_periodIdentifier=', $bus_periodIdentifier, ' ', implode("", explode("-", $fromDate)), '_', implode("", explode("-", $enteredDate)), PHP_EOL; $cor_entriestype = $header['cor_entriestype']; $entriesType = $documentInfo->addChild('gl-cor:entriesType', $cor_entriestype, $cor_schema); $language = $documentInfo->addChild('gl-cor:language', 'iso639:en', $cor_schema); $creationDate = $documentInfo->addChild('gl-cor:creationDate', '2017-08-17', $cor_schema); $entriesComment = $documentInfo->addChild('gl-cor:entriesComment', 'ADC GL_Detail', $cor_schema); $periodCoveredStart = $documentInfo->addChild('gl-cor:periodCoveredStart', $fromDate, $cor_schema); $periodCoveredEnd = $documentInfo->addChild('gl-cor:periodCoveredEnd', $enteredDate, $cor_schema); $entriesType->addAttribute('contextRef', 'now'); $language->addAttribute('contextRef', 'now'); $creationDate->addAttribute('contextRef', 'now'); $entriesComment->addAttribute('contextRef', 'now'); $periodCoveredStart->addAttribute('contextRef', 'now'); $periodCoveredEnd->addAttribute('contextRef', 'now'); $os = $entityInformation->addChild('gl-bus:organizationIdentifiers', null, $bus_schema); $oi = $os->addChild('gl-bus:organizationIdentifier', $bus_organizationIdentifier, $bus_schema); $fy = $entityInformation->addChild('gl-bus:fiscalYearEnd', $bus_fiscalYearEnd, $bus_schema); $rc = $entityInformation->addChild('gl-bus:reportingCalendar', null, $bus_schema); $rp = $rc->addChild('gl-bus:reportingCalendarPeriod', null, $bus_schema); $ap = $rp->addChild('gl-bus:periodIdentifier', $bus_periodIdentifier, $bus_schema); $oi->addAttribute('contextRef', 'now'); $fy->addAttribute('contextRef', 'now'); $ap->addAttribute('contextRef', 'now'); $filename = 'gl_detail_'.implode("", explode("-", $fromDate)).'_'.implode("", explode("-", $enteredDate)).'.xml'; $xbrlgl->asXML($filename); $end = microtime(true); echo 'END:', $end, PHP_EOL; $etime = $end - $start; echo 'ETIME:', $etime, PHP_EOL; ?>