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); }
echo number_format($bonus_per_unit_sum, 2); ?> </td> <td style="text-align: right;"> <?php echo number_format($value['bill_sale_detail_price'] * $value['bill_sale_detail_qty'], 2); ?> </td> </tr> <?php $sum_bill_sale_detail_qty += $value['bill_sale_detail_qty']; $sum_bonus += $value['bill_sale_detail_price'] - $value['product_price_buy']; /* * add to temp */ $tempSalePerDay = new TempSalePerDay(); $tempSalePerDay->no = $i - 1; $tempSalePerDay->sale_date = Util::mysqlToThaiDate($value['bill_sale_created_date']); $tempSalePerDay->bill_id = $value['bill_sale_id']; $tempSalePerDay->barcode = $value['bill_sale_detail_barcode']; $tempSalePerDay->name = $value['product_name']; $tempSalePerDay->bill_status = $label_bill_status; $tempSalePerDay->price = $value['product_price']; $tempSalePerDay->sale_price = $value['bill_sale_detail_price']; $tempSalePerDay->price_old = $price_old; $tempSalePerDay->bonus_per_unit = $bonus_per_unit; $tempSalePerDay->qty = $value['bill_sale_detail_qty']; $tempSalePerDay->total_bonus = $bonus_per_unit_sum; $tempSalePerDay->total_income = $value['bill_sale_detail_price'] * $value['bill_sale_detail_qty']; $tempSalePerDay->save(); ?>