?> </td> </tr> <?php } ?> <?php if (round($itemInvoice->{$type})) { ?> <tr> <td style="text-align:left; font-size:14px;font-weight:bold; padding-bottom:10px" colspan="2">TOTAL <span style="display:block; font-weight:normal;font-size:11px">(including vat)</span></td> <td style="text-align:right;padding-right:10px; font-size:14px;padding-bottom:10px"><?php echo prep_costd($cdata->total, true, false); ?> </td> </tr> <?php } else { ?> <tr> <td style="text-align:left; font-size:14px;font-weight:bold; padding-bottom:10px" colspan="2">TOTAL</td> <td style="text-align:right;padding-right:10px; font-size:14px;padding-bottom:10px"><?php echo prep_costd($cdata->total, true, false); ?> </td> </tr> <?php } ?> </tfooter> </table>
private function createXLSDate() { include_once APPPATH . 'third_party/PHPExcel/PHPExcel.php'; $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator("Inmediative")->setLastModifiedBy("Inmediative")->setTitle($this->config->item('client', 'app'))->setSubject($this->config->item('client', 'app'))->setDescription($this->config->item('client', 'app'))->setKeywords($this->config->item('client', 'app'))->setCategory("Result file"); $alphabet = range('A', 'Z'); // Add some data $fields = array('DESTINATARIO DEL ENVÍO', 'DIRECCION', 'CIUDAD', 'REGION/ESTADO', 'C.P.', 'PAIS', 'TELEFONO', 'EMAIL', 'PESO', 'TRACK', 'Lista de productos', 'CODIGO', 'FECHA', 'DNI/CIF/ ID NUMBER/UE VAT', 'CLIENTE', 'DIRECCION COMPLETA', 'BASE 4%', 'IVA 4%', 'BASE 10%', 'IVA 10%', 'BASE 21%', 'IVA 21%', 'TOTAL', 'GASTOS ENVIO', 'CATEGORÍA'); $dd = date('Y-m-d', strtotime('-1 week')); $sql = "select id_cart from cart where id_state = 3 AND modified > '{$dd}' order by modified"; $result = $this->db->query($sql)->result(); $k = 2; $sheet = $objPHPExcel->setActiveSheetIndex(0); foreach ($fields as $ke => $value) { $sheet->setCellValue($alphabet[$ke] . '1', $value); } foreach ($result as $row) { $idc = $row->id_cart; $fdata = $this->Cart->DataCart($idc); $cdata = $this->Cart->DataCartComplete($idc); $cartItems = $this->Cart->ListItems($idc); if (!$fdata || !$cdata) { die('NO XLS'); } $itemInvoice = $this->Data->GetCountry($fdata['id_country']); $type = 'iva_ind'; if ($fdata['type'] == 'company') { $type = 'iva_emp'; } if ($fdata['id_region']) { $ret = $this->Data->GetRegion($fdata['id_region'], $fdata['id_country']); if ($ret) { $itemInvoice = $ret; } } $key = 0; $productsArr = array(); $catArr = array(); foreach ($cartItems as $c) { $productsArr[] = $c->title . ($c->size ? " {$c->size}" : "") . ' x' . $c->items; $catArr[] = strtoupper($c->category); } $products = implode(', ', $productsArr); $categories = implode(', ', $catArr); $dateTimeZone = new DateTimeZone('Europe/Madrid'); $dateTime = new DateTime(); $dateTime->setTimestamp(mysql_to_unix($cdata->modified)); $dateTime->setTimeZone($dateTimeZone); $code = $cdata->invoice_code . str_pad($cdata->code, 4, "0", STR_PAD_LEFT); $sheet = $objPHPExcel->setActiveSheetIndex(0); if ($fdata['dname']) { $sheet->setCellValue($alphabet[$key++] . $k, $fdata['dname'] . ' ' . $fdata['dlastname']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['daddress']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['dcity']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['dprovince']); $sheet->setCellValue($alphabet[$key++] . $k, ' ' . $fdata['dcp']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['country2_name']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['dphone']); } else { $sheet->setCellValue($alphabet[$key++] . $k, $fdata['name'] . ' ' . $fdata['lastname']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['address']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['city']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['province']); $sheet->setCellValue($alphabet[$key++] . $k, ' ' . $fdata['cp']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['country_name']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['phone']); } $sheet->setCellValue($alphabet[$key++] . $k, $fdata['mail']); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, $products); $sheet->setCellValue($alphabet[$key++] . $k, $code); $sheet->setCellValue($alphabet[$key++] . $k, $dateTime->format('d/m/Y H:i:s')); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['taxid'] ? $fdata['taxid'] : $fdata['vat']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['name'] . ' ' . $fdata['lastname']); $sheet->setCellValue($alphabet[$key++] . $k, $fdata['address'] . ', ' . $fdata['city'] . ', ' . $fdata['province'] . ', ' . $fdata['cp'] . ', ' . $fdata['country_name']); if ($itemInvoice && round($itemInvoice->{$type})) { $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax4t - $cdata->tax4, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax4, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax10t - $cdata->tax10, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax10, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax21t - $cdata->tax21, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->tax21, true, false)); } else { $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); $sheet->setCellValue($alphabet[$key++] . $k, ''); } $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->total, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, prep_costd($cdata->shipping_notax, true, false)); $sheet->setCellValue($alphabet[$key++] . $k, $categories); $k++; } PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT); $objPHPExcel->setActiveSheetIndex(0); foreach (range('A', $objPHPExcel->getActiveSheet()->getHighestDataColumn()) as $col) { $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setAutoSize(true); } /* // Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="List.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*/ header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="Pedidos.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'); }
public function ItemCost($cost = 0, $symbol = true) { return prep_costd($cost, $symbol, false); }
} ?> </div> </td> </tr> <?php } ?> <tr class="row-total"> <td class="delete"></th> <td class="image"></td> <td class="name"> <div class="label">Total</div> <div class="cost"><?php echo prep_costd($subtotal); ?> </div> </td> </tr> </tbody> </table> <div class="table-legend">* Shipping cost in the last step</div> <script> $(document).ready(function() { $('.table-list-cart-section tr').each(function(index, item){ var dataId = $(this).attr('data-id'); $('.select-size', item).change(function(e){ var data = {};
echo prep_costd($fdata['subtotal_notax']); ?> </div> </div> <div class="row rowl"> <div class="label">Shipping</div> <div class="cost"><?php echo prep_costd($fdata['shipping_notax']); ?> </div> </div> <?php if (round($fdata['desc_notax'])) { ?> <div class="row"> <div class="label">Discount</div> <div class="cost">- <?php echo prep_costd($fdata['desc_notax']); ?> </div> </div> <?php } ?> <div class="row rowt"> <div class="label">Total</div> <div class="cost"><?php echo prep_costd($fdata['total']); ?> </div> </div>