diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 0f1f88f8c42..e3ea95d18b5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -328,20 +328,20 @@ if ($action == 'edit' || $action == 'updateedit') // Name print ''; - print ''."\n"; + print ''."\n"; // Addresse print ''; - print ''."\n"; + print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; // Country @@ -363,29 +363,29 @@ if ($action == 'edit' || $action == 'updateedit') print ''; - print ''; + print ''; print ''."\n"; print ''; - print ''; + print ''; print ''."\n"; print ''; - print ''; + print ''; print ''."\n"; // Web print ''; - print ''; + print ''; print ''."\n"; // Barcode if (! empty($conf->barcode->enabled)) { print ''; - print ''; + print ''; print ''; } @@ -424,19 +424,19 @@ if ($action == 'edit' || $action == 'updateedit') // Managing Director(s) print ''; - print ''; + print ''; // GDPR contact print ''; print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); print ''; - print ''; + print ''; // Capital print ''; - print ''; + print ''; // Juridical Status @@ -455,7 +455,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -471,7 +471,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -487,7 +487,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -503,7 +503,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -519,7 +519,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -535,7 +535,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if (! empty($mysoc->country_code)) { - print ''; + print ''; } else { @@ -547,7 +547,7 @@ if ($action == 'edit' || $action == 'updateedit') // TVA Intra print ''; - print ''; + print ''; print ''; // Object of the company diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index b1732e0883b..643269bfacd 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -96,7 +96,7 @@ $usefilter=0; $listofsessions=listOfSessions(); $num=count($listofsessions); -print_barre_liste($langs->trans("Sessions"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'setup'); +print_barre_liste($langs->trans("Sessions"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'', $num, ($num?$num:''),'setup'); // Do not show numer (0) if no session found (it means we can't know) $savehandler=ini_get("session.save_handler"); $savepath=ini_get("session.save_path"); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f1419f83e45..08cc08da707 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -954,6 +954,8 @@ if (empty($reshook)) if($facture_source->type == Facture::TYPE_SITUATION) { + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from if(!empty($facture_source->tab_previous_situation_invoice)) { @@ -977,7 +979,7 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $line->fk_prev_id) + if($prevLine->id == $source_fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent); @@ -1535,7 +1537,8 @@ if (empty($reshook)) $line->origin = $object->origin; $line->origin_id = $line->id; $line->fetch_optionals($line->id); - + $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note + // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3ab5d84bfdb..ded797b3307 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4913,9 +4913,10 @@ class FactureLigne extends CommonInvoiceLine * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. * * @param int $invoiceid Invoice id + * @param bool $include_credit_note Include credit note or not * @return int >= 0 */ - function get_prev_progress($invoiceid) + function get_prev_progress($invoiceid, $include_credit_note=true) { // phpcs:enable if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { @@ -4930,7 +4931,26 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); - return floatval($res['situation_percent']); + + $returnPercent = floatval($res['situation_percent']); + + if($include_credit_note) { + + $sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd'; + $sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) '; + $sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id; + $sql.= ' AND f.situation_cycle_ref = '.$tmpinvoice->situation_cycle_ref; // Prevent cycle outed + $sql.= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + + $res = $this->db->query($sql); + if($res) { + while($obj = $this->db->fetch_object($res)) { + $returnPercent = $returnPercent + floatval($obj->situation_percent); + } + } + } + + return $returnPercent; } else { $this->error = $this->db->error(); dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b60fdd8886b..04132fa9b75 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -732,7 +732,7 @@ while ($i < min($num,$limit)) // Job position if (! empty($arrayfields['p.poste']['checked'])) { - print ''.dol_trunc($obj->poste,20).''; + print ''.$obj->poste.''; if (! $i) $totalarray['nbfield']++; } // Zip diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index d1a46e4d0b9..7562cd609c2 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -389,13 +389,17 @@ class CMailFile // TODO if (! empty($moreinheader)) ... // Give the message a subject - $this->message->setSubject($this->encodetorfc2822($subject)); + try { + $result = $this->message->setSubject($subject); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } // Set the From address with an associative array //$this->message->setFrom(array('john@doe.com' => 'John Doe')); if (! empty($from)) { try { - $this->message->setFrom($this->getArrayAddress($from)); + $result = $this->message->setFrom($this->getArrayAddress($from)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -404,7 +408,7 @@ class CMailFile // Set the To addresses with an associative array if (! empty($to)) { try { - $this->message->setTo($this->getArrayAddress($to)); + $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } @@ -412,13 +416,17 @@ class CMailFile if (! empty($replyto)) { try { - $this->message->SetReplyTo($this->getArrayAddress($replyto)); + $result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); } catch (Exception $e) { $this->errors[] = $e->getMessage(); } } - $this->message->setCharSet($conf->file->character_set_client); + try { + $result = $this->message->setCharSet($conf->file->character_set_client); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } if (! empty($this->html)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 149f1681725..cee64d930cc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3422,7 +3422,7 @@ class Form if ($obj->situation_final != 1) { //Not prov? if (substr($obj->facnumber, 1, 4) != 'PROV') { - if ($selected == $obj->situation_final) { + if ($selected == $obj->rowid) { $opt .= ''; } else { $opt .= ''; diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 4532a7a294a..bad8d7ffdca 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -763,7 +763,7 @@ function xml2php($xml) } //Let see if the new child is not in the array - if ($tab==false && in_array($key,array_keys($array))) + if ($tab === false && in_array($key,array_keys($array))) { //If this element is already in the array we will create an indexed array $tmp = $array[$key]; @@ -772,7 +772,7 @@ function xml2php($xml) $array[$key][] = $child; $tab = true; } - elseif($tab == true) + elseif($tab === true) { //Add an element in an existing array $array[$key][] = $child; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 57bb32ef1a3..1cce7527018 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -172,7 +172,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -213,7 +213,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -320,7 +320,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -361,7 +361,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -465,7 +465,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; $sql.= " ORDER BY e.rowid"; if (! $sql) @@ -641,7 +641,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -682,7 +682,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -789,7 +789,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -830,7 +830,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -934,7 +934,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service - $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; $sql.= " ORDER BY e.rowid"; if (! $sql) diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index 2fe6204f3b9..3f9c1eb0a1d 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2013 Laurent Destailleur +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Laurent Destailleur + * Copyright (C) 2018 Frédéric France * * 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 @@ -42,7 +43,7 @@ print '});'."\n"; print '$("#show-'.$blocname.'").click(function(){'."\n"; print ' setShowHide(1);'."\n"; -print ' $("#'.$blocname.'").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n"; +print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n"; print ' $(this).hide();'."\n"; print ' $("#hide-'.$blocname.'").show();'."\n"; print '});'."\n"; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index bc5d03c7296..994edfa823e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -190,6 +190,7 @@ if ($action == 'order' && isset($_POST['valid'])) $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " WHERE fk_soc = ".$suppliersid[$i]; $sql.= " AND source = 42 AND fk_statut = 0"; + $sql.= " AND entity IN (".getEntity('commande_fournisseur').")"; $sql.= " ORDER BY date_creation DESC"; $resql = $db->query($sql); if($resql && $db->num_rows($resql) > 0) {