/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = FormaPagamento::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['idforma_pagamento' => $this->idforma_pagamento]); $query->andFilterWhere(['like', 'forma_pagamento', $this->forma_pagamento]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getFopaCodigo() { return $this->hasOne(FormaPagamento::className(), ['fopa_codigo' => 'fopa_codigo']); }
?> <div class="pedido-form"> <?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?> <?php $rows = \app\models\Cliente::find()->all(); $data = ArrayHelper::map($rows, 'clien_codigo', 'clien_nome'); echo $form->field($model, 'clien_codigo')->dropDownList($data, ['prompt' => 'Selecione um cliente']); ?> <?php $rows = \app\models\FormaPagamento::find()->all(); $data = ArrayHelper::map($rows, 'fopa_codigo', 'fopa_nome'); echo $form->field($model, 'fopa_codigo')->dropDownList($data, ['prompt' => 'Selecione uma forma de pagamento']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Cadastrar' : 'Alterar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
</tr> <tr> <td><strong>Est. Civil: </strong><?php echo $model->estadocivil ?></td> <td colspan="2"><strong>Cônjuge: </strong><?php echo $model->conjuge ?></td> <td><strong>Tel.: </strong><?php echo $model->telefone2 ?></td> </tr> <tr> <td colspan="3"><strong>Referência 1: </strong><?php echo $model->referencia1 ?></td> <td><strong>Tel.: </strong><?php echo $model->telefone11 ?></td> </tr> <tr> <td colspan="3"><strong>Referência 2: </strong><?php echo $model->referencia2 ?></td> <td><strong>Tel.: </strong><?php echo $model->telefone21 ?></td> </tr> <tr> <td colspan="2"><strong>F. Pagamento:</strong> <?php echo FormaPagamento::findOne($model2->forma_pagamento_idforma_pagamento)->forma_pagamento ?></td> <td><strong>V. Compra: </strong><?php echo Yii::$app->formatter->asCurrency($model2->valortotal) ?></td> <td><strong>N. Parcelas: </strong><?php echo $model2->qtd_parcelas ?></td> </tr> <tr> <td colspan="4"><strong>V. Compra: </strong><?php echo $model2->valortotal ?></td> </tr> </table> <h5><strong>Parcelamento</strong></h5> <table class="table table-bordered"> <?php //$items = FormaPagamento::findOne($model2->forma_pagamento_idforma_pagamento); $qtdparcelas = $model2->qtd_parcelas; //$qtdparcelas = 10;
use yii\widgets\ActiveForm; use kartik\widgets\Select2; use \kartik\money\MaskMoney; /* @var $this yii\web\View */ /* @var $model app\models\Parcela */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="parcela-form"> <?php $form = ActiveForm::begin(); ?> <? $model->valor_pago = $model->valor_a_pagar; ?> <?= $form->field($model, 'valor_pago')->widget(MaskMoney::classname(), []); ?> <?= $form->field($model, 'forma_pagamento_id')->dropDownList(\app\models\FormaPagamento::map()) ?> <?= $form->field($model, 'obs')->textInput(['maxlength' => true]) ?> <div class="form-group"> <?= Html::submitButton('Quitar parcela', ['class' => 'btn btn-success']) ?> </div> <?php ActiveForm::end(); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getFormaPagamento() { return $this->hasOne(FormaPagamento::className(), ['idforma_pagamento' => 'forma_pagamento_id']); }
/** * Finds the FormaPagamento model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return FormaPagamento the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = FormaPagamento::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="col-md-3"> <?= $form->field($model, 'desconto')->widget(MaskMoney::classname(), [ ]); ?> </div> <div class="col-md-3"> <? echo $form->field($model, 'forma_pagamento_idforma_pagamento')->widget(Select2::classname(), [ 'data' => \app\models\FormaPagamento::map(), 'options' => ['placeholder' => 'Select a state ...'], 'pluginOptions' => [ 'allowClear' => true ], 'options' => ['placeholder' => 'Selecione uma forma de pagamento...'], 'pluginEvents' => [ "change" => "function(){ var forma_pag_selecionada = $('#venda-forma_pagamento_idforma_pagamento').val(); if(forma_pag_selecionada != ''){ $('#gerar-parcelas').removeClass('hidden'); } else { $('#gerar-parcelas').addClass('hidden');
/*[ 'header' => 'Valor Total', // 'format' => ['decimal', 2], 'value' => function ($data) { return Yii::$app->formatter->asCurrency($data->valortotal - $data->desconto); //return Yii::$app->formatter->asDecimal($data->valortotal - $data->desconto); }, 'pageSummary' => true, //Parcela1-R$100,00 venceu em 10/10/10 , Parcela9-R$100,00 ],*/ [ 'attribute' => 'forma_pagamento_idforma_pagamento', 'header' => 'Forma de Pagamento', 'value' => 'formaPagamentoIdformaPagamento.forma_pagamento', 'filter' => Html::activeDropDownList($searchModel, 'forma_pagamento_idforma_pagamento', \app\models\FormaPagamento::map(),['class'=>'form-control','prompt' => 'Selecione...']), ], [ 'attribute' => 'valorFinal', 'header' => 'Valor Total', 'format' => 'currency', 'pageSummary' => true, ], [ 'attribute' => 'loja', 'header' => 'Loja', 'value' => 'lojaIdloja.nome', ]];?> <div class="text-left">