?> <hr> <h1>Time Quantity:</h1> <?php /* <?= $form->field($purchase_mdl, 'device_count_id')->textInput() ?> <?= $form->field($purchase_mdl, 'time_id')->textInput() ?> */ echo $form->field($purchase_mdl, 'user_id')->label(false)->hiddenInput(['value' => Yii::$app->user->getIdentity()->getAttribute('id')]); ?> <div class="form-group field-purchase-type required"> <div class="col-sm-6 col-sm-offset-3"> <?php echo Html::activeDropDownList($purchase_mdl, 'time_amount_id', ArrayHelper::map(TimeAmountOptions::find()->all(), 'id', 'key', 'cost'), ['prompt' => '--Select Number of Devices--', 'class' => 'form-control']); ?> </div> </div> <?php echo $this->render('_billing', ['form' => $form, 'purchase_mdl' => $purchase_mdl]); ?> <?php echo $this->render('_payment', ['form' => $form, 'cc_format_mdl' => $cc_format_mdl]); ?> <?php echo $this->render('_submitbuttons'); ?>
/** * Get the users current expiration time, OR current timestamp OR future expiration time * * @version 0.6.5 * @since 0.6.5 * @param object $param_data * @return integer $return_data */ private static function getCurrentExpiration($param_data) { $prev_expiration = Device::find()->where(['user_id' => $param_data['user_id']])->one(); // calculate the new expiration time $return_data = isset($prev_expiration) && count($prev_expiration) > 0 ? $prev_expiration->getAttribute('expiration') : time(); // if the form wants to set a new expiratin time if ($param_data->getAttribute('time_amount_id') !== null) { $return_data = $return_data + TimeAmountOptions::find()->where(['id' => $param_data->getAttribute('time_amount_id')])->one()->getAttribute('value'); } return $return_data; }
?> <div class="purchase-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php /* <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a('Delete', ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => 'Are you sure you want to delete this item?', 'method' => 'post', ], ]) ?> */ ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Length of Time', 'value' => TimeAmountOptions::find()->where(['id' => $model->getAttribute('time_amount_id')])->one()->getAttribute('key')], ['label' => '# of Devices', 'value' => DeviceCountOptions::find()->where(['id' => $model->getAttribute('device_count_id')])->one()->getAttribute('key')], 'f_name', 'l_name', 'street_1', 'street_2', 'city', ['label' => 'State / Prov.', 'value' => $model->getAttribute('prov')], 'postal', 'last_4', 'price', 'created_at:datetime']]); ?> </div>
/** * [prepPayPalData description] * * Maps data from the two forms into the way the paypal component expects it. * * @version 0.5.1 * @since 0.5.1 * @param Purchase $param_data * @param CCFormat $cc_data * @return array */ private function prepPayPalData(Purchase $param_data, CCFormat $cc_data) { // todo This iteration is Paypal only. - DJE : 2015-04-11 // Process the CC transaction $return_data['Address'] = ['City' => $param_data->getAttribute('city'), 'CountryCode' => Country::find('value')->where(['id' => $param_data->getAttribute('country_id')])->one()->getAttribute('key'), 'Line1' => $param_data->getAttribute('street_1'), 'Line2' => $param_data->getAttribute('street_2'), 'PostalCode' => $param_data->getAttribute('postal'), 'State' => $param_data->getAttribute('prov')]; // Process the CC transaction $return_data['CreditCard'] = ['Cvv2' => $cc_data['cvv2'], 'FirstName' => $param_data->getAttribute('f_name'), 'LastName' => $param_data->getAttribute('l_name'), 'Month' => $cc_data['exp_month'], 'Number' => $cc_data['number'], 'Type' => $cc_data['type'], 'Year' => $cc_data['exp_year']]; $subtotal = []; $subtotal[0] = isset(\Yii::$app->request->post()['Purchase']['time_amount_id']) ? TimeAmountOptions::find('value')->where(['id' => \Yii::$app->request->post()['Purchase']['time_amount_id']])->one()->getAttribute('cost') : 0; $subtotal[1] = isset(\Yii::$app->request->post()['Purchase']['device_count_id']) ? DeviceCountOptions::find('value')->where(['id' => \Yii::$app->request->post()['Purchase']['device_count_id']])->one()->getAttribute('cost') : 0; $return_data['Details']['SubTotal'] = array_sum($subtotal); return $return_data; }
/** * Finds the TimeAmountOptions model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TimeAmountOptions the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TimeAmountOptions::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }