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

This commit is contained in:
Laurent Destailleur 2016-12-11 02:32:13 +01:00
commit 859a9cadcb
11 changed files with 102 additions and 53 deletions

View File

@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
// Translations // Translations
$langs->load("admin");
$langs->load("multicurrency"); $langs->load("multicurrency");
// Access control // Access control
@ -323,8 +324,17 @@ print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td></form></tr>'; print '</td></form></tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$conf->currency.$form->textwithpicto(' ', $langs->trans("BaseCurrency")).'</td>';
print '<td align="center" width="20">&nbsp;</td>';
print '<td align="right" width="300">1';
print '</td></form></tr>';
foreach ($TCurrency as &$currency) foreach ($TCurrency as &$currency)
{ {
if($currency->code == $conf->currency) continue;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$currency->code.' - '.$currency->name.'</td>'; print '<td>'.$currency->code.' - '.$currency->name.'</td>';
@ -334,10 +344,12 @@ foreach ($TCurrency as &$currency)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_currency">'; print '<input type="hidden" name="action" value="update_currency">';
print '<input type="hidden" name="fk_multicurrency" value="'.$currency->id.'">'; 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 '1 '.$conf->currency.' = ';
print '<input type="text" name="rate" value="'.($currency->rate->rate ? $currency->rate->rate : '').'" size="13" />&nbsp;'.$currency->code.'&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("Modify").'">&nbsp;';
print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Delete").'">'; print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Delete").'">';
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -281,7 +281,7 @@ if (empty($reshook))
// Multicurrency rate // Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) { else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} }
else if ($action == 'setinvoicedate' && $user->rights->facture->creer) else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
@ -1314,6 +1314,7 @@ if (empty($reshook))
$predef=''; $predef='';
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
$price_ht = GETPOST('price_ht'); $price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
if (GETPOST('prod_entry_mode') == 'free') if (GETPOST('prod_entry_mode') == 'free')
{ {
$idprod=0; $idprod=0;
@ -1348,7 +1349,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error ++; $error ++;
} }
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && empty($price_ht_devise)) // Unit price can be 0 but not ''
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error ++; $error ++;
@ -1505,6 +1506,7 @@ if (empty($reshook))
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$fk_unit= GETPOST('units', 'alpha'); $fk_unit= GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
} }
// Margin // Margin
@ -1524,7 +1526,7 @@ if (empty($reshook))
setEventMessages($mesg, null, 'errors'); setEventMessages($mesg, null, 'errors');
} else { } else {
// Insert line // Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit); $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise);
if ($result > 0) if ($result > 0)
{ {
@ -1604,6 +1606,7 @@ if (empty($reshook))
$pu_ht = GETPOST('price_ht'); $pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty'); $qty = GETPOST('qty');
$pu_ht_devise = GETPOST('multicurrency_subprice');
// Define info_bits // Define info_bits
$info_bits = 0; $info_bits = 0;
@ -1688,7 +1691,7 @@ if (empty($reshook))
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'),
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'), GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'),
$_POST['units']); $_POST['units'],$pu_ht_devise);
if ($result >= 0) { if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@ -3234,10 +3237,16 @@ else if ($id > 0 || ! empty($ref))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; 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 '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencyrate') { if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
}
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else { } else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
print '</div>';
} }
print '</td></tr>'; print '</td></tr>';
//} //}

View File

