public function actionTool() { // master value $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null); $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null); $arrPurchaseType = MasterValueUtils::getArrData('oef_purchase_type'); OefFundCertificate::$_PHP_FM_SHORTDATE = $fmShortDatePhp; // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model = new OefFundCertificate(); $model->load($postData); // init value $model->scenario = MasterValueUtils::SCENARIO_TOOL; if (Yii::$app->request->getIsGet()) { $today = DateTimeUtils::getNow(); $model->sell_date = $today->format($fmShortDatePhp); $model->income_tax_rate = ParamUtils::getIncomeTaxRateSale(); $sumPurchaseQuery = (new Query())->select(['SUM(found_stock) AS found_stock', 'SUM(found_stock_sold) AS found_stock_sold']); $sumPurchaseQuery->from('oef_purchase')->where(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->andWhere('found_stock > found_stock_sold'); $sumPurchaseData = $sumPurchaseQuery->createCommand()->queryOne(); if (!is_null($sumPurchaseData['found_stock']) && !is_null($sumPurchaseData['found_stock_sold'])) { $model->sell_certificate = $sumPurchaseData['found_stock'] - $sumPurchaseData['found_stock_sold']; } } $isValidSellDate = $model->validate(['sell_date']); if ($isValidSellDate && empty($model->nav)) { $sellDate = DateTimeUtils::parse($model->sell_date, $fmShortDatePhp); $oefNavModel = OefNav::findOne(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE, 'trade_date' => $sellDate->format(DateTimeUtils::FM_DB_DATE)]); if (!is_null($oefNavModel)) { $model->nav = $oefNavModel->nav_value; } } // render GUI $renderView = 'tool'; $renderData = ['model' => $model, 'fmShortDateJui' => $fmShortDateJui, 'arrPurchaseType' => $arrPurchaseType, 'arrFundCertificate4Sell' => false]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); if ($isValid) { $arrFundCertificate4Sell = $this->getFundCertificate4Sell($model, $fmShortDatePhp); $renderData['arrFundCertificate4Sell'] = $arrFundCertificate4Sell; } break; default: break; } // render GUI return $this->render($renderView, $renderData); }
</th> <th style="text-align: center"><?php echo Yii::t('fin.grid', 'Unit'); ?> </th> <th style="text-align: center"><?php echo Yii::t('fin.grid', 'Shared'); ?> </th> </tr></thead> <tbody> <?php foreach ($arrShareDetail as $item) { ?> <?php $class = MasterValueUtils::getColorRow($rowindex); $sumUnit += $item->share_unit; $sumShared += $item->share_value; $rowindex++; ?> <tr class="<?php echo $class; ?> "> <td style="vertical-align: middle; text-align: center"><?php echo $rowindex; ?> </td> <td style="vertical-align: middle; text-align: left"><?php echo $item->account_name; ?>
}, 'value' => function ($model) use($arrFinAccount) { return isset($arrFinAccount[$model->account_target]) ? $arrFinAccount[$model->account_target] : ''; }, 'footer' => $htmlFooterCredit], ['class' => DataColumn::className(), 'label' => Yii::t('fin.grid', 'Credit Amount'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['colspan' => 0], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)]; }, 'value' => function ($model) { $amount = $model->account_target == 0 ? '' : NumberUtils::format($model->entry_value); return $amount; }], ['attribute' => 'description', 'label' => Yii::t('fin.grid', 'Description'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['style' => 'text-align: right'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: left', 'class' => MasterValueUtils::getColorRow($index)]; }, 'enableSorting' => false, 'value' => function ($model) use($arrEntryLog) { $arrEntryLogVal = StringUtils::unserializeArr($model->description); return StringUtils::showArrValueAsString($arrEntryLogVal, $arrEntryLog); }], ['label' => Yii::t('fin.grid', 'Action'), 'headerOptions' => ['style' => 'text-align: center; width: 100px;'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)]; }, 'format' => 'raw', 'value' => function ($model, $key, $index) { $btnClass = MasterValueUtils::getColorRow($index); $lblView = Yii::t('button', 'View'); $lblEdit = Yii::t('button', 'Edit'); $lblCopy = Yii::t('button', 'Copy'); $urlEdit = false; $arrBtns = []; $entryId = $model->entry_id; $timeDepositTranId = $model->time_deposit_tran_id; switch ($model->entry_status) { case MasterValueUtils::MV_FIN_ENTRY_TYPE_SIMPLE: $urlEdit = BaseUrl::toRoute(['payment/update', 'id' => $entryId]); $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlEdit, $lblEdit]); $urlView = BaseUrl::toRoute(['payment/view', 'id' => $entryId]); $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlView, $lblView]); $urlCopy = BaseUrl::toRoute(['payment/copy', 'id' => $entryId]); $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlCopy, $lblCopy]);
?> </th> <th style="text-align: center"><?php echo Yii::t('fin.grid', 'Interest'); ?> </th> <th style="text-align: center"><?php echo Yii::t('fin.grid', 'Description'); ?> </th> </tr> <?php foreach ($arrAccount as $account) { ?> <?php $rowClass = $account->status == MasterValueUtils::MV_JAR_ACCOUNT_STATUS_ON ? MasterValueUtils::getColorRow($rowindex) : 'danger'; $rowindex++; ?> <tr class="<?php echo $rowClass; ?> "> <td style="text-align: center"><?php echo $rowindex; ?> </td> <td style="text-align: left"><?php echo $account->account_name; ?> </td> <td style="text-align: right"><?php
public function actionUpdate($id) { $this->objectId = $id; // master value $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null); $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null); OefPurchase::$_PHP_FM_SHORTDATE = $fmShortDatePhp; $model = OefPurchase::getModel($id); $renderView = 'update'; if (is_null($model)) { $model = false; $renderData = ['model' => $model]; Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('oef.models', 'Purchase')])); } else { // master value $arrPurchaseType = MasterValueUtils::getArrData('oef_purchase_type'); // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model->load($postData); // init value $model->scenario = MasterValueUtils::SCENARIO_UPDATE; // render GUI $renderData = ['model' => $model, 'fmShortDatePhp' => $fmShortDatePhp, 'fmShortDateJui' => $fmShortDateJui, 'arrPurchaseType' => $arrPurchaseType]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); $model->calculate(); if ($isValid) { $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } break; case MasterValueUtils::SM_MODE_CONFIRM: $isValid = $model->validate(); if ($isValid) { $model->calculate(); $result = $this->updatePurchase($model, $fmShortDatePhp); if ($result === true) { Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('oef.models', 'Purchase')])); return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id])); } else { // restore Data for View $model->purchase_date = DateTimeUtils::parse($model->purchase_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp); if (!empty($model->sip_date)) { $model->sip_date = DateTimeUtils::parse($model->sip_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp); } // render View Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result); $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } } break; case MasterValueUtils::SM_MODE_BACK: break; default: break; } } // render GUI return $this->render($renderView, $renderData); }
public function actionUpdate($id) { $this->objectId = $id; // master value $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null); $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null); JarPayment::$_PHP_FM_SHORTDATE = $fmShortDatePhp; $model = JarPayment::findOne(['id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]); $renderView = 'update'; if (is_null($model)) { $model = false; $renderData = ['model' => $model]; Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('jar.models', 'Payment')])); } else { if ($model->share_id > 0) { return Yii::$app->getResponse()->redirect(Url::to(['/jar/distribute/update', 'id' => $model->share_id])); } // master value $arrAccount = ModelUtils::getArrData(JarAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->orderBy('account_type, order_num'), 'account_id', 'account_name'); $arrEntryLog = MasterValueUtils::getArrData('jar_payment_status'); // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model->load($postData); // init value $model->scenario = MasterValueUtils::SCENARIO_UPDATE; // render GUI $renderData = ['model' => $model, 'fmShortDatePhp' => $fmShortDatePhp, 'fmShortDateJui' => $fmShortDateJui, 'arrAccount' => $arrAccount, 'arrEntryLog' => $arrEntryLog]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); if ($isValid) { $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } break; case MasterValueUtils::SM_MODE_CONFIRM: $isValid = $model->validate(); if ($isValid) { $result = $this->updatePayment($model, $fmShortDatePhp); if ($result === true) { Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('jar.models', 'Payment')])); return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id])); } else { // restore Data for View $model->entry_date = DateTimeUtils::parse($model->entry_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp); // render View Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result); $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } } break; case MasterValueUtils::SM_MODE_BACK: break; default: break; } } // render GUI return $this->render($renderView, $renderData); }
public function actionCopy($id) { $this->objectId = $id; $model = FinTimeDepositTran::findOne(['transactions_id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]); $renderView = 'copy'; if (is_null($model)) { $model = false; $renderData = ['model' => $model]; Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('fin.models', 'Fixed Deposit')])); } else { // master value $phpFmShortDate = DateTimeUtils::getPhpDateFormat(); $arrTimedepositTrantype = MasterValueUtils::getArrData('fin_timedeposit_trantype'); $arrSavingAccount = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => 4])->orderBy('account_type, order_num'), 'account_id', 'account_name'); $arrCurrentAssets = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => [1, 2]])->orderBy('account_type, order_num'), 'account_id', 'account_name'); // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model->load($postData); // reset value if (Yii::$app->request->getIsGet()) { $openingDate = DateTimeUtils::getDateFromDB($model->opening_date); $closingDate = DateTimeUtils::getDateFromDB($model->closing_date); $dateDiff = $closingDate->diff($openingDate); $interval = 'P' . $dateDiff->m . 'M'; DateTimeUtils::addDateTime($closingDate, $interval, null, false); $model->opening_date = $model->closing_date; $model->closing_date = $closingDate->format(DateTimeUtils::FM_DB_DATE); $model->interest_add = 0; $model->add_flag = MasterValueUtils::MV_FIN_TIMEDP_TRANTYPE_ADDING; } // init value FinTimeDepositTran::$_PHP_FM_SHORTDATE = $phpFmShortDate; FinTimeDepositTran::$_ARR_SAVING_ACOUNT = $arrSavingAccount; $model->scenario = MasterValueUtils::SCENARIO_COPY; $renderData = ['model' => $model, 'phpFmShortDate' => $phpFmShortDate, 'arrTimedepositTrantype' => $arrTimedepositTrantype, 'arrSavingAccount' => $arrSavingAccount, 'arrCurrentAssets' => $arrCurrentAssets]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); if ($isValid) { $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY]; } break; case MasterValueUtils::SM_MODE_CONFIRM: $isValid = $model->validate(); if ($isValid) { $result = $this->copyFixedDeposit($model); if ($result === true) { Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('fin.models', 'Fixed Deposit')])); return Yii::$app->getResponse()->redirect(Url::to(['index'])); } else { Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result); $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY]; } } break; case MasterValueUtils::SM_MODE_BACK: break; default: break; } } // render GUI return $this->render($renderView, $renderData); }
public function actionUpdate($id) { $this->objectId = $id; $model = NetCustomer::findOne(['id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]); $renderView = 'update'; if (is_null($model)) { $model = false; $renderData = ['model' => $model]; Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('net.models', 'Customer')])); } else { // master value $arrCustomerStatus = MasterValueUtils::getArrData('net_customer_status'); // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model->load($postData); // init value $model->scenario = MasterValueUtils::SCENARIO_UPDATE; $renderData = ['model' => $model, 'arrCustomerStatus' => $arrCustomerStatus]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); if ($isValid) { $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } break; case MasterValueUtils::SM_MODE_CONFIRM: $isValid = $model->validate(); if ($isValid) { $result = $this->createCustomer($model); if ($result === true) { Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('net.models', 'Customer')])); return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id])); } else { Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result); $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT]; } } break; case MasterValueUtils::SM_MODE_BACK: break; default: break; } } // render GUI return $this->render($renderView, $renderData); }
<div class="widget-detail-header bg-maroon"><h3 class="widget-detail-title"><?php echo Yii::t('fin.form', 'Payment History'); ?> </h3></div> <div class="box-footer"><div class="row"><?php Pjax::begin(); echo GridView::widget(['layout' => '{summary}<div class="table-responsive">{items}</div>{pager}', 'options' => ['class' => 'grid-view col-xs-12'], 'tableOptions' => ['class' => 'table table-bordered'], 'showFooter' => true, 'headerRowOptions' => ['class' => 'warning'], 'footerRowOptions' => ['class' => 'warning', 'style' => 'font-weight:bold'], 'pager' => ['options' => ['class' => 'pagination pagination-bottom'], 'maxButtonCount' => 6], 'dataProvider' => new ActiveDataProvider(['query' => $dataPaymentQuery, 'pagination' => ['pagesize' => 20]]), 'columns' => [['label' => Yii::t('fin.grid', 'Date'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['style' => 'text-align: right'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)]; }, 'format' => 'raw', 'value' => function ($model) { return DateTimeUtils::htmlDateFormatFromDB($model->entry_date, DateTimeUtils::FM_VIEW_DATE, true); }, 'footer' => $htmlFooterBalance], ['label' => Yii::t('fin.grid', 'Credit'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['style' => 'text-align: right'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)]; }, 'value' => function ($model) { return $model->credit > 0 ? NumberUtils::format($model->credit) : ''; }, 'footer' => $htmlFooterCredit], ['label' => Yii::t('fin.grid', 'Debit'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['style' => 'text-align: right'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)]; }, 'value' => function ($model) { return $model->debit > 0 ? NumberUtils::format($model->debit) : ''; }, 'footer' => $htmlFooterDebit], ['label' => Yii::t('fin.grid', 'Bill Date'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) { return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)]; }, 'format' => 'raw', 'value' => function ($model) { if ($model->order_id > 0 && !is_null($model->bill_date)) { return DateTimeUtils::htmlDateFormatFromDB($model->bill_date, DateTimeUtils::FM_VIEW_DATE, true); } return ''; }]]]); Pjax::end(); ?> </div></div> </div></div></div><?php }
public function actionCopy($id) { $this->objectId = $id; $model = FinAccountEntry::findOne(['entry_id' => $id, 'entry_status' => MasterValueUtils::MV_FIN_ENTRY_TYPE_SIMPLE, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]); $renderView = 'copy'; if (is_null($model)) { $model = false; $renderData = ['model' => $model]; Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('fin.models', 'Payment')])); } else { // master value $phpFmShortDate = DateTimeUtils::getPhpDateFormat(); $arrFinAccount = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => [1, 2, 3, 5, 6, 7]])->orderBy('account_type, order_num'), 'account_id', 'account_name'); $arrEntryLog = MasterValueUtils::getArrData('fin_entry_log'); // reset value $model->entry_date = DateTimeUtils::formatNow($phpFmShortDate); // submit data $postData = Yii::$app->request->post(); $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false; // populate model attributes with user inputs $model->load($postData); if (is_null($model->arr_entry_log)) { $model->arr_entry_log = StringUtils::unserializeArr($model->description); } // init value FinAccountEntry::$_PHP_FM_SHORTDATE = $phpFmShortDate; $model->scenario = MasterValueUtils::SCENARIO_COPY; $renderData = ['model' => $model, 'phpFmShortDate' => $phpFmShortDate, 'arrFinAccount' => $arrFinAccount, 'arrEntryLog' => $arrEntryLog]; switch ($submitMode) { case MasterValueUtils::SM_MODE_INPUT: $isValid = $model->validate(); if ($isValid) { $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY]; } break; case MasterValueUtils::SM_MODE_CONFIRM: $isValid = $model->validate(); if ($isValid) { $result = $this->copyPayment($model); if ($result === true) { Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('fin.models', 'Payment')])); return Yii::$app->getResponse()->redirect(Url::to(['index'])); } else { Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result); $renderView = 'confirm'; $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY]; } } break; case MasterValueUtils::SM_MODE_BACK: break; default: break; } } // render GUI return $this->render($renderView, $renderData); }