echo ($n + 1) % 2 ? 'even' : 'odd';
?>
">
<td colspan="3"></td>
    <td><?php 
echo '<div style=\'text-align:right;\'>' . TransController::formatNumber($debit, $numberFormatter, $numberFormat) . '</div>';
?>
</td>
    <td><?php 
echo '<div style=\'text-align:right;\'>' . TransController::formatNumber($credit, $numberFormatter, $numberFormat) . '</div>';
?>
</td>
    <td>
    <?php 
if (bccomp($debit, $credit, 5) != 0) {
    echo CHtml::label(TransController::formatNumber(abs($debit - $credit), $numberFormatter, $numberFormat), false, array("style" => 'color:red'));
}
?>
    </td>
</tr>
<tr class="<?php 
echo ($n + 2) % 2 ? 'even' : 'odd';
?>
">
<td colspan="6">
<div class="action">
<?php 
echo CHtml::submitButton(Yii::t('lazy8', 'Add Row'), array('name' => 'accountAddRow', 'title' => Yii::t('lazy8', 'contexthelp.Add Row')));
?>
</div>
</td>
 private function getFromTempTrans($template, $rowcount)
 {
     $trans = null;
     if (isset($_POST['TempTrans'])) {
         $trans = TempTrans::model()->findAll(array('condition' => 'userId=' . Yii::app()->user->id, 'order' => 'rownum'));
     }
     if ($trans !== null) {
         $cLoc = CLocale::getInstance('en');
         $numberFormatter = $cLoc->getNumberFormatter();
         $dateformatter = $cLoc->getDateFormatter();
         $numberFormat = User::getNumberFormat();
         $models = array();
         //make sure the data is current
         $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId'));
         $per = Period::model()->findbyPk(Yii::app()->user->getState('selectedPeriodId'));
         $multipleRowNumber = 0;
         foreach ($trans as $n => $transrow) {
             if ($n < count($template->templateRows) && $template->templateRows[$n]->allowRepeatThisRow) {
                 $multipleRowNumber = $n;
             }
             $templateRowNum = $n;
             if ($n >= count($template->templateRows)) {
                 $templateRowNum = $multipleRowNumber;
             }
             //see if there is new data to be added..
             if (isset($_POST['TempTrans'][$transrow->rownum]) && $_POST['TempTrans'][$transrow->rownum]) {
                 //make sure only one of debit or credit are filled
                 $olddebit = TransController::parseNumber($transrow->amountdebit, $cLoc);
                 $transrow->attributes = $_POST['TempTrans'][$transrow->rownum];
                 $amountdebit = TransController::parseNumber($transrow->amountdebit, $cLoc);
                 $amountcredit = TransController::parseNumber($transrow->amountcredit, $cLoc);
                 $transrow->invDate = User::parseDate($transrow->invDate, $cLoc);
                 if ($amountdebit != 0 and $amountcredit != 0) {
                     //keep only the newly added amount
                     if ($olddebit != '') {
                         $transrow->amountdebit = '';
                     } else {
                         $transrow->amountcredit = '';
                     }
                 }
             }
             $amountdebit = TransController::parseNumber($transrow->amountdebit, $cLoc);
             $amountcredit = TransController::parseNumber($transrow->amountcredit, $cLoc);
             //echo $transrow->amountdebit;die();
             if ($template->templateRows[$templateRowNum]->allowMinus && bccomp($amountcredit, 0, 5) < 0) {
                 $amountdebit = -$amountcredit;
                 $amountcredit = 0;
             }
             if ($template->templateRows[$templateRowNum]->allowMinus && bccomp($amountdebit, 0, 5) < 0) {
                 $amountcredit = -$amountdebit;
                 $amountdebit = 0;
             }
             //amount must be positive at this stage
             if ($amountdebit < 0) {
                 $amountdebit = -$amountdebit;
             }
             if ($amountcredit < 0) {
                 $amountcredit = -$amountcredit;
             }
             //this gets rid of extra zeros
             if (strlen($amountcredit) > 0) {
                 $amountcredit += 0.0;
             }
             if (strlen($amountdebit) > 0) {
                 $amountdebit += 0.0;
             }
             if (!isset($_GET['id'])) {
                 $transrow->regDate = date('Y-m-d');
                 $transrow->periodNum = $per->lastPeriodTransNum + 1;
                 $transrow->companyNum = $comp->lastAbsTransNum + 1;
             }
             if ($template->forceDateToday) {
                 $transrow->invDate = date('Y-m-d');
             }
             $transrow->amountdebit = $amountdebit;
             $transrow->amountcredit = $amountcredit;
             $transrow->save();
             $transrow->amountdebit = TransController::formatNumber($transrow->amountdebit, $numberFormatter, $numberFormat);
             $transrow->amountcredit = TransController::formatNumber($transrow->amountcredit, $numberFormatter, $numberFormat);
             $transrow->invDate = User::getDateFormatted($transrow->invDate, $cLoc, $dateformatter);
             $transrow->regDate = User::getDateFormatted($transrow->regDate, $cLoc, $dateformatter);
             $transrow->dateChanged = User::getDateFormatted($transrow->dateChanged, $cLoc, $dateformatter);
         }
         //return what was found in the temptrans table.
         $models = $trans;
     } else {
         $this->getBlankTempTrans($models, $rowcount);
     }
     return $models;
 }