From 06fe172669500d3e5b8d5fd0163695da58c35205 Mon Sep 17 00:00:00 2001 From: Philippe Date: Thu, 27 Sep 2018 20:06:00 +0200 Subject: [PATCH 01/13] FIX Product marge tabs on product card Credit note are not negative so the grand total are false --- htdocs/margin/tabs/productMargins.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 9175736d5db..f899d112a2d 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -138,9 +138,9 @@ if ($id > 0 || ! empty($ref)) $sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,"; $sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive - $sql.= " sum(d.qty) as qty,"; - $sql.= " sum(d.qty * d.buy_price_ht) as buying_price,"; // always positive - $sql.= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // always positive + $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty) as qty,"; // not always positive in case of Credit note + $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note + $sql.= " IF(f.type = 2, -1, 1) * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; From 2acd69033cf233d7716cdc1001f2b5ae9db419b0 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 3 Oct 2018 22:48:29 +0200 Subject: [PATCH 02/13] Fix minor error in dom --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1797617a26d..f760dd32cc1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2806,7 +2806,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if ($picto == 'off') { $fakey = 'fa-square-o'; $fasize='1.3em'; } if ($picto == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } $enabledisablehtml=''; - $enabledisablehtml.=''; + $enabledisablehtml.=''; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$titlealt; $enabledisablehtml.=''; return $enabledisablehtml; From 292dab192b5f9547e86127fbcfda26b4a842fa0b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 4 Oct 2018 09:42:11 +0200 Subject: [PATCH 03/13] FIX : #9161 --- htdocs/core/lib/company.lib.php | 40 ++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2dd4cf090f5..9440f911eeb 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1213,6 +1213,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= global $param; + dol_include_once('/comm/action/class/actioncomm.class.php'); + // Check parameters if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('','BadParameter'); @@ -1261,6 +1263,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; } + //TODO check how ot work with new table actioncomm_resources and multiple contact affectation if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id; // Condition on actioncode if (! empty($actioncode)) @@ -1297,6 +1300,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= { $obj = $db->fetch_object($resql); + $contactaction = new ActionComm($db); + $contactaction->id=$obj->id; + $result = $contactaction->fetchResources(); + if ($result<0) { + dol_print_error($db); + setEventMessage("company.lib::show_actions_done Error fetch ressource"); + } + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; $tododone=''; @@ -1318,6 +1329,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= 'userphoto'=>$obj->user_photo, 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'fk_element'=>$obj->fk_element, @@ -1470,7 +1482,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList(''); - $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], 'a.fk_contact', '', $param, '', $sortfield, $sortorder); + $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); $out.=''; @@ -1616,11 +1628,33 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $contactstatic->lastname=$histo[$key]['lastname']; $contactstatic->firstname=$histo[$key]['firstname']; $contactstatic->id=$histo[$key]['contact_id']; + var_dump($histo[$key]['contact_id']); $out.=''.$contactstatic->getNomUrl(1,'',10).''; } - else + elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned'])>0) { - $out.=' '; + $out.=''; + foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) + { + $contact = new Contact($db); + $result = $contact->fetch($cid); + + if ($result < 0) dol_print_error($db,$contact->error); + + if ($result > 0) + { + $out.= $contact->getNomUrl(1); + if ($object->type_code == 'AC_TEL') + { + if (!empty($contact->phone_pro)) $out.= '('.dol_print_phone($contact->phone_pro).')'; + } + $out.= '
'; + } + } + $out.=''; + } + else { + $out.=' '; } // Status From 7f4f27ebfec407b419ed2e782881d4b0d05691de Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 4 Oct 2018 09:45:12 +0200 Subject: [PATCH 04/13] indent --- htdocs/core/lib/company.lib.php | 41 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 9440f911eeb..4dfbe47e9e3 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1305,7 +1305,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $result = $contactaction->fetchResources(); if ($result<0) { dol_print_error($db); - setEventMessage("company.lib::show_actions_done Error fetch ressource"); + setEventMessage("company.lib::show_actions_done Error fetch ressource",'errors'); } //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; @@ -1630,29 +1630,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $contactstatic->id=$histo[$key]['contact_id']; var_dump($histo[$key]['contact_id']); $out.=''.$contactstatic->getNomUrl(1,'',10).''; - } - elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned'])>0) - { - $out.=''; - foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) - { - $contact = new Contact($db); - $result = $contact->fetch($cid); + } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { + $out .= ''; + foreach ( $histo[$key]['socpeopleassigned'] as $cid => $Tab ) { + $contact = new Contact($db); + $result = $contact->fetch($cid); - if ($result < 0) dol_print_error($db,$contact->error); + if ($result < 0) + dol_print_error($db, $contact->error); - if ($result > 0) - { - $out.= $contact->getNomUrl(1); - if ($object->type_code == 'AC_TEL') - { - if (!empty($contact->phone_pro)) $out.= '('.dol_print_phone($contact->phone_pro).')'; - } - $out.= '
'; - } - } - $out.=''; - } + if ($result > 0) { + $out .= $contact->getNomUrl(1); + if ($object->type_code == 'AC_TEL') { + if (! empty($contact->phone_pro)) + $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; + } + $out .= '
'; + } + } + $out .= ''; + } else { $out.=' '; } From e95921eb934d8d3f3d891978ad0cf489269777fc Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 4 Oct 2018 09:47:04 +0200 Subject: [PATCH 05/13] better test --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4dfbe47e9e3..02652892305 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1641,7 +1641,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($result > 0) { $out .= $contact->getNomUrl(1); - if ($object->type_code == 'AC_TEL') { + if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { if (! empty($contact->phone_pro)) $out .= '(' . dol_print_phone($contact->phone_pro) . ')'; } From c048f515624098ad0e8c19a66949cc3aa560aafc Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Thu, 4 Oct 2018 09:54:40 +0200 Subject: [PATCH 06/13] FIX : Wrong variable name --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 139fe355d3d..6c9822fd8a3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -451,7 +451,7 @@ if ($search_month > 0) if ($search_year > 0 && empty($search_day)) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; else if ($search_year > 0 && ! empty($search_day)) - $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $serch_year))."'"; + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; else $sql.= " AND date_format(f.datef, '%m') = '".$month."'"; } From 58d1ac427e1af794e662327b999291319e70a142 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 4 Oct 2018 10:57:22 +0200 Subject: [PATCH 07/13] Fix missing hook on sellsjournal --- htdocs/accountancy/journal/sellsjournal.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b10e0d37c75..2c0ab7c1a2f 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -59,11 +59,15 @@ $now = dol_now(); if ($user->societe_id > 0) accessforbidden(); +$hookmanager->initHooks(array('sellsjournal')); +$parameters=array(); /* * Actions */ +$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks + // Get informations of journal $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); From bfaf25ca2a0ace725b58ae45f92768dc7caded3e Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 4 Oct 2018 16:55:16 +0200 Subject: [PATCH 08/13] Fix wrong value for module part and return access denied --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 890996bddce..4afde1e0ac4 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1611,7 +1611,7 @@ if ($id > 0) $var=true; - print $formfile->showdocuments('agenda',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang); + print $formfile->showdocuments('actions',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang); print '
'; From 68c99d01a7a545ec91965e2f717c2437d717733a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 5 Oct 2018 10:35:32 +0200 Subject: [PATCH 09/13] OMG!!!! var_dump.... --- htdocs/core/lib/company.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 02652892305..db6ef2de6cb 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1628,7 +1628,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $contactstatic->lastname=$histo[$key]['lastname']; $contactstatic->firstname=$histo[$key]['firstname']; $contactstatic->id=$histo[$key]['contact_id']; - var_dump($histo[$key]['contact_id']); $out.=''.$contactstatic->getNomUrl(1,'',10).''; } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { $out .= ''; From 82651cd920478b419d0677081be4a5fbd3e81b42 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 5 Oct 2018 12:12:04 +0200 Subject: [PATCH 10/13] FIX: invoice stats: situation invoices were not counted --- htdocs/compta/facture/class/facturestats.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index b6874862286..484d6447878 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -84,8 +84,8 @@ class FactureStats extends Stats $this->where.=" AND f.fk_soc = ".$this->socid; } if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2)"; - else $this->where.= " AND f.type IN (0,1,2,3)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)"; + else $this->where.= " AND f.type IN (0,1,2,3,5)"; } From 320ca3db673a9b8098ea3ffaadd1b460dc0b5780 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 6 Oct 2018 22:53:28 +0200 Subject: [PATCH 11/13] Fix request on project overview Fixes #9220 --- htdocs/projet/element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3263309187a..713e5ec74f1 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -291,7 +291,7 @@ $listofreferent=array( 'title'=>"ListSupplierProposalsAssociatedProject", 'class'=>'SupplierProposal', 'table'=>'supplier_proposal', - 'datefieldname'=>'date', + 'datefieldname'=>'datec', 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&socid='.$socid, 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', From 021f9552dd91fb017d3ff403f3722d2bcc143365 Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 8 Oct 2018 15:41:31 +0200 Subject: [PATCH 12/13] FIX : when we're just admin and not super admin, if we create new user with transverse mode, we don't see it then we can't add him in usergroup --- htdocs/user/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 704c04d2593..813d1e5ad05 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -194,7 +194,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; // TODO add hook if (! empty($conf->multicompany->enabled)) { if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (! empty($user->admin) && empty($user->entity)) { + if (! empty($user->admin)) { if ($conf->entity == 1) { $sql.= " WHERE u.entity IS NOT NULL"; } else { From dc498173c8755119fc63a46df9c434fd2b1a0c9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Oct 2018 16:58:55 +0200 Subject: [PATCH 13/13] Code comment --- htdocs/install/mysql/tables/llx_facturedet.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 05c68e92751..bf008d41f03 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -52,7 +52,7 @@ create table llx_facturedet date_end datetime DEFAULT NULL, -- date end if service info_bits integer DEFAULT 0, -- VAT NPR or not (for france only) - buy_price_ht double(24,8) DEFAULT 0, -- buying price + buy_price_ht double(24,8) DEFAULT 0, -- buying price. Note: this value is saved as an always positive value, even on credit notes (it is price we bought the product before selling it). fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line