Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2016-02-08 15:50:34 +01:00
commit 404663472a
52 changed files with 2799 additions and 225 deletions

View File

@ -77,7 +77,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,0,25,0,26);
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@ -110,6 +110,7 @@ $tabname[26]= MAIN_DB_PREFIX."c_units";
$tabname[27]= MAIN_DB_PREFIX."c_stcomm";
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
$tabname[29]= MAIN_DB_PREFIX."c_lead_status";
$tabname[30]= MAIN_DB_PREFIX."c_format_cards";
// Dictionary labels
$tablib=array();
@ -142,6 +143,7 @@ $tablib[26]= "DictionaryUnits";
$tablib[27]= "DictionaryProspectStatus";
$tablib[28]= "DictionaryHolidayTypes";
$tablib[29]= "DictionaryOpportunityStatus";
$tablib[30]= "DictionaryFormatCards";
// Requests to extract data
$tabsql=array();
@ -174,6 +176,7 @@ $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".M
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
// Criteria to sort dictionaries
$tabsqlsort=array();
@ -206,6 +209,7 @@ $tabsqlsort[26]="code ASC";
$tabsqlsort[27]="code ASC";
$tabsqlsort[28]="country ASC, code ASC";
$tabsqlsort[29]="position ASC";
$tabsqlsort[30]="code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@ -238,6 +242,7 @@ $tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country";
$tabfield[29]= "code,label,percent,position";
$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@ -270,6 +275,7 @@ $tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country";
$tabfieldvalue[29]= "code,label,percent,position";
$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@ -302,6 +308,7 @@ $tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27]= "code,libelle";
$tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position";
$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@ -336,6 +343,7 @@ $tabrowid[26]= "";
$tabrowid[27]= "id";
$tabrowid[28]= "";
$tabrowid[29]= "";
$tabrowid[30]= "";
// Condition to show dictionary in setup page
$tabcond=array();
@ -368,6 +376,7 @@ $tabcond[26]= ! empty($conf->product->enabled);
$tabcond[27]= ! empty($conf->societe->enabled);
$tabcond[28]= ! empty($conf->holiday->enabled);
$tabcond[29]= ! empty($conf->projet->enabled);
$tabcond[30]= ! empty($conf->label->enabled);
// List of help for fields
$tabhelp=array();
@ -400,6 +409,7 @@ $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
@ -432,6 +442,7 @@ $tabfieldcheck[26] = array();
$tabfieldcheck[27] = array();
$tabfieldcheck[28] = array();
$tabfieldcheck[29] = array();
$tabfieldcheck[30] = array();
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);

View File

