public function actionReportSalePerDayExcel() { $tempSalePerDays = TempSalePerDay::model()->findAll(); $output = ""; foreach ($tempSalePerDays as $row) { $output .= "{$row->no},{$row->sale_date},{$row->bill_id},{$row->barcode},{$row->name},{$row->bill_status},{$row->price},{$row->sale_price},{$row->price_old},{$row->bonus_per_unit},{$row->qty},{$row->total_bonus},{$row->total_income}\n"; } file_put_contents('report-sale-per-day.csv', $output); }
</th> </tr> </thead> <tbody> <?php $i = 1; $sum = 0; $sum_bill_sale_detail_qty = 0; $sum_bonus = 0; $sum_footer_bonus_per_unit = 0; $sum_qty = 0; /* * clear in temp */ TempSalePerDay::model()->deleteAll(); foreach ($result as $value) { // ค้นหาราคาทุนสินค้า $barcodePrice = BarcodePrice::model()->findByAttributes(array('barcode' => $value['bill_sale_detail_barcode'])); $price_old = 0; // ราคาทุน if (!empty($barcodePrice)) { // price old from barcode price $price_old = $barcodePrice->price_before; $product = Product::model()->findByAttributes(array('product_code' => $barcodePrice->barcode_fk)); if (!empty($product)) { $value['product_name'] = $product->product_name . ' (' . $barcodePrice->name . ')'; } } else { // old price from product if (empty($value['old_price'])) {