Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionPrintinvoice($id) {
- $model = $this->findModel($id);
- $searchModel = new ProdfinSearch();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
- $data = Prodfin::findOne($id);
- $dataProvider = new ActiveDataProvider([
- 'query' => Prodsummary::find()->select(['productcode','productname','qty','rate','amount'])->where(['prfinid' => $id]),
- 'pagination' => [
- 'pageSize' => 20,
- ],
- ]);
- $posts = $dataProvider->getModels();
- $content = $this->renderPartial('_printInvoice', [
- 'model' => $model,
- 'dataProvider' => $dataProvider,
- 'searchModel' => $searchModel,
- 'data'=> $data,
- ]);
- $pdf = new Pdf([
- 'mode'=> Pdf::MODE_UTF8,
- 'format'=> Pdf::FORMAT_A4,
- 'destination'=> Pdf::DEST_BROWSER,
- //'destination' => Pdf::DEST_DOWNLOAD,
- 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
- // any css to be embedded if required
- 'cssInline' => '.kv-heading-1{font-size:18px}',
- // set mPDF properties on the fly
- 'options' => ['title' => 'Print Invoice'],
- // call mPDF methods on the fly
- 'methods' => [
- 'SetHeader'=>['Private and Confidential'],
- 'SetFooter'=>['This Payslip is computer generated.'],
- ],
- 'content' => $content,
- ]);
- return $pdf->render();
- //return $this->render('_printSalarystatement', ['s_period' => $s_period]);
- }
- <?php
- use yiihelpersHtml;
- use yiiwidgetsDetailView;
- /* @var $this yiiwebView */
- /* @var $model frontendmodulesprintinvoicemodelsProdfin */
- $this->title = $model->prfinslno;
- $this->params['breadcrumbs'][] = ['label' => 'Prodfins', 'url' => ['index']];
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="ps-details">
- <div style="width:38%; float:left;border:1px solid black;">
- <h3 style="margin-bottom:0;margin-bottom:0;margin-top:2;margin-left:2;"><strong><p class="text-left">M/S. My Company</p></strong></h3>
- <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-left">My details</p></h5>
- <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-left">My Address</p></h5>
- </div>
- <div style="width:61.25%; float:right;border:1px solid black;">
- <table style="width:100%">
- <tr>
- <td>PAN No.</td>
- <td>AGZPD/2365A</td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td>Invoice No.</td>
- <td><?php echo $model['invoiceno'];?></td>
- <td>Date : </td>
- <td><?php echo $model['date'];?></td>
- </tr>
- <tr>
- <td>Challan No.</td>
- <td><?php echo $model['challanno'];?></td>
- <td>Date : </td>
- <td><?php echo $model['date'];?></td>
- </tr>
- <tr>
- <td>Order No.</td>
- <td><?php echo $model['orderno'];?></td>
- <td>Date : </td>
- <td><?php echo $model['date'];?></td>
- </tr>
- </table>
- </div>
- </div>
- <div class="orient-details">
- <div style="width:100%; float:center;border:1px solid black;">
- <h3 style="margin-bottom:0;margin-top:2;margin-left:2;"><strong><p class="text-center">My Company</p></strong></h3>
- <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-center">A Division of My Company</p></h5>
- <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-center">My Address</p></h5>
- </div>
- </div>
- <div class="product-details">
- <?= DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- //'id',
- 'productcode',
- 'productname',
- 'qty',
- 'rate',
- 'amount:ntext'
- //'ativo',
- ],
- ]) ?>
- </div>
- <div class="prodfin-view">
- <!-- <h1><?= Html::encode($this->title) ?></h1> -->
- <!-- <strong>Using display: inline-block; </strong><br>
- <table style="border:1px solid black;border-collapse:collapse;width:100%" class="inlineTable">
- <tr>
- <td style="border-right: 1px solid";><font face="Calibri";size="72">M/S P.S. Enterprise</font></td>
- <td>This One will contain the Invoice details</td>
- </tr>
- </table> -->
- <?= DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'prfinslno',
- 'invoiceno',
- 'challanno',
- 'orderno',
- 'amount',
- 'date',
- ],
- ]) ?>
- </div>
- <?php
- namespace frontendmodulesprintinvoicemodels;
- use Yii;
- /**
- * This is the model class for table "prodfin".
- *
- * @property string $prfinslno
- * @property string $invoiceno
- * @property string $challanno
- * @property string $orderno
- * @property string $amount
- * @property string $date
- */
- class Prodfin extends yiidbActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'prodfin';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['date'], 'safe'],
- [['invoiceno', 'challanno', 'orderno', 'amount'], 'string', 'max' => 40],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'prfinslno' => 'Prfinslno',
- 'invoiceno' => 'Invoiceno',
- 'challanno' => 'Challanno',
- 'orderno' => 'Orderno',
- 'amount' => 'Amount',
- 'date' => 'Date',
- ];
- }
- }
- <?php
- namespace frontendmodulesprintinvoicemodels;
- use Yii;
- /**
- * This is the model class for table "prodsummary".
- *
- * @property string $prid
- * @property string $productiondate
- * @property string $invoiceno
- * @property string $challanno
- * @property string $orderno
- * @property string $productcode
- * @property string $productname
- * @property string $unit
- * @property string $qty
- * @property string $rate
- * @property string $amount
- */
- class Prodsummary extends yiidbActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'prodsummary';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['productiondate'], 'safe'],
- [['invoiceno', 'challanno', 'orderno'], 'string', 'max' => 40],
- [['productcode', 'amount'], 'string', 'max' => 15],
- [['productname'], 'string', 'max' => 80],
- [['unit', 'qty', 'rate'], 'string', 'max' => 10],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'prid' => 'Prid',
- 'productiondate' => 'Productiondate',
- 'invoiceno' => 'Invoiceno',
- 'challanno' => 'Challanno',
- 'orderno' => 'Orderno',
- 'productcode' => 'Productcode',
- 'productname' => 'Productname',
- 'unit' => 'Unit',
- 'qty' => 'Qty',
- 'rate' => 'Rate',
- 'amount' => 'Amount',
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement