diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3e50b92f543..ba4d05712a1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -446,8 +446,8 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; - $newinvoiceline->origin = $this->element; - $newinvoiceline->origin_id = $this->lines[$i]->id; + $newinvoiceline->origin = $this->element; // TODO This seems not used. Here we but origin 'facture' but after + $newinvoiceline->origin_id = $this->lines[$i]->id; // we put an id of object ! if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e130f1b726f..1e16d48b499 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur - * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014-2016 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 @@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject $dir=$conf->prelevement->dir_output.'/receipts'; if (! is_dir($dir)) dol_mkdir($dir); - $this->filename = $dir.'/receipts/'.$ref.'.xml'; + $this->filename = $dir.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index a71ed57ab2c..1b3bd883d54 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -170,7 +170,8 @@ class HookManager 'printObjectLine', 'printObjectSubLine', 'createDictionaryFieldList', - 'editDictionaryFieldlist' + 'editDictionaryFieldlist', + 'getFormMail' ) )) $hooktype='addreplace'; // Deprecated hook types ('returnvalue') diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 0eca137f6d3..a588fc8f241 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -140,8 +140,8 @@ class FormProjets if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0 && empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; if (!empty($filterkey)) { - $sql .= ' AND p.title LIKE "%'.$this->db->escape($filterkey).'%"'; - $sql .= ' OR p.ref LIKE "%'.$this->db->escape($filterkey).'%"'; + $sql .= " AND p.title LIKE '%".$this->db->escape($filterkey)."%'"; + $sql .= " OR p.ref LIKE '%".$this->db->escape($filterkey)."%'"; } $sql.= " ORDER BY p.ref ASC"; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c49de2a2b55..1593dd5eee5 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -166,7 +166,7 @@ class pdf_crabe extends ModelePDFFactures function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf,$mysoc,$db,$hookmanager; - + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; @@ -338,6 +338,11 @@ class pdf_crabe extends ModelePDFFactures $height_incoterms = 0; if ($conf->incoterm->enabled) { + if (is_object($object->thirdparty)) + { + $object->fk_incoterms=$object->thirdparty->fk_incoterms; + $object->location_incoterms=$object->thirdparty->location_incoterms; + } $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { @@ -553,7 +558,7 @@ class pdf_crabe extends ModelePDFFactures if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva; else $tvaligne= $sign * $object->lines[$i]->total_tva; } - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -1577,7 +1582,7 @@ class pdf_crabe extends ModelePDFFactures $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - + $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index d9a71dd410d..33a960e91ca 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -286,7 +286,7 @@ IMG; /** * Merge template variables - * Called automatically for a save + * Called at the beginning of the _save function * * @param string $type 'content', 'styles' or 'meta' * @return void @@ -296,6 +296,7 @@ IMG; // Search all tags fou into condition to complete $this->vars, so we will proceed all tests even if not defined $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); + //var_dump($this->vars);exit; foreach($matches as $match) // For each match, if there is no entry into this->vars, we add it { @@ -313,15 +314,23 @@ IMG; // If value is true (not 0 nor false nor null nor empty string) if ($value) { + dol_syslog("Var ".$key." is defined, we remove the IF, ELSE and ENDIF "); + $sav=$this->contentXml; // Remove the IF tag $this->contentXml = str_replace('[!-- IF '.$key.' --]', '', $this->contentXml); // Remove everything between the ELSE tag (if it exists) and the ENDIF tag $reg = '@(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy $this->contentXml = preg_replace($reg, '', $this->contentXml); + if ($sav != $this->contentXml) + { + dol_syslog("We found a IF and it was processed"); + } } // Else the value is false, then two cases: no ELSE and we're done, or there is at least one place where there is an ELSE clause, then we replace it else { + dol_syslog("Var ".$key." is not defined, we remove the IF, ELSE and ENDIF "); + $sav=$this->contentXml; // Find all conditional blocks for this variable: from IF to ELSE and to ENDIF $reg = '@\[!--\sIF\s' . $key . '\s--\](.*)(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); @@ -330,6 +339,11 @@ IMG; } // Cleanup the other conditional blocks (all the others where there were no ELSE clause, we can just remove them altogether) $this->contentXml = preg_replace($reg, '', $this->contentXml); + if ($sav != $this->contentXml) + { + dol_syslog("We found a IF and it was processed"); + //var_dump($sav);exit; + } } } diff --git a/htdocs/install/doctemplates/orders/template_order.odt b/htdocs/install/doctemplates/orders/template_order.odt index 100afe5dac4..eb21fae8595 100644 Binary files a/htdocs/install/doctemplates/orders/template_order.odt and b/htdocs/install/doctemplates/orders/template_order.odt differ diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cebc1dd43f7..a44fdf252b1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1983,12 +1983,24 @@ class Societe extends CommonObject { global $langs; - $contact_emails = $this->contact_property_array('email'); + $contact_emails = $this->contact_property_array('email',1); if ($this->email && $addthirdparty) { - if (empty($this->name)) $this->name=$this->nom; - // TODO: Tester si email non deja present dans tableau contact - $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + $exist = 0; + foreach($contact_emails as $contacts){ + if($exist ===0){ + $contacts = str_replace('>','',$contacts); + $contacts = explode ('<',$contacts); + if($contacts[1]===$this->email){ + $exist = 1; + } + } + } + if($exist ===0){ + if (empty($this->name)) $this->name=$this->nom; + $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + } + } return $contact_emails; }