/**
  * Fill the body of email's message with a facture
  *
  * @param int $id
  *
  * @return string		String with ticket data
  */
 public static function fillMailFactureBody($id)
 {
     global $db, $conf, $langs, $mysoc;
     $langs->Load("rewards@rewards");
     $facture = new Facture($db);
     $res = $facture->fetch($id);
     $mysoc = new Societe($db);
     $mysoc->fetch($facture->socid);
     $userstatic = new User($db);
     $userstatic->fetch($facture->user_valid);
     $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($facture->date_creation, 'dayhourtext') . " \n";
     $message .= $langs->transnoentities("Vendor") . ': ' . $userstatic->fistname . " " . $userstatic->lastname . "\n";
     $sql = "SELECT fk_place,fk_cash FROM " . MAIN_DB_PREFIX . "pos_facture WHERE fk_facture =" . $facture->id;
     $result = $db->query($sql);
     if ($result) {
         $objp = $db->fetch_object($result);
         if ($objp->fk_place > 0) {
             $place = new Place($db);
             $place->fetch($objp->fk_place);
             $message .= $langs->trans("Place") . ': ' . $place->name . "\n";
         }
     }
     $message .= "\n";
     $message .= $langs->transnoentities("Label") . "\t\t\t\t\t\t" . $langs->transnoentities("Qty") . "/" . $langs->transnoentities("Price") . "\t\t" . $langs->transnoentities("Total") . "\n";
     //$facture->getLinesArray();
     if (!empty($facture->lines)) {
         $subtotal = 0;
         foreach ($facture->lines as $line) {
             $espacio = '';
             $totalline = $line->qty * $line->subprice;
             if (empty($line->libelle)) {
                 $line->libelle = $line->description;
             }
             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->subprice) . "\t\t" . price($line->total_ht) . ' ' . $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($facture->total_ttc) . " " . $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) {
             if ($tvakey > 0) {
                 $message .= price($subtotal[$totkey], "", "", "", "", 2) . "\t\t\t" . price($totkey, "", "", "", "", 2) . "%\t" . price($subtotaltva[$totkey], "", "", "", "", 2) . "\n";
             }
         }
     }
     $message .= "-------------------------------\n";
     $message .= price($facture->total_ht, "", "", "", "", 2) . "\t\t\t----\t" . price($facture->total_tva, "", "", "", "", 2) . "\n";
     if ($facture->total_localtax1 != 0) {
         $message .= $langs->transcountrynoentities("TotalLT1", $mysoc->country_code) . " " . price($localtax1, "", "", "", "", 2) . "%\t" . price($facture->total_localtax1, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     }
     if ($facture->total_localtax2 != 0) {
         $message .= $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "%\t" . price($facture->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "\n";
     }
     $message .= "\n\n";
     $terminal = new Cash($db);
     $sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $facture->id;
     $resql = $db->query($sql);
     $obj = $db->fetch_object($resql);
     $customer_pay = $obj->customer_pay;
     $terminal->fetch($obj > fk_cash);
     if (!empty($conf->rewards->enabled)) {
         $rewards = new Rewards($db);
         $points = $rewards->getInvoicePoints($facture->id);
     }
     if ($facture->type == 0) {
         $pay = $facture->getSommePaiement();
         if (!empty($conf->rewards->enabled)) {
             $usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
             $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
             //falta fer algo per aci
             if ($customer_pay > $pay - $moneypoints) {
                 $pay = $customer_pay;
             } else {
                 $pay = $pay - $moneypoints;
             }
         } else {
             if ($customer_pay > $pay) {
                 $pay = $customer_pay;
             }
         }
     }
     if ($facture->type == 2) {
         $customer_pay = $customer_pay * -1;
         $pay = $facture->getSommePaiement();
         if (!empty($conf->rewards->enabled)) {
             $usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
             $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
             //falta fer algo per aci
             if ($customer_pay > $pay - $moneypoints) {
                 $pay = $customer_pay;
             } else {
                 $pay = $pay - $moneypoints;
             }
         } else {
             if ($customer_pay > $pay) {
                 $pay = $customer_pay;
             }
         }
     }
     $diff_payment = $facture->total_ttc - $moneypoints - $pay;
     $listofpayments = $facture->getListOfPayments();
     foreach ($listofpayments as $paym) {
         if ($paym['type'] != 'PNT') {
             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";
             }
         }
     }
     if (!empty($conf->rewards->enabled)) {
         if ($moneypoints > 0) {
             $message .= $usepoints . " " . $langs->trans("Points") . "\t" . price($moneypoints, "", "", "", "", 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";
     if ($points != 0 && !empty($conf->rewards->enabled)) {
         $message .= $langs->trans("TotalPointsInvoice") . "\t" . price($points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n";
         $total_points = $rewards->getCustomerPoints($facture->socid);
         $message .= $langs->trans("DispoPoints") . "\t" . price($total_points, "", "", "", "", 2) . " " . $langs->trans('Points') . "\n";
     }
     $message .= $conf->global->POS_PREDEF_MSG;
     return $message;
 }
 } else {
     $json_data['localtax1'] = "";
 }
 if ($facture->total_localtax2 != 0) {
     $json_data['localtax2'] = $langs->transcountrynoentities("TotalLT2", $mysoc->country_code) . " " . price($localtax2, "", "", "", "", 2) . "% " . price($facture->total_localtax2, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency));
 } else {
     $json_data['localtax2'] = "";
 }
 $terminal = new Cash($db);
 $sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $facture->id;
 $resql = $db->query($sql);
 $obj = $db->fetch_object($resql);
 $customer_pay = $obj->customer_pay;
 $terminal->fetch($obj > fk_cash);
 if (!empty($conf->rewards->enabled)) {
     $rewards = new Rewards($db);
     $points = $rewards->getInvoicePoints($facture->id);
 }
 if ($facture->type == 0) {
     $pay = $facture->getSommePaiement();
     if (!empty($conf->rewards->enabled)) {
         $usepoints = abs($rewards->getInvoicePoints($facture->id, 1));
         $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
         //falta fer algo per aci
         if ($customer_pay > $pay - $moneypoints) {
             $pay = $customer_pay;
         } else {
             $pay = $pay - $moneypoints;
         }
     } else {
         if ($customer_pay > $pay) {
Пример #3
0
<?php

include_once "includes/header.php";
include_once "includes/rewards.php";
$objRewards = new Rewards();
include "BusinnesIncludes/BusinnesReport.php";
$objReport = new BusinnesReport();
$Result = $objReport->GetReportByUserId($_REQUEST["id"]);
$id = $_REQUEST["id"];
$years = "";
$fileName = "";
$filePath = "";
$email = "";
$age_started = "";
$current_age = "";
$average_packs = "";
$current_price = "";
$money_spent = "";
$true_cost = "";
$six_months = "";
$one_year = "";
$five_years = "";
$ten_years = "";
$twenty_years = "";
$six_months = "";
//$datetime = new DateTime();
$url = $_SERVER['SERVER_NAME'];
$page = $_SERVER['PHP_SELF'];
//$url = "http://".$url.$page."?id=".$id."-".$datetime->format('Y/m/d').".pdf";
if (count($Result) > 0 && $Result[0] != "") {
    $id = $Result["UserID"];
}
?>
		</table>
		
		<table class="totpay">
		<?php 
echo '<tr><td></td></tr>';
echo '<tr><td></td></tr>';
$terminal = new Cash($db);
$sql = 'SELECT fk_cash, customer_pay FROM ' . MAIN_DB_PREFIX . 'pos_facture WHERE fk_facture = ' . $object->id;
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
$customer_pay = $obj->customer_pay;
$terminal->fetch($obj > fk_cash);
if (!empty($conf->rewards->enabled)) {
    $rewards = new Rewards($db);
    $points = $rewards->getInvoicePoints($object->id);
}
if ($object->type == 0) {
    $pay = $object->getSommePaiement();
    if (!empty($conf->rewards->enabled)) {
        $usepoints = abs($rewards->getInvoicePoints($object->id, 1));
        $moneypoints = abs($usepoints * $conf->global->REWARDS_DISCOUNT);
        //falta fer algo per aci
        if ($customer_pay > $pay - $moneypoints) {
            $pay = $customer_pay;
        } else {
            $pay = $pay - $moneypoints;
        }
    } else {
        if ($customer_pay > $pay) {
Пример #5
0
<?php

//include_once("includes/header.php");
include "includes/rewards.php";
$objRewards = new Rewards();
include "BusinnesIncludes/BusinnesReport.php";
$objReport = new BusinnesReport();
$Result = $objReport->GetReportByUserId($_REQUEST["id"]);
$id = "";
$years = "";
$fileName = "";
$filePath = "";
$email = "";
$age_started = "";
$current_age = "";
$average_packs = "";
$current_price = "";
$money_spent = "";
$true_cost = "";
$six_months = "";
$one_year = "";
$five_years = "";
$ten_years = "";
$twenty_years = "";
$six_months = "";
//$url = $_SERVER['SERVER_NAME'];
//$page = $_SERVER['PHP_SELF'];
//$url = "http://".$url.$page;
if (count($Result) > 0 && $Result[0] != "") {
    $id = $Result["UserID"];
    $years = (int) $Result["CurrentAge"] - (int) $Result["AgeStarted"];