Example #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInvoice()
 {
     return $this->hasOne(AccountInvoice::className(), ['id' => 'invoice_id']);
 }
 public function actionNotaRetur($id)
 {
     $this->layout = 'report';
     $model = new AccountInvoice();
     $AccountInvoice = AccountInvoice::find()->where(['id' => $id])->one();
     return $this->render('report/noteretur', ['model' => $AccountInvoice]);
 }
Example #3
0
 public function actionGetInvoicesCsv($ids)
 {
     $ids = explode(',', $ids);
     // \yii\helpers\VarDumper::dump($ids);
     if (is_array($ids)) {
         $invoices = AccountInvoice::find()->where(['id' => $ids])->with(['currency', 'accountInvoiceLines', 'partner', 'partner.state', 'partner.parent', 'accountInvoiceLines.product', 'stockPickings', 'accountInvoiceLines.account', 'fakturAddress', 'fakturAddress.parent'])->asArray()->all();
         $maped = $this->prepareCsvInvoiceData($invoices);
         if (!$maped) {
             throw new NotFoundHttpException('Tidak ada data yang dapat di export. Tolong pastikan data yang dipilih untuk di export adalah data yang ber status sudah Proforma!');
         }
         /*\yii\helpers\VarDumper::dump($maped);
         		die();*/
         $filename = 'INVOICES-' . (isset($maped['OUT']) ? 'OUT' : 'IN') . '-' . implode('+', array_keys($maped[isset($maped['OUT']) ? 'OUT' : 'IN'])) . '.csv';
         header("Content-Type: text/csv;charset=UTF-8");
         header("Content-Disposition: attachment;filename=\"{$filename}\"");
         header("Pragma: no-cache");
         header("Expires: 0");
         $output = fopen('php://output', 'w');
         // $ctn = '';
         //
         if (isset($maped['OUT'])) {
             fputcsv($output, array_map(function ($e) {
                 return $e;
             }, ["FK", "KD_JENIS_TRANSAKSI", "FG_PENGGANTI", "NOMOR_FAKTUR", "MASA_PAJAK", "TAHUN_PAJAK", "TANGGAL_FAKTUR", "NPWP", "NAMA", "ALAMAT_LENGKAP", "JUMLAH_DPP", "JUMLAH_PPN", "JUMLAH_PPNBM", "ID_KETERANGAN_TAMBAHAN", "FG_UANG_MUKA", "UANG_MUKA_DPP", "UANG_MUKA_PPN", "UANG_MUKA_PPNBM", "REFERENSI"]), ',');
             fputcsv($output, array_map(function ($e) {
                 return $e;
             }, ["LT", "NPWP", "NAMA", "JALAN", "BLOK", "NOMOR", "RT", "RW", "KECAMATAN", "KELURAHAN", "KABUPATEN", "PROPINSI", "KODE_POS", "NOMOR_TELEPON"]), ',');
             fputcsv($output, array_map(function ($e) {
                 return $e;
             }, ["OF", "KODE_OBJEK", "NAMA", "HARGA_SATUAN", "JUMLAH_BARANG", "HARGA_TOTAL", "DISKON", "DPP", "PPN", "TARIF_PPNBM", "PPNBM"]), ',');
             foreach ($maped['OUT'] as $invId => $map) {
                 /*echo count($map['fk']).'-';
                 		echo count($map['fapr']).'-';
                 		echo count($map['of'][0]).'-';*/
                 fputcsv($output, array_map(function ($e) {
                     return mb_convert_encoding(utf8_encode($e), 'ISO-8859-1', 'UTF-8');
                 }, $map['fk']), ',');
                 fputcsv($output, array_map(function ($e) {
                     return mb_convert_encoding(utf8_encode($e), 'ISO-8859-1', 'UTF-8');
                 }, $map['fapr']), ',');
                 foreach ($map['of'] as $of) {
                     fputcsv($output, array_map(function ($e) {
                         return mb_convert_encoding(utf8_encode($e), 'ISO-8859-1', 'UTF-8');
                     }, $of), ',');
                 }
             }
         } else {
             fputcsv($output, ["FM", "KD_JENIS_TRANSAKSI", "FG_PENGGANTI", "NOMOR_FAKTUR", "MASA_PAJAK", "TAHUN_PAJAK", "TANGGAL_FAKTUR", "NPWP", "NAMA", "ALAMAT_LENGKAP", "JUMLAH_DPP", "JUMLAH_PPN", "JUMLAH_PPNBM", "IS_CREDITABLE"]);
             foreach ($maped['IN'] as $in) {
                 fputcsv($output, $in);
             }
         }
         fclose($output);
         Yii::$app->end();
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAccountInvoices()
 {
     return $this->hasMany(AccountInvoice::className(), ['payment_term' => 'id']);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAccountInvoices()
 {
     return $this->hasMany(AccountInvoice::className(), ['partner_id' => 'id']);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = null, $type = null, $dateRange = null, $groupBy = null)
 {
     $query = AccountInvoice::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date_invoice' => SORT_DESC]]]);
     /*if (!($this->load($params) && $this->validate())) {
     			return $dataProvider;
     		}*/
     $dateInvoiceFilter = $this->date_invoice;
     if (preg_match('/To/', $this->date_invoice)) {
         // if date range
         $dateInvoiceFilter = 'BETWEEN :date_from AND :date_to';
         $expl = explode('To', $this->date_invoice);
         $query->where(['between', 'date_invoice', $expl[0], $expl[1]]);
     }
     $query->andFilterWhere(['id' => $this->id, 'create_uid' => $this->create_uid, 'create_date' => $this->create_date, 'write_date' => $this->write_date, 'write_uid' => $this->write_uid, 'date_due' => $this->date_due, 'check_total' => $this->check_total, 'account_id' => $this->account_id, 'company_id' => $this->company_id, 'currency_id' => $this->currency_id, 'partner_id' => $this->partner_id, 'fiscal_position' => $this->fiscal_position, 'user_id' => $this->user_id, 'partner_bank_id' => $this->partner_bank_id, 'payment_term' => $this->payment_term, 'journal_id' => $this->journal_id, 'amount_tax' => $this->amount_tax, 'reconciled' => $this->reconciled, 'residual' => $this->residual, 'period_id' => $this->period_id, 'amount_untaxed' => $this->amount_untaxed, 'move_id' => $this->move_id, 'amount_untaxed' => $this->amount_untaxed, 'sent' => $this->sent, 'commercial_partner_id' => $this->commercial_partner_id, 'pajak' => $this->pajak, 'kurs' => $this->kurs, 'approver' => $this->approver]);
     $query->andFilterWhere(['like', 'origin', $this->origin])->andFilterWhere(['like', 'reference', $this->reference])->andFilterWhere(['like', 'supplier_invoice_number', $this->supplier_invoice_number])->andFilterWhere(['like', 'number', $this->number])->andFilterWhere(['like', 'reference_type', $this->reference_type])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'internal_number', $this->internal_number])->andFilterWhere(['like', 'move_name', $this->move_name])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'kmk', $this->kmk])->andFilterWhere(['like', 'faktur_pajak_no', $this->faktur_pajak_no])->andFilterWhere(['like', 'kwitansi', $this->kwitansi]);
     return $dataProvider;
 }
 /**
  * Finds the AccountInvoice model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AccountInvoice the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AccountInvoice::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #8
0
 public function getInvoices()
 {
     return $this->hasMany(AccountInvoice::className(), ['id' => 'invoice_id'])->via('saleOrderInvoiceRels');
 }