/**
  * Fill the body of email's message with a ticket
  * 
  * @param int $id
  * 
  * @return string		String with ticket data
  */
 public static function fillMailTicketBody($id)
 {
     global $db, $conf, $langs, $mysoc;
     $ticket = new Ticket($db);
     $res = $ticket->fetch($id);
     $mysoc = new Societe($db);
     $mysoc->fetch($ticket->socid);
     $userstatic = new User($db);
     $userstatic->fetch($ticket->user_close);
     $label = $ticket->ref;
     $facture = new Facture($db);
     if ($ticket->fk_facture) {
         $facture->fetch($ticket->fk_facture);
         $label = $facture->ref;
     }
     $message = $conf->global->MAIN_INFO_SOCIETE_NOM . " \n" . $conf->global->MAIN_INFO_SOCIETE_ADRESSE . " \n" . $conf->global->MAIN_INFO_SOCIETE_CP . ' ' . $conf->global->MAIN_INFO_SOCIETE_VILLE . " \n\n";
     $message .= $label . " \n" . dol_print_date($ticket->date_closed, 'dayhourtext') . " \n";
     $message .= $langs->transnoentities("Vendor") . ': ' . $userstatic->firstname . " " . $userstatic->lastname . "\n";
     if (!empty($ticket->fk_place)) {
         $place = new Place($db);
         $place->fetch($ticket->fk_place);
         $message .= $langs->trans("Place") . ': ' . $place->name . "\n";
     }
     $message .= "\n";
     $message .= $langs->transnoentities("Label") . "\t\t\t\t\t\t\t\t\t" . $langs->transnoentities("Qty") . "/" . $langs->transnoentities("Price") . "\t\t" . $langs->transnoentities("Total") . "\n";
     //$ticket->getLinesArray();
     if (!empty($ticket->lines)) {
         //$subtotal=0;
         foreach ($ticket->lines as $line) {
             $espacio = '';
             $totalline = $line->qty * $line->subprice;
             while (dol_strlen(dol_trunc($line->libelle, 30) . $espacio) < 29) {
                 $espacio .= "    \t";
             }
             $message .= dol_trunc($line->libelle, 33) . $espacio;
             $message .= "\t\t" . $line->qty . " * " . price($line->total_ttc / $line->qty, "", "", "", "", 2) . "\t\t" . price($line->total_ttc, "", "", "", "", 2) . ' ' . $langs->trans(currency_name($conf->currency)) . "\n";
             $subtotal[$line->tva_tx] += $line->total_ht;
             $subtotaltva[$line->tva_tx] += $line->total_tva;
             if (!empty($line->total_localtax1)) {
                 $localtax1 = $line->localtax1_tx;
             }
             if (!empty($line->total_localtax2)) {
                 $localtax2 = $line->localtax2_tx;
             }
         }
     } else {
         $message .= $langs->transnoentities("ErrNoArticles") . "\n";
     }
     $message .= $langs->transnoentities("TotalTTC") . ":\t" . price($ticket->total_ttc, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     $message .= '\\n' . $langs->trans("TotalHT") . "\t" . $langs->trans("VAT") . "\t" . $langs->trans("TotalVAT") . "\n";
     if (!empty($subtotal)) {
         foreach ($subtotal as $totkey => $totval) {
             $message .= price($subtotal[$totkey], "", "", "", "", 2) . "\t\t\t" . price($totkey, "", "", "", "", 2) . "%\t" . price($subtotaltva[$totkey], "", "", "", "", 2) . "\n";
         }
     }
     $message .= "-------------------------------\n";
     $message .= price($ticket->total_ht, "", "", "", "", 2) . "\t\t\t----\t" . price($ticket->total_tva, "", "", "", "", 2) . "\n";
     if ($ticket->total_localtax1 != 0) {
         $message .= $langs->transcountrynoentities("TotalLT1", $mysoc->country_code) . " " . price($localtax1, "", "", "", "", 2) . "%\t" . price($ticket->total_localtax1, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     }
     if ($ticket->total_localtax2 != 0) {
         $message .= $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "%\t" . price($ticket->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     }
     $message .= "\n\n";
     $terminal = new Cash($db);
     $terminal->fetch($ticket->fk_cash);
     $pay = $ticket->getSommePaiement();
     if ($ticket->customer_pay > $pay) {
         $pay = $ticket->customer_pay;
     }
     $diff_payment = $ticket->total_ttc - $pay;
     $listofpayments = $ticket->getListOfPayments();
     foreach ($listofpayments as $paym) {
         if ($paym['type'] != 'LIQ') {
             $message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
         } else {
             $message .= $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . "\t" . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
         }
     }
     $message .= ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . "\t" . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     $message .= $conf->global->POS_PREDEF_MSG;
     return $message;
 }
	<?php 
$presupuesto = substr($object->ref, 0, 2);
if ($presupuesto == "TK") {
    echo "Precios Sujetos a cambio sin Previo Aviso";
}
?>
</div>

<table class="totpay">
		<?php 
echo '<tr><td></td></tr>';
echo '<tr><td></td></tr>';
$terminal = new Cash($db);
$terminal->fetch($object->fk_cash);
$pay = $object->getSommePaiement();
if ($object->customer_pay > $pay) {
    $pay = $object->customer_pay;
}
$diff_payment = $object->total_ttc - $pay;
$listofpayments = $object->getListOfPayments();
foreach ($listofpayments as $paym) {
    if ($paym['type'] != 'LIQ') {
        echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
    } else {
        echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
    }
}
echo '<tr><th nowrap="nowrap">' . ($diff_payment < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . '</th><td nowrap="nowrap">' . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
?>
</table>
 print "</td></tr>\n";
 if ($num > 0) {
     $var = True;
     $total = 0;
     $totalrecu = 0;
     while ($i < min($num, $limit)) {
         $objp = $db->fetch_object($resql);
         $var = !$var;
         $cash = new Cash($db);
         $cash->fetch($objp->fk_cash);
         if ($user->id == 1 && $cash->id == 2) {
             print '<tr ' . $bc[$var] . '>';
             print '<td nowrap="nowrap">';
             $ticketstatic->id = $objp->ticketid;
             $ticketstatic->ref = $objp->ticketnumber;
             $paiement = $ticketstatic->getSommePaiement();
             print '<table class="nobordernopadding"><tr class="nocellnopadd">';
             print '<td class="nobordernopadding" nowrap="nowrap">';
             //print $ticketstatic->ref;
             print $ticketstatic->getNomUrl(1);
             print '</td>';
             print '</tr></table>';
             print "</td>\n";
             // Date
             print '<td align="center" nowrap>';
             print dol_print_date($db->jdate($objp->df), 'day');
             print '</td>';
             print '<td>';
             //$cash=new Cash($db);
             //$cash->fetch($objp->fk_cash);
             print $cash->getNomUrl(1);
 }
 $json_data['desg_lines'] = $desgs;
 $json_data['desg_tot'] = str_pad(price($facture->total_ht, "", "", "", "", 2), 12, ' ', STR_PAD_RIGHT) . "----------- " . str_pad(price($facture->total_tva, "", "", "", "", 2), 12, ' ', STR_PAD_LEFT);
 if ($facture->total_localtax1 != 0) {
     $json_data['localtax1'] = $langs->transcountrynoentities("TotalLT1", $mysoc->country_code) . " " . price($localtax1, "", "", "", "", 2) . "% " . price($ticket->total_localtax1, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
 } else {
     $json_data['localtax1'] = "";
 }
 if ($facture->total_localtax2 != 0) {
     $json_data['localtax2'] = $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "% " . price($ticket->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
 } else {
     $json_data['localtax2'] = "";
 }
 $terminal = new Cash($db);
 $terminal->fetch($ticket->fk_cash);
 $pay = $ticket->getSommePaiement();
 if ($ticket->customer_pay > $pay) {
     $pay = $ticket->customer_pay;
 }
 $diff_payment = $ticket->total_ttc - $pay;
 $listofpayments = $ticket->getListOfPayments();
 $pays = array();
 if (!empty($listofpayments)) {
     foreach ($listofpayments as $paym) {
         if ($paym['type'] != 'LIQ') {
             $paytext = $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . " " . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
         } else {
             $paytext = $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . " " . price($paym['amount'] - ($diff_payment < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
         }
         $pays[] = $paytext;
     }
 print '<td align="right">' . $langs->trans('Received') . '</td>';
 print '<td align="right">' . $langs->trans('RemainderToPay') . '</td>';
 print '<td align="right">' . $langs->trans('PaymentAmount') . '</td>';
 print '<td align="right">&nbsp;</td>';
 print "</tr>\n";
 $var = True;
 $total = 0;
 $totalrecu = 0;
 $totalrecucreditnote = 0;
 $totalrecudeposits = 0;
 while ($i < $num) {
     $objp = $db->fetch_object($resql);
     $var = !$var;
     $invoice = new Ticket($db);
     $invoice->fetch($objp->ticketid);
     $paiement = $invoice->getSommePaiement();
     $alreadypayed = price2num($paiement, 'MT');
     $remaintopay = price2num($invoice->total_ttc - $paiement, 'MT');
     //if ($remaintopay>0)
     //{
     print '<tr ' . $bc[$var] . '>';
     print '<td>';
     print $invoice->getNomUrl(1, '');
     print "</td>\n";
     // Date
     print '<td align="center">' . dol_print_date($db->jdate($objp->df), 'day') . "</td>\n";
     // Prix
     print '<td align="right">' . price($objp->total_ttc) . '</td>';
     // Recu
     print '<td align="right">' . price($paiement);
     if ($creditnotes) {