@ -0,0 +1,289 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file admin/multicurrency.php
* \ingroup quickpriceupdate
* \brief This file is an example module setup page
* Put some comments here
*/
// Dolibarr environment
require '../main.inc.php';
// Libraries
dol_include_once('/core/lib/admin.lib.php');
dol_include_once('/core/lib/multicurrency.lib.php');
dol_include_once('/multicurrency/class/multicurrency.class.php');
// Translations
$langs->load("multicurrency");
// Access control
if (! $user->admin) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'alpha');
/*
* Actions
*/
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
if (preg_match('/del_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, 0) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
if ($action == 'add_currency')
{
$code = GETPOST('code', 'alpha');
$name = GETPOST('name', 'alpha');
$rate = GETPOST('rate', 'alpha');
$currency = new MultiCurrency($db);
$currency->code = $code;
$currency->name = $name;
if ($currency->create($user) > 0)
{
if ($currency->addRate($rate)) setEventMessages($langs->trans('SuccessAddRate'), array());
else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors');
}
else setEventMessages($langs->trans('ErrorAddCurrencyFail'), array());
}
elseif ($action == 'update_currency')
{
$submit = GETPOST('submit', 'alpha');
if ($submit == $langs->trans('Modify'))
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$rate = GETPOST('rate', 'float');
$currency = new MultiCurrency($db);
if ($currency->fetch($fk_multicurrency) > 0)
{
$currency->updateRate($rate);
}
}
elseif ($submit == $langs->trans('Delete'))
{
$fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$currency = new MultiCurrency($db);
if ($currency->fetch($fk_multicurrency) > 0)
{
if ($currency->delete() > 0) setEventMessages($langs->trans('SuccessDeleteCurrency'), array());
else setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors');
}
}
}
$TCurrency = array();
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
$currency = new MultiCurrency($db);
$currency->fetch($obj->rowid);
$TCurrency[] = $currency;
}
}
/*
* View
*/
$page_name = "multicurrency";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">'
. $langs->trans("BackToModuleList") . '</a>';
print_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = multicurrencyAdminPrepareHead();
dol_fiche_head(
$head,
'settings',
$langs->trans("Module500000Name"),
0,
"multicurrency"
);
// Setup page goes here
$form=new Form($db);
$var=false;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_useRateOnInvoiceDate").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_USE_RATE_ON_INVOICE_DATE">';
print $form->selectyesno("MULTICURRENCY_USE_RATE_ON_INVOICE_DATE",$conf->global->MULTICURRENCY_USE_RATE_ON_INVOICE_DATE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_USE_ORIGIN_TX">';
print $form->selectyesno("MULTICURRENCY_USE_ORIGIN_TX",$conf->global->MULTICURRENCY_USE_ORIGIN_TX,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_buyPriceInCurrency").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_BUY_PRICE_IN_CURRENCY">';
print $form->selectyesno("MULTICURRENCY_BUY_PRICE_IN_CURRENCY",$conf->global->MULTICURRENCY_BUY_PRICE_IN_CURRENCY,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_MODIFY_RATE_APPLICATION">';
print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'));
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appId").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_CURRENCY_APP_ID">';
print '<input type="text" name="CURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.'" size="28" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_FROM_TO_RATE">';
print '<input type="text" name="MULTICURRENCY_FROM_TO_RATE" value="'.$conf->global->MULTICURRENCY_FROM_TO_RATE.'" size="10" placeholder="USD-EUR-1" />&nbsp;'; // CURRENCY_BASE - CURRENCY_ENTITY - ID_ENTITY
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
print '</table>';
print '</form>';
print '<br />';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Currencies").'</td>'."\n";
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="center" width="100">'.$langs->trans("Rate").'</td>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_currency">';
print '<td><input type="text" name="code" value="" size="5" placeholder="'.$langs->trans('code').'" /> - <input type="text" name="name" value="" size="35" placeholder="'.$langs->trans('name').'" /></td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="300">';
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('rate').'" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></form></tr>';
foreach ($TCurrency as &$currency)
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$currency->code.' - '.$currency->name.'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="400">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_currency">';
print '<input type="hidden" name="fk_multicurrency" value="'.$currency->id.'">';
print '<input type="text" name="rate" value="'.($currency->rate->rate ? $currency->rate->rate : '').'" size="13" />&nbsp;';
print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Modify").'">&nbsp;';
print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Delete").'">';
print '</form>';
print '</td></tr>';
}
print '</table>';
llxFooter();
$db->close();

View File

@ -344,6 +344,12 @@ if (empty($reshook))
$object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid');
// Multicurrency
if (!empty($conf->multicurrency->enabled))
{
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
}
for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++)
{
@ -1084,6 +1090,16 @@ if (empty($reshook))
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
}
// Multicurrency Code
else if ($action == 'setmulticurrencycode' && $user->rights->propal->creer) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
}
// Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->propal->creer) {
$result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int'));
}
// bank account
else if ($action == 'setbankaccount' && $user->rights->propal->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
@ -1422,6 +1438,17 @@ if ($action == 'create')
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_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">';
$currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency));
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
// Public note
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
@ -1900,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&amp;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&amp;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))
{
@ -2034,7 +2099,25 @@ if ($action == 'create')
print '<tr><td height="10">' . $langs->trans('AmountTTC') . '</td>';
print '<td class="nowrap" colspan="2">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $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>';
}
// Statut
print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -37,6 +37,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 .'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
dol_include_once('/multicurrency/class/multicurrency.class.php');
/**
* Class to manage proposals
@ -156,6 +157,14 @@ class Propal extends CommonObject
var $specimen;
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_tx;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
/**
* Draft status
*/
@ -441,7 +450,7 @@ class Propal extends CommonObject
$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];
@ -449,6 +458,11 @@ class Propal extends CommonObject
$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)
@ -505,6 +519,14 @@ class Propal extends CommonObject
$this->line->origin_id = $origin_id;
$this->line->origin = $origin;
// 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;
// Mise en option de la ligne
if (empty($qty) && empty($special_code)) $this->line->special_code=3;
@ -603,13 +625,18 @@ class Propal extends CommonObject
$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, $remise (a ne plus utiliser)
$price = $pu;
if ($remise_percent > 0)
@ -672,6 +699,12 @@ class Propal extends CommonObject
$this->line->array_options=$array_options;
}
// Multicurrency
$this->line->multicurrency_subprice = price2num($pu * $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;
$result=$this->line->update();
if ($result > 0)
{
@ -756,6 +789,15 @@ 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 = $conf->currency;
$this->fk_multicurrency = 0;
$this->multicurrency_tx = 1;
}
dol_syslog(get_class($this)."::create");
// Check parameters
@ -819,6 +861,9 @@ class Propal extends CommonObject
$sql.= ", fk_incoterms";
$sql.= ", location_incoterms";
$sql.= ", entity";
$sql.= ", fk_multicurrency";
$sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx";
$sql.= ") ";
$sql.= " VALUES (";
$sql.= $this->socid;
@ -848,6 +893,9 @@ class Propal extends CommonObject
$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);
@ -1184,6 +1232,7 @@ class Propal extends CommonObject
$sql.= ', p.fk_account';
$sql.= ", p.fk_shipping_method";
$sql.= ", p.fk_incoterms, p.location_incoterms";
$sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
@ -1268,6 +1317,14 @@ class Propal extends CommonObject
$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 ($obj->fk_statut == self::STATUS_DRAFT)
{
$this->brouillon = 1;
@ -1292,6 +1349,7 @@ class Propal extends CommonObject
$sql.= " d.fk_unit,";
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' d.date_start, d.date_end';
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql.= " WHERE d.fk_propal = ".$this->id;
@ -1357,6 +1415,15 @@ class Propal extends CommonObject
$line->date_start = $objp->date_start;
$line->date_end = $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;
$line->fetch_optionals($line->id,$extralabelsline);
$this->lines[$i] = $line;
@ -2785,6 +2852,7 @@ class Propal extends CommonObject
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc,';
$sql.= ' p.entity';
$sql.= ' ,pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql.= ' WHERE pt.fk_propal = '.$this->id;
@ -2833,6 +2901,14 @@ class Propal extends CommonObject
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
$this->lines[$i]->date_end = $this->db->jdate($obj->date_end);
$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++;
}
@ -3003,6 +3079,14 @@ class PropaleLigne extends CommonObjectLine
var $skip_update_total; // Skip update price total for special lines
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
var $multicurrency_subprice;
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
/**
* Class line Contructor
*
@ -3026,6 +3110,7 @@ class PropaleLigne extends CommonObjectLine
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
$sql.= ' pd.fk_unit,';
$sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
$sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc,';
$sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
$sql.= ' pd.date_start, pd.date_end, pd.product_type';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
@ -3078,6 +3163,14 @@ class PropaleLigne extends CommonObjectLine
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
// Multicurrency
$this->fk_multicurrency = $objp->fk_multicurrency;
$this->multicurrency_code = $objp->multicurrency_code;
$this->multicurrency_subprice = $objp->multicurrency_subprice;
$this->multicurrency_total_ht = $objp->multicurrency_total_ht;
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$this->db->free($result);
return 1;
@ -3148,7 +3241,8 @@ class PropaleLigne extends CommonObjectLine
$sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
$sql.= ' fk_unit,';
$sql.= ' date_start, date_end)';
$sql.= ' date_start, date_end';
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc)';
$sql.= " VALUES (".$this->fk_propal.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
@ -3177,6 +3271,12 @@ class PropaleLigne extends CommonObjectLine
$sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit).',';
$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_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);
@ -3349,6 +3449,13 @@ class PropaleLigne extends CommonObjectLine
$sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$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);

View File

@ -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&amp;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&amp;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>';

View File

@ -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);

View File

@ -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)
{
@ -1856,6 +1874,8 @@ if ($action == 'create')
if ($socid > 0)
$res = $soc->fetch($socid);
$currency_code = $conf->currency;
// Load objectsrc
$remise_absolue = 0;
@ -1924,6 +1944,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;
@ -1937,6 +1963,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();
@ -1959,7 +1987,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%">';
@ -2338,6 +2367,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>';
@ -2420,6 +2459,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
{
@ -3392,6 +3438,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&amp;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&amp;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">';
@ -3506,6 +3590,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>';

View File

@ -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++;
@ -2259,7 +2301,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];
@ -2268,6 +2310,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)
@ -2316,7 +2363,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;
}
@ -2427,7 +2482,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];
@ -2438,6 +2493,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;
@ -2494,6 +2554,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;
}
@ -3594,6 +3660,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';
@ -3646,7 +3713,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);
@ -4043,7 +4118,11 @@ class FactureLigne extends CommonInvoiceLine
if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100;
if (empty($this->pa_ht)) $this->pa_ht=0;
if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0;
if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0;
if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0;
if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
@ -4085,7 +4164,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").",";
@ -4117,6 +4198,12 @@ class FactureLigne extends CommonInvoiceLine
$sql .= ", " . $this->situation_percent;
$sql .= ", " . $this->fk_prev_id;
$sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".price2num($this->multicurrency_subprice);
$sql.= ", ".price2num($this->multicurrency_total_ht);
$sql.= ", ".price2num($this->multicurrency_total_tva);
$sql.= ", ".price2num($this->multicurrency_total_ttc);
$sql.= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@ -4290,6 +4377,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);

View File

@ -1414,6 +1414,108 @@ abstract class CommonObject
}
}
/**
* Change the multicurrency code
*
* @param string $code multicurrency code
* @return int >0 if OK, <0 if KO
*/
function setMulticurrencyCode($code)
{
dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
{
$fieldname = 'multicurrency_code';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"';
$sql .= ' WHERE rowid='.$this->id;
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
{
dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
/**
* Change the multicurrency rate
*
* @param double $rate multicurrency rate
* @return int >0 if OK, <0 if KO
*/
function setMulticurrencyRate($rate)
{
dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe')
{
$fieldname = 'multicurrency_tx';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$rate;
$sql .= ' WHERE rowid='.$this->id;
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
{
dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut;
return -2;
}
}
/**
* Change the payments terms
*
@ -2076,6 +2178,7 @@ abstract class CommonObject
$sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,';
$sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent';
$sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
if ($exclspec)
@ -2098,6 +2201,9 @@ abstract class CommonObject
$total_ht_by_vats = array();
$total_tva_by_vats = array();
$total_ttc_by_vats = array();
$this->multicurrency_total_ht = 0;
$this->multicurrency_total_tva = 0;
$this->multicurrency_total_ttc = 0;
$num = $this->db->num_rows($resql);
$i = 0;
@ -2106,11 +2212,11 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
// Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
$multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100));
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
$diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
if ($diff)
{
@ -2129,6 +2235,7 @@ abstract class CommonObject
$this->total_localtax1 += $obj->total_localtax1;
$this->total_localtax2 += $obj->total_localtax2;
$this->total_ttc += $obj->total_ttc;
if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0;
if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0;
if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0;
@ -2174,7 +2281,12 @@ abstract class CommonObject
$this->total_ttc -= $sit->total_ttc;
}
}
// Multicurrency
$this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx;
$this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx;
$this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx;
$this->db->free($resql);
// Now update global field total_ht, total_ttc and tva
@ -2198,6 +2310,9 @@ abstract class CommonObject
$sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',";
$sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',";
$sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'";
$sql .= ", multicurrency_total_ht='".price2num($this->multicurrency_total_ht, 'MT', 1)."'";
$sql .= ", multicurrency_total_tva='".price2num($this->multicurrency_total_tva, 'MT', 1)."'";
$sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'";
$sql .= ' WHERE rowid = '.$this->id;
//print "xx".$sql;
@ -3068,6 +3183,9 @@ abstract class CommonObject
// Price HT
print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
// Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency').'</td>';
if ($inputalsopricewithtax) print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>';
// Qty
@ -3101,6 +3219,9 @@ abstract class CommonObject
// Total HT
print '<td class="linecolht" align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
// Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoltotalht_currency" align="right" width="50">'.$langs->trans('TotalHTShortCurrency').'</td>';
print '<td class="linecoledit"></td>'; // No width to allow autodim
print '<td class="linecoldelete" width="10"></td>';
@ -3288,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)
{
@ -3418,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 : '&nbsp;';
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) : '&nbsp;';

View File

@ -3723,6 +3723,65 @@ class Form
}
}
}
/**
* Show form with multicurrency code
*
* @param string $page Page
* @param string $selected code pre-selectionne
* @param string $htmlname Name of select html field
* @return void
*/
function form_multicurrency_code($page, $selected='', $htmlname='multicurrency_code')
{
global $langs;
if ($htmlname != "none")
{
print '<form method="POST" action="'.$page.'">';
print '<input type="hidden" name="action" value="setmulticurrencycode">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print $this->selectMultiCurrency($selected,$htmlname);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
dol_include_once('/core/lib/company.lib.php');
print !empty($selected) ? currency_name($selected,1) : '&nbsp;';
}
}
/**
* Show form with multicurrency rate
*
* @param string $page Page
* @param double $rate Current rate
* @param string $htmlname Name of select html field
* @return void
*/
function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx')
{
global $langs;
if ($htmlname != "none")
{
print '<form method="POST" action="'.$page.'">';
print '<input type="hidden" name="action" value="setmulticurrencyrate">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? $rate : 1).'" size="10" />';
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
print !empty($rate) ? $rate : 1;
}
}
/**
@ -3926,7 +3985,53 @@ class Form
return $out;
}
/**
* Return array of currencies in user language
*
* @param string $selected preselected currency code
* @param string $htmlname name of HTML select list
* @param integer $useempty 1=Add empty line
* @return string
*/
function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0)
{
global $db,$conf,$langs,$user;
$langs->loadCacheCurrencies('');
$TCurrency = array();
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code;
}
$out='';
$out.= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty) $out .= '<option value="">&nbsp;</option>';
if (count($TCurrency) > 0)
{
foreach ($langs->cache_currencies as $code_iso => $currency)
{
if (isset($TCurrency[$code_iso]))
{
if (!empty($selected) && $selected == $code_iso) $out.= '<option value="'.$code_iso.'" selected>';
else $out.= '<option value="'.$code_iso.'">';
$out.= $currency['label'];
$out.= ' ('.$langs->getCurrencySymbol($code_iso).')';
$out.= '</option>';
}
}
}
$out.= '</select>';
return $out;
}
/**
* Load into the cache vat rates of a country
*

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,118 +31,29 @@ global $_Avery_Labels;
// To get into inch, just /25.4
// Size of pages available on: http://www.worldlabel.com/Pages/pageaverylabels.htm
// _PosX = marginLeft+(_COUNTX*(width+SpaceX));
$_Avery_Labels = array (
'5160'=>array('name'=>'Avery-5160, WL-875WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>5.58165, // 0.21975 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>3,
'NY'=>10,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>65.8749, // 2.59350 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5161'=>array('name'=>'Avery-5161, WL-75WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>4.445, // 0.175 inch
'marginTop'=>12.7,
'NX'=>2,
'NY'=>10,
'SpaceX'=>3.968, // 0.15625 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5162'=>array('name'=>'Avery-5162, WL-100WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>3.8735, // 0.1525 inch
'marginTop'=>22.352, // 0.88 inch
'NX'=>2,
'NY'=>7,
'SpaceX'=>4.954, // 0.195 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>33.781, // 1.33 inch
'font-size'=>8),
'5163'=>array('name'=>'Avery-5163, WL-125WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>4.572, // 0.18 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>2,
'NY'=>5,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>50.8, // 2 inch
'font-size'=>10),
/* Bugged '5164'=>array('name'=>'5164 (Letter)',
'paper-size'=>'letter',
'metric'=>'in',
'marginLeft'=>0.148,
'marginTop'=>0.5,
'NX'=>2,
'NY'=>3,
'SpaceX'=>0.2031,
'SpaceY'=>0,
'width'=>4.0,
'height'=>3.33,
'font-size'=>12), */
'8600'=>array('name'=>'Avery-8600',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>7.1,
'marginTop'=>19,
'NX'=>3,
'NY'=>10,
'SpaceX'=>9.5,
'SpaceY'=>3.1,
'width'=>66.6,
'height'=>25.4,
'font-size'=>7),
'L7163'=>array('name'=>'Avery-L7163',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>5,
'marginTop'=>15,
'NX'=>2,
'NY'=>7,
'SpaceX'=>2.5,
'SpaceY'=>0,
'width'=>99.1,
'height'=>38.1,
'font-size'=>8),
// 85.0 x 54.0 mm
'AVERYC32010'=>array('name'=>'Avery-C32010',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
'marginTop'=>13,
'NX'=>2,
'NY'=>5,
'SpaceX'=>10,
'SpaceY'=>0,
'width'=>85,
'height'=>54,
'font-size'=>10),
'CARD'=>array('name'=>'Dolibarr Business cards',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
'marginTop'=>15,
'NX'=>2,
'NY'=>5,
'SpaceX'=>0,
'SpaceY'=>0,
'width'=>85,
'height'=>54,
'font-size'=>10)
);
$sql = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards WHERE active=1 ORDER BY code ASC";
$resql = $db->query($sql);
while ($row = $db->fetch_array($resql)) {
$_Avery_Labels[$row['code']]['name']=$row['name'];
$_Avery_Labels[$row['code']]['paper-size']=$row['paper_size'];
$_Avery_Labels[$row['code']]['orientation']=$row['orientation'];
$_Avery_Labels[$row['code']]['metric']=$row['metric'];
$_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin'];
$_Avery_Labels[$row['code']]['marginTop']=$row['topmargin'];
$_Avery_Labels[$row['code']]['marginTop']=$row['topmargin'];
$_Avery_Labels[$row['code']]['NX']=$row['nx'];
$_Avery_Labels[$row['code']]['NY']=$row['ny'];
$_Avery_Labels[$row['code']]['SpaceX']=$row['spacex'];
$_Avery_Labels[$row['code']]['SpaceY']=$row['spacey'];
$_Avery_Labels[$row['code']]['width']=$row['width'];
$_Avery_Labels[$row['code']]['height']=$row['height'];
$_Avery_Labels[$row['code']]['font-size']=$row['font_size'];
$_Avery_Labels[$row['code']]['custom_x']=$row['custom_x'];
$_Avery_Labels[$row['code']]['custom_y']=$row['custom_y'];
}
// we add characteristics to the name
foreach($_Avery_Labels as $key => $val)
{
$_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')';

View File

@ -0,0 +1,54 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file lib/multicurrency.lib.php
* \ingroup multicurency
* \brief This file is an example module library
* Put some comments here
*/
/**
* Prepare array with list of tabs
*
* @return array Array of tabs to show
*/
function multicurrencyAdminPrepareHead()
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'settings';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@quickpriceupdate:/quickpriceupdate/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@quickpriceupdate:/quickpriceupdate/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'multicurrency');
return $head;
}

