public function beforeSave($insert) { if (parent::beforeSave($insert)) { $this->slug = Helpers::getSlug($this->name); return true; } else { return false; } }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $this->slug = Helpers::getSlug($this->title); if ($insert) { $this->date = date('Y-m-d'); } return true; } else { return false; } }
" class="product thumbnail"> <img src="<?php echo $product['thumbnail']; ?> " alt="<?php echo $product['name']; ?> "> <div class="cat"><?php echo $product->category->name; ?> </div> <div class="title"><?php echo $product['name']; ?> </div> <div class="price text-bold"><?php echo Helpers::formatPrice($product['price']); ?> </div> </a> </div> <?php } ?> </div> <div class="text-right"> <?php echo \yii\widgets\LinkPager::widget(['pagination' => $pagination]); ?> </div>
<?php } ?> </div> </a> <p class="doc"></p> <p class="info"><em>Read more...</em></p> </div> <div class="col-md-7" id="thumb-content"> <div class="caption"> <h4><?php echo $tour->name; ?> </h4> <p><?php echo \app\components\Helpers::limit_text($tour->briefinfo, 50); ?> </p> <ul class="tour-info inline text-right"> <li class="details"> <span class="glyphicon glyphicon-share-alt"></span> <a class="details" href="<?php echo \yii\helpers\Url::to(['tour/show-detail', 'id' => $tour->id]); ?> ">Details</a> </li> <li class="enquire" data-toggle="modal" data-target="#book_tour"> <span class="glyphicon glyphicon-share-alt"></span> ENQUIRE NOW </li> </ul> </div>
<?php use yii\helpers\Html; use yii\grid\GridView; use app\components\Helpers; $this->title = 'Sản phẩm'; $this->params['breadcrumbs'][] = $this->title; ?> <div id="product-list"> <p class="text-right"><?php echo Html::a('Tạo mới', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'summary' => '', 'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'thumbnail', 'format' => 'image', 'contentOptions' => ['class' => 'thumbnail-list']], ['attribute' => 'pro_id', 'value' => function ($model) { return $model->producer->name; }], ['attribute' => 'cate_id', 'value' => function ($model) { return $model->category->name; }], ['attribute' => 'price', 'value' => function ($model) { return Helpers::formatPrice($model->price); }], ['attribute' => 'status', 'value' => function ($model) { return $model->getStatusLabel($model->status); }], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['class' => 'text-center'], 'template' => '{update} {delete} {thumbnail}', 'header' => 'Tùy chọn', 'headerOptions' => ['class' => 'text-center'], 'buttons' => ['thumbnail' => function ($url, $model, $key) { return Html::a('<i class="fa fa-picture-o"></i>', ['thumbnail/list', 'product_id' => $key], ['title' => 'Danh sách hình']); }]]]]); ?> </div>
public static function getSlug($str) { $helper = new Helpers(); Inflector::$transliteration = array_merge(Inflector::$transliteration, $helper->listUnicodeChar()); return Inflector::slug($str, '-', false); }
public function actionAjaxcall() { echo Helpers::renderOption(Page::listPagesUrl()); }
<div id="category-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 100]); ?> <div class="form-group"> <?php echo Html::label('Loại liên kết', ['class' => 'control-label']); ?> <?php echo Html::dropDownList('type', null, Helpers::listUrlType(), ['class' => 'form-control type-select']); ?> </div> <div class="form-group"> <?php echo Html::label('Trang', ['class' => 'control-label']); ?> <?php echo Html::dropDownList('type', null, Page::listPagesUrl(), ['class' => 'form-control url-select']); ?> </div> <?php echo $form->field($model, 'url')->textInput(['maxlength' => 100, 'class' => 'form-control url-input']); ?>
public function actionAjaxcall() { echo Helpers::renderOption(Product::listProductsUrl()); }
public function actionExportExcel() { //$searchModel = new SecuritasSearch(); //$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $session = Yii::$app->session; $renderHarvestToolsReport = $session->get('renderHarvestToolsReport'); $objReader = \PHPExcel_IOFactory::createReader('Excel2007'); $template = Yii::getAlias('@app/views/' . $this->id) . '/_export.xlsx'; $objPHPExcel = $objReader->load($template); $activeSheet = $objPHPExcel->getActiveSheet(); $border_style = ['borders' => ['allborders' => ['style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => ['argb' => '000000']]]]; $text_center = ['horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER]; $font_bold9 = ['font' => ['bold' => true, 'color' => ['rgb' => '000000'], 'size' => 9, 'name' => 'Calibri']]; $font_bold8 = ['font' => ['bold' => true, 'color' => ['rgb' => '000000'], 'size' => 8, 'name' => 'Calibri']]; $bg_gray = ['fill' => ['type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => ['rgb' => 'dddddd']]]; $activeSheet->setCellValue('G2', 'print at ' . date('d-M-Y H:i:s')); $years = 'Semua'; if (!empty($renderHarvestToolsReport['years'])) { $years = implode(', ', $renderHarvestToolsReport['years']); } $activeSheet->setCellValue('C3', $years); $quarters = 'Semua'; if (!empty($renderHarvestToolsReport['quarters'])) { $quarters = implode(', ', $renderHarvestToolsReport['quarters']); } $activeSheet->setCellValue('C4', $quarters); $states = 'Semua'; if (!empty($renderHarvestToolsReport['states'])) { $states = implode(', ', $renderHarvestToolsReport['states']); } $activeSheet->setCellValue('C5', $states); $typeToolses2 = 'Semua'; if (!empty($renderHarvestToolsReport['typeToolses2'])) { $typeToolses2 = implode(', ', $renderHarvestToolsReport['typeToolses2']); } $activeSheet->setCellValue('C7', $typeToolses2); $typeToolses = $renderHarvestToolsReport['typeToolses']; $stateCount = $renderHarvestToolsReport['stateCount']; $startRow = 11; $i = 0; foreach ($typeToolses as $typeTools) { if ($i == 0) { $row = $startRow + $i; } else { $row++; } //$activeSheet->insertNewRowBefore($row,1); $activeSheet->setCellValue('A' . $row, Helpers::columnLetter($i + 1)); $activeSheet->setCellValue('B' . $row, $typeTools->name); $activeSheet->getStyle("A" . $row . ":B" . $row)->applyFromArray($font_bold9); $activeSheet->getStyle("A" . $row . ":A" . $row)->getAlignment()->applyFromArray($text_center); $toolss = Tools::find()->where(['type_tools_id' => $typeTools->id])->all(); $idx_tools = 0; foreach ($toolss as $tools) { //$activeSheet->insertNewRowBefore($row,1); $row++; $activeSheet->setCellValue('B' . $row, $idx_tools + 1); $activeSheet->setCellValue('C' . $row, $tools->name); $activeSheet->getStyle("B" . $row . ":C" . $row)->applyFromArray($font_bold8); $activeSheet->getStyle("B" . $row . ":B" . $row)->getAlignment()->applyFromArray($text_center); $where['tools_id'] = $tools->id; if (!empty($renderHarvestToolsReport['years'])) { $where['year'] = $renderHarvestToolsReport['years']; } if (!empty($renderHarvestToolsReport['quarters'])) { $where['quarter'] = $renderHarvestToolsReport['quarters']; } if (!empty($renderHarvestToolsReport['stateIds'])) { $where['state_id'] = $renderHarvestToolsReport['stateIds']; } $harvestToolses = HarvestTools::find()->select("\n sum(param1) as sparam1,\n sum(param2) as sparam2,\n sum(param3) as sparam3,\n sum(param4) as sparam4,\n sum(param5) as sparam5,\n group_concat(note1) as gcnote1,\n group_concat(note2) as gcnote2,\n group_concat(note3) as gcnote3,\n group_concat(note4) as gcnote4,\n group_concat(note5) as gcnote5,\n count(state_id) as cstate\n ")->where($where)->asArray()->one(); $params = explode('|', $typeTools->params); $units = explode('|', $typeTools->units); if (count($params) > 0 and count($units) > 0 and count($params) == count($units)) { $combines = array_combine($params, $units); $idx = 1; $row++; $starRowTable = $row; $activeSheet->setCellValue('B' . $row, 'NO'); $activeSheet->setCellValue('C' . $row, 'PARAMETER'); $activeSheet->setCellValue('D' . $row, 'NILAI'); $activeSheet->setCellValue('E' . $row, 'SATUAN'); $activeSheet->setCellValue('F' . $row, 'KETERANGAN'); $activeSheet->setCellValue('G' . $row, 'DATA MASUK'); $activeSheet->getStyle('B' . $row . ':G' . $row)->applyFromArray($bg_gray); foreach ($combines as $param => $unit) { $row++; $activeSheet->setCellValue('B' . $row, $idx); $activeSheet->setCellValue('C' . $row, $param); $activeSheet->setCellValue('D' . $row, $harvestToolses['sparam' . $idx]); $activeSheet->setCellValue('E' . $row, $unit); //$activeSheet->getStyle("F".$row)->getAlignment()->setWrapText(true); //$activeSheet->getDefaultRowDimension()->setRowHeight(-1); $activeSheet->getRowDimension($row)->setRowHeight(-1); $activeSheet->setCellValue('F' . $row, $harvestToolses['gcnote' . $idx] . ' lorem ipsum sit dolor amet lorem ipsum sit dolor amet lorem ipsum sit dolor amet lorem ipsum sit dolor amet '); $data = number_format($harvestToolses['cstate'] / $stateCount * 100, 2); $activeSheet->setCellValue('G' . $row, $data . '%'); $idx++; } $activeSheet->getStyle("B" . $starRowTable . ":G" . $row)->applyFromArray($border_style); $activeSheet->getStyle("B" . $starRowTable . ":G" . $row)->getAlignment()->applyFromArray($text_center); $activeSheet->getStyle("F" . ($starRowTable + 1) . ":F" . $row)->getAlignment()->setWrapText(true); } $row++; $idx_tools++; } $i++; } header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $this->id . '_' . date('YmdHis') . '.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007"); $objWriter->save('php://output'); exit; }
<?php } ?> </ul> </div> <div class="info pull-left text-black"> <div class="text-uppercase"><?php echo $product->sku; ?> </div> <p class="text-uppercase"><?php echo $product->name; ?> </p> <div class="price text-bold"><?php echo Helpers::formatPrice($product->price); ?> </div> <table class="option"> <tr> <td class="quantity"> <button class="down"><i class="fa fa-caret-left"></i></button> <span>1</span> <button class="up"><i class="fa fa-caret-right"></i></button> </td> <td>Màu sắc: <i class="fa fa-square" style="color: teal"></i></td> <td>Size: L</td> </tr> </table> <button class="add-to-cart"> <i class="fa fa-cart-plus text-24"></i>