use kartik\money\MaskMoney; use kartik\widgets\Select2; use kartik\widgets\SwitchInput; use kartik\datetime\DateTimePicker; use amilna\yes\models\Payment; /* @var $this yii\web\View */ /* @var $model amilna\cap\models\Transaction */ /* @var $form yii\widgets\ActiveForm */ $this->title = 'Invoice ' . $model->reference; //$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $data = json_decode($model->data); $customer = $data->customer; $shipping = isset($data->shipping) ? json_decode($data->shipping) : null; $cart = isset($data->cart) && $data->cart != "null" ? json_decode($data->cart) : []; $payment = isset($data->payment) ? Payment::findOne($data->payment) : false; $module = Yii::$app->getModule('yes'); $company = '<strong>' . $module->company["name"] . '</strong><br> ' . $module->company["address"] . '<br> ' . Yii::t("app", "Phones") . ': ' . $module->company["phone"] . '<br/> ' . Yii::t("app", "Email") . ': <a href="mailto:' . $model->toHex($module->company["email"]) . '">' . str_replace("@", " [AT] ", $module->company["email"]) . '</a>'; $subject = '<strong>' . Html::encode($customer->name) . '</strong><br> ' . Html::encode($customer->address) . '<br> ' . ($shipping != null ? Html::encode($shipping->city . ', ' . $shipping->area) . '<br>' : '') . ' ' . Yii::t("app", "Phones") . ': ' . Html::encode($customer->phones) . '<br/> ' . (isset($customer->email) ? Yii::t("app", "Email") . ': <a href="mailto:' . $model->toHex($customer->email) . '">' . str_replace("@", " [AT] ", $customer->email) : "") . '</a>'; ?> <h1><small><?php echo Html::encode($this->title); ?>
/** * Finds the Payment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Payment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Payment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function find() { return parent::find()->where([Payment::tableName() . '.isdel' => 0]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = $this->find(); $query->joinWith(['order', 'payment']); $dataProvider = new ActiveDataProvider(['query' => $query]); /* uncomment to sort by relations table on respective column */ $dataProvider->sort->attributes['paymentTerminal'] = ['asc' => [Payment::tableName() . '.terminal' => SORT_ASC], 'desc' => [Payment::tableName() . '.terminal' => SORT_DESC]]; $dataProvider->sort->attributes['orderReference'] = ['asc' => [Order::tableName() . '.reference' => SORT_ASC], 'desc' => [Order::tableName() . '.reference' => SORT_DESC]]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $params = self::queryNumber([['id', $this->tableName()], ['order_id'], ['payment_id'], ['amount'], ['isdel']]); foreach ($params as $p) { $query->andFilterWhere($p); } $params = self::queryString([['terminal', Confirmation::tableName()], ['account', Confirmation::tableName()], ['name', Confirmation::tableName()], ['remarks']]); foreach ($params as $p) { $query->andFilterWhere($p); } $params = self::queryTime([['time']]); foreach ($params as $p) { $query->andFilterWhere($p); } /* example to use search all in field1,field2,field3 or field4 */ if ($this->paymentTerminal) { $query->andFilterWhere(["OR", "lower(" . Payment::tableName() . ".terminal) like '%" . strtolower($this->paymentTerminal) . "%'", ["OR", "lower(" . Payment::tableName() . ".account) like '%" . strtolower($this->paymentTerminal) . "%'", "lower(" . Payment::tableName() . ".name) like '%" . strtolower($this->paymentTerminal) . "%'"]]); } $query->andFilterWhere(["like", "lower(" . Order::tableName() . ".reference)", strtolower($this->orderReference)]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPayment() { return $this->hasOne(Payment::className(), ['id' => 'payment_id']); }