@ -2411,9 +2411,10 @@ class Facture extends CommonInvoice
* @param int $situation_percent Situation advance percentage * @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference * @param int $fk_prev_id Previous situation line id reference
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @return int <0 if KO, Id of line if OK * @return int <0 if KO, Id of line if OK
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null) function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null, $pu_ht_devise = 0)
{ {
// Deprecation warning // Deprecation warning
if ($label) { if ($label) {
@ -2493,7 +2494,7 @@ class Facture extends CommonInvoice
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$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); $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, $pu_ht_devise);
$total_ht = $tabprice[0]; $total_ht = $tabprice[0];
$total_tva = $tabprice[1]; $total_tva = $tabprice[1];
@ -2506,6 +2507,7 @@ class Facture extends CommonInvoice
$multicurrency_total_ht = $tabprice[16]; $multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17]; $multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18]; $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
// Rank to use // Rank to use
$rangtouse = $rang; $rangtouse = $rang;
@ -2565,7 +2567,7 @@ class Facture extends CommonInvoice
// Multicurrency // Multicurrency
$this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->fk_multicurrency = $this->fk_multicurrency;
$this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx); $this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_ht = $multicurrency_total_ht;
$this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
@ -2628,9 +2630,10 @@ class Facture extends CommonInvoice
* @param array $array_options extrafields array * @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage * @param int $situation_percent Situation advance percentage
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @return int < 0 if KO, > 0 if OK * @return int < 0 if KO, > 0 if OK
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null) function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $pu_ht_devise = 0)
{ {
global $conf,$user; global $conf,$user;
// Deprecation warning // Deprecation warning
@ -2688,7 +2691,7 @@ class Facture extends CommonInvoice
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. $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, $this->multicurrency_tx); $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, $pu_ht_devise);
$total_ht = $tabprice[0]; $total_ht = $tabprice[0];
$total_tva = $tabprice[1]; $total_tva = $tabprice[1];
@ -2703,6 +2706,7 @@ class Facture extends CommonInvoice
$multicurrency_total_ht = $tabprice[16]; $multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17]; $multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18]; $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
// Old properties: $price, $remise (deprecated) // Old properties: $price, $remise (deprecated)
$price = $pu; $price = $pu;
@ -2778,7 +2782,7 @@ class Facture extends CommonInvoice
$this->line->pa_ht = $pa_ht; $this->line->pa_ht = $pa_ht;
// Multicurrency // Multicurrency
$this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx); $this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_ht = $multicurrency_total_ht;
$this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;

View File

@ -1990,8 +1990,8 @@ else
if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) if (! empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices)
{ {
$langs->load("bills"); $langs->load("orders");
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>'; if ($user->rights->commande->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>';
} }

View File

@ -1491,9 +1491,10 @@ abstract class CommonObject
* Change the multicurrency rate * Change the multicurrency rate
* *
* @param double $rate multicurrency rate * @param double $rate multicurrency rate
* @param int $mode mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function setMulticurrencyRate($rate) function setMulticurrencyRate($rate, $mode=1)
{ {
dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')'); dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe') if ($this->statut >= 0 || $this->element == 'societe')
@ -1513,6 +1514,10 @@ abstract class CommonObject
{ {
foreach ($this->lines as &$line) foreach ($this->lines as &$line)
{ {
if($mode == 1) {
$line->subprice = 0;
}
switch ($this->element) { switch ($this->element) {
case 'propal': 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); $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);
@ -1521,7 +1526,7 @@ abstract class CommonObject
$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); $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; break;
case 'facture': 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); $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, $line->multicurrency_subprice);
break; break;
case 'supplier_proposal': case 'supplier_proposal':
$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->array_options, $line->ref_fourn); $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->array_options, $line->ref_fourn);
@ -3307,7 +3312,7 @@ abstract class CommonObject
print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
// Multicurrency // Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency').'</td>'; if (!empty($conf->multicurrency->enabled)) print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).'</td>';
if ($inputalsopricewithtax) print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>'; if ($inputalsopricewithtax) print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>';
@ -3343,7 +3348,7 @@ abstract class CommonObject
print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>'; print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>';
// Multicurrency // Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoltotalht_currency" align="right">'.$langs->trans('TotalHTShortCurrency').'</td>'; if (!empty($conf->multicurrency->enabled)) print '<td class="linecoltotalht_currency" align="right">'.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).'</td>';
if ($outputalsopricetotalwithtax) print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>'; if ($outputalsopricetotalwithtax) print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>';

View File

@ -3956,7 +3956,11 @@ class Form
print '<form method="POST" action="'.$page.'">'; print '<form method="POST" action="'.$page.'">';
print '<input type="hidden" name="action" value="setmulticurrencyrate">'; print '<input type="hidden" name="action" value="setmulticurrencyrate">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? price($rate) : 1).'" size="10" />'; print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? price($rate) : 1).'" size="10" /> ';
print '<select name="calculation_mode">';
print '<option value="1">'.$currency.' > '.$conf->currency.'</option>';
print '<option value="2">'.$conf->currency.' > '.$currency.'</option>';
print '</select> ';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
} }
@ -4231,6 +4235,10 @@ class Form
} }
$out.= '</select>'; $out.= '</select>';
// Make select dynamic
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out.= ajax_combobox($htmlname);
return $out; return $out;
} }

View File

@ -50,6 +50,7 @@
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default)
* @param double $multicurrency_tx Currency rate (1 by default) * @param double $multicurrency_tx Currency rate (1 by default)
* @param double $pu_ht_devise Amount in currency
* @return array [ * @return array [
* 0=total_ht, * 0=total_ht,
* 1=total_vat, (main vat only) * 1=total_vat, (main vat only)
@ -70,8 +71,9 @@
* 16=multicurrency_total_ht * 16=multicurrency_total_ht
* 17=multicurrency_total_tva * 17=multicurrency_total_tva
* 18=multicurrency_total_ttc * 18=multicurrency_total_ttc
* 19=multicurrency_pu_ht
*/ */
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) 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, $pu_ht_devise=0)
{ {
global $conf,$mysoc,$db; global $conf,$mysoc,$db;
@ -140,6 +142,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
} }
else dol_print_error($db); else dol_print_error($db);
} }
// pu calculation from pu_devise if pu empty
if(empty($pu) && !empty($pu_ht_devise)) {
$pu = $pu_ht_devise / $multicurrency_tx;
} else {
$pu_ht_devise = $pu * $multicurrency_tx;
}
// initialize total (may be HT or TTC depending on price_base_type) // initialize total (may be HT or TTC depending on price_base_type)
$tot_sans_remise = $pu * $qty * $progress / 100; $tot_sans_remise = $pu * $qty * $progress / 100;
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100));
@ -332,6 +342,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
$result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); $result[16] = price2num($result[0] * $multicurrency_tx, 'MT');
$result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); $result[17] = price2num($result[1] * $multicurrency_tx, 'MT');
$result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); $result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
$result[19] = price2num($pu_ht_devise, 'MU');
// initialize result array // initialize result array
//for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i];

View File

@ -35,7 +35,7 @@ function stock_prepare_head($object)
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("WarehouseCard"); $head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;

View File

@ -122,6 +122,7 @@ $coldisplay=-1; // We remove first td
print '></td>'; print '></td>';
if (!empty($conf->multicurrency->enabled)) { if (!empty($conf->multicurrency->enabled)) {
$colspan++;
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>'; 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>';
} }

View File

@ -243,13 +243,13 @@ if (! $error) {
dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG); dol_syslog("databasefortest=" . $databasefortest . " connected=" . $db->connected . " database_selected=" . $db->database_selected, LOG_DEBUG);
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected; //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
if (empty($db_create_database) && $db->connected && !$db->database_selected) { if (empty($db_create_database) && $db->connected && !$db->database_selected) {
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>'; print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>';
print '<br>'; print '<br>';
if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>'; if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++; $error++;
} elseif ($db->error && (empty($db_create_database) && $db->connected)) { } elseif ($db->error && ! (! empty($db_create_database) && $db->connected)) {
// Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched. // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>'; if ($db->error == "No such file or directory") print '<div class="error">'.$langs->trans("ErrorToConnectToMysqlCheckInstance").'</div>';
else print '<div class="error">'.$db->error.'</div>'; else print '<div class="error">'.$db->error.'</div>';
@ -991,4 +991,3 @@ function write_conf_file($conffile)
return $error; return $error;
} }

View File

