diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 70168b5e1a9..1f32c69dc93 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos GarcĂ­a - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -136,6 +136,7 @@ class Commande extends CommonOrder public $linked_objects=array(); public $user_author_id; + public $user_valid; /** * @var OrderLine[] @@ -1542,7 +1543,7 @@ class Commande extends CommonOrder // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; + $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; @@ -1586,6 +1587,7 @@ class Commande extends CommonOrder $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; + $this->user_valid = $obj->fk_user_valid; $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; $this->total_localtax1 = $obj->total_localtax1; @@ -3004,8 +3006,8 @@ class Commande extends CommonOrder $sql.= " total_ht=".(isset($this->total_ht)?$this->total_ht:"null").","; $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").","; $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " fk_user_author=".(isset($this->user_author)?$this->user_author:"null").","; - $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").","; + $sql.= " fk_user_author=".(isset($this->user_author_id)?$this->user_author_id:"null").","; + $sql.= " fk_user_valid=".(isset($this->user_valid)?$this->user_valid:"null").","; $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").","; $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").","; $sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").","; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b3396e1082c..454c2dfca93 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1360,7 +1360,7 @@ class Account extends CommonObject { $country_code=$this->getCountryCode(); - if (in_array($country_code,array('CH','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon, ... + if (in_array($country_code,array('CH','FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... if (in_array($country_code,array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... return 0; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 41c1171ccef..ef23a30b878 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -169,11 +169,16 @@ class FactureRec extends CommonInvoice $num=count($facsrc->lines); for ($i = 0; $i < $num; $i++) { - $result_insert = $this->addline( + $tva_tx = $facsrc->lines[$i]->tva_tx; + if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + + $result_insert = $this->addline( $facsrc->lines[$i]->desc, $facsrc->lines[$i]->subprice, $facsrc->lines[$i]->qty, - $facsrc->lines[$i]->tva_tx, + $tva_tx, + $facsrc->lines[$i]->localtax1_tx, + $facsrc->lines[$i]->localtax2_tx, $facsrc->lines[$i]->fk_product, $facsrc->lines[$i]->remise_percent, 'HT', @@ -243,7 +248,8 @@ class FactureRec extends CommonInvoice */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='') { - $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; + $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; + $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; @@ -284,6 +290,8 @@ class FactureRec extends CommonInvoice $this->remise = $obj->remise; $this->total_ht = $obj->total; $this->total_tva = $obj->tva; + $this->total_localtax1 = $obj->localtax1; + $this->total_localtax2 = $obj->localtax2; $this->total_ttc = $obj->total_ttc; $this->paye = $obj->paye; $this->close_code = $obj->close_code; @@ -364,8 +372,8 @@ class FactureRec extends CommonInvoice { $this->lines=array(); - $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; - $sql.= ' l.remise, l.remise_percent, l.subprice,'; + $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; + $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; //$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; @@ -404,7 +412,13 @@ class FactureRec extends CommonInvoice $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; + + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->localtax1_type = $objp->localtax1_type; + $line->localtax2_type = $objp->localtax2_type; $line->remise_percent = $objp->remise_percent; $line->fk_remise_except = $objp->fk_remise_except; $line->fk_product = $objp->fk_product; @@ -493,6 +507,8 @@ class FactureRec extends CommonInvoice * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) * @param double $qty Quantite * @param double $txtva Taux de tva force, sinon -1 + * @param double $txlocaltax1 Local tax 1 rate (deprecated) + * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id du produit/service predefini * @param double $remise_percent Pourcentage de remise de la ligne * @param string $price_base_type HT or TTC @@ -506,29 +522,40 @@ class FactureRec extends CommonInvoice * @param string $fk_unit Unit * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::addline facid=$facid,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,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,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,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters if ($type < 0) return -1; + $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. + } + if ($this->brouillon) { // Clean parameters $remise_percent=price2num($remise_percent); if (empty($remise_percent)) $remise_percent=0; $qty=price2num($qty); - if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva=price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); if ($price_base_type=='HT') { @@ -543,10 +570,14 @@ class FactureRec extends CommonInvoice // qty, pu, remise_percent et txtva // 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. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits, $type, $mysoc); + + + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; + $total_localtax1=$tabprice[9]; + $total_localtax2=$tabprice[10]; $product_type=$type; if ($fk_product) @@ -563,6 +594,11 @@ class FactureRec extends CommonInvoice $sql.= ", price"; $sql.= ", qty"; $sql.= ", tva_tx"; + $sql.= ", vat_src_code"; + $sql.= ", localtax1_tx"; + $sql.= ", localtax1_type"; + $sql.= ", localtax2_tx"; + $sql.= ", localtax2_type"; $sql.= ", fk_product"; $sql.= ", product_type"; $sql.= ", remise_percent"; @@ -570,6 +606,8 @@ class FactureRec extends CommonInvoice $sql.= ", remise"; $sql.= ", total_ht"; $sql.= ", total_tva"; + $sql.= ", total_localtax1"; + $sql.= ", total_localtax2"; $sql.= ", total_ttc"; $sql.= ", rang"; $sql.= ", special_code"; @@ -581,6 +619,11 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($pu_ht); $sql.= ", ".price2num($qty); $sql.= ", ".price2num($txtva); + $sql.= ", '".$this->db->escape($vat_src_code)."'"; + $sql.= ", ".price2num($txlocaltax1); + $sql.= ", '".$this->db->escape($localtaxes_type[0])."'"; + $sql.= ", ".price2num($txlocaltax2); + $sql.= ", '".$this->db->escape($localtaxes_type[2])."'"; $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", ".$product_type; $sql.= ", ".price2num($remise_percent); @@ -588,6 +631,8 @@ class FactureRec extends CommonInvoice $sql.= ", null"; $sql.= ", ".price2num($total_ht); $sql.= ", ".price2num($total_tva); + $sql.= ", ".price2num($total_localtax1); + $sql.= ", ".price2num($total_localtax2); $sql.= ", ".price2num($total_ttc); $sql.= ", ".$rang; $sql.= ", ".$special_code; @@ -616,6 +661,8 @@ class FactureRec extends CommonInvoice * @param double $pu_ht Prix unitaire HT (> 0 even for credit note) * @param double $qty Quantite * @param double $txtva Taux de tva force, sinon -1 + * @param double $txlocaltax1 Local tax 1 rate (deprecated) + * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id du produit/service predefini * @param double $remise_percent Pourcentage de remise de la ligne * @param string $price_base_type HT or TTC @@ -629,28 +676,39 @@ class FactureRec extends CommonInvoice * @param string $fk_unit Unit * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) + function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null) { global $mysoc; $facid=$this->id; - dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,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,type=$type,fk_unit=$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,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,type=$type,fk_unit=$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Check parameters if ($type < 0) return -1; - + + $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. + } + if ($this->brouillon) { // Clean parameters $remise_percent=price2num($remise_percent); $qty=price2num($qty); - if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva=price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); if ($price_base_type=='HT') { @@ -665,10 +723,13 @@ class FactureRec extends CommonInvoice // qty, pu, remise_percent et txtva // 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. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, 0, $price_base_type, $info_bits, $type, $mysoc); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; + $total_localtax1=$tabprice[9]; + $total_localtax2=$tabprice[10]; $product_type=$type; if ($fk_product) @@ -685,18 +746,25 @@ class FactureRec extends CommonInvoice $sql.= ", price=".price2num($pu_ht); $sql.= ", qty=".price2num($qty); $sql.= ", tva_tx=".price2num($txtva); + $sql.= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql.= ", localtax1_tx=".price2num($txlocaltax1); + $sql.= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql.= ", localtax2_tx=".price2num($txlocaltax2); + $sql.= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; $sql.= ", fk_product=".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", product_type=".$product_type; $sql.= ", remise_percent='".price2num($remise_percent)."'"; $sql.= ", subprice='".price2num($pu_ht)."'"; $sql.= ", total_ht='".price2num($total_ht)."'"; $sql.= ", total_tva='".price2num($total_tva)."'"; + $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; $sql.= ", total_ttc='".price2num($total_ttc)."'"; $sql.= ", rang=".$rang; $sql.= ", special_code=".$special_code; $sql.= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); $sql.= " WHERE rowid = ".$rowid; - + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index cb60b8bcff5..acf97a3893a 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -615,7 +615,7 @@ if (empty($reshook)) else { // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit); if ($result > 0) { @@ -787,7 +787,9 @@ if (empty($reshook)) $description, $pu_ht, $qty, - $vat_rate, + $vat_rate, + $localtax1_rate, + $localtax1_rate, GETPOST('productid'), GETPOST('remise_percent'), 'HT', @@ -1180,9 +1182,23 @@ else print ''.$langs->trans("AmountVAT").''.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).''; print ''; + + // Amount Local Taxes + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 + { + print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; + print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ''; + } + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 + { + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; + print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; + } + print ''.$langs->trans("AmountTTC").''.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).''; print ''; + // Payment term print ''; print '
'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6b92265aac9..b12e58fe8f7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6041,7 +6041,7 @@ class Form { if ($addlinktofullsize) { - $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile); + $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); if ($urladvanced) $ret.=''; else $ret.=''; } @@ -6052,7 +6052,7 @@ class Form { if ($addlinktofullsize) { - $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile); + $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); if ($urladvanced) $ret.=''; else $ret.=''; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ca3bf804750..adacddb2163 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -710,7 +710,7 @@ class FormFile // Show file name with link to download $out.= ''; - $tmp = $this->showPreview($file,$modulepart,$relativepath); + $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= ($tmp?$tmp.' ':''); $out.= 'use_javascript_ajax) && ($conf->browser->layout != 'phone')) { - $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1); + $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); if ($tmparray && $tmparray['url']) $tmpout.= '
  • '.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'
  • '; } @@ -1161,7 +1161,7 @@ class FormFile if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$minifile.'
    '; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 0, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); if (empty($urlforhref)) $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print ''; print ''; @@ -1677,16 +1677,17 @@ class FormFile * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs * @param string $ruleforpicto Rule for picto: 0=Preview picto, 1=Use picto of mime type of file) + * @param string $param More param on http links * @return string $out Output string with HTML */ - public function showPreview($file, $modulepart, $relativepath, $ruleforpicto=0) + public function showPreview($file, $modulepart, $relativepath, $ruleforpicto=0, $param='') { global $langs, $conf; $out=''; if ($conf->browser->layout != 'phone') { - $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1); // Return if a file is qualified for preview. + $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. if (count($urladvancedpreview)) { $out.= ''; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 88b001ba093..169aec16307 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -467,7 +467,7 @@ class Translate if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$this->defaultlang."'"; + $sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'"; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bd3a79e7241..d2638898a33 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6047,9 +6047,10 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs. * @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php) + * @param string $param More param on http links * @return string|array Output string with href link or array with all components of link */ -function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0) +function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='') { global $conf, $langs; @@ -6067,7 +6068,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0) } // old behavior - if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath)).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; + if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; else return ''; } diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 915883cbdaa..3dc615d9deb 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** - * Classe permettant de generer les projets au modele Baleine + * Classe permettant de generer les projets au modele SEPAMandate */ class pdf_sepamandate extends ModeleBankAccountDoc diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 1b2cabb573d..4a82c946cfd 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -33,6 +33,8 @@ UPDATE llx_const SET name = __ENCRYPT('THIRDPARTY_DEFAULT_CREATE_CONTACT')__ WHE ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1; UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL; +ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); + ALTER TABLE llx_societe ALTER COLUMN fk_stcomm SET DEFAULT 0; ALTER TABLE llx_c_actioncomm ADD COLUMN picto varchar(48); @@ -162,6 +164,7 @@ ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_facturedet_rec ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_facture_fourn_det ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_commandedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_commande_fournisseurdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql index 6db2857ddae..af35fb0eca1 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.sql @@ -58,5 +58,6 @@ create table llx_bank_account comment text, -- TODO rename in note_private note_public text, model_pdf varchar(255), - import_key varchar(14) + import_key varchar(14), + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.sql index cea176b2aa8..8b2c70b09f7 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.sql @@ -29,6 +29,7 @@ create table llx_facturedet_rec product_type integer DEFAULT 0, label varchar(255) DEFAULT NULL, description text, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- taux tva localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 76a609e0a44..4e6c3f49738 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4062,7 +4062,7 @@ class Product extends CommonObject $relativefile=preg_replace('/^\//', '', $pdir.$photo); if (empty($nolink)) { - $urladvanced=getAdvancedPreviewUrl('product', $relativefile); + $urladvanced=getAdvancedPreviewUrl('product', $relativefile, 0, 'entity='.$this->entity); if ($urladvanced) $return.=''; else $return.= ''; } diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index a7d3d4b3fcd..3ca058acb8a 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -26,7 +26,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 185589f01cb..36914d74585 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -294,13 +294,13 @@ if (empty($reshook)) $action = 'builddoc'; $moreparams = array( 'use_companybankid'=>GETPOST('companybankid'), - 'force_dir_output'=>$conf->societe->dir_output.'/'.dol_sanitizeFileName($object->id) + 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) ); $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid')); $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid')); } $id = $socid; - $upload_dir = $conf->societe->dir_output; + $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissioncreate=$user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -658,7 +658,7 @@ if ($socid && $action != 'edit' && $action != "create") $var=true; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); print '
    ';