Skip to content

Commit

Permalink
Merge pull request #11743 from ptibogxiv/patch-243
Browse files Browse the repository at this point in the history
NEW print / send email form in takepos
  • Loading branch information
eldy committed Nov 7, 2019
2 parents c0b8684 + e671a11 commit cd5a0b5
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 1 deletion.
9 changes: 8 additions & 1 deletion htdocs/takepos/invoice.php
Expand Up @@ -451,10 +451,11 @@ function fail($message)
} else {
$sectionwithinvoicelink.=' <button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
}
$sectionwithinvoicelink.=' <button id="buttonprintsend" type="button" onclick="PrintSend('.$placeid.');">'.$langs->trans('PrintSendTicket').'</button>';

if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink.='<script language="javascript">$("#buttonprint").click();</script>';
}


/*
* View
*/
Expand Down Expand Up @@ -536,6 +537,12 @@ function fail($message)
?>

});

function PrintSend(id)
{
console.log("Open box to select the Print/Send form");
$.colorbox({href:"printsend.php?facid="+id, width:"90%", height:"50%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("PrintSend");?>"});
}

function Print(id){
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php
Expand Down
156 changes: 156 additions & 0 deletions htdocs/takepos/printsend.php
@@ -0,0 +1,156 @@
<?php
/* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/takepos/printsend.php
* \ingroup takepos
* \brief Page with the content of the popup to enter payments
*/

//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');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');

require '../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';

$invoiceid = GETPOST('facid', 'int');

/*
* View
*/

$invoice = new Facture($db);
if ($invoiceid > 0)
{
$invoice->fetch($invoiceid);
}
else
{
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
$invoiceid = $obj->rowid;
}
if (! $invoiceid)
{
$invoiceid=0; // Invoice does not exist yet
}
else
{
$invoice->fetch($invoiceid);
}
}

$langs->loadLangs(array("main", "bills", "cashdesk"));

?>
<link rel="stylesheet" href="css/pos.css">
</head>
<body>

<script>
<?php
$remaintopay = 0;
$invoice->fetch_thirdparty($invoice->socid);
if ($invoice->id > 0)
{
$remaintopay = $invoice->getRemainToPay();
}
$alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0);

if ($conf->global->TAKEPOS_NUMPAD==0) print "var received='';";
else print "var received=0;";

?>
var alreadypayed = <?php echo $alreadypayed ?>;

function addreceived(price)
{
<?php
if (empty($conf->global->TAKEPOS_NUMPAD)) print 'received+=String(price);'."\n";
else print 'received+=parseFloat(price);'."\n";
?>
$('.change1').html(pricejs(parseFloat(received), 'MT'));
$('.change1').val(parseFloat(received));
alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received));
//console.log("already+received = "+alreadypaydplusreceived);
//console.log("total_ttc = "+<?php echo $invoice->total_ttc;?>);
if (alreadypaydplusreceived > <?php echo $invoice->total_ttc;?>)
{
var change=parseFloat(alreadypayed + parseFloat(received) - <?php echo $invoice->total_ttc;?>);
$('.change2').html(pricejs(change, 'MT'));
$('.change2').val(change);
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorwhite');
$('.change2').addClass('colorred');
}
else
{
$('.change2').html(pricejs(0, 'MT'));
$('.change2').val(0);
if (alreadypaydplusreceived == <?php echo $invoice->total_ttc;?>)
{
$('.change1').removeClass('colorred');
$('.change1').addClass('colorgreen');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
else
{
$('.change1').removeClass('colorgreen');
$('.change1').addClass('colorred');
$('.change2').removeClass('colorred');
$('.change2').addClass('colorwhite');
}
}
}

function Print(id){
$.colorbox.close();
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php
echo $langs->trans("PrintTicket"); ?>"});
}

</script>

<div style="position:absolute; top:2%; left:5%; height:30%; width:91%;">
<center>
<center><input type="email" id="email" name="email" style="width:60%;font-size: 200%;" value="<?php echo $invoice->thirdparty->email;?>"></center>
</center>
</div>

<div style="position:absolute; top:33%; left:5%; height:60%; width:91%;">

<button type="button" class="calcbutton" onclick="Print('.<?php echo $placeid; ?>.');"><?php print $langs->trans("PrintTicket"); ?></button>
<button type="button" class="calcbutton" onclick="addreceived();"><?php print $langs->trans("SendInvoice"); ?></button>
<button type="button" class="calcbutton" onclick="addreceived();"><?php print $langs->trans("SaveSendInvoice"); ?></button>

</div>

</body>
</html>

0 comments on commit cd5a0b5

Please sign in to comment.