Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. public function actionPrintinvoice($id) {
  2. $model = $this->findModel($id);
  3. $searchModel = new ProdfinSearch();
  4. $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  5. $data = Prodfin::findOne($id);
  6. $dataProvider = new ActiveDataProvider([
  7. 'query' => Prodsummary::find()->select(['productcode','productname','qty','rate','amount'])->where(['prfinid' => $id]),
  8. 'pagination' => [
  9. 'pageSize' => 20,
  10. ],
  11. ]);
  12. $posts = $dataProvider->getModels();
  13. $content = $this->renderPartial('_printInvoice', [
  14. 'model' => $model,
  15. 'dataProvider' => $dataProvider,
  16. 'searchModel' => $searchModel,
  17. 'data'=> $data,
  18.  
  19. ]);
  20. $pdf = new Pdf([
  21. 'mode'=> Pdf::MODE_UTF8,
  22. 'format'=> Pdf::FORMAT_A4,
  23. 'destination'=> Pdf::DEST_BROWSER,
  24. //'destination' => Pdf::DEST_DOWNLOAD,
  25. 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
  26. // any css to be embedded if required
  27. 'cssInline' => '.kv-heading-1{font-size:18px}',
  28. // set mPDF properties on the fly
  29. 'options' => ['title' => 'Print Invoice'],
  30. // call mPDF methods on the fly
  31. 'methods' => [
  32. 'SetHeader'=>['Private and Confidential'],
  33. 'SetFooter'=>['This Payslip is computer generated.'],
  34. ],
  35. 'content' => $content,
  36.  
  37. ]);
  38. return $pdf->render();
  39. //return $this->render('_printSalarystatement', ['s_period' => $s_period]);
  40.  
  41. }
  42.  
  43. <?php
  44.  
  45. use yiihelpersHtml;
  46. use yiiwidgetsDetailView;
  47.  
  48. /* @var $this yiiwebView */
  49. /* @var $model frontendmodulesprintinvoicemodelsProdfin */
  50.  
  51. $this->title = $model->prfinslno;
  52. $this->params['breadcrumbs'][] = ['label' => 'Prodfins', 'url' => ['index']];
  53. $this->params['breadcrumbs'][] = $this->title;
  54. ?>
  55. <div class="ps-details">
  56. <div style="width:38%; float:left;border:1px solid black;">
  57. <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>
  58. <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-left">My details</p></h5>
  59. <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-left">My Address</p></h5>
  60. </div>
  61. <div style="width:61.25%; float:right;border:1px solid black;">
  62. <table style="width:100%">
  63. <tr>
  64. <td>PAN No.</td>
  65. <td>AGZPD/2365A</td>
  66. <td>&nbsp;</td>
  67. <td>&nbsp;</td>
  68. </tr>
  69. <tr>
  70. <td>Invoice No.</td>
  71. <td><?php echo $model['invoiceno'];?></td>
  72. <td>Date : </td>
  73. <td><?php echo $model['date'];?></td>
  74. </tr>
  75. <tr>
  76. <td>Challan No.</td>
  77. <td><?php echo $model['challanno'];?></td>
  78. <td>Date : </td>
  79. <td><?php echo $model['date'];?></td>
  80. </tr>
  81. <tr>
  82. <td>Order No.</td>
  83. <td><?php echo $model['orderno'];?></td>
  84. <td>Date : </td>
  85. <td><?php echo $model['date'];?></td>
  86. </tr>
  87. </table>
  88. </div>
  89. </div>
  90. <div class="orient-details">
  91. <div style="width:100%; float:center;border:1px solid black;">
  92. <h3 style="margin-bottom:0;margin-top:2;margin-left:2;"><strong><p class="text-center">My Company</p></strong></h3>
  93. <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-center">A Division of My Company</p></h5>
  94. <h5 style="margin-bottom:0;margin-top:0;margin-left:2;"><p class="text-center">My Address</p></h5>
  95. </div>
  96. </div>
  97. <div class="product-details">
  98. <?= DetailView::widget([
  99. 'model' => $model,
  100. 'attributes' => [
  101. //'id',
  102. 'productcode',
  103. 'productname',
  104. 'qty',
  105. 'rate',
  106. 'amount:ntext'
  107. //'ativo',
  108. ],
  109. ]) ?>
  110. </div>
  111. <div class="prodfin-view">
  112.  
  113. <!-- <h1><?= Html::encode($this->title) ?></h1> -->
  114.  
  115.  
  116. <!-- <strong>Using display: inline-block; </strong><br>
  117. <table style="border:1px solid black;border-collapse:collapse;width:100%" class="inlineTable">
  118. <tr>
  119. <td style="border-right: 1px solid";><font face="Calibri";size="72">M/S P.S. Enterprise</font></td>
  120. <td>This One will contain the Invoice details</td>
  121. </tr>
  122. </table> -->
  123. <?= DetailView::widget([
  124. 'model' => $model,
  125. 'attributes' => [
  126. 'prfinslno',
  127. 'invoiceno',
  128. 'challanno',
  129. 'orderno',
  130. 'amount',
  131. 'date',
  132. ],
  133. ]) ?>
  134.  
  135. </div>
  136.  
  137. <?php
  138.  
  139. namespace frontendmodulesprintinvoicemodels;
  140.  
  141. use Yii;
  142.  
  143. /**
  144. * This is the model class for table "prodfin".
  145. *
  146. * @property string $prfinslno
  147. * @property string $invoiceno
  148. * @property string $challanno
  149. * @property string $orderno
  150. * @property string $amount
  151. * @property string $date
  152. */
  153. class Prodfin extends yiidbActiveRecord
  154. {
  155. /**
  156. * @inheritdoc
  157. */
  158. public static function tableName()
  159. {
  160. return 'prodfin';
  161. }
  162.  
  163. /**
  164. * @inheritdoc
  165. */
  166. public function rules()
  167. {
  168. return [
  169. [['date'], 'safe'],
  170. [['invoiceno', 'challanno', 'orderno', 'amount'], 'string', 'max' => 40],
  171. ];
  172. }
  173.  
  174. /**
  175. * @inheritdoc
  176. */
  177. public function attributeLabels()
  178. {
  179. return [
  180. 'prfinslno' => 'Prfinslno',
  181. 'invoiceno' => 'Invoiceno',
  182. 'challanno' => 'Challanno',
  183. 'orderno' => 'Orderno',
  184. 'amount' => 'Amount',
  185. 'date' => 'Date',
  186. ];
  187. }
  188. }
  189.  
  190. <?php
  191.  
  192. namespace frontendmodulesprintinvoicemodels;
  193.  
  194. use Yii;
  195.  
  196. /**
  197. * This is the model class for table "prodsummary".
  198. *
  199. * @property string $prid
  200. * @property string $productiondate
  201. * @property string $invoiceno
  202. * @property string $challanno
  203. * @property string $orderno
  204. * @property string $productcode
  205. * @property string $productname
  206. * @property string $unit
  207. * @property string $qty
  208. * @property string $rate
  209. * @property string $amount
  210. */
  211. class Prodsummary extends yiidbActiveRecord
  212. {
  213. /**
  214. * @inheritdoc
  215. */
  216. public static function tableName()
  217. {
  218. return 'prodsummary';
  219. }
  220.  
  221. /**
  222. * @inheritdoc
  223. */
  224. public function rules()
  225. {
  226. return [
  227. [['productiondate'], 'safe'],
  228. [['invoiceno', 'challanno', 'orderno'], 'string', 'max' => 40],
  229. [['productcode', 'amount'], 'string', 'max' => 15],
  230. [['productname'], 'string', 'max' => 80],
  231. [['unit', 'qty', 'rate'], 'string', 'max' => 10],
  232. ];
  233. }
  234.  
  235. /**
  236. * @inheritdoc
  237. */
  238. public function attributeLabels()
  239. {
  240. return [
  241. 'prid' => 'Prid',
  242. 'productiondate' => 'Productiondate',
  243. 'invoiceno' => 'Invoiceno',
  244. 'challanno' => 'Challanno',
  245. 'orderno' => 'Orderno',
  246. 'productcode' => 'Productcode',
  247. 'productname' => 'Productname',
  248. 'unit' => 'Unit',
  249. 'qty' => 'Qty',
  250. 'rate' => 'Rate',
  251. 'amount' => 'Amount',
  252. ];
  253. }
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement