Esempio n. 1
0
}, 'value' => function ($model) {
    $amount = $model->account_source == 0 ? '' : NumberUtils::format($model->entry_value);
    return $amount;
}], ['label' => Yii::t('fin.grid', 'Credit Account'), 'headerOptions' => ['style' => 'text-align: center'], 'footerOptions' => ['style' => 'text-align: right', 'colspan' => 2], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: left', 'class' => MasterValueUtils::getColorRow($index)];
}, '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]);
Esempio n. 2
0
 /**
  * get Basic of Bill
  * @param $billId
  * @param $postData
  * @param $fmShortDatePhp
  * @return NetBill|false
  */
 private function loadBill($billId, $postData, $fmShortDatePhp)
 {
     $result = null;
     if (is_null($billId)) {
         $result = new NetBill();
         $result->total = 0;
         $result->member_num = 0;
     } else {
         $result = NetBill::findOne(['id' => $billId, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
         if (is_null($result)) {
             return false;
         }
         $result->bill_date = DateTimeUtils::parse($result->bill_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp);
         $result->arr_member_list = StringUtils::unserializeArr($result->member_list);
         $result->arr_member_list_old = StringUtils::unserializeArr($result->member_list);
     }
     $result->total_old = $result->total;
     $result->member_num_old = $result->member_num;
     $result->load($postData);
     return $result;
 }
Esempio n. 3
0
}], ['label' => Yii::t('fin.grid', 'Amount'), '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 NumberUtils::format($model->total);
}, 'footer' => $htmlFooterTotal], ['label' => Yii::t('fin.grid', 'Member'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) {
    return $model->member_num;
}], ['label' => Yii::t('fin.grid', 'Per Member'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) {
    return NumberUtils::format(NumberUtils::rounds($model->total / $model->member_num, NumberUtils::NUM_CEIL));
}], ['label' => Yii::t('fin.grid', 'Member'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: left; max-width:280px', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) use($arrNetCustomer) {
    $arrMemberListVal = StringUtils::unserializeArr($model->member_list);
    return StringUtils::showArrValueAsString($arrMemberListVal, $arrNetCustomer);
}], ['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');
    $arrBtns = [];
    $entryId = $model->id;
    $urlEdit = BaseUrl::toRoute(['bill/update', 'id' => $entryId]);
    $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlEdit, $lblEdit]);
    $urlView = BaseUrl::toRoute(['bill/view', 'id' => $entryId]);
    $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlView, $lblView]);
    $html = '<div class="btn-group">';
    $html .= Html::a($lblEdit, [$urlEdit], ['class' => 'btn btn-' . $btnClass]);
Esempio n. 4
0
 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);
 }