From eb9d26a9e0fa38673db05beced0b1485875067cb Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Mon, 27 Jun 2016 11:36:13 +0200 Subject: [PATCH 1/8] FIX #5383 bad object id on don delete --- htdocs/don/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index b56171b8796..cc27b1bcfd1 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -740,9 +740,9 @@ if (! empty($id) && $action != 'edit') // Delete if ($user->rights->don->supprimer) { - if ($don->statut == -1 || $don->statut == 0) + if ($object->statut == -1 || $object->statut == 0) { - print '
'.$langs->trans("Delete")."
"; + print '
'.$langs->trans("Delete")."
"; } else { From d9035e53089f4cc2599f54a7852daf3c657d67dd Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 28 Jun 2016 11:41:23 +0200 Subject: [PATCH 2/8] FIX : receiving link never works --- htdocs/core/lib/sendings.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 1c0c589870e..f95fd5dbe76 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -302,7 +302,9 @@ function show_list_sending_receive($origin,$origin_id,$filter='') $expedition->id=$objp->sendingid; $expedition->fetchObjectLinked($expedition->id,$expedition->element); //var_dump($expedition->linkedObjects); - $receiving=(! empty($expedition->linkedObjects['delivery'][0])?$expedition->linkedObjects['delivery'][0]:''); + reset($expedition->linkedObjects['delivery']); + $first = key($expedition->linkedObjects['delivery']); + $receiving=(! empty($expedition->linkedObjects['delivery'][$first])?$expedition->linkedObjects['delivery'][$first]:''); if (! empty($receiving)) { From 7e8506e25ff3579cd54bb360ff52114a1726899e Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 28 Jun 2016 13:25:47 +0200 Subject: [PATCH 3/8] FIX #5338 use of not initialized var $aphour, $apmin, etc --- htdocs/comm/action/card.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 5b013e7a57c..e54fd788a92 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -61,8 +61,14 @@ $originid=GETPOST('originid','int'); $confirm = GETPOST('confirm', 'alpha'); $fulldayevent=GETPOST('fullday'); -$datep=dol_mktime($fulldayevent?'00':GETPOST("aphour"), $fulldayevent?'00':GETPOST("apmin"), 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); -$datef=dol_mktime($fulldayevent?'23':GETPOST("p2hour"), $fulldayevent?'59':GETPOST("p2min"), $fulldayevent?'59':'0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); + +$aphour = GETPOST('aphour'); +$apmin = GETPOST('apmin'); +$p2hour = GETPOST('p2hour'); +$p2min = GETPOST('p2min'); + +$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); +$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); // Security check $socid = GETPOST('socid','int'); @@ -92,7 +98,6 @@ $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('actioncard','globalcard')); - /* * Actions */ From e4a2b5abb372eeb43a7d46d507344fdd6cea7a5f Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 30 Jun 2016 11:27:29 +0200 Subject: [PATCH 4/8] Fix: Incorrect document link on supplier invoices's list --- htdocs/core/class/html.formfile.class.php | 4 +--- htdocs/fourn/facture/list.php | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 48dc7a3ebf2..3faedf4b601 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 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 @@ -716,9 +717,6 @@ class FormFile if ($modulepart == 'export') { $relativepath = $file["name"]; } - if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_fournisseur') { - $relativepath = get_exdir($modulesubdir, 2,0,0,null,'invoice_supplier'). $modulesubdir. "/" . $file["name"]; - } // Show file name with link to download $out.= 'getNomUrl(1); $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink('facture_fournisseur', $filename, $filedir); + $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); print "\n"; // Ref supplier From 22bc44620b8f2733009867e6a6ca6c9065b5dbc6 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 30 Jun 2016 14:27:58 +0200 Subject: [PATCH 5/8] FIX #5170 tva sign with INVOICE_POSITIVE_CREDIT_NOTE option --- htdocs/core/lib/pdf.lib.php | 14 ++++++++++---- .../core/modules/facture/doc/pdf_crabe.modules.php | 7 +++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 6389c71b06c..9fe2bbb1b40 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1342,7 +1342,10 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) */ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) { - global $hookmanager; + global $hookmanager,$conf; + + $sign=1; + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { @@ -1355,7 +1358,7 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) } else { - if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) return price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); } } @@ -1629,7 +1632,10 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) */ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) { - global $hookmanager; + global $hookmanager,$conf; + + $sign=1; + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; if ($object->lines[$i]->special_code == 3) { @@ -1648,7 +1654,7 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) } else { - if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) return price($sign * (($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); } } return ''; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 719449bcbd4..33febb9028b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -539,13 +539,16 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + + $sign=1; + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress(); if ($prev_progress > 0) // Compute progress from previous situation { - $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { - $tvaligne = $object->lines[$i]->total_tva; + $tvaligne = $sign * $object->lines[$i]->total_tva; } $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; From 0ffe106e2cdb7cfa5213a93a12baf3fc89026267 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 30 Jun 2016 16:03:48 +0200 Subject: [PATCH 6/8] FIX #4749 --- htdocs/compta/bank/annuel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 68ef0a42e32..61941a4cefb 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -36,10 +36,10 @@ $id=GETPOST('account'); $ref=GETPOST('ref'); // Security check -$fieldid = (! empty($ref)?$ref:$id); -$fieldname = isset($ref)?'ref':'rowid'; +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); +$fieldtype = (! empty($ref) ? 'ref' :'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque',$fieldid,'bank_account','','',$fieldname); +$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype); $year_start=GETPOST('year_start'); $year_current = strftime("%Y",time()); @@ -146,7 +146,7 @@ $linkback = ''.$langs->trans("B // Ref print ''.$langs->trans("Ref").''; print ''; -if ($_GET["account"]) +if (!empty($id)) { if (! preg_match('/,/', $id)) { From 38dcb0de4988a9a632db69b1f96278983615f042 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 30 Jun 2016 16:53:24 +0200 Subject: [PATCH 7/8] FIX #4455 --- htdocs/fourn/card.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 5188003c115..956d4b52452 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -407,6 +407,18 @@ if ($object->id > 0) } // TODO move to DAO class + $sql = "SELECT count(p.rowid) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " WHERE p.fk_soc =".$object->id; + $sql.= " AND p.entity =".$conf->entity; + $sql.= " ORDER BY p.date_commande DESC"; + $resql=$db->query($sql); + if ($resql) + { + $object_count = $db->fetch_object($resql); + $num = $object_count->total; + } + $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$object->id; @@ -417,7 +429,6 @@ if ($object->id > 0) if ($resql) { $i = 0 ; - $num = $db->num_rows($resql); if ($num > 0) { @@ -433,7 +444,7 @@ if ($object->id > 0) } $var = True; - while ($i < $num && $i <= $MAXLIST) + while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); $var=!$var; From d004f3a538c6a0907ea75cb2e07671f47a775bc9 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 30 Jun 2016 17:03:56 +0200 Subject: [PATCH 8/8] FIX #4448 $filebonprev is not used, $this->filename now --- .../compta/prelevement/class/bonprelevement.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 610fe257732..8fd5450d66a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -918,7 +918,10 @@ class BonPrelevement extends CommonObject $row = $this->db->fetch_row($resql); $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1,0,2),2,"0",STR_PAD_LEFT); - $this->filename = $conf->prelevement->dir_output.'/receipts/'.$ref.'.xml'; + $dir=$conf->prelevement->dir_output.'/receipts'; + if (! is_dir($dir)) dol_mkdir($dir); + + $this->filename = $dir.'/receipts/'.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; @@ -934,10 +937,6 @@ class BonPrelevement extends CommonObject { $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); $this->id = $prev_id; - - $dir=$conf->prelevement->dir_output.'/receipts'; - $file=$filebonprev; - if (! is_dir($dir)) dol_mkdir($dir); } else { @@ -1033,7 +1032,7 @@ class BonPrelevement extends CommonObject // Generation of SEPA file $this->generate(); } - dol_syslog(__METHOD__."::End withdraw receipt, file ".$filebonprev, LOG_DEBUG); + dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } /*