Merge branch 'new_multicurrency_module' of github.com:atm-ph/dolibarr into new_multicurrency_module
Conflicts: htdocs/commande/card.php
This commit is contained in:
commit
83f90e2b1f
@ -1927,6 +1927,44 @@ if ($action == 'create')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency code
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Currency','multicurrency_code');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencycode') {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
|
||||
} else {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency rate
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Rate','multicurrency_tx');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencyrate') {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
|
||||
} else {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
@ -2018,45 +2056,6 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency code
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Currency','multicurrency_code');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencycode') {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
|
||||
} else {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency rate
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Rate','multicurrency_tx');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencyrate') {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
|
||||
} else {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Other attributes
|
||||
$cols = 5;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
@ -2101,21 +2100,24 @@ if ($action == 'create')
|
||||
print '<td class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
|
||||
|
||||
|
||||
@ -789,10 +789,11 @@ class Propal extends CommonObject
|
||||
if (empty($this->availability_id)) $this->availability_id=0;
|
||||
if (empty($this->demand_reason_id)) $this->demand_reason_id=0;
|
||||
|
||||
// Multicurrency
|
||||
if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
|
||||
if (empty($this->fk_multicurrency))
|
||||
{
|
||||
$this->multicurrency_code = '';
|
||||
$this->multicurrency_code = $conf->currency;
|
||||
$this->fk_multicurrency = 0;
|
||||
$this->multicurrency_tx = 1;
|
||||
}
|
||||
|
||||
@ -260,7 +260,9 @@ if (empty($reshook))
|
||||
$object->contactid = GETPOST('contactid');
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
if (! $error)
|
||||
{
|
||||
@ -489,7 +491,17 @@ if (empty($reshook))
|
||||
if ($result < 0)
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
// Multicurrency Code
|
||||
else if ($action == 'setmulticurrencycode' && $user->rights->commande->creer) {
|
||||
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
|
||||
}
|
||||
|
||||
// Multicurrency rate
|
||||
else if ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) {
|
||||
$result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setavailability' && $user->rights->commande->creer) {
|
||||
$result = $object->availability(GETPOST('availability_id'));
|
||||
if ($result < 0)
|
||||
@ -1259,7 +1271,8 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
|
||||
$projectid = 0;
|
||||
$remise_absolue = 0;
|
||||
|
||||
$currency_code = $conf->currency;
|
||||
|
||||
if (! empty($origin) && ! empty($originid)) {
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $subelement = $origin;
|
||||
@ -1327,6 +1340,12 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
|
||||
$datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : '');
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
|
||||
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
|
||||
}
|
||||
|
||||
$note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null));
|
||||
$note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null));
|
||||
|
||||
@ -1347,6 +1366,8 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
$remise_absolue = 0;
|
||||
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:'';
|
||||
$projectid = 0;
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
|
||||
|
||||
$note_private = $object->getDefaultCreateValueFor('note_private');
|
||||
$note_public = $object->getDefaultCreateValueFor('note_public');
|
||||
@ -1362,6 +1383,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">';
|
||||
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||
if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">';
|
||||
|
||||
dol_fiche_head('');
|
||||
|
||||
@ -1531,6 +1553,16 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF);
|
||||
print "</td></tr>";
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Note public
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
|
||||
@ -1602,6 +1634,13 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
}
|
||||
|
||||
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2050,6 +2089,44 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency code
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Currency','multicurrency_code');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencycode') {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
|
||||
} else {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency rate
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Rate','multicurrency_tx');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencyrate') {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
|
||||
} else {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Availability
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
@ -2206,6 +2283,24 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
// Total TTC
|
||||
print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Statut
|
||||
print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
|
||||
dol_include_once('/multicurrency/class/multicurrency.class.php');
|
||||
|
||||
/**
|
||||
* Class to manage customers orders
|
||||
@ -143,6 +144,14 @@ class Commande extends CommonOrder
|
||||
var $nbtodo;
|
||||
var $nbtodolate;
|
||||
|
||||
// Multicurrency
|
||||
var $fk_multicurrency;
|
||||
var $multicurrency_code;
|
||||
var $multicurrency_tx;
|
||||
var $multicurrency_total_ht;
|
||||
var $multicurrency_total_tva;
|
||||
var $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* ERR Not enough stock
|
||||
*/
|
||||
@ -692,7 +701,17 @@ class Commande extends CommonOrder
|
||||
|
||||
// Clean parameters
|
||||
$this->brouillon = 1; // set command as draft
|
||||
|
||||
|
||||
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
|
||||
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
|
||||
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
|
||||
if (empty($this->fk_multicurrency))
|
||||
{
|
||||
$this->multicurrency_code = $conf->currency;
|
||||
$this->fk_multicurrency = 0;
|
||||
$this->multicurrency_tx = 1;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::create user=".$user->id);
|
||||
|
||||
// Check parameters
|
||||
@ -738,6 +757,9 @@ class Commande extends CommonOrder
|
||||
$sql.= ", remise_absolue, remise_percent";
|
||||
$sql.= ", fk_incoterms, location_incoterms";
|
||||
$sql.= ", entity";
|
||||
$sql.= ", fk_multicurrency";
|
||||
$sql.= ", multicurrency_code";
|
||||
$sql.= ", multicurrency_tx";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES ('(PROV)',".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
|
||||
$sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
|
||||
@ -763,6 +785,9 @@ class Commande extends CommonOrder
|
||||
$sql.= ", ".(int) $this->fk_incoterms;
|
||||
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".(int) $this->fk_multicurrency;
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".(double) $this->multicurrency_tx;
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
@ -1254,13 +1279,18 @@ class Commande extends CommonOrder
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
|
||||
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Rang to use
|
||||
$rangtouse = $rang;
|
||||
if ($rangtouse == -1)
|
||||
@ -1318,6 +1348,14 @@ class Commande extends CommonOrder
|
||||
$this->line->fk_fournprice = $fk_fournprice;
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
// Multicurrency
|
||||
$this->line->fk_multicurrency = $this->fk_multicurrency;
|
||||
$this->line->multicurrency_code = $this->multicurrency_code;
|
||||
$this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
// TODO Ne plus utiliser
|
||||
$this->line->price=$price;
|
||||
$this->line->remise=$remise;
|
||||
@ -1464,6 +1502,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
|
||||
$sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams';
|
||||
$sql.= ', c.fk_incoterms, c.location_incoterms';
|
||||
$sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
|
||||
$sql.= ", i.libelle as libelle_incoterms";
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
|
||||
@ -1537,6 +1576,14 @@ class Commande extends CommonOrder
|
||||
$this->location_incoterms = $obj->location_incoterms;
|
||||
$this->libelle_incoterms = $obj->libelle_incoterms;
|
||||
|
||||
// Multicurrency
|
||||
$this->fk_multicurrency = $obj->fk_multicurrency;
|
||||
$this->multicurrency_code = $obj->multicurrency_code;
|
||||
$this->multicurrency_tx = $obj->multicurrency_tx;
|
||||
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
|
||||
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
$this->extraparams = (array) json_decode($obj->extraparams, true);
|
||||
|
||||
$this->lines = array();
|
||||
@ -1666,6 +1713,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
|
||||
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
||||
$sql.= ' l.fk_unit,';
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
||||
@ -1728,6 +1776,14 @@ class Commande extends CommonOrder
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
|
||||
// Multicurrency
|
||||
$line->fk_multicurrency = $objp->fk_multicurrency;
|
||||
$line->multicurrency_code = $objp->multicurrency_code;
|
||||
$line->multicurrency_subprice = $objp->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
@ -2478,13 +2534,18 @@ class Commande extends CommonOrder
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
|
||||
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1 = $tabprice[9];
|
||||
$total_localtax2 = $tabprice[10];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
$subprice = $pu;
|
||||
@ -2540,6 +2601,12 @@ class Commande extends CommonOrder
|
||||
$this->line->fk_fournprice = $fk_fournprice;
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
// Multicurrency
|
||||
$this->line->multicurrency_subprice = price2num($subprice * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
// TODO deprecated
|
||||
$this->line->price=$price;
|
||||
$this->line->remise=$remise;
|
||||
@ -3222,6 +3289,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,';
|
||||
$sql.= ' l.date_start, l.date_end,';
|
||||
$sql.= ' l.fk_unit,';
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
||||
$sql.= ' p.description as product_desc, p.stock as stock_reel,';
|
||||
$sql.= ' p.entity';
|
||||
@ -3272,7 +3340,15 @@ class Commande extends CommonOrder
|
||||
$this->lines[$i]->marge_tx = $marginInfos[1];
|
||||
$this->lines[$i]->marque_tx = $marginInfos[2];
|
||||
$this->lines[$i]->fk_unit = $obj->fk_unit;
|
||||
|
||||
|
||||
// Multicurrency
|
||||
$this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency;
|
||||
$this->lines[$i]->multicurrency_code = $obj->multicurrency_code;
|
||||
$this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice;
|
||||
$this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht;
|
||||
$this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -3608,7 +3684,9 @@ class OrderLine extends CommonOrderLine
|
||||
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
||||
$sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
|
||||
$sql.= ' fk_unit)';
|
||||
$sql.= ' fk_unit';
|
||||
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
||||
$sql.= ')';
|
||||
$sql.= " VALUES (".$this->fk_commande.",";
|
||||
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
|
||||
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
|
||||
@ -3639,6 +3717,12 @@ class OrderLine extends CommonOrderLine
|
||||
$sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
|
||||
$sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
|
||||
$sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
|
||||
$sql.= ", ".$this->fk_multicurrency;
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".$this->multicurrency_subprice;
|
||||
$sql.= ", ".$this->multicurrency_total_ht;
|
||||
$sql.= ", ".$this->multicurrency_total_tva;
|
||||
$sql.= ", ".$this->multicurrency_total_ttc;
|
||||
$sql.= ')';
|
||||
|
||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
||||
@ -3766,6 +3850,13 @@ class OrderLine extends CommonOrderLine
|
||||
$sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null");
|
||||
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
|
||||
$sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
|
||||
|
||||
// Multicurrency
|
||||
$sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice)."";
|
||||
$sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
|
||||
$sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
|
||||
$sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
|
||||
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
|
||||
@ -271,6 +271,16 @@ if (empty($reshook))
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
// Multicurrency Code
|
||||
else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) {
|
||||
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
|
||||
}
|
||||
|
||||
// Multicurrency rate
|
||||
else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) {
|
||||
$result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
@ -699,7 +709,9 @@ if (empty($reshook))
|
||||
$object->remise_percent = $_POST['remise_percent'];
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
|
||||
// Proprietes particulieres a facture de remplacement
|
||||
$object->fk_facture_source = $_POST['fac_replacement'];
|
||||
$object->type = Facture::TYPE_REPLACEMENT;
|
||||
@ -746,7 +758,9 @@ if (empty($reshook))
|
||||
$object->remise_percent = $_POST['remise_percent'];
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
|
||||
// Proprietes particulieres a facture avoir
|
||||
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
|
||||
$object->type = Facture::TYPE_CREDIT_NOTE;
|
||||
@ -831,7 +845,9 @@ if (empty($reshook))
|
||||
$object->ref_client = $_POST['ref_client'];
|
||||
$object->ref_int = $_POST['ref_int'];
|
||||
$object->modelpdf = $_POST['model'];
|
||||
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
|
||||
// Source facture
|
||||
$object->fac_rec = GETPOST('fac_rec');
|
||||
|
||||
@ -876,6 +892,8 @@ if (empty($reshook))
|
||||
$object->remise_percent = $_POST['remise_percent'];
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
|
||||
if (GETPOST('type') == Facture::TYPE_SITUATION)
|
||||
{
|
||||
@ -1855,6 +1873,8 @@ if ($action == 'create')
|
||||
if ($socid > 0)
|
||||
$res = $soc->fetch($socid);
|
||||
|
||||
$currency_code = $conf->currency;
|
||||
|
||||
// Load objectsrc
|
||||
$remise_absolue = 0;
|
||||
|
||||
@ -1923,6 +1943,12 @@ if ($action == 'create')
|
||||
$remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||
$dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice);
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
|
||||
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
|
||||
}
|
||||
|
||||
// Replicate extrafields
|
||||
$objectsrc->fetch_optionals($originid);
|
||||
$object->array_options = $objectsrc->array_options;
|
||||
@ -1936,6 +1962,8 @@ if ($action == 'create')
|
||||
$remise_percent = $soc->remise_percent;
|
||||
$remise_absolue = 0;
|
||||
$dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970)
|
||||
|
||||
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
|
||||
}
|
||||
|
||||
$absolute_discount = $soc->getAvailableDiscounts();
|
||||
@ -1958,7 +1986,8 @@ if ($action == 'create')
|
||||
print '<input name="ref_int" type="hidden" value="' . $ref_int . '">';
|
||||
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||
|
||||
if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">';
|
||||
|
||||
dol_fiche_head('');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -2337,6 +2366,16 @@ if ($action == 'create')
|
||||
print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF);
|
||||
print "</td></tr>";
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
|
||||
print '<td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Public note
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
|
||||
@ -2419,6 +2458,13 @@ if ($action == 'create')
|
||||
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>";
|
||||
}
|
||||
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3384,6 +3430,44 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency code
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Currency','multicurrency_code');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencycode') {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
|
||||
} else {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Multicurrency rate
|
||||
print '<tr>';
|
||||
print '<td width="25%">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Rate','multicurrency_tx');
|
||||
print '</td>';
|
||||
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="5">';
|
||||
if ($action == 'editmulticurrencyrate') {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx');
|
||||
} else {
|
||||
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Bank Account
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
@ -3498,6 +3582,24 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Total with tax
|
||||
print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td colspan="3" class="nowrap">' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Multicurrency Amount HT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount VAT
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Multicurrency Amount TTC
|
||||
print '<tr><td height="10">' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
|
||||
print '<td class="nowrap" colspan="2">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Statut
|
||||
print '<tr><td>' . $langs->trans('Status') . '</td>';
|
||||
print '<td colspan="3">' . ($object->getLibStatut(4, $totalpaye)) . '</td></tr>';
|
||||
|
||||
@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
|
||||
|
||||
dol_include_once('/multicurrency/class/multicurrency.class.php');
|
||||
|
||||
/**
|
||||
* Class to manage invoices
|
||||
@ -107,6 +107,14 @@ class Facture extends CommonInvoice
|
||||
var $specimen;
|
||||
|
||||
var $fac_rec;
|
||||
|
||||
// Multicurrency
|
||||
var $fk_multicurrency;
|
||||
var $multicurrency_code;
|
||||
var $multicurrency_tx;
|
||||
var $multicurrency_total_ht;
|
||||
var $multicurrency_total_tva;
|
||||
var $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* @var int Situation cycle reference number
|
||||
@ -230,6 +238,16 @@ class Facture extends CommonInvoice
|
||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||
$this->brouillon = 1;
|
||||
|
||||
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
|
||||
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
|
||||
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
|
||||
if (empty($this->fk_multicurrency))
|
||||
{
|
||||
$this->multicurrency_code = $conf->currency;
|
||||
$this->fk_multicurrency = 0;
|
||||
$this->multicurrency_tx = 1;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::create user=".$user->id);
|
||||
|
||||
// Check parameters
|
||||
@ -301,6 +319,9 @@ class Facture extends CommonInvoice
|
||||
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf";
|
||||
$sql.= ", situation_cycle_ref, situation_counter, situation_final";
|
||||
$sql.= ", fk_incoterms, location_incoterms";
|
||||
$sql.= ", fk_multicurrency";
|
||||
$sql.= ", multicurrency_code";
|
||||
$sql.= ", multicurrency_tx";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "'(PROV)'";
|
||||
@ -328,6 +349,9 @@ class Facture extends CommonInvoice
|
||||
$sql.= ", ".($this->situation_final?$this->situation_final:0);
|
||||
$sql.= ", ".(int) $this->fk_incoterms;
|
||||
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql.= ", ".(int) $this->fk_multicurrency;
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".(double) $this->multicurrency_tx;
|
||||
$sql.=")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
@ -973,6 +997,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
|
||||
$sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
|
||||
$sql.= ', f.fk_account';
|
||||
$sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc";
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
|
||||
$sql.= ', f.fk_incoterms, f.location_incoterms';
|
||||
@ -1045,6 +1070,14 @@ class Facture extends CommonInvoice
|
||||
$this->location_incoterms = $obj->location_incoterms;
|
||||
$this->libelle_incoterms = $obj->libelle_incoterms;
|
||||
|
||||
// Multicurrency
|
||||
$this->fk_multicurrency = $obj->fk_multicurrency;
|
||||
$this->multicurrency_code = $obj->multicurrency_code;
|
||||
$this->multicurrency_tx = $obj->multicurrency_tx;
|
||||
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
|
||||
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
if ($this->type == self::TYPE_SITUATION && $fetch_situation)
|
||||
{
|
||||
$this->fetchPreviousNextSituationInvoice();
|
||||
@ -1104,6 +1137,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
|
||||
$sql.= ' l.fk_unit,';
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
@ -1163,7 +1197,15 @@ class Facture extends CommonInvoice
|
||||
$line->situation_percent= $objp->situation_percent;
|
||||
$line->fk_prev_id = $objp->fk_prev_id;
|
||||
$line->fk_unit = $objp->fk_unit;
|
||||
|
||||
|
||||
// Multicurrency
|
||||
$line->fk_multicurrency = $objp->fk_multicurrency;
|
||||
$line->multicurrency_code = $objp->multicurrency_code;
|
||||
$line->multicurrency_subprice = $objp->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
@ -2255,7 +2297,7 @@ class Facture extends CommonInvoice
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
|
||||
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent);
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx);
|
||||
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
@ -2264,6 +2306,11 @@ class Facture extends CommonInvoice
|
||||
$total_localtax2 = $tabprice[10];
|
||||
$pu_ht = $tabprice[3];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Rank to use
|
||||
$rangtouse = $rang;
|
||||
if ($rangtouse == -1)
|
||||
@ -2313,7 +2360,15 @@ class Facture extends CommonInvoice
|
||||
// infos marge
|
||||
$this->line->fk_fournprice = $fk_fournprice;
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
|
||||
// Multicurrency
|
||||
$this->line->fk_multicurrency = $this->fk_multicurrency;
|
||||
$this->line->multicurrency_code = $this->multicurrency_code;
|
||||
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
if (is_array($array_options) && count($array_options)>0) {
|
||||
$this->line->array_options=$array_options;
|
||||
}
|
||||
@ -2424,7 +2479,7 @@ class Facture extends CommonInvoice
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
|
||||
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent);
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx);
|
||||
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
@ -2435,6 +2490,11 @@ class Facture extends CommonInvoice
|
||||
$pu_tva = $tabprice[4];
|
||||
$pu_ttc = $tabprice[5];
|
||||
|
||||
// MultiCurrency
|
||||
$multicurrency_total_ht = $tabprice[16];
|
||||
$multicurrency_total_tva = $tabprice[17];
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Old properties: $price, $remise (deprecated)
|
||||
$price = $pu;
|
||||
$remise = 0;
|
||||
@ -2491,6 +2551,12 @@ class Facture extends CommonInvoice
|
||||
$this->line->fk_fournprice = $fk_fournprice;
|
||||
$this->line->pa_ht = $pa_ht;
|
||||
|
||||
// Multicurrency
|
||||
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx);
|
||||
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
|
||||
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
|
||||
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
|
||||
|
||||
if (is_array($array_options) && count($array_options)>0) {
|
||||
$this->line->array_options=$array_options;
|
||||
}
|
||||
@ -3591,6 +3657,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
|
||||
$sql.= ' l.date_start, l.date_end,';
|
||||
$sql.= ' l.fk_unit,';
|
||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,';
|
||||
$sql.= ' p.description as product_desc,';
|
||||
$sql.= ' p.entity';
|
||||
@ -3643,7 +3710,15 @@ class Facture extends CommonInvoice
|
||||
$this->lines[$i]->marge_tx = $marginInfos[1];
|
||||
$this->lines[$i]->marque_tx = $marginInfos[2];
|
||||
$this->lines[$i]->fk_unit = $obj->fk_unit;
|
||||
|
||||
|
||||
// Multicurrency
|
||||
$this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency;
|
||||
$this->lines[$i]->multicurrency_code = $obj->multicurrency_code;
|
||||
$this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice;
|
||||
$this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht;
|
||||
$this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
@ -4079,7 +4154,9 @@ class FactureLigne extends CommonInvoiceLine
|
||||
$sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
|
||||
$sql.= ' situation_percent, fk_prev_id,';
|
||||
$sql.= ' fk_unit)';
|
||||
$sql.= ' fk_unit';
|
||||
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
||||
$sql.= ')';
|
||||
$sql.= " VALUES (".$this->fk_facture.",";
|
||||
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
|
||||
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
|
||||
@ -4111,6 +4188,12 @@ class FactureLigne extends CommonInvoiceLine
|
||||
$sql .= ", " . $this->situation_percent;
|
||||
$sql .= ", " . $this->fk_prev_id;
|
||||
$sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
|
||||
$sql.= ", ".$this->fk_multicurrency;
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".$this->multicurrency_subprice;
|
||||
$sql.= ", ".$this->multicurrency_total_ht;
|
||||
$sql.= ", ".$this->multicurrency_total_tva;
|
||||
$sql.= ", ".$this->multicurrency_total_ttc;
|
||||
$sql.= ')';
|
||||
|
||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
||||
@ -4284,6 +4367,13 @@ class FactureLigne extends CommonInvoiceLine
|
||||
if (! empty($this->rang)) $sql.= ", rang=".$this->rang;
|
||||
$sql .= ", situation_percent=" . $this->situation_percent;
|
||||
$sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
|
||||
|
||||
// Multicurrency
|
||||
$sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice)."";
|
||||
$sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
|
||||
$sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
|
||||
$sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
|
||||
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
|
||||
@ -1434,6 +1434,10 @@ abstract class CommonObject
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->multicurrency_code = $code;
|
||||
|
||||
list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code);
|
||||
if ($rate) $this->setMulticurrencyRate($rate);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -1471,6 +1475,30 @@ abstract class CommonObject
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->multicurrency_tx = $rate;
|
||||
|
||||
// Update line price
|
||||
if (!empty($this->lines))
|
||||
{
|
||||
foreach ($this->lines as &$line)
|
||||
{
|
||||
switch ($this->element) {
|
||||
case 'propal':
|
||||
$this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit);
|
||||
break;
|
||||
case 'commande':
|
||||
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit);
|
||||
break;
|
||||
case 'facture':
|
||||
$this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
|
||||
break;
|
||||
default:
|
||||
dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -3381,6 +3409,7 @@ abstract class CommonObject
|
||||
print '<td>'.$langs->trans('Description').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
if (!empty($conf->multicurrency->enabled)) print '<td align="right">'.$langs->trans('PriceUHTCurrency').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
@ -3511,6 +3540,7 @@ abstract class CommonObject
|
||||
|
||||
$this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
|
||||
$this->tpl['price'] = price($line->subprice);
|
||||
$this->tpl['multicurrency_price'] = price($line->multicurrency_subprice);
|
||||
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' ';
|
||||
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long');
|
||||
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' ';
|
||||
|
||||
@ -449,8 +449,9 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
|
||||
|
||||
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
|
||||
$tvaligne=$object->lines[$i]->total_tva;
|
||||
|
||||
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
|
||||
else $tvaligne=$object->lines[$i]->total_tva;
|
||||
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
$localtax1_rate=$object->lines[$i]->localtax1_tx;
|
||||
@ -501,11 +502,11 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->setPage($pagenb);
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
$pagenb++;
|
||||
@ -517,11 +518,11 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
{
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
// New page
|
||||
@ -535,12 +536,12 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
|
||||
@ -827,8 +828,9 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
// Show VAT by rates and total
|
||||
$pdf->SetFillColor(248,248,248);
|
||||
@ -1006,8 +1008,9 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetFillColor(224,224,224);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
|
||||
|
||||
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1058,9 +1061,10 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
* @param Translate $outputlangs Langs object
|
||||
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
|
||||
* @param int $hidebottom Hide bottom bar of array
|
||||
* @param string $currency Currency code
|
||||
* @return void
|
||||
*/
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1068,6 +1072,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$hidebottom=0;
|
||||
if ($hidetop) $hidetop=-1;
|
||||
|
||||
$currency = !empty($currency) ? $currency : $conf->currency;
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
// Amount in (at tab_top - 1)
|
||||
@ -1076,7 +1081,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
|
||||
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
|
||||
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
|
||||
|
||||
|
||||
@ -543,9 +543,11 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$prev_progress = $object->lines[$i]->get_prev_progress();
|
||||
if ($prev_progress > 0) // Compute progress from previous situation
|
||||
{
|
||||
$tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
|
||||
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
|
||||
else $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
|
||||
} else {
|
||||
$tvaligne = $object->lines[$i]->total_tva;
|
||||
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
|
||||
else $tvaligne=$object->lines[$i]->total_tva;
|
||||
}
|
||||
$localtax1ligne=$object->lines[$i]->total_localtax1;
|
||||
$localtax2ligne=$object->lines[$i]->total_localtax2;
|
||||
@ -599,11 +601,11 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->setPage($pagenb);
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
$pagenb++;
|
||||
@ -615,11 +617,11 @@ class pdf_crabe extends ModelePDFFactures
|
||||
{
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
|
||||
}
|
||||
$this->_pagefoot($pdf,$object,$outputlangs,1);
|
||||
// New page
|
||||
@ -633,12 +635,12 @@ class pdf_crabe extends ModelePDFFactures
|
||||
// Show square
|
||||
if ($pagenb == 1)
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
|
||||
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
|
||||
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
|
||||
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
|
||||
}
|
||||
|
||||
@ -1020,8 +1022,10 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->SetFillColor(255,255,255);
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
// Show VAT by rates and total
|
||||
$pdf->SetFillColor(248,248,248);
|
||||
@ -1214,8 +1218,9 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->SetFillColor(224,224,224);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
|
||||
|
||||
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1286,9 +1291,10 @@ class pdf_crabe extends ModelePDFFactures
|
||||
* @param Translate $outputlangs Langs object
|
||||
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
|
||||
* @param int $hidebottom Hide bottom bar of array
|
||||
* @param string $currency Currency code
|
||||
* @return void
|
||||
*/
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -1296,6 +1302,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$hidebottom=0;
|
||||
if ($hidetop) $hidetop=-1;
|
||||
|
||||
$currency = !empty($currency) ? $currency : $conf->currency;
|
||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||
|
||||
// Amount in (at tab_top - 1)
|
||||
@ -1304,7 +1311,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
|
||||
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
|
||||
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
|
||||
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
<td><?php echo $this->tpl['description']; ?></td>
|
||||
<td align="right"><?php echo $this->tpl['vat_rate']; ?></td>
|
||||
<td align="right"><?php echo $this->tpl['price']; ?></td>
|
||||
<?php if (!empty($conf->multicurrency->enabled)) { ?><td align="right"><?php echo $this->tpl['multicurrency_price']; ?></td><?php } ?>
|
||||
<td align="right"><?php echo $this->tpl['qty']; ?></td>
|
||||
<?php
|
||||
if($conf->global->PRODUCT_USE_UNITS) echo '<td align="left">'.$langs->trans($this->tpl['unit']).'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user