2018-09-28 13:31:41 +02:00
< ? php
/* Copyright ( C ) 2007 - 2008 Jeremie Ollivier < jeremie . o @ laposte . net >
* Copyright ( C ) 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2012 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2018 Andreu Bisquerra < jove @ bisquerra . com >
2019-03-13 15:43:34 +01:00
* Copyright ( C ) 2019 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2021-02-24 15:48:15 +01:00
* Copyright ( C ) 2021 Nicolas ZABOURI < info @ inovea - conseil . com >
2018-09-28 13:31:41 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-09-28 13:31:41 +02:00
*/
2019-03-28 09:56:01 +01:00
/**
2020-10-25 13:48:08 +01:00
* \file htdocs / takepos / receipt . php
2019-03-28 09:56:01 +01:00
* \ingroup takepos
* \brief Page to show a receipt .
*/
2020-10-25 13:48:08 +01:00
if ( ! isset ( $action )) {
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
2021-02-26 21:17:52 +01:00
if ( ! defined ( 'NOTOKENRENEWAL' )) {
define ( 'NOTOKENRENEWAL' , '1' );
}
if ( ! defined ( 'NOREQUIREMENU' )) {
define ( 'NOREQUIREMENU' , '1' );
}
if ( ! defined ( 'NOREQUIREHTML' )) {
define ( 'NOREQUIREHTML' , '1' );
}
if ( ! defined ( 'NOREQUIREAJAX' )) {
define ( 'NOREQUIREAJAX' , '1' );
}
2020-10-25 13:48:08 +01:00
require '../main.inc.php' ; // If this file is called from send.php avoid load again
}
2018-09-28 13:31:41 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2022-03-01 00:33:24 +01:00
$langs -> loadLangs ( array ( " main " , " bills " , " cashdesk " , " companies " ));
2018-09-28 13:31:41 +02:00
2021-04-27 19:33:11 +02:00
$place = ( GETPOST ( 'place' , 'aZ09' ) ? GETPOST ( 'place' , 'aZ09' ) : 0 ); // $place is id of table for Bar or Restaurant
2019-03-27 20:13:12 +01:00
2019-11-14 12:09:46 +01:00
$facid = GETPOST ( 'facid' , 'int' );
2019-03-27 20:13:12 +01:00
2021-10-07 09:51:55 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-08-02 11:13:41 +02:00
$gift = GETPOST ( 'gift' , 'int' );
2020-03-16 18:04:22 +01:00
if ( empty ( $user -> rights -> takepos -> run )) {
2020-03-23 15:46:16 +01:00
accessforbidden ();
2020-03-16 18:04:22 +01:00
}
2019-03-27 20:13:12 +01:00
2018-09-28 13:31:41 +02:00
/*
* View
*/
top_httphead ( 'text/html' );
2021-02-26 21:17:52 +01:00
if ( $place > 0 ) {
2022-03-01 00:33:24 +01:00
$sql = " SELECT rowid FROM " . MAIN_DB_PREFIX . " facture where ref='(PROV-POS " . $db -> escape ( $_SESSION [ " takeposterminal " ] . " - " . $place ) . " )' " ;
2020-10-31 14:32:18 +01:00
$resql = $db -> query ( $sql );
$obj = $db -> fetch_object ( $resql );
2021-02-26 21:17:52 +01:00
if ( $obj ) {
2020-10-31 14:32:18 +01:00
$facid = $obj -> rowid ;
}
2018-09-28 13:31:41 +02:00
}
2019-11-14 12:09:46 +01:00
$object = new Facture ( $db );
2018-09-28 13:31:41 +02:00
$object -> fetch ( $facid );
2019-09-29 20:56:24 +02:00
// Call to external receipt modules if exist
2022-03-01 00:33:24 +01:00
$parameters = array ();
2019-09-29 20:56:24 +02:00
$hookmanager -> initHooks ( array ( 'takeposfrontend' ), $facid );
2019-11-14 12:09:46 +01:00
$reshook = $hookmanager -> executeHooks ( 'TakeposReceipt' , $parameters , $object );
2019-09-29 20:56:24 +02:00
if ( ! empty ( $hookmanager -> resPrint )) {
2020-10-31 14:32:18 +01:00
print $hookmanager -> resPrint ;
2019-09-29 20:56:24 +02:00
exit ;
2019-09-29 21:30:06 +02:00
}
2019-09-29 20:56:24 +02:00
2019-02-10 12:59:09 +01:00
// IMPORTANT: This file is sended to 'Takepos Printing' application. Keep basic file. No external files as css, js... If you need images use absolute path.
2018-09-28 13:31:41 +02:00
?>
< html >
< body >
2019-03-28 20:33:41 +01:00
< style >
. right {
2021-02-26 21:17:52 +01:00
text - align : right ;
2019-03-28 20:33:41 +01:00
}
. center {
2021-02-26 21:17:52 +01:00
text - align : center ;
2019-03-28 20:33:41 +01:00
}
. left {
2021-02-26 21:17:52 +01:00
text - align : left ;
2019-03-28 20:33:41 +01:00
}
</ style >
2018-09-28 13:31:41 +02:00
< center >
< font size = " 4 " >
2019-11-14 12:09:46 +01:00
< ? php echo '<b>' . $mysoc -> name . '</b>' ; ?>
2018-09-28 13:31:41 +02:00
</ font >
</ center >
< br >
2019-03-17 10:27:06 +01:00
< p class = " left " >
2018-12-30 22:20:55 +01:00
< ? php
2020-10-07 15:01:28 +02:00
$constFreeText = 'TAKEPOS_HEADER' . $_SESSION [ 'takeposterminal' ];
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_HEADER ) || ! empty ( $conf -> global -> { $constFreeText })) {
2020-06-05 10:47:45 +02:00
$newfreetext = '' ;
2019-11-14 12:09:46 +01:00
$substitutionarray = getCommonSubstitutionArray ( $langs );
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_HEADER )) {
$newfreetext .= make_substitutions ( $conf -> global -> TAKEPOS_HEADER , $substitutionarray );
}
if ( ! empty ( $conf -> global -> { $constFreeText })) {
$newfreetext .= make_substitutions ( $conf -> global -> { $constFreeText }, $substitutionarray );
}
2021-09-20 22:51:43 +02:00
print nl2br ( $newfreetext );
2018-12-30 22:20:55 +01:00
}
?>
2018-09-28 13:31:41 +02:00
</ p >
2019-03-17 10:27:06 +01:00
< p class = " right " >
2018-09-28 13:31:41 +02:00
< ? php
print $langs -> trans ( 'Date' ) . " " . dol_print_date ( $object -> date , 'day' ) . '<br>' ;
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_RECEIPT_NAME )) {
print $conf -> global -> TAKEPOS_RECEIPT_NAME . " " ;
}
if ( $object -> statut == Facture :: STATUS_DRAFT ) {
print str_replace ( " ) " , " " , str_replace ( " - " , " " . $langs -> trans ( 'Place' ) . " " , str_replace ( " (PROV-POS " , $langs -> trans ( " Terminal " ) . " " , $object -> ref )));
} else {
print $object -> ref ;
}
if ( $conf -> global -> TAKEPOS_SHOW_CUSTOMER ) {
if ( $object -> socid != $conf -> global -> { 'CASHDESK_ID_THIRDPARTY' . $_SESSION [ " takeposterminal " ]}) {
2019-09-29 20:56:24 +02:00
$soc = new Societe ( $db );
2021-02-26 21:17:52 +01:00
if ( $object -> socid > 0 ) {
$soc -> fetch ( $object -> socid );
} else {
$soc -> fetch ( $conf -> global -> { 'CASHDESK_ID_THIRDPARTY' . $_SESSION [ " takeposterminal " ]});
}
2019-09-29 20:56:24 +02:00
print " <br> " . $langs -> trans ( " Customer " ) . ': ' . $soc -> name ;
}
}
2018-09-28 13:31:41 +02:00
?>
</ p >
< br >
2018-12-07 00:40:00 +01:00
< table width = " 100% " style = " border-top-style: double; " >
2021-02-26 21:17:52 +01:00
< thead >
2018-09-28 13:31:41 +02:00
< tr >
2021-02-26 21:17:52 +01:00
< th class = " center " >< ? php print $langs -> trans ( " Label " ); ?> </th>
< th class = " right " >< ? php print $langs -> trans ( " Qty " ); ?> </th>
< th class = " right " >< ? php if ( $gift != 1 ) {
print $langs -> trans ( " Price " );
} ?> </th>
< ? php if ( ! empty ( $conf -> global -> TAKEPOS_SHOW_HT_RECEIPT )) { ?>
< th class = " right " >< ? php if ( $gift != 1 ) {
print $langs -> trans ( " TotalHT " );
} ?> </th>
< ? php } ?>
< th class = " right " >< ? php if ( $gift != 1 ) {
print $langs -> trans ( " TotalTTC " );
} ?> </th>
2018-09-28 13:31:41 +02:00
</ tr >
2021-02-26 21:17:52 +01:00
</ thead >
< tbody >
< ? php
2021-10-07 09:51:55 +02:00
if ( $action == 'without_details' ) {
$qty = GETPOST ( 'qty' , 'int' ) > 0 ? GETPOST ( 'qty' , 'int' ) : 1 ;
print '<tr>' ;
print '<td>' . GETPOST ( 'label' , 'alphanohtml' ) . '</td>' ;
print '<td class="right">' . $qty . '</td>' ;
print '<td class="right">' . price ( price2num ( $object -> total_ttc / $qty , 'MU' ), 1 ) . '</td>' ;
if ( ! empty ( $conf -> global -> TAKEPOS_SHOW_HT_RECEIPT )) {
print '<td class="right">' . price ( $object -> total_ht , 1 ) . '</td>' ;
}
print '<td class="right">' . price ( $object -> total_ttc , 1 ) . '</td>' ;
print '</tr>' ;
} else {
foreach ( $object -> lines as $line ) {
?>
< tr >
< td >
< ? php if ( ! empty ( $line -> product_label )) {
echo $line -> product_label ;
} else {
echo $line -> description ;
} ?>
</ td >
< td class = " right " >< ? php echo $line -> qty ; ?> </td>
< td class = " right " >< ? php if ( $gift != 1 ) {
echo price ( price2num ( $line -> total_ttc / $line -> qty , 'MT' ), 1 );
} ?> </td>
< ? php
if ( ! empty ( $conf -> global -> TAKEPOS_SHOW_HT_RECEIPT )) { ?>
< td class = " right " >< ? php if ( $gift != 1 ) {
echo price ( $line -> total_ht , 1 );
} ?> </td>
< ? php
}
?>
< td class = " right " >< ? php if ( $gift != 1 ) {
echo price ( $line -> total_ttc , 1 );
} ?> </td>
</ tr >
2021-02-26 21:17:52 +01:00
< ? php
}
2020-10-31 14:32:18 +01:00
}
?>
2021-02-26 21:17:52 +01:00
</ tbody >
2018-09-28 13:31:41 +02:00
</ table >
< br >
2019-03-17 10:27:06 +01:00
< table class = " right " >
2018-09-28 13:31:41 +02:00
< tr >
2021-02-26 21:17:52 +01:00
< th class = " right " >< ? php if ( $gift != 1 ) {
echo $langs -> trans ( " TotalHT " );
} ?> </th>
< td class = " right " >< ? php if ( $gift != 1 ) {
echo price ( $object -> total_ht , 1 , '' , 1 , - 1 , - 1 , $conf -> currency ) . " \n " ;
} ?> </td>
2018-09-28 13:31:41 +02:00
</ tr >
2020-01-30 01:48:28 +01:00
< ? php if ( $conf -> global -> TAKEPOS_TICKET_VAT_GROUPPED ) {
2019-03-13 11:56:21 +01:00
$vat_groups = array ();
2021-02-26 21:17:52 +01:00
foreach ( $object -> lines as $line ) {
2020-01-30 01:48:28 +01:00
if ( ! array_key_exists ( $line -> tva_tx , $vat_groups )) {
2019-03-13 11:56:21 +01:00
$vat_groups [ $line -> tva_tx ] = 0 ;
}
$vat_groups [ $line -> tva_tx ] += $line -> total_tva ;
}
2020-01-30 01:48:28 +01:00
foreach ( $vat_groups as $key => $val ) {
2020-10-31 14:32:18 +01:00
?>
2019-03-13 11:56:21 +01:00
< tr >
2021-02-26 21:17:52 +01:00
< th align = " right " >< ? php if ( $gift != 1 ) {
echo $langs -> trans ( " VAT " ) . ' ' . vatrate ( $key , 1 );
} ?> </th>
< td align = " right " >< ? php if ( $gift != 1 ) {
echo price ( $val , 1 , '' , 1 , - 1 , - 1 , $conf -> currency ) . " \n " ;
} ?> </td>
2019-03-13 11:56:21 +01:00
</ tr >
2021-02-26 21:17:52 +01:00
< ? php
2019-03-13 11:56:21 +01:00
}
2019-10-27 10:38:52 +01:00
} else { ?>
2018-09-28 13:31:41 +02:00
< tr >
2021-02-26 21:17:52 +01:00
< th class = " right " >< ? php if ( $gift != 1 ) {
echo $langs -> trans ( " TotalVAT " ) . '</th><td class="right">' . price ( $object -> total_tva , 1 , '' , 1 , - 1 , - 1 , $conf -> currency ) . " \n " ;
} ?> </td>
2018-09-28 13:31:41 +02:00
</ tr >
2019-10-27 10:38:52 +01:00
< ? php } ?>
2018-09-28 13:31:41 +02:00
< tr >
2021-02-26 21:17:52 +01:00
< th class = " right " >< ? php if ( $gift != 1 ) {
echo '' . $langs -> trans ( " TotalTTC " ) . '</th><td class="right">' . price ( $object -> total_ttc , 1 , '' , 1 , - 1 , - 1 , $conf -> currency ) . " \n " ;
} ?> </td>
2018-09-28 13:31:41 +02:00
</ tr >
2020-08-22 18:28:15 +02:00
< ? php
2022-08-26 17:03:20 +02:00
if ( isModEnabled ( 'multicurrency' ) && $_SESSION [ " takeposcustomercurrency " ] != " " && $conf -> currency != $_SESSION [ " takeposcustomercurrency " ]) {
2020-10-03 22:13:32 +02:00
//Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency
include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php' ;
$multicurrency = new MultiCurrency ( $db );
$multicurrency -> fetch ( 0 , $_SESSION [ " takeposcustomercurrency " ]);
echo '<tr><th class="right">' ;
2021-02-26 21:17:52 +01:00
if ( $gift != 1 ) {
echo '' . $langs -> trans ( " TotalTTC " ) . ' ' . $_SESSION [ " takeposcustomercurrency " ] . '</th><td class="right">' . price ( $object -> total_ttc * $multicurrency -> rate -> rate , 1 , '' , 1 , - 1 , - 1 , $_SESSION [ " takeposcustomercurrency " ]) . " \n " ;
}
2020-10-03 22:13:32 +02:00
echo '</td></tr>' ;
}
2020-08-22 18:28:15 +02:00
if ( $conf -> global -> TAKEPOS_PRINT_PAYMENT_METHOD ) {
2020-08-23 22:29:55 +02:00
$sql = " SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount, " ;
2020-08-22 18:28:15 +02:00
$sql .= " cp.code " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " paiement_facture as pf, " . MAIN_DB_PREFIX . " paiement as p " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_paiement as cp ON p.fk_paiement = cp.id " ;
2021-03-30 19:12:07 +02:00
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = " . (( int ) $facid );
2020-08-22 18:28:15 +02:00
$sql .= " ORDER BY p.datep " ;
$resql = $db -> query ( $sql );
2021-02-26 21:17:52 +01:00
if ( $resql ) {
2020-08-22 18:28:15 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
while ( $i < $num ) {
$row = $db -> fetch_object ( $resql );
echo '<tr>' ;
echo '<td class="right">' ;
echo $langs -> transnoentitiesnoconv ( " PaymentTypeShort " . $row -> code );
echo '</td>' ;
echo '<td class="right">' ;
2022-08-26 17:03:20 +02:00
$amount_payment = ( isModEnabled ( 'multicurrency' ) && $object -> multicurrency_tx != 1 ) ? $row -> multicurrency_amount : $row -> amount ;
2021-02-26 21:17:52 +01:00
if ( $row -> code == " LIQ " ) {
$amount_payment = $amount_payment + $row -> pos_change ; // Show amount with excess received if is cash payment
}
2020-08-22 18:28:15 +02:00
echo price ( $amount_payment , 1 , '' , 1 , - 1 , - 1 , $conf -> currency );
echo '</td>' ;
echo '</tr>' ;
2021-02-26 21:17:52 +01:00
if ( $row -> code == " LIQ " && $row -> pos_change > 0 ) { // Print change only in cash payments
2020-08-22 18:28:15 +02:00
echo '<tr>' ;
echo '<td class="right">' ;
echo $langs -> trans ( " Change " );
echo '</td>' ;
echo '<td class="right">' ;
2020-08-23 22:29:55 +02:00
echo price ( $row -> pos_change , 1 , '' , 1 , - 1 , - 1 , $conf -> currency );
2020-08-22 18:28:15 +02:00
echo '</td>' ;
echo '</tr>' ;
}
$i ++ ;
}
}
}
?>
2018-09-28 13:31:41 +02:00
</ table >
2018-12-07 00:40:00 +01:00
< div style = " border-top-style: double; " >
< br >
< br >
< br >
< ? php
2020-10-07 15:01:28 +02:00
$constFreeText = 'TAKEPOS_FOOTER' . $_SESSION [ 'takeposterminal' ];
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> TAKEPOS_FOOTER ) || ! empty ( $conf -> global -> { $constFreeText })) {
2020-06-05 10:47:45 +02:00
$newfreetext = '' ;
2019-11-14 12:09:46 +01:00
$substitutionarray = getCommonSubstitutionArray ( $langs );
2021-02-26 21:17:52 +01:00
if ( ! empty ( $conf -> global -> { $constFreeText })) {
$newfreetext .= make_substitutions ( $conf -> global -> { $constFreeText }, $substitutionarray );
}
if ( ! empty ( $conf -> global -> TAKEPOS_FOOTER )) {
$newfreetext .= make_substitutions ( $conf -> global -> TAKEPOS_FOOTER , $substitutionarray );
}
2020-06-05 10:47:45 +02:00
print $newfreetext ;
2018-12-30 22:20:55 +01:00
}
2018-12-07 00:40:00 +01:00
?>
2018-09-28 13:31:41 +02:00
< script type = " text/javascript " >
2021-02-26 21:17:52 +01:00
window . print ();
2018-09-28 13:31:41 +02:00
</ script >
2021-04-27 19:33:11 +02:00
2018-09-28 13:31:41 +02:00
</ body >
</ html >