View File

@ -1414,7 +1414,11 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
}
if (empty($reshook))
{
if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * $object->lines[$i]->subprice, 0, $outputlangs);
if (empty($hidedetails) || $hidedetails > 1)
{
$subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
$result.=price($sign * $subprice, 0, $outputlangs);
}
}
return $result;
}
@ -1735,7 +1739,11 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
{
return $outputlangs->transnoentities("Option");
}
if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * $object->lines[$i]->total_ht, 0, $outputlangs);
if (empty($hidedetails) || $hidedetails > 1)
{
$total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
$result.=price($sign * $total_ht, 0, $outputlangs);
}
}
return $result;
}

View File

@ -49,6 +49,7 @@
* @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc.
* @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default)
* @param double $multicurrency_tx Currency rate (1 by default)
* @return result[ 0=total_ht,
* 1=total_vat, (main vat only)
* 2=total_ttc, (total_ht + main vat + local taxes)
@ -65,8 +66,11 @@
* 13=!! should not be used
* 14=total_tax1 for total_ht_without_discount,
* 15=total_tax2 for total_ht_without_discount]
* 16=multicurrency_total_ht
* 17=multicurrency_total_tva
* 18=multicurrency_total_ttc
*/
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100)
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1)
{
global $conf,$mysoc,$db;
@ -322,9 +326,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
}
}
// Multicurrency
$result[16] = price2num($result[0] * $multicurrency_tx, 'MT');
$result[17] = price2num($result[1] * $multicurrency_tx, 'MT');
$result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
// initialize result array
//for ($i=0; $i <= 15; $i++) $result[$i] = (float) $result[$i];
//for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i];
dol_syslog('Price.lib::calcul_price_total MAIN_ROUNDING_RULE_TOT='.$conf->global->MAIN_ROUNDING_RULE_TOT.' pu='.$pu.' qty='.$qty.' price_base_type='.$price_base_type.' total_ht='.$result[0].'-total_vat='.$result[1].'-total_ttc='.$result[2]);

View File

@ -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);

View File

@ -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);

View File

@ -247,7 +247,14 @@ class pdf_standard extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -284,7 +291,7 @@ class pdf_standard extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -0,0 +1,290 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup multicurrency Module MultiCurrency
* \brief Handle multiple currencies on company/propal/orders ...
* \file htdocs/core/modules/modMultiCurrency.class.php
* \ingroup multicurrency
* \brief Description and activation file for module MultiCurrency
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module MyModule
*/
class modMultiCurrency extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
global $langs,$conf;
$this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'multicurrency';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "financial";
// Module position in the family
$this->module_position = 500;
// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
$this->familyinfo = array('financial' => array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial")));
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Description of module MyModule";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'development';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 0;
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto='multicurrency';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable)
// for specific path of parts (eg: /multicurrency/core/modules/barcode)
// for specific css file (eg: /multicurrency/css/multicurrency.css.php)
//$this->module_parts = array(
// 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
// 'login' => 0, // Set this to 1 if module has its own login method directory (core/login)
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
// 'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
// 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
// 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
// 'css' => array('/multicurrency/css/multicurrency.css.php'), // Set this to relative path of css file if module has its own css file
// 'js' => array('/multicurrency/js/multicurrency.js'), // Set this to relative path of js file if module must load a js on all pages
// 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
// 'dir' => array('output' => 'othermodulename'), // To force the default directories names
// 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@multicurrency')) // Set here all workflow context managed by module
// );
$this->module_parts = array();
// Data directories to create when module is enabled.
// Example: this->dirs = array("/multicurrency/temp");
$this->dirs = array();
// Config pages. Put here list of php page, stored into multicurrency/admin directory, to use to setup module.
$this->config_page_url = array("multicurrency.php");
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array(); // List of modules id this module is in conflict with
$this->phpmin = array(5,0); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("multicurrency");
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array();
// Array to add new pages in new tabs
// Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@multicurrency:$user->rights->multicurrency->read:/multicurrency/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1
// 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
// where objecttype can be
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
// 'contact' to add a tab in contact view
// 'contract' to add a tab in contract view
// 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view
// 'invoice_supplier' to add a tab in supplier invoice view
// 'member' to add a tab in fundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in customer order view
// 'order_supplier' to add a tab in supplier order view
// 'payment' to add a tab in payment view
// 'payment_supplier' to add a tab in supplier payment view
// 'product' to add a tab in product view
// 'propal' to add a tab in propal view
// 'project' to add a tab in project view
// 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view
$this->tabs = array();
// Dictionaries
if (! isset($conf->multicurrency->enabled))
{
$conf->multicurrency=new stdClass();
$conf->multicurrency->enabled=0;
}
$this->dictionaries=array();
/* Example:
if (! isset($conf->multicurrency->enabled)) $conf->multicurrency->enabled=0; // This is to avoid warnings
$this->dictionaries=array(
'langs'=>'mylangfile@multicurrency',
'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor
'tablib'=>array("Table1","Table2","Table3"), // Label of tables
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields
'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order
'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary)
'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record)
'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert)
'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid')
'tabcond'=>array($conf->multicurrency->enabled,$conf->multicurrency->enabled,$conf->multicurrency->enabled) // Condition to show each dictionary
);
*/
// Boxes
// Add here list of php file(s) stored in core/boxes that contains class to show a box.
$this->boxes = array(); // List of boxes
// Example:
//$this->boxes=array(
// 0=>array('file'=>'myboxa.php@multicurrency','note'=>'','enabledbydefaulton'=>'Home'),
// 1=>array('file'=>'myboxb.php@multicurrency','note'=>''),
// 2=>array('file'=>'myboxc.php@multicurrency','note'=>'')
//);
// Cronjobs
$this->cronjobs = array(); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
// );
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
// Example:
// $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
// $this->rights[$r][1] = 'Permision label'; // Permission label
// $this->rights[$r][3] = 1; // Permission by default for new user (0/1)
// $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $r++;
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
// Add here entries to declare new menus
//
// Example to declare a new Top Menu entry and its Left menu entry:
// $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
// 'type'=>'top', // This is a Top menu entry
// 'titre'=>'MyModule top menu',
// 'mainmenu'=>'multicurrency',
// 'leftmenu'=>'multicurrency',
// 'url'=>'/multicurrency/pagetop.php',
// 'langs'=>'mylangfile@multicurrency', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
// 'position'=>100,
// 'enabled'=>'$conf->multicurrency->enabled', // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled.
// 'perms'=>'1', // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
//
// Example to declare a Left Menu entry into an existing Top menu entry:
// $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
// 'type'=>'left', // This is a Left menu entry
// 'titre'=>'MyModule left menu',
// 'mainmenu'=>'xxx',
// 'leftmenu'=>'multicurrency',
// 'url'=>'/multicurrency/pagelevel2.php',
// 'langs'=>'mylangfile@multicurrency', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
// 'position'=>100,
// 'enabled'=>'$conf->multicurrency->enabled', // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
// 'perms'=>'1', // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
// Exports
$r=1;
// Example:
// $this->export_code[$r]=$this->rights_class.'_'.$r;
// $this->export_label[$r]='MyModule'; // Translation key (used only if key ExportDataset_xxx_z not found)
// $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.
// $this->export_icon[$r]='generic:MyModule';
// $this->export_permission[$r]=array(array("multicurrency","level1","level2"));
// $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef');
// $this->export_TypeFields_array[$r]=array('t.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text');
// $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product');
// $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// $this->export_sql_start[$r]='SELECT DISTINCT ';
// $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
// $this->export_sql_order[$r] .=' ORDER BY s.nom';
// $r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options='')
{
$sql = array();
//$this->_load_tables('/multicurrency/sql/');
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function remove($options = '')
{
$sql = array();
return $this->_remove($sql, $options);
}
}

View File

@ -241,7 +241,14 @@ class pdf_standardlabel extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -268,7 +275,7 @@ class pdf_standardlabel extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -282,7 +282,14 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -309,7 +316,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -536,14 +536,15 @@ class pdf_azur extends ModelePDFPropales
$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;
$localtax2_rate=$object->lines[$i]->localtax2_tx;
$localtax1_type=$object->lines[$i]->localtax1_type;
$localtax2_type=$object->lines[$i]->localtax2_type;
$localtax2_type=$object->lines[$i]->localtax2_type;
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
@ -589,11 +590,11 @@ class pdf_azur extends ModelePDFPropales
$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++;
@ -605,11 +606,11 @@ class pdf_azur extends ModelePDFPropales
{
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
@ -623,12 +624,12 @@ class pdf_azur extends ModelePDFPropales
// 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;
}
@ -973,8 +974,9 @@ class pdf_azur extends ModelePDFPropales
$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);
@ -1155,8 +1157,9 @@ class pdf_azur extends ModelePDFPropales
$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);
}
}
@ -1220,9 +1223,10 @@ class pdf_azur extends ModelePDFPropales
* @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;
@ -1230,6 +1234,7 @@ class pdf_azur extends ModelePDFPropales
$hidebottom=0;
if ($hidetop) $hidetop=-1;
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1)
@ -1238,7 +1243,7 @@ class pdf_azur extends ModelePDFPropales
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);

View File

@ -61,6 +61,9 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','inv
<?php } ?>
<td class="linecolvat" align="right"><span id="title_vat"><?php echo $langs->trans('VAT'); ?></span></td>
<td class="linecoluht" align="right"><span id="title_up_ht"><?php echo $langs->trans('PriceUHT'); ?></span></td>
<?php if (!empty($conf->multicurrency->enabled)) { $colspan++;?>
<td class="linecoluht_currency" align="right"><span id="title_up_ht_currency"><?php echo $langs->trans('PriceUHTCurrency'); ?></span></td>
<?php } ?>
<?php if (! empty($inputalsopricewithtax)) { ?>
<td class="linecoluttc" align="right"><span id="title_up_ttc"><?php echo $langs->trans('PriceUTTC'); ?></span></td>
<?php } ?>
@ -227,6 +230,13 @@ else {
<td class="nobottom linecoluht" align="right">
<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>">
</td>
<?php if (!empty($conf->multicurrency->enabled)) { $colspan++;?>
<td class="nobottom linecoluht_currency" align="right">
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat" value="<?php echo (isset($_POST["multicurrency_price_ht"])?$_POST["multicurrency_price_ht"]:''); ?>">
</td>
<?php } ?>
<?php if (! empty($inputalsopricewithtax)) { ?>
<td class="nobottom linecoluttc" align="right">
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?$_POST["price_ttc"]:''); ?>">
@ -354,6 +364,8 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
}
}
if (!empty($conf->multicurrency->enabled)) $colspan+=2;
if (! empty($usemargins))
{
$colspan++; // For the buying price

View File

@ -121,6 +121,10 @@ $coldisplay=-1; // We remove first td
if ($this->situation_counter > 1) print ' readonly';
print '></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td align="right"><input rel="'.$object->multicurrency_tx.'" type="text" class="flat" size="8" id="multicurrency_subprice" name="multicurrency_subprice" value="'.price($line->multicurrency_subprice).'" /></td>';
}
if ($inputalsopricewithtax)
{
$coldisplay++;

View File

@ -130,7 +130,11 @@ if (empty($usemargins)) $usemargins=0;
<td align="right" class="linecolvat nowrap"><?php $coldisplay++; ?><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>
<td align="right" class="linecoluht nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
<?php if (!empty($conf->multicurrency->enabled)) { ?>
<td align="right" class="linecoluht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_subprice); ?></td>
<?php } ?>
<?php if ($inputalsopricewithtax) { ?>
<td align="right" class="linecoluttc nowrap"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td>
<?php } ?>
@ -190,6 +194,9 @@ if (empty($usemargins)) $usemargins=0;
<td align="right" class="linecoloption nowrap"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
<?php } else { ?>
<td align="right" class="liencolht nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
<?php if (!empty($conf->multicurrency->enabled)) { ?>
<td align="right" class="linecolutotalht_currency nowrap"><?php $coldisplay++; ?><?php echo price($line->multicurrency_total_ht); ?></td>
<?php } ?>
<?php } ?>
<?php if ($this->statut == 0 && ($object_rights->creer)) { ?>

View File

@ -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>';

View File

@ -0,0 +1,34 @@
-- ========================================================================
-- Copyright (C) 2016 Frederic France <frederic.france@free.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (1, '5160', 'Avery-5160, WL-875WX', 'letter', 'P', 'mm', 5.58165000, 12.70000000, 3, 10, 3.55600000, 0.00000000, 65.87490000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (2, '5161', 'Avery-5161, WL-75WX', 'letter', 'P', 'mm', 4.44500000, 12.70000000, 2, 10, 3.96800000, 0.00000000, 101.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (3, '5162', 'Avery-5162, WL-100WX', 'letter', 'P', 'mm', 3.87350000, 22.35200000, 2, 7, 4.95400000, 0.00000000, 101.60000000, 33.78100000, 8, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (4, '5163', 'Avery-5163, WL-125WX', 'letter', 'P', 'mm', 4.57200000, 12.70000000, 2, 5, 3.55600000, 0.00000000, 101.60000000, 50.80000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (5, '5164', '5164 (Letter)', 'letter', 'P', 'in', 0.14800000, 0.50000000, 2, 3, 0.20310000, 0.00000000, 4.00000000, 3.33000000, 12, 0.00000000, 0.00000000, 0);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (6, '8600', 'Avery-8600', 'letter', 'P', 'mm', 7.10000000, 19.00000000, 3, 10, 9.50000000, 3.10000000, 66.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (7, '99012', 'DYMO 99012 89*36mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 36.00000000, 89.00000000, 10, 36.00000000, 89.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (8, '99014', 'DYMO 99014 101*54mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 54.00000000, 101.00000000, 10, 54.00000000, 101.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (9, 'AVERYC32010', 'Avery-C32010', 'A4', 'P', 'mm', 15.00000000, 13.00000000, 2, 5, 10.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (10, 'CARD', 'Dolibarr Business cards', 'A4', 'P', 'mm', 15.00000000, 15.00000000, 2, 5, 0.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (11, 'L7163', 'Avery-L7163', 'A4', 'P', 'mm', 5.00000000, 15.00000000, 2, 7, 2.50000000, 0.00000000, 99.10000000, 38.10000000, 8, 0.00000000, 0.00000000, 1);

View File

@ -76,7 +76,139 @@ ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pa
ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid);
CREATE TABLE llx_c_format_cards
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(50) NOT NULL,
name varchar(50) NOT NULL,
paper_size varchar(20) NOT NULL,
orientation varchar(1) NOT NULL,
metric varchar(5) NOT NULL,
leftmargin double(24,8) NOT NULL,
topmargin double(24,8) NOT NULL,
nx integer NOT NULL,
ny integer NOT NULL,
spacex double(24,8) NOT NULL,
spacey double(24,8) NOT NULL,
width double(24,8) NOT NULL,
height double(24,8) NOT NULL,
font_size integer NOT NULL,
custom_x double(24,8) NOT NULL,
custom_y double(24,8) NOT NULL,
active integer NOT NULL
) ENGINE=InnoDB;
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (1, '5160', 'Avery-5160, WL-875WX', 'letter', 'P', 'mm', 5.58165000, 12.70000000, 3, 10, 3.55600000, 0.00000000, 65.87490000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (2, '5161', 'Avery-5161, WL-75WX', 'letter', 'P', 'mm', 4.44500000, 12.70000000, 2, 10, 3.96800000, 0.00000000, 101.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (3, '5162', 'Avery-5162, WL-100WX', 'letter', 'P', 'mm', 3.87350000, 22.35200000, 2, 7, 4.95400000, 0.00000000, 101.60000000, 33.78100000, 8, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (4, '5163', 'Avery-5163, WL-125WX', 'letter', 'P', 'mm', 4.57200000, 12.70000000, 2, 5, 3.55600000, 0.00000000, 101.60000000, 50.80000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (5, '5164', '5164 (Letter)', 'letter', 'P', 'in', 0.14800000, 0.50000000, 2, 3, 0.20310000, 0.00000000, 4.00000000, 3.33000000, 12, 0.00000000, 0.00000000, 0);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (6, '8600', 'Avery-8600', 'letter', 'P', 'mm', 7.10000000, 19.00000000, 3, 10, 9.50000000, 3.10000000, 66.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (7, '99012', 'DYMO 99012 89*36mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 36.00000000, 89.00000000, 10, 36.00000000, 89.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (8, '99014', 'DYMO 99014 101*54mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 54.00000000, 101.00000000, 10, 54.00000000, 101.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (9, 'AVERYC32010', 'Avery-C32010', 'A4', 'P', 'mm', 15.00000000, 13.00000000, 2, 5, 10.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (10, 'CARD', 'Dolibarr Business cards', 'A4', 'P', 'mm', 15.00000000, 15.00000000, 2, 5, 0.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (11, 'L7163', 'Avery-L7163', 'A4', 'P', 'mm', 5.00000000, 15.00000000, 2, 7, 2.50000000, 0.00000000, 99.10000000, 38.10000000, 8, 0.00000000, 0.00000000, 1);
ALTER TABLE llx_extrafields ADD COLUMN ishidden integer DEFAULT 0;
CREATE TABLE IF NOT EXISTS llx_multicurrency
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_create datetime DEFAULT NULL,
code varchar(255) DEFAULT NULL,
name varchar(255) DEFAULT NULL,
entity integer DEFAULT NULL,
fk_user integer DEFAULT NULL,
KEY code (code)
) ENGINE=innodb;
CREATE TABLE IF NOT EXISTS llx_multicurrency_rate
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_sync datetime DEFAULT NULL,
rate double NOT NULL DEFAULT '0',
fk_multicurrency integer NOT NULL DEFAULT '0',
entity integer NOT NULL DEFAULT '0',
KEY fk_multicurrency (fk_multicurrency),
KEY entity (entity)
) ENGINE=innodb;
ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_societe ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_product_price ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_product_price ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_product_price ADD COLUMN multicurrency_price double(24,8) DEFAULT 0;
ALTER TABLE llx_commande ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_commande ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_commande ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
ALTER TABLE llx_commande ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_commande ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_commande ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_commandedet ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_commandedet ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_commandedet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_facture ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_facture ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_facture ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
ALTER TABLE llx_facture ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_facture ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_facture ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_facturedet ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_facturedet ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_facturedet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_propal ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_propal ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_propal ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
ALTER TABLE llx_propal ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_propal ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_propal ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
ALTER TABLE llx_propaldet ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_code varchar(255);
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;

View File

@ -0,0 +1,39 @@
-- ========================================================================
-- Copyright (C) 2016 Frederic France <frederic.france@free.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
CREATE TABLE llx_c_format_cards
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(50) NOT NULL,
name varchar(50) NOT NULL,
paper_size varchar(20) NOT NULL,
orientation varchar(1) NOT NULL,
metric varchar(5) NOT NULL,
leftmargin double(24,8) NOT NULL,
topmargin double(24,8) NOT NULL,
nx integer NOT NULL,
ny integer NOT NULL,
spacex double(24,8) NOT NULL,
spacey double(24,8) NOT NULL,
width double(24,8) NOT NULL,
height double(24,8) NOT NULL,
font_size integer NOT NULL,
custom_x double(24,8) NOT NULL,
custom_y double(24,8) NOT NULL,
active integer NOT NULL
) ENGINE=InnoDB;

View File

@ -70,6 +70,12 @@ create table llx_commande
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255) -- for stock other parameters with json format
extraparams varchar(255), -- for stock other parameters with json format
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -66,6 +66,12 @@ create table llx_commande_fournisseur
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255) -- for stock other parameters with json format
extraparams varchar(255), -- for stock other parameters with json format
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -49,5 +49,12 @@ create table llx_commande_fournisseurdet
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
import_key varchar(14),
fk_unit integer DEFAULT NULL
fk_unit integer DEFAULT NULL,
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_subprice double(24,8) DEFAULT 0,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -55,7 +55,14 @@ create table llx_commandedet
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
fk_unit integer DEFAULT NULL, -- lien vers table des unités
import_key varchar(14)
import_key varchar(14),
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_subprice double(24,8) DEFAULT 0,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;
--

View File

@ -84,5 +84,12 @@ create table llx_facture
situation_final smallint, -- is the situation final ?
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
extraparams varchar(255), -- for other parameters with json format
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -70,6 +70,12 @@ create table llx_facture_fourn
location_incoterms varchar(255), -- for incoterms
model_pdf varchar(255),
import_key varchar(14),
extraparams varchar(255) -- for stock other parameters with json format
extraparams varchar(255), -- for stock other parameters with json format
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -49,5 +49,12 @@ create table llx_facture_fourn_det
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0,
import_key varchar(14),
fk_unit integer DEFAULT NULL
fk_unit integer DEFAULT NULL,
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_subprice double(24,8) DEFAULT 0,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -61,8 +61,14 @@ create table llx_facturedet
situation_percent real, -- % progression of lines invoicing
fk_prev_id integer, -- id of the line in the previous situation,
fk_unit integer DEFAULT NULL -- id of the unit code¡
fk_unit integer DEFAULT NULL, -- id of the unit code¡
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_subprice double(24,8) DEFAULT 0,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;
--

View File

@ -0,0 +1,28 @@
-- ========================================================================
-- Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
CREATE TABLE llx_multicurrency
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_create datetime DEFAULT NULL,
code varchar(255) DEFAULT NULL,
name varchar(255) DEFAULT NULL,
entity integer DEFAULT NULL,
fk_user integer DEFAULT NULL,
KEY code (code)
) ENGINE=innodb;

View File

@ -0,0 +1,28 @@
-- ========================================================================
-- Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
CREATE TABLE llx_multicurrency_rate
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
date_sync datetime DEFAULT NULL,
rate double NOT NULL DEFAULT '0',
fk_multicurrency integer NOT NULL DEFAULT '0',
entity integer NOT NULL DEFAULT '0',
KEY fk_multicurrency (fk_multicurrency),
KEY entity (entity)
) ENGINE=innodb;

View File

@ -21,5 +21,9 @@ create table llx_paiement_facture
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_paiement integer,
fk_facture integer,
amount double(24,8) DEFAULT 0
amount double(24,8) DEFAULT 0,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_amount double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -23,5 +23,9 @@ create table llx_paiementfourn_facturefourn
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_paiementfourn INTEGER DEFAULT NULL,
fk_facturefourn INTEGER DEFAULT NULL,
amount double(24,8) DEFAULT 0
amount double(24,8) DEFAULT 0,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_amount double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -39,6 +39,10 @@ create table llx_product_price
tosell tinyint DEFAULT 1,
price_by_qty integer NOT NULL DEFAULT 0,
fk_price_expression integer, -- Link to the rule for dynamic price calculation
import_key varchar(14)
import_key varchar(14),
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_price double(24,8) DEFAULT NULL
)ENGINE=innodb;

View File

@ -69,6 +69,12 @@ create table llx_propal
location_incoterms varchar(255), -- for incoterms
import_key varchar(14),
extraparams varchar(255), -- for stock other parameters with json format
fk_delivery_address integer -- delivery address (deprecated)
fk_delivery_address integer, -- delivery address (deprecated)
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;

View File

@ -53,8 +53,14 @@ create table llx_propaldet
special_code integer DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0, -- ordre affichage sur la propal
fk_unit integer DEFAULT NULL -- lien vers table des unités
fk_unit integer DEFAULT NULL, -- lien vers table des unités
fk_multicurrency integer,
multicurrency_code varchar(255),
multicurrency_subprice double(24,8) DEFAULT 0,
multicurrency_total_ht double(24,8) DEFAULT 0,
multicurrency_total_tva double(24,8) DEFAULT 0,
multicurrency_total_ttc double(24,8) DEFAULT 0
)ENGINE=innodb;
--

View File

@ -99,5 +99,8 @@ create table llx_societe
canvas varchar(32), -- type of canvas if used (null by default)
import_key varchar(14), -- import key
webservices_url varchar(255), -- supplier webservice url
webservices_key varchar(128) -- supplier webservice key
webservices_key varchar(128), -- supplier webservice key
fk_multicurrency integer,
multicurrency_code varchar(255)
)ENGINE=innodb;

View File

@ -310,7 +310,8 @@ UnitPrice=Unit price
UnitPriceHT=Unit price (net)
UnitPriceTTC=Unit price
PriceU=U.P.
PriceUHT=U.P. (net)
PriceUHT=U.P. (net in currency)
PriceUHTCurrency=U.P (currency)
SupplierProposalUHT=U.P. net Requested
PriceUTTC=U.P. (inc. tax)
Amount=Amount
@ -335,6 +336,7 @@ Percentage=Percentage
Total=Total
SubTotal=Subtotal
TotalHTShort=Total (net)
TotalHTShortCurrency=Total (net in currency)
TotalTTCShort=Total (inc. tax)
TotalHT=Total (net of tax)
TotalHTforthispage=Total (net of tax) for this page

View File

@ -0,0 +1,726 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file dev/skeletons/skeleton_class.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put some comments here
*/
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php";
/**
* Class Currency
*
* Put here description of your class
* @see CommonObject
*/
class MultiCurrency extends CommonObject
{
/**
* @var string Id to identify managed objects
*/
public $element = 'multicurrency';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'multicurrency';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element_line="multicurrency_rate";
/**
* @var CurrencyRate[] rates
*/
public $rates = array();
/**
* @var mixed Sample property 1
*/
public $id;
/**
* @var mixed Sample property 1
*/
public $code;
/**
* @var mixed Sample property 2
*/
public $name;
/**
* @var mixed Sample property 2
*/
public $entity;
/**
* @var mixed Sample property 2
*/
public $date_create;
/**
* @var mixed Sample property 2
*/
public $fk_user;
/**
* @var mixed Sample property 2
*/
public $rate;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = &$db;
return 1;
}
/**
* Create object into database
*
* @param User $user User that creates
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, Id of created object if OK
*/
public function create(User $user, $trigger = true)
{
global $conf;
dol_syslog('Currency::create', LOG_DEBUG);
$error = 0;
if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity;
$now=date('Y-m-d H:i:s');
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql .= ' code,';
$sql .= ' name,';
$sql .= ' entity,';
$sql .= ' date_create,';
$sql .= ' fk_user';
$sql .= ') VALUES (';
$sql .= ' \'' . $this->db->escape($this->code) . '\',';
$sql .= ' \'' . $this->db->escape($this->name) . '\',';
$sql .= ' \'' . $this->entity . '\',';
$sql .= ' \'' . $now . '\',';
$sql .= ' \'' . $user->id . '\'';
$sql .= ')';
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::create ' . join(',', $this->errors), LOG_ERR);
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->date_create = $now;
$this->fk_user = $user->id;
if ($trigger) {
$result=$this->call_trigger('CURRENCY_CREATE', $user);
if ($result < 0) $error++;
}
}
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $code code
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id, $code = null)
{
dol_syslog('Currency::fetch', LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user';
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' AS c';
if (!empty($code)) $sql .= ' WHERE c.code = "'.$this->db->escape($code).'"';
else $sql .= ' WHERE c.rowid = ' . $id;
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
if ($numrows) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->name = $obj->name;
$this->code = $obj->code;
$this->entity = $obj->entity;
$this->date_create = $obj->date_create;
$this->fk_user = $obj->fk_user;
$this->fetchAllCurrencyRate();
$this->getRate();
}
$this->db->free($resql);
if ($numrows) {
return 1;
} else {
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Load all rates in object from the database
*
* @return int <0 if KO, >=0 if OK
*/
public function fetchAllCurrencyRate()
{
dol_syslog('Currency::fetchAllCurrencyRate', LOG_DEBUG);
$sql = 'SELECT cr.rowid';
$sql.= ' FROM ' . MAIN_DB_PREFIX . $this->table_element_line. ' as cr';
$sql.= ' WHERE cr.fk_multicurrency = '.$this->id;
$sql.= ' ORDER BY cr.date_sync DESC';
$this->rates = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$rate = new CurrencyRate($this->db);
$rate->fetch($obj->rowid);
$this->rates[] = $rate;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
* @param User $user User that modifies
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function update(User $user, $trigger = true)
{
$error = 0;
dol_syslog('Currency::update', LOG_DEBUG);
// Clean parameters
$this->name = trim($this->name);
$this->code = trim($this->code);
// Check parameters
if (empty($this->code)) {
$error++;
dol_syslog('Currency::update $this->code can not be empty', LOG_ERR);
return -1;
}
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' name="'.$this->db->escape($this->name).'"';
$sql .= ' code="'.$this->db->escape($this->code).'"';
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::update ' . join(',', $this->errors), LOG_ERR);
}
if (!$error && $trigger) {
$result=$this->call_trigger('CURRENCY_MODIFY',$user);
if ($result < 0) $error++;
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function delete($trigger = true)
{
global $user;
dol_syslog('Currency::delete', LOG_DEBUG);
$error = 0;
$this->db->begin();
if ($trigger) {
$result=$this->call_trigger('CURRENCY_DELETE',$user);
if ($result < 0) $error++;
}
if (!$error) {
// Delete all rates before
if (!$this->deleteRates()) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR);
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete rates in database
*
* @return bool false if KO, true if OK
*/
public function deleteRates()
{
foreach ($this->rates as &$rate)
{
if ($rate->delete() <= 0)
{
return false;
}
}
return true;
}
/**
* Delete rate in database
*
* @param double $rate rate value
*
* @return bool false if KO, true if OK
*/
public function addRate($rate)
{
$currencyRate = new CurrencyRate($this->db);
$currencyRate->rate = $rate;
if ($currencyRate->create($this->id) > 0)
{
$this->rate = $currencyRate;
return 1;
}
else
{
$this->rate = null;
return -1;
}
}
/**
* Update rate in database
*
* @param double $rate rate value
*
* @return int <0 if KO, >0 if OK
*/
public function updateRate($rate)
{
if (is_object($this->rate))
{
$this->rate->rate = $rate;
return $this->rate->update();
}
else
{
return $this->addRate($rate);
}
}
/**
* Fetch CurrencyRate object in $this->rate
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function getRate()
{
$sql = 'SELECT cr.rowid';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr';
$sql.= ' WHERE cr.fk_multicurrency = '.$this->id;
$sql.= ' AND cr.date_sync >= ALL (SELECT cr2.date_sync FROM '.MAIN_DB_PREFIX.$this->table_element_line.' AS cr2 WHERE cr.rowid = cr2.rowid)';
$resql = $this->db->query($sql);
if ($resql && ($obj = $this->db->fetch_object($resql))) {
$this->rate = new CurrencyRate($this->db);
return $this->rate->fetch($obj->rowid);
}
}
/**
* Get id of currency from code
*
* @param DoliDB $db object db
* @param string $code code value search
*
* @return 0 if not found, >0 if OK
*/
public static function getIdFromCode(&$db, $code)
{
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE code = "'.$db->escape($code).'"';
$resql = $db->query($sql);
if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid;
else return 0;
}
/**
* Get id and rate of currency from code
*
* @param DoliDB $db object db
* @param string $code code value search
*
* @return array [0] => id currency
* [1] => rate
*/
public static function getIdAndTxFromCode(&$db, $code)
{
$sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
$sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)';
$resql = $db->query($sql);
if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
else return array(0, 1);
}
}
/**
* Class CurrencyRate
*/
class CurrencyRate extends CommonObjectLine
{
/**
* @var string Id to identify managed objects
*/
public $element = 'multicurrency_rate';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'multicurrency_rate';
/**
* @var int ID
*/
public $id;
/**
* @var double Rate
*/
public $rate;
/**
* @var date Date synchronisation
*/
public $date_sync;
/**
* @var int Id of currency
*/
public $fk_multicurrency;
/**
* @var int Id of entity
*/
public $entity;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
$this->db = &$db;
return 1;
}
/**
* Create object into database
*
* @param int $fk_multicurrency Id of currency
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, Id of created object if OK
*/
public function create($fk_multicurrency, $trigger = true)
{
global $conf, $user;
dol_syslog('CurrencyRate::create', LOG_DEBUG);
$error = 0;
$this->rate = price2num($this->rate);
if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity;
$now=date('Y-m-d H:i:s');
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql .= ' rate,';
$sql .= ' date_sync,';
$sql .= ' fk_multicurrency,';
$sql .= ' entity';
$sql .= ') VALUES (';
$sql .= ' '.$this->rate.',';
$sql .= ' \'' . $now . '\',';
$sql .= ' \'' . $fk_multicurrency . '\',';
$sql .= ' \'' . $this->entity . '\'';
$sql .= ')';
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('CurrencyRate::create ' . join(',', $this->errors), LOG_ERR);
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->fk_multicurrency = $fk_multicurrency;
$this->date_sync = $now;
if ($trigger) {
$result=$this->call_trigger('CURRENCYRATE_CREATE', $user);
if ($result < 0) $error++;
}
}
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function fetch($id)
{
dol_syslog('CurrencyRate::fetch', LOG_DEBUG);
$sql = 'SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS cr';
$sql .= ' WHERE cr.rowid = ' . $id;
$resql = $this->db->query($sql);
if ($resql) {
$numrows = $this->db->num_rows($resql);
if ($numrows) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->rate = $obj->rate;
$this->date_sync = $obj->date_sync;
$this->fk_multicurrency = $obj->fk_multicurrency;
$this->entity = $obj->entity;
}
$this->db->free($resql);
if ($numrows) {
return 1;
} else {
return 0;
}
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('CurrencyRate::fetch ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function update($trigger = true)
{
global $user;
$error = 0;
dol_syslog('CurrencyRate::update', LOG_DEBUG);
$this->rate = price2num($this->rate);
// Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
$sql .= ' rate='.$this->rate;
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('CurrencyRate::update ' . join(',', $this->errors), LOG_ERR);
}
if (!$error && $trigger) {
$result=$this->call_trigger('CURRENCYRATE_MODIFY',$user);
if ($result < 0) $error++;
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK
*/
public function delete($trigger = true)
{
global $user;
dol_syslog('CurrencyRate::delete', LOG_DEBUG);
$error = 0;
$this->db->begin();
if ($trigger) {
$result=$this->call_trigger('CURRENCYRATE_DELETE',$user);
if ($result < 0) $error++;
}
if (!$error) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' WHERE rowid='.$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('CurrencyRate::delete ' . join(',', $this->errors), LOG_ERR);
}
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
}

View File

@ -714,12 +714,12 @@ if ($resql)
print '<td align="right">'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').'</td>';
// Sell price
print '<td align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1);
else print $langs->trans("Variable");
print '</td>';
// Value sell
print '<td align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>';
else print $langs->trans("Variable");
print '</tr>'; ;
$total += $obj->reel;
@ -782,12 +782,12 @@ print '<td class="liste_total" align="right">';
print $totalvalue?price(price2num($totalvalue,'MT'),1):'&nbsp;';
print '</td>';
print '<td class="liste_total" align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print ($total?price($totalvaluesell/$total,1):'&nbsp;');
if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total?price($totalvaluesell/$total,1):'&nbsp;');
else print $langs->trans("Variable");
print '</td>';
// Value to sell
print '<td class="liste_total" align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($totalvaluesell,'MT'),1);
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell,'MT'),1);
else print $langs->trans("Variable");
print '</td>';
print "</tr>";

View File

@ -33,7 +33,7 @@
* \brief File for third party class
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
dol_include_once('/multicurrency/class/multicurrency.class.php');
/**
* Class to manage third parties objects (customers, suppliers, prospects...)
@ -354,6 +354,10 @@ class Societe extends CommonObject
var $location_incoterms;
var $libelle_incoterms; //Used into tooltip
// Multicurrency
var $fk_multicurrency;
var $multicurrency_code;
/**
* To contains a clone of this when we need to save old properties of object
* @var Societe
@ -402,7 +406,14 @@ class Societe extends CommonObject
if (empty($this->client)) $this->client=0;
if (empty($this->fournisseur)) $this->fournisseur=0;
$this->import_key = trim($this->import_key);
if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency))
{
$this->multicurrency_code = '';
$this->fk_multicurrency = 0;
}
dol_syslog(get_class($this)."::create ".$this->name);
// Check parameters
@ -427,7 +438,7 @@ class Societe extends CommonObject
if ($result >= 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)";
$sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$conf->entity.", '".$this->db->idate($now)."'";
$sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null");
$sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null");
@ -437,7 +448,9 @@ class Societe extends CommonObject
$sql.= ", 0";
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null").")";
$sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null");
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."')";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result=$this->db->query($sql);
@ -670,6 +683,13 @@ class Societe extends CommonObject
$this->tva_intra = dol_sanitizeFileName($this->tva_intra,'');
if (empty($this->status)) $this->status = 0;
if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency))
{
$this->multicurrency_code = '';
$this->fk_multicurrency = 0;
}
// Local taxes
$this->localtax1_assuj=trim($this->localtax1_assuj);
$this->localtax2_assuj=trim($this->localtax2_assuj);
@ -841,6 +861,8 @@ class Societe extends CommonObject
$sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
}
$sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null");
$sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency;
$sql .= ', multicurrency_code = "'.$this->db->escape($this->multicurrency_code).'"';
$sql .= " WHERE rowid = '" . $id ."'";
@ -992,6 +1014,7 @@ class Societe extends CommonObject
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
$sql .= ', s.fk_multicurrency, s.multicurrency_code';
$sql .= ', fj.libelle as forme_juridique';
$sql .= ', e.libelle as effectif';
$sql .= ', c.code as country_code, c.label as country';
@ -1142,6 +1165,10 @@ class Societe extends CommonObject
$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;
$result = 1;
// Retreive all extrafield for thirdparty

View File

@ -338,6 +338,13 @@ if (empty($reshook))
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
}
// Multicurrency
if (!empty($conf->multicurrency->enabled))
{
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0)
@ -1249,6 +1256,16 @@ else
}
}
// Multicurrency
if (! empty($conf->multicurrency->enabled))
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
print '</td></tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -1801,6 +1818,16 @@ else
}
}
// Multicurrency
if (! empty($conf->multicurrency->enabled))
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
print '</td></tr>';
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -2212,6 +2239,16 @@ else
print '</td></tr>';
}
// Multicurrency
if (! empty($conf->multicurrency->enabled))
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td>';
print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : '';
print '</td></tr>';
}
// Other attributes
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

View File

@ -217,7 +217,7 @@ class FactureTest extends PHPUnit_Framework_TestCase
$newlocalobject=new Facture($this->savdb);
$newlocalobject->initAsSpecimen();
$this->changeProperties($newlocalobject);
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final')), array()); // Actual, Expected
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx')), array()); // Actual, Expected
return $localobject;
}

View File

@ -151,9 +151,17 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1 FR');
$this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36),$result1,'Test1 FR');
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value)
$mysoc->country_code='FR';
$mysoc->country_id=1;
$result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205);
print __METHOD__." result1=".join(', ',$result1)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56),$result1,'Test1 FR');
/*
* Country Spain
*/
@ -166,7 +174,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test1 ES');
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test1 ES');
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect)
$mysoc->country_code='ES';
@ -176,7 +184,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test2 ES');
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test2 ES');
// --------------------------------------------------------
@ -188,7 +196,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test3 ES');
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4),$result2,'Test3 ES');
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
$mysoc->country_code='ES';
@ -198,7 +206,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test4 ES');
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4),$result2,'Test4 ES');
// --------------------------------------------------------
@ -209,7 +217,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1);
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test5 ES for service');
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91),$result2,'Test5 ES for service');
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product
$mysoc->country_code='ES';
@ -219,7 +227,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test6 ES for product');
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test6 ES for product');
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service
$mysoc->country_code='ES';
@ -229,7 +237,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test6 ES for service');
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91),$result2,'Test6 ES for service');
// --------------------------------------------------------
@ -241,7 +249,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0);
print __METHOD__." result2=".join(', ',$result2)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test7 ES for product');
$this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110),$result2,'Test7 ES for product');
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product
$mysoc->country_code='ES';
@ -250,7 +258,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$mysoc->localtax2_assuj=1;
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1);
print __METHOD__." result2=".join(', ',$result2)."\n";
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test8 ES for service');
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91),$result2,'Test8 ES for service');
/*
@ -267,7 +275,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test9 CI');
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85),$result3,'Test9 CI');
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect)
$mysoc->country_code='CI';
@ -277,7 +285,7 @@ class PricesTest extends PHPUnit_Framework_TestCase
$result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
print __METHOD__." result3=".join(', ',$result3)."\n";
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test10 CI');
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85),$result3,'Test10 CI');
return true;
}