Merge remote-tracking branch 'upstream/7.0' into 7.0

This commit is contained in:
Juanjo Menent 2018-12-07 11:34:42 +01:00
commit 531cfe791d
11 changed files with 375 additions and 315 deletions

View File

@ -70,18 +70,8 @@ else if ($action == 'update')
$res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity);
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha'); $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha');
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity);
}
else if ($action == 'updateengine')
{
// TODO Update engines.
} if ($res > 0)
if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
{
if (! $res > 0) $error++;
if (! $error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
@ -90,6 +80,42 @@ if ($action && $action != 'setcoder' && $action != 'setModuleOptions')
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
else if ($action == 'updateengine')
{
$sql = "SELECT rowid, coder";
$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " ORDER BY code";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if (GETPOST('coder'.$obj->rowid, 'alpha'))
{
$coder = GETPOST('coder'.$obj->rowid,'alpha');
$code_id = $obj->rowid;
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
$sqlp.= " SET coder = '" . $coder."'";
$sqlp.= " WHERE rowid = ". $code_id;
$sqlp.= " AND entity = ".$conf->entity;
$upsql=$db->query($sqlp);
if (! $upsql) dol_print_error($db);
}
$i++;
}
}
}
/* /*
* View * View
@ -162,9 +188,12 @@ $var=true;
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'','');
//print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">"; if (empty($conf->use_javascript_ajax))
//print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; {
//print "<input type=\"hidden\" name=\"action\" value=\"updateengine\">"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateengine">';
}
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -260,10 +289,9 @@ print "</table>\n";
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax))
{ {
// TODO Implement code behind action updateengine print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
//print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>'; print '</form>';
} }
//print '</form>';
print "<br>"; print "<br>";

View File

@ -13,6 +13,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -415,38 +416,40 @@ class Propal extends CommonObject
global $mysoc, $conf, $langs; global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except); dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ht_devise=price2num($pu_ht_devise);
$pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$pa_ht=price2num($pa_ht);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters
if ($type < 0) return -1;
if ($this->statut == self::STATUS_DRAFT) if ($this->statut == self::STATUS_DRAFT)
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ht_devise=price2num($pu_ht_devise);
$pu_ttc=price2num($pu_ttc);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$pa_ht=price2num($pa_ht);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters
if ($type < 0) return -1;
$this->db->begin(); $this->db->begin();
$product_type=$type; $product_type=$type;

View File

@ -9,7 +9,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1270,44 +1270,46 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; if ($this->statut == self::STATUS_DRAFT)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters // Clean parameters
if (empty($remise_percent)) $remise_percent=0; if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0; if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0; if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0; if (empty($rang)) $rang=0;
if (empty($txtva)) $txtva=0; if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0; if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
$pu_ht_devise=price2num($pu_ht_devise); $pu_ht_devise=price2num($pu_ht_devise);
$pu_ttc=price2num($pu_ttc); $pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht); $pa_ht=price2num($pa_ht);
$txtva = price2num($txtva); if (!preg_match('/\((.*)\)/', $txtva)) {
$txlocaltax1 = price2num($txlocaltax1); $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
$txlocaltax2 = price2num($txlocaltax2); }
if ($price_base_type=='HT') $txlocaltax1 = price2num($txlocaltax1);
{ $txlocaltax2 = price2num($txlocaltax2);
$pu=$pu_ht; if ($price_base_type=='HT')
} {
else $pu=$pu_ht;
{ }
$pu=$pu_ttc; else
} {
$label=trim($label); $pu=$pu_ttc;
$desc=trim($desc); }
$label=trim($label);
$desc=trim($desc);
// Check parameters // Check parameters
if ($type < 0) return -1; if ($type < 0) return -1;
if ($this->statut == self::STATUS_DRAFT)
{
$this->db->begin(); $this->db->begin();
$product_type=$type; $product_type=$type;

View File

@ -2580,55 +2580,47 @@ class Facture extends CommonInvoice
global $mysoc, $conf, $langs; global $mysoc, $conf, $langs;
dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG); dol_syslog(get_class($this)."::addline id=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type, fk_unit=$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
if (empty($ventil)) $ventil=0;
if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
if (empty($fk_prev_id)) $fk_prev_id = 'null';
if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ht_devise=price2num($pu_ht_devise);
$pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht);
$txtva=price2num($txtva);
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters
if ($type < 0) return -1;
if (! empty($this->brouillon)) if (! empty($this->brouillon))
{ {
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
if (empty($qty)) $qty=0;
if (empty($info_bits)) $info_bits=0;
if (empty($rang)) $rang=0;
if (empty($ventil)) $ventil=0;
if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
if (empty($fk_prev_id)) $fk_prev_id = 'null';
if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
$pu_ht_devise=price2num($pu_ht_devise);
$pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
// Check parameters
if ($type < 0) return -1;
$this->db->begin(); $this->db->begin();
$product_type=$type; $product_type=$type;
@ -2651,6 +2643,16 @@ 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.
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$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, $this->multicurrency_tx, $pu_ht_devise); $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];

View File

@ -8,7 +8,7 @@
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015-2018 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1358,11 +1358,23 @@ class Contrat extends CommonObject
{ {
$this->db->begin(); $this->db->begin();
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
// Clean parameters // Clean parameters
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc); $pu_ttc=price2num($pu_ttc);
$pa_ht=price2num($pa_ht); $pa_ht=price2num($pa_ht);
$txtva=price2num($txtva); if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1=price2num($txlocaltax1); $txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2); $txlocaltax2=price2num($txlocaltax2);
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
@ -1392,16 +1404,6 @@ class Contrat extends CommonObject
// 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.
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$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, 1,$mysoc, $localtaxes_type); $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,$mysoc, $localtaxes_type);
$total_ht = $tabprice[0]; $total_ht = $tabprice[0];
$total_tva = $tabprice[1]; $total_tva = $tabprice[1];

View File

@ -59,7 +59,7 @@ class FormBarCode
$disable = ''; $disable = '';
if ($conf->use_javascript_ajax) if (!empty($conf->use_javascript_ajax))
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
@ -80,18 +80,28 @@ class FormBarCode
$disable = 'disabled'; $disable = 'disabled';
} }
$select_encoder = '<form action="'.DOL_URL_ROOT.'/admin/barcode.php" method="post" id="form'.$idForm.'">'; if (!empty($conf->use_javascript_ajax))
$select_encoder.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; {
$select_encoder.= '<input type="hidden" name="action" value="update">'; $select_encoder = '<form action="'.DOL_URL_ROOT.'/admin/barcode.php" method="POST" id="form'.$idForm.'">';
$select_encoder.= '<input type="hidden" name="code_id" value="'.$code_id.'">'; $select_encoder.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$select_encoder.= '<select id="select'.$idForm.'" class="flat" name="coder">'; $select_encoder.= '<input type="hidden" name="action" value="update">';
$select_encoder.= '<input type="hidden" name="code_id" value="'.$code_id.'">';
}
$selectname=(!empty($conf->use_javascript_ajax)?'coder':'coder'.$code_id);
$select_encoder.= '<select id="select'.$idForm.'" class="flat" name="'.$selectname.'">';
$select_encoder.= '<option value="0"'.($selected==0?' selected':'').' '.$disable.'>'.$langs->trans('Disable').'</option>'; $select_encoder.= '<option value="0"'.($selected==0?' selected':'').' '.$disable.'>'.$langs->trans('Disable').'</option>';
$select_encoder.= '<option value="-1" disabled>--------------------</option>'; $select_encoder.= '<option value="-1" disabled>--------------------</option>';
foreach($barcodelist as $key => $value) foreach($barcodelist as $key => $value)
{ {
$select_encoder.= '<option value="'.$key.'"'.($selected==$key?' selected':'').'>'.$value.'</option>'; $select_encoder.= '<option value="'.$key.'"'.($selected==$key?' selected':'').'>'.$value.'</option>';
} }
$select_encoder.= '</select></form>'; $select_encoder.= '</select>';
if (!empty($conf->use_javascript_ajax))
{
$select_encoder.= '</form>';
}
return $select_encoder; return $select_encoder;
} }

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com> /* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1678,19 +1678,21 @@ class ExpenseReport extends CommonObject
dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG); dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG);
if (empty($qty)) $qty = 0;
if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0;
if (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) $fk_c_exp_tax_cat = 0;
if (empty($vatrate) || $vatrate < 0) $vatrate = 0;
if (empty($date)) $date = '';
if (empty($fk_project)) $fk_project = 0;
$qty = price2num($qty);
$vatrate = price2num($vatrate);
$up = price2num($up);
if ($this->fk_statut == self::STATUS_DRAFT) if ($this->fk_statut == self::STATUS_DRAFT)
{ {
if (empty($qty)) $qty = 0;
if (empty($fk_c_type_fees) || $fk_c_type_fees < 0) $fk_c_type_fees = 0;
if (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) $fk_c_exp_tax_cat = 0;
if (empty($vatrate) || $vatrate < 0) $vatrate = 0;
if (empty($date)) $date = '';
if (empty($fk_project)) $fk_project = 0;
$qty = price2num($qty);
if (!preg_match('/\((.*)\)/', $vatrate)) {
$vatrate = price2num($vatrate); // $txtva can have format '5.0(XXX)' or '5'
}
$up = price2num($up);
$this->db->begin(); $this->db->begin();
$this->line = new ExpenseReportLine($this->db); $this->line = new ExpenseReportLine($this->db);

View File

@ -8,6 +8,7 @@
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1424,44 +1425,48 @@ class CommandeFournisseur extends CommonOrder
$error = 0; $error = 0;
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit, $pu_ht_devise, $origin, $origin_id"); dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit, $pu_ht_devise, $origin, $origin_id");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters if ($this->statut == self::STATUS_DRAFT)
if (! $qty) $qty=1; {
if (! $info_bits) $info_bits=0; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($remise_percent)) $remise_percent=0;
$remise_percent=price2num($remise_percent); // Clean parameters
$qty=price2num($qty); if (! $qty) $qty=1;
$pu_ht=price2num($pu_ht); if (! $info_bits) $info_bits=0;
$pu_ht_devise=price2num($pu_ht_devise); if (empty($txtva)) $txtva=0;
$pu_ttc=price2num($pu_ttc); if (empty($txlocaltax1)) $txlocaltax1=0;
$txtva = price2num($txtva); if (empty($txlocaltax2)) $txlocaltax2=0;
$txlocaltax1 = price2num($txlocaltax1); if (empty($remise_percent)) $remise_percent=0;
$txlocaltax2 = price2num($txlocaltax2);
if ($price_base_type=='HT') $remise_percent=price2num($remise_percent);
{ $qty=price2num($qty);
$pu=$pu_ht; $pu_ht=price2num($pu_ht);
} $pu_ht_devise=price2num($pu_ht_devise);
else $pu_ttc=price2num($pu_ttc);
{ if (!preg_match('/\((.*)\)/', $txtva)) {
$pu=$pu_ttc; $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
} }
$desc=trim($desc); $txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if ($price_base_type=='HT')
{
$pu=$pu_ht;
}
else
{
$pu=$pu_ttc;
}
$desc=trim($desc);
// Check parameters
if ($qty < 1 && ! $fk_product)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Product"));
return -1;
}
if ($type < 0) return -1;
// Check parameters
if ($qty < 1 && ! $fk_product)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Product"));
return -1;
}
if ($type < 0) return -1;
if ($this->statut == 0)
{
$this->db->begin(); $this->db->begin();
if ($fk_product > 0) if ($fk_product > 0)

View File

@ -1392,136 +1392,140 @@ class FactureFournisseur extends CommonInvoice
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc; global $mysoc;
// Clean parameters if ($this->statut == self::STATUS_DRAFT){
if (empty($remise_percent)) $remise_percent=0; // Clean parameters
if (empty($qty)) $qty=0; if (empty($remise_percent)) $remise_percent=0;
if (empty($info_bits)) $info_bits=0; if (empty($qty)) $qty=0;
if (empty($rang)) $rang=0; if (empty($info_bits)) $info_bits=0;
if (empty($ventil)) $ventil=0; if (empty($rang)) $rang=0;
if (empty($txtva)) $txtva=0; if (empty($ventil)) $ventil=0;
if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txtva)) $txtva=0;
if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
if ($rang < 0) { if ($rang < 0) {
$rangmax = $this->line_max(); $rangmax = $this->line_max();
$rang = $rangmax + 1; $rang = $rangmax + 1;
} }
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); $remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu=price2num($pu);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
// Clean vat code $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty);
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$remise_percent=price2num($remise_percent); // Clean vat code
$qty=price2num($qty); $vat_src_code='';
$pu=price2num($pu); if (preg_match('/\((.*)\)/', $txtva, $reg))
$txtva=price2num($txtva); {
$txlocaltax1=price2num($txlocaltax1); $vat_src_code = $reg[1];
$txlocaltax2=price2num($txlocaltax2); $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, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
$total_ht = $tabprice[0]; $total_ht = $tabprice[0];
$total_tva = $tabprice[1]; $total_tva = $tabprice[1];
$total_ttc = $tabprice[2]; $total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9]; $total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10]; $total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3]; $pu_ht = $tabprice[3];
// MultiCurrency // MultiCurrency
$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]; $pu_ht_devise = $tabprice[19];
// Check parameters // Check parameters
if ($type < 0) return -1; if ($type < 0) return -1;
if ($rang < 0) if ($rang < 0)
{ {
$rangmax = $this->line_max(); $rangmax = $this->line_max();
$rang = $rangmax + 1; $rang = $rangmax + 1;
} }
// Insert line // Insert line
$this->line=new SupplierInvoiceLine($this->db); $this->line=new SupplierInvoiceLine($this->db);
$this->line->context = $this->context; $this->line->context = $this->context;
$this->line->fk_facture_fourn=$this->id; $this->line->fk_facture_fourn=$this->id;
//$this->line->label=$label; // deprecated //$this->line->label=$label; // deprecated
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->ref_supplier=$ref_supplier; $this->line->ref_supplier=$ref_supplier;
$this->line->vat_src_code=$vat_src_code; $this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva; $this->line->tva_tx=$txtva;
$this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
$this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
$this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2]; $this->line->localtax2_type = $localtaxes_type[2];
$this->line->fk_product=$fk_product; $this->line->fk_product=$fk_product;
$this->line->product_type=$type; $this->line->product_type=$type;
$this->line->remise_percent=$remise_percent; $this->line->remise_percent=$remise_percent;
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
$this->line->date_start=$date_start; $this->line->date_start=$date_start;
$this->line->date_end=$date_end; $this->line->date_end=$date_end;
$this->line->ventil=$ventil; $this->line->ventil=$ventil;
$this->line->rang=$rang; $this->line->rang=$rang;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative
$this->line->total_tva= $total_tva; $this->line->total_tva= $total_tva;
$this->line->total_localtax1=$total_localtax1; $this->line->total_localtax1=$total_localtax1;
$this->line->total_localtax2=$total_localtax2; $this->line->total_localtax2=$total_localtax2;
$this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc);
$this->line->special_code=$this->special_code; $this->line->special_code=$this->special_code;
$this->line->fk_parent_line=$this->fk_parent_line; $this->line->fk_parent_line=$this->fk_parent_line;
$this->line->origin=$this->origin; $this->line->origin=$this->origin;
$this->line->origin_id=$origin_id; $this->line->origin_id=$origin_id;
$this->line->fk_unit=$fk_unit; $this->line->fk_unit=$fk_unit;
// 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 = $pu_ht_devise; $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;
if (is_array($array_options) && count($array_options)>0) { if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options; $this->line->array_options=$array_options;
} }
$result=$this->line->insert($notrigger); $result=$this->line->insert($notrigger);
if ($result > 0) if ($result > 0)
{ {
// Reorder if child line // Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la facture meme // Mise a jour informations denormalisees au niveau de la facture meme
$result=$this->update_price(1,'auto',0,$this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. $result=$this->update_price(1,'auto',0,$this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
return $this->line->id; return $this->line->id;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
else else
{ {
$this->error=$this->line->error; $this->error=$this->line->error;
$this->errors=$this->line->errors; $this->errors=$this->line->errors;
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
}
} }
} }

View File

@ -317,6 +317,7 @@ ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount double
ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);
ALTER TABLE llx_paiementfourn ADD COLUMN fk_user_modif integer AFTER fk_user_author;
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202);

View File

@ -28,6 +28,7 @@ create table llx_paiementfourn
amount double(24,8) DEFAULT 0, -- montant amount double(24,8) DEFAULT 0, -- montant
multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount
fk_user_author integer, -- auteur fk_user_author integer, -- auteur
fk_user_modif integer,
fk_paiement integer NOT NULL, -- moyen de paiement fk_paiement integer NOT NULL, -- moyen de paiement
num_paiement varchar(50), -- numero de paiement (cheque) num_paiement varchar(50), -- numero de paiement (cheque)
note text, note text,