add inventory
This commit is contained in:
@@ -26,6 +26,8 @@ use frontend\models\CustomerCartPayoutForm;
|
||||
use frontend\models\UserCartPayoutForm;
|
||||
use frontend\components\DefaultAccountBehavior;
|
||||
use frontend\components\CassaOpenBehavior;
|
||||
use common\components\ProductInventory;
|
||||
use frontend\models\ProductInventorySearch;
|
||||
|
||||
/**
|
||||
* ProductController implements the CRUD actions for Product model.
|
||||
@@ -278,6 +280,97 @@ class ProductController extends Controller {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionInventory( ) {
|
||||
|
||||
$searchModel = new ProductInventorySearch(
|
||||
['account' => Account::readDefaultObject()]
|
||||
);
|
||||
|
||||
// $searchModel->search(\Yii::$app->request->params);
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
// $inventory = new ProductInventory([
|
||||
// ]);
|
||||
// if ( $output == 'xls'){
|
||||
// $inventory->pagination = false;
|
||||
// }
|
||||
|
||||
// $inventory->createDataProvider();
|
||||
// $dp = $inventory->dataProvider;
|
||||
|
||||
if ( $searchModel->output == 'xls' ){
|
||||
|
||||
$models = $dataProvider->getModels();
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex(0);
|
||||
/**
|
||||
*
|
||||
Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
|
||||
* */
|
||||
$row = 1;
|
||||
$sheet
|
||||
->setCellValue('A'.$row, "Termék azonosító")
|
||||
->setCellValue('B'.$row, "Termék név")
|
||||
->setCellValue('C'.$row, "Termék szám")
|
||||
->setCellValue('D'.$row, "Termék vonalkód")
|
||||
->setCellValue('E'.$row, "Termék raktáron");
|
||||
// ->setCellValue('F'.$row, "Eladott mennyiség");
|
||||
|
||||
foreach ($models as $model ){
|
||||
$row++;
|
||||
$sheet->setCellValue('A'.$row, $model['product_id'])
|
||||
->setCellValue('B'.$row, $model['product_name'])
|
||||
->setCellValue('C'.$row, $model['product_number'])
|
||||
->setCellValue('D'.$row, $model['product_barcode'])
|
||||
->setCellValue('E'.$row, $model['product_stock']);
|
||||
// ->setCellValue('F'.$row, $model['product_sold']);
|
||||
}
|
||||
|
||||
$styleArray = array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
// 'color' => array('rgb' => 'FF0000'),
|
||||
// 'size' => 15,
|
||||
// 'name' => 'Verdana'
|
||||
));
|
||||
|
||||
foreach(range('A','E') as $columnID)
|
||||
{
|
||||
$sheet->getColumnDimension($columnID)->setAutoSize(true);
|
||||
$sheet->getStyle($columnID.'1')->applyFromArray($styleArray);
|
||||
}
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="leltar.xls"');
|
||||
header('Cache-Control: max-age=0');
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
header('Cache-Control: max-age=1');
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
|
||||
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header ('Pragma: public'); // HTTP/1.0
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save('php://output');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->render('inventory',[ 'searchModel' =>$searchModel, 'dataProvider' => $dataProvider]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Finds the Product model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
@@ -305,6 +398,8 @@ class ProductController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Product models.
|
||||
|
||||
Reference in New Issue
Block a user