@ -193,7 +193,7 @@ if ($action == 'create')
// Ref // Ref
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input name="libelle" size="20" value=""></td></tr>'; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input name="libelle" size="20" value=""></td></tr>';
print '<tr><td >'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.(!empty($object->lieu)?$object->lieu:'').'"></td></tr>'; print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" size="40" value="'.(!empty($object->lieu)?$object->lieu:'').'"></td></tr>';
// Parent entrepot // Parent entrepot
print '<tr><td>'.$langs->trans("AddIn").'</td><td>'; print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
@ -289,30 +289,29 @@ else
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
} }
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
// Warehouse card // Warehouse card
$linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
$morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu;
$morehtmlref.='</div>'; $morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'libelle', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Parent entrepot // Parent entrepot
$e = new Entrepot($db); $e = new Entrepot($db);
if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) { if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>'; print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
print $e->getNomUrl(3); print $e->getNomUrl(3);
print '</td></tr>'; print '</td></tr>';
@ -324,32 +323,32 @@ else
$calcproductsunique=$object->nb_different_products(); $calcproductsunique=$object->nb_different_products();
$calcproducts=$object->nb_products(); $calcproducts=$object->nb_products();
// Total nb of different products // Total nb of different products
print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>'; print '<tr><td>'.$langs->trans("NumberOfDifferentProducts").'</td><td>';
print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb'];
print "</td></tr>"; print "</td></tr>";
// Nb of products // Nb of products
print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>'; print '<tr><td>'.$langs->trans("NumberOfProducts").'</td><td>';
$valtoshow=price2num($calcproducts['nb'], 'MS'); $valtoshow=price2num($calcproducts['nb'], 'MS');
print empty($valtoshow)?'0':$valtoshow; print empty($valtoshow)?'0':$valtoshow;
print "</td></tr>"; print "</td></tr>";
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Value // Value
print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("EstimatedStockValueShort").'</td><td>';
print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency);
print "</td></tr>"; print "</td></tr>";
// Last movement // Last movement
$sql = "SELECT max(m.datem) as datem"; $sql = "SELECT max(m.datem) as datem";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
@ -375,15 +374,15 @@ else
print $langs->trans("None"); print $langs->trans("None");
} }
print "</td></tr>"; print "</td></tr>";
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
dol_fiche_end(); dol_fiche_end();
@ -486,7 +485,7 @@ else
$productstatic->entity=$objp->entity; $productstatic->entity=$objp->entity;
print $productstatic->getNomUrl(1,'stock',16); print $productstatic->getNomUrl(1,'stock',16);
print '</td>'; print '</td>';
// Label // Label
print '<td>'.$objp->produit.'</td>'; print '<td>'.$objp->produit.'</td>';
@ -498,7 +497,7 @@ else
// Price buy PMP // Price buy PMP
print '<td align="right">'.price(price2num($objp->ppmp,'MU')).'</td>'; print '<td align="right">'.price(price2num($objp->ppmp,'MU')).'</td>';
// Total PMP // Total PMP
print '<td align="right">'.price(price2num($objp->ppmp*$objp->value,'MT')).'</td>'; print '<td align="right">'.price(price2num($objp->ppmp*$objp->value,'MT')).'</td>';
$totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); $totalvalue+=price2num($objp->ppmp*$objp->value,'MT');
@ -580,41 +579,42 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value="'.$object->libelle.'"></td></tr>'; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td><input name="libelle" size="20" value="'.$object->libelle.'"></td></tr>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
// Parent entrepot // Parent entrepot
print '<tr><td>'.$langs->trans("AddIn").'</td><td>'; print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1); print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1);
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'; print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
// Editeur wysiwyg // Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('desc',$object->description,'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,ROWS_5,'90%'); $doleditor=new DolEditor('desc',$object->description,'',180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,ROWS_5,'90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">'; print '<tr><td>'.$langs->trans('Address').'</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">';
print $object->address; print $object->address;
print '</textarea></td></tr>'; print '</textarea></td></tr>';
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans('Zip').'</td><td>'; print '<tr><td>'.$langs->trans('Zip').'</td><td>';
print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'),6); print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'),6);
print '</td><td>'.$langs->trans('Town').'</td><td>'; print '</td></tr>';
print '<tr><td>'.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id')); print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id'));
print '</td></tr>'; print '</td></tr>';
// Country // Country
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Country').'</td><td>';
print $form->select_country($object->country_id?$object->country_id:$mysoc->country_code,'country_id'); print $form->select_country($object->country_id?$object->country_id:$mysoc->country_code,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
print '<select name="statut" class="flat">'; print '<select name="statut" class="flat">';
foreach ($object->statuts as $key => $value) foreach ($object->statuts as $key => $value)
{ {