public function actionPayment()
 {
     $headers = Yii::$app->request->getHeaders();
     if ($headers->has('X-TERMINAL')) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $model = new PaymentForm();
         if ($model->hasError()) {
             return $model->getError();
         }
         $transaction = Transaction::create();
         $connector = new CateringConnector();
         $response = $connector->pay($transaction);
         if (in_array($response['status'], ['error', 'redirect'])) {
             return $response;
         }
         $transaction->is_fulfilled = true;
         $transaction->save();
         return ['status' => 'success'];
     }
     Yii::$app->getSession()->set('payer.account_type', Yii::$app->request->get('account_type'));
     $bills = Bill::find()->where(['enabled' => true])->select('denomination')->asArray()->all();
     $denominations = [];
     foreach ($bills as $bill) {
         $denominations[] = $bill['denomination'];
     }
     Yii::$app->get('xmlrpc')->enableBillTypes();
     return $this->render('payment', ['denominations' => implode(', ', $denominations)]);
 }
Example #2
0
 public static function create($billType, $data)
 {
     $countryCode = $data[0];
     $denomination = $data[1];
     $enabled = $data[2];
     $security = $data[3];
     if ($countryCode !== '' && $countryCode !== 'BAR') {
         $bill = new Bill();
         $bill->bill_type = $billType;
         $bill->country_code = $countryCode;
         $bill->denomination = $denomination;
         $bill->enabled = $enabled;
         $bill->security = $security;
         $bill->save();
         return $bill;
     }
     return null;
 }
 public function enableBillTypes()
 {
     $bills = Bill::find()->select('bill_type')->where(['enabled' => true])->asArray()->all();
     $data = [];
     foreach ($bills as $bill) {
         $data[] = (int) $bill['bill_type'];
     }
     $this->sendCommand('enable_bill_types', [$data]);
 }
 public function search($input)
 {
     $query = Bill::query();
     $columns = Schema::getColumnListing('bills');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
 public function actionInit()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $xmlrpc = Yii::$app->xmlrpc;
     $xmlrpc->sendCommand('get_bill_table');
     if ($xmlrpc->hasError()) {
         return ['status' => 'error', 'error' => $xmlrpc->getErrorMessage($xmlrpc->getErrorCode())];
     }
     Bill::truncate();
     $response = $xmlrpc->getResponse();
     foreach ($response as $index => $item) {
         Bill::create($index, $item);
     }
     Yii::$app->session->setFlash('bill_types_initialized', true);
     return $this->redirect(['/admin/bill']);
 }
Example #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchWithPerson($params)
 {
     $query = Bill::find();
     $query->innerJoinWith('price');
     $query->joinWith('billPersonals');
     $query->orderBy(BillPersonal::tableName() . '.updated_at DESC');
     if (isset($params['id'])) {
         $query->where([BillPersonal::tableName() . '.personal_id' => $params['id']]);
         $query->orWhere([BillPersonal::tableName() . '.personal_id' => null]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new Sort(['attributes' => [self::tableName() . '.id', 'price_total' => ['asc' => ['price.total' => SORT_ASC], 'desc' => ['price.total' => SORT_DESC]], 'discount', 'bp_paid' => ['asc' => [BillPersonal::tableName() . '.paid' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.paid' => SORT_DESC]], 'bp_description' => ['asc' => [BillPersonal::tableName() . '.description' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.description' => SORT_DESC]], 'bp_amount' => ['asc' => [BillPersonal::tableName() . '.amount' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.amount' => SORT_DESC]], self::tableName() . '.created_at', self::tableName() . '.updated_at'], 'defaultOrder' => [self::tableName() . '.updated_at' => SORT_DESC]])]);
     $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;
     }
     if ($this->bp_paid == 0) {
         $this->bp_paid = null;
     }
     $query->andFilterWhere([self::tableName() . '.id' => $this->id, 'price_id' => $this->price_id, 'discount' => $this->discount, self::tableName() . '.created_at' => $this->created_at, self::tableName() . '.updated_at' => $this->updated_at, BillPersonal::tableName() . '.paid' => $this->bp_paid]);
     $query->andFilterWhere(['like', 'price.total', $this->price_total]);
     $query->andFilterWhere(['like', BillPersonal::tableName() . '.amount', $this->bp_amount]);
     $query->andFilterWhere(['like', BillPersonal::tableName() . '.description', $this->bp_description]);
     return $dataProvider;
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBill()
 {
     return $this->hasOne(Bill::className(), ['id' => 'bill_id']);
 }
Example #8
0
 /**
  * Finds the Bill model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Bill the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Bill::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionPrint($id)
 {
     if (($bill = Bill::findOne($id)) !== null) {
         $content = $this->renderPartial('print', ['bill' => $bill]);
         $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => Yii::t('app', 'Bill') . ' ' . Yii::t('app', 'Report')], 'methods' => ['SetHeader' => [Yii::t('app', 'Summary')], 'SetFooter' => ['{PAGENO}']]]);
         return $pdf->render();
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #10
0
 protected function addControls()
 {
     $this->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('nr_bill')->caption('Nr Factura')->class('form-control  data-source')->controlsource('nr_bill')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Combobox::make('~layouts.form.controls.comboboxes.combobox')->name('type_bill')->caption('Tip Factura')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('type_bill')->controltype('combobox')->enabled('false')->options(Bill::tip()))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('consumption_billed')->caption('Consum Facturat')->class('form-control  data-source')->controlsource('consumption_billed')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('value_witch_tva')->caption('Valoare cu T.V.A.')->class('form-control  data-source')->controlsource('value_witch_tva')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox-addon')->name('date_bill')->caption('Data Facturii')->class('form-control  data-source datepicker')->controlsource('date_bill')->controltype('textbox')->addon(['before' => '<i class="fa fa-calendar"></i>', 'after' => NULL]))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox-addon')->name('start_billing')->caption('Inceput Facturare')->class('form-control  data-source datepicker')->controlsource('start_billing')->controltype('textbox')->addon(['before' => '<i class="fa fa-calendar"></i>', 'after' => NULL]))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox-addon')->name('stop_billing')->caption('Sfirsit Perioada Facturare')->class('form-control  data-source datepicker')->controlsource('stop_billing')->controltype('textbox')->addon(['before' => '<i class="fa fa-calendar"></i>', 'after' => NULL]))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('u_m')->caption('Unitatea de Masura')->class('form-control  data-source')->controlsource('u_m')->controltype('textbox')->maxlength(255));
 }