2
0
forked from Wavyzz/dolibarr

New: Print ticket show ref of invoice

This commit is contained in:
eldy
2011-10-12 19:24:27 +02:00
parent 548c90bf79
commit 781eb01c96
5 changed files with 87 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.2 compared to 3.1 *****
For users:
- New: Print ticket show invoice ref into POS module.
- New: Can edit customer discounts from invoice create and edit card.
- New: task #11243: Show quantity into stocks for each sub-products into the sub-product tab.
- New: task #10500: Option to choose if professional id are unique.

View File

@@ -1,22 +1,29 @@
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.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 2 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/>.
*/
include_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
$langs->load("main");
header("Content-type: text/html; charset=".$conf->file->character_set_client);
$facid=GETPOST('facid');
$object=new Facture($db);
$object->fetch($facid);
?>
<!--Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.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 2 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/>.
-->
<html>
<head>
<title>Print ticket</title>
@@ -97,17 +104,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div class="infos">
<p class="address"><?php echo $mysoc->name; ?><br>
<?php echo $mysoc->address; ?><br>
<?php echo $mysoc->zip.' '.$mysoc->town; ?></p>
<?php print dol_nl2br(dol_format_address($langs,$mysoc)); ?><br>
</p>
<p class="date_heure">
<?php
// Recuperation et affichage de la date et de l'heure
$now = dol_now();
print '<p class="date_heure">'.dol_print_date($now,'dayhourtext').'</p>';
print dol_print_date($now,'dayhourtext').'<br>';
print $object->ref;
?>
</p>
</div>
</div>
<br>
<table class="liste_articles">
<tr class="titres"><th><?php print $langs->trans("Code"); ?></th><th><?php print $langs->trans("Label"); ?></th><th><?php print $langs->trans("Qty"); ?></th><th><?php print $langs->trans("Discount").' (%)'; ?></th><th><?php print $langs->trans("TotalHT"); ?></th></tr>
@@ -119,12 +131,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id');
if ( $db->num_rows($res) ) {
if ($db->num_rows($res))
{
$ret=array(); $i=0;
while ( $tab = $db->fetch_array($res) )
while ($tab = $db->fetch_array($res))
{
foreach ( $tab as $cle => $valeur )
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur;
}
@@ -133,17 +145,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
$tab = $ret;
$tab_size=count($tab);
for($i=0;$i < $tab_size;$i++) {
for($i=0;$i < $tab_size;$i++)
{
$remise = $tab[$i]['remise'];
echo ('<tr><td>'.$tab[$i]['ref'].'</td><td>'.$tab[$i]['label'].'</td><td>'.$tab[$i]['qte'].'</td><td>'.$tab[$i]['remise_percent'].'</td><td class="total">'.price2num($tab[$i]['total_ht'],'MT').' '.$conf->monnaie.'</td></tr>'."\n");
}
} else {
}
else
{
echo ('<p>Erreur : aucun article</p>'."\n");
}
?>
@@ -158,11 +169,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</table>
<script type="text/javascript">
window.print();
</script>
<a class="lien" href="#" onclick="javascript: window.close(); return(false);">Fermer cette fenetre</a>
<a class="lien" href="#" onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a>
</body>

View File

@@ -22,13 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<script type="text/javascript">
function popupTicket () {
function popupTicket()
{
largeur = 600;
hauteur = 500
opt = 'width='+largeur+', height='+hauteur+', left='+(screen.width - largeur)/2+', top='+(screen.height-hauteur)/2+'';
window.open ('validation_ticket.php', 'Impression du ticket', opt);
window.open('validation_ticket.php?facid=<?php echo $_GET['facid']; ?>', 'Print ticket', opt);
}
popupTicket();

View File

@@ -619,6 +619,45 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc
return dol_print_date($time,$format,$to_gmt,$outputlangs,$encodetooutput);
}
/**
* Return a formated address (part address/zip/town/state) according to country rules
*
* @param outputlangs Output langs object
* @param object A company or contact object
* @return string Formated string
*/
function dol_format_address($outputlangs,$object)
{
$ret='';
$countriesusingstate=array('US','IN');
// Address
$ret .= $outputlangs->convToOutputCharset($object->address);
// Zip/Town/State
if (in_array($object->country_code,array('US'))) // US: town, state, zip
{
$ret .= ($ret ? "\n" : '' ).$outputlangs->convToOutputCharset($object->town);
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
$ret.=", ".$outputlangs->convToOutputCharset($object->departement);
}
if ($object->zip) $ret .= ', '.$outputlangs->convToOutputCharset($object->zip);
}
else // Other: zip town, state
{
$ret .= ($ret ? "\n" : '' ).$outputlangs->convToOutputCharset($object->zip);
$ret .= ' '.$outputlangs->convToOutputCharset($object->town);
if ($object->state && in_array($object->country_code,$countriesusingstate))
{
$ret.=", ".$outputlangs->convToOutputCharset($object->state);
}
}
return $ret;
}
/**
* Output date in a string format according to outputlangs (or langs if not defined).
* Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset

View File

@@ -163,44 +163,6 @@ function pdf_getPDFFontSize($outputlangs)
}
/**
* Return a formated address (part address/zip/town/state) according to country rules
*
* @param outputlangs Output langs object
* @param object A company or contact object
* @return string Formated string
*/
function pdf_format_address($outputlangs,$object)
{
$ret='';
$countriesusingstate=array('US','IN');
// Address
$ret .= $outputlangs->convToOutputCharset($object->address);
// Zip/Town/State
if (in_array($object->pays_code,array('US'))) // US: town, state, zip
{
$ret .= ($ret ? "\n" : '' ).$outputlangs->convToOutputCharset($object->town);
if ($object->departement && in_array($object->pays_code,$countriesusingstate))
{
$ret.=", ".$outputlangs->convToOutputCharset($object->departement);
}
if ($object->cp) $ret .= ', '.$outputlangs->convToOutputCharset($object->zip);
}
else // Other: zip town, state
{
$ret .= ($ret ? "\n" : '' ).$outputlangs->convToOutputCharset($object->zip);
$ret .= ' '.$outputlangs->convToOutputCharset($object->town);
if ($object->departement && in_array($object->pays_code,$countriesusingstate))
{
$ret.=", ".$outputlangs->convToOutputCharset($object->departement);
}
}
return $ret;
}
/**
* Return a string with full address formated
*
@@ -228,7 +190,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
if ($mode == 'source')
{
$stringaddress .= ($stringaddress ? "\n" : '' ).pdf_format_address($outputlangs,$sourcecompany)."\n";
$stringaddress .= ($stringaddress ? "\n" : '' ).dol_format_address($outputlangs,$sourcecompany)."\n";
// Tel
if ($sourcecompany->tel) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($sourcecompany->tel);
@@ -245,13 +207,13 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
if ($usecontact)
{
$stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1));
$stringaddress .= ($stringaddress ? "\n" : '' ).pdf_format_address($outputlangs,$targetcontact)."\n";
$stringaddress .= ($stringaddress ? "\n" : '' ).dol_format_address($outputlangs,$targetcontact)."\n";
// Country
if ($targetcontact->pays_code && $targetcontact->pays_code != $sourcecompany->pays_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->pays_code))."\n";
}
else
{
$stringaddress .= ($stringaddress ? "\n" : '' ).pdf_format_address($outputlangs,$targetcompany)."\n";
$stringaddress .= ($stringaddress ? "\n" : '' ).dol_format_address($outputlangs,$targetcompany)."\n";
// Country
if ($targetcompany->pays_code && $targetcompany->pays_code != $sourcecompany->pays_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->pays_code))."\n";
}
@@ -288,7 +250,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
if ($mode == 'delivery') // for a delivery address (address + phone/fax)
{
$stringaddress .= ($stringaddress ? "\n" : '' ).pdf_format_address($outputlangs,$deliverycompany)."\n";
$stringaddress .= ($stringaddress ? "\n" : '' ).dol_format_address($outputlangs,$deliverycompany)."\n";
// Tel
if ($deliverycompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($deliverycompany->phone);