require 'views/form.php'; $aDirectJson['html'] = ob_get_clean(); break; case 'save_dim_data': $sTranTableName = $_REQUEST['table_name']; $nRecordId = (int) $_REQUEST['record_id']; $nL1Id = (int) $_REQUEST['l1_id']; $nL2Id = (int) $_REQUEST['l2_id']; $nL3Id = (int) $_REQUEST['l3_id']; //amt convert to cents $nAmt = (int) $_REQUEST['amt'] * 100; $dDateFrom = $_REQUEST['date_from']; $dDateTo = $_REQUEST['date_to']; $oPeriod = new Period($Database); $oPeriod->setPeriodType('monthly'); $oData = new Data($Database, $oPeriod); $oData->setPeriodType('monthly'); //get table_id $nTableId = $oTable->getTableIdByName($sTranTableName); //get existing dimension data record $aDimData = $oData->getDimData($nTableId, $nRecordId); //fix level3 if it has external table $nL3Id = $oLevel->fixLevelId($oLevel::LEVEL_3, $nL2Id, $nL3Id); $aData = array('table_id' => $nTableId, 'record_id' => $nRecordId, 'l1_id' => $nL1Id, 'l2_id' => $nL2Id, 'l3_id' => $nL3Id, 'amt' => $nAmt, 'date_from' => $dDateFrom, 'date_to' => $dDateTo); if ($aDimData === false) { if (!$oData->addRecord($aData)) { $aDirectJson['error'] = implode(PHP_EOL, $oData->getErrors()); } } else { if (!$oData->updateRecord($aDimData['id'], $aData)) { $aDirectJson['error'] = implode(PHP_EOL, $oData->getErrors());
* @author Uldis Nelsons <*****@*****.**> */ use DBRisinajumi\Dimensions\Period; use DBRisinajumi\Dimensions\Data; use DBRisinajumi\Dimensions\Level; if (!isset($_REQUEST['table_id']) || !isset($_REQUEST['record_id']) || !isset($_REQUEST['amt'])) { echo "not all params provided"; exit; } require 'init.php'; $nTableId = (int) $_GET['table_id']; $nRecordId = (int) $_GET['record_id']; $nAmt = (double) $_GET['amt']; $oPeriod = new Period($Database); $oPeriod->setPeriodType('monthly'); $oData = new Data($Database, $oPeriod); $oLevel = new Level($Database); $aDimData = $oData->getDimData($nTableId, $nRecordId); //var_dump($aDimData); $sDateFrom = $sDateTo = date($oData->getUserDateFormat()); if (!empty($aDimData['date_from'])) { $sDateFrom = date($oData->getUserDateFormat(), strtotime($aDimData['date_from'])); } if (!empty($aDimData['date_to'])) { $sDateTo = date($oData->getUserDateFormat(), strtotime($aDimData['date_to'])); } $sTitle = "Set levels for items and split sums by periods"; require 'views/header.php'; ?> <form method="post" action=""> <input type="hidden" id="record_id" name="record_id" value="<?php
<th rowspan="2">Info</th> <th colspan="6">Dimension</th> </tr> <tr> <th>Date from</th> <th>Date to</th> <th>Level I</th> <th>Level II</th> <th>Level III</th> <th></th> </tr> <?php require 'init.php'; $oPeriod = new Period($Database); $oPeriod->setPeriodType('monthly'); $oData = new Data($Database, $oPeriod); $oLevel = new Level($Database); $oTable = new \DBRisinajumi\Dimensions\Table($Database); $nTableId = $oTable->getTableIdByName('dim_sample_bank_trans'); $sSql = "SELECT id, acc_holder, amount, message FROM dim_sample_bank_trans"; $q = $Database->query($sSql); while ($row = $q->fetch_assoc()) { $aDimData = $oData->getDimData($nTableId, $row['id']); $sDateFrom = $sDateTo = ''; if (!empty($aDimData['date_from'])) { $sDateFrom = date($oData->getUserDateFormat(), strtotime($aDimData['date_from'])); } if (!empty($aDimData['date_to'])) { $sDateTo = date($oData->getUserDateFormat(), strtotime($aDimData['date_to'])); } echo "<tr>\n <td>" . $row['acc_holder'] . "</td>\n <td>" . $row['amount'] . "</td>\n <td>" . $row['message'] . "</td>\n <td>" . $sDateFrom . "</td>\n <td>" . $sDateTo . "</td>\n <td>" . $aDimData['l1_code'] . "</td>\n <td>" . $aDimData['l2_code'] . "</td>\n <td>" . $aDimData['l3_code'] . "</td>\n ";