From 0ab4827091cd5dd181cffe7ff0eea202ed4e00f6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 5 Jun 2016 02:06:32 +0200 Subject: [PATCH 1/6] FIX #5087 --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index d354721332a..fa3967284d9 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -970,7 +970,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks= $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount"; + $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount"; $sql2.= " ORDER BY p.title, p.ref"; $var=true; From 23b748aca3774768c89b6112b2ece090724d1027 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 5 Jun 2016 14:22:13 +0200 Subject: [PATCH 2/6] Fix: Accountancy - Access rights --- htdocs/accountancy/admin/account.php | 4 +++- htdocs/accountancy/admin/fiscalyear.php | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 3f251e0090b..99b78ff7c5c 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -43,7 +43,9 @@ $search_pcgtype = GETPOST("search_pcgtype"); $search_pcgsubtype = GETPOST("search_pcgsubtype"); // Security check -if (! $user->admin) +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->chartofaccount) accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 75411d6402f..199e04bb856 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2016 Alexandre Spangaro * * 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 @@ -30,12 +30,15 @@ $action = GETPOST('action'); $langs->load("admin"); $langs->load("compta"); -if (! $user->admin) +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->fiscalyear) accessforbidden(); $error = 0; -// List of statut +// List of status static $tmpstatut2label = array ( '0' => 'OpenFiscalYear', '1' => 'CloseFiscalYear' From e10db62b3ae39edb5c93eb93159b38e24609bfff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Jun 2016 13:29:37 +0200 Subject: [PATCH 3/6] Fix a deadlock situation. If order set to billed by error, no way to solve situation. --- htdocs/commande/card.php | 16 +++++++- htdocs/commande/class/commande.class.php | 52 +++++++++++++++++++++++- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 489eee73932..ee576ed48e5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -445,7 +445,15 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + else if ($action == 'classifyunbilled' && $user->rights->commande->creer) + { + $ret=$object->classifyUnBilled(); + + if ($ret < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + // Positionne ref commande client else if ($action == 'set_ref_client' && $user->rights->commande->creer) { $object->set_ref_client($user, GETPOST('ref_client')); @@ -2373,7 +2381,11 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } } - + if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { + if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + print ''; + } + } // Clone if ($user->rights->commande->creer) { print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 06628ee4ea5..30d22e7588e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2420,7 +2420,57 @@ class Commande extends CommonOrder return $this->classifyBilled(); } - + /** + * Classify the order as not invoiced + * + * @return int <0 if ko, >0 if ok + */ + function classifyUnBilled() + { + global $conf, $user, $langs; + $error = 0; + + $this->db->begin(); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0'; + $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; + + dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG); + if ($this->db->query($sql)) + { + // Call trigger + $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user); + if ($result < 0) $error++; + // End call triggers + + if (! $error) + { + $this->facturee=0; // deprecated + $this->billed=0; + + $this->db->commit(); + return 1; + } + else + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** * Update a line in database * From fb254d3287105bc5dc1b188ce0f266b4f0dbd36e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Jun 2016 13:47:46 +0200 Subject: [PATCH 4/6] Update changelog for 3.9.2 --- ChangeLog | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index ef52f808ec7..052b8bcaaf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,47 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. + +***** ChangeLog for 3.9.2 compared to 3.9.1 ***** +FIX: #4813 Won translation for the key OppStatusWON instead OppStatusWIN +FIX: #5008 SQL error when editing the reference of a supplier invoice that already exists +FIX: #5236 Cron module activated but "Modules tools" does not appear in the left menu. +FIX: Accountancy - 3.9 - Chart of accounts are limited on only one country +FIX: bug on email template +FIX: Can't create a stock transfer from product card +FIX: can't fetch by siret or siren because of first "if" +FIX: Check stock of product by warehouse if $entrepot_id defined on shippings +FIX: Compatible with multicompany +FIX: Creation of the second ressource type fails. +FIX: end of select when no fournprice +FIX: Filter on assigned to was preselected on current user on list "All events" (instead of no filtering) +FIX: Filter on category tag for suppliers +FIX: hook on group card called but not initialized +FIX: Infinite loop on menu tree output for edition +FIX: Can show tree of entries added by external modules using fk_mainmenu and fk_leftmenu instead of fk_menu. +FIX: init var at wrong place report incorrect "shippable" flag on draft order. +FIX: It doesn't check if there is enough stock to update the lines of orders/invoices +FIX: Menu statistics was not visible if module proposal was not enabled +FIX: Merge manually PR #5161 - Bad translation key +FIX: missing column when module was installed before standard integration +FIX: Missing number total of modules +FIX: Not filtering correctly when coming from dashboard +FIX: PROPAL_MERGE_PDF with PRODUCT_USE_OLD_PATH +FIX: Remove PHP Warning: Creating default object from empty value. +FIX: same page added several times on mergepropal option +FIX: search on date into supplier invoice list dont work because of status -1 +FIX: Search supplier ref on contract +FIX: Split of credit note into discount page generates records not correctly recognised as credit note. +FIX: SQL error function on getAvailableDiscounts function, on bill create mode if socid is empty +FIX: #5087 +FIX: #5108 +FIX: #5163 +FIX: #5195 +FIX: #5203 +FIX: #5207 +FIX: #5209 +FIX: #5230 + ***** ChangeLog for 3.9.1 compared to 3.9.* ***** FIX: #3815 Call to undefined function local_by_date() FIX: #4424 Missing email of user popup in supplier orders area From 4c922f073b876ec403dd54f3022a1d6afb573169 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Jun 2016 18:21:58 +0200 Subject: [PATCH 5/6] FIX Can't create thirdparty or validate invoice if profid is mandatory and profid does not exists for other countries --- htdocs/compta/facture.php | 27 ++++++++++++++------------- htdocs/societe/soc.php | 23 +++++++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 85bcf2c68fa..04951cbb6cd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -392,21 +392,22 @@ if (empty($reshook)) // Check parameters - // Check for mandatory prof id - for($i = 1; $i < 6; $i ++) + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; - $idprof = 'idprof' . $i; - if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) - { - if (! $error) - $langs->load("errors"); - $error ++; - - setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors'); - } + for ($i = 1; $i <= 6; $i++) + { + $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; + $idprof = 'idprof' . $i; + if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) + { + if (! $error) $langs->load("errors"); + $error++; + setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors'); + } + } } - + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 85eacc44341..012aaf374e2 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -396,7 +396,7 @@ if (empty($reshook)) // Only for companies if (!($object->particulier || $private)) { - for ($i = 1; $i < 5; $i++) + for ($i = 1; $i <= 6; $i++) { $slabel="idprof".$i; $_POST[$slabel]=trim($_POST[$slabel]); @@ -411,15 +411,18 @@ if (empty($reshook)) } } - $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) - { - $langs->load("errors"); - $error++; - $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = (($action=='add'||$action=='create')?'create':'edit'); - } + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->country_id == $mysoc->country_id) + { + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + { + $langs->load("errors"); + $error++; + $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); + $action = (($action=='add'||$action=='create')?'create':'edit'); + } + } } } } From 630a063283c15a0113b68fae01273ed5bd2f8459 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Jun 2016 18:21:58 +0200 Subject: [PATCH 6/6] FIX Can't create thirdparty or validate invoice if profid is mandatory and profid does not exists for other countries Conflicts: htdocs/compta/facture.php --- htdocs/compta/facture.php | 27 ++++++++++++++------------- htdocs/societe/soc.php | 23 +++++++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ccfd057ccde..e805d1ecac9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -390,21 +390,22 @@ if (empty($reshook)) // Check parameters - // Check for mandatory prof id - for($i = 1; $i < 6; $i ++) + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; - $idprof = 'idprof' . $i; - if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) - { - if (! $error) - $langs->load("errors"); - $error ++; - - setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); - } + for ($i = 1; $i <= 6; $i++) + { + $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; + $idprof = 'idprof' . $i; + if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) + { + if (! $error) $langs->load("errors"); + $error++; + setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), null, 'errors'); + } + } } - + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change = $object->hasProductsOrServices(2); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 76680649958..3a5ed38e2d5 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -363,7 +363,7 @@ if (empty($reshook)) // Only for companies if (!($object->particulier || $private)) { - for ($i = 1; $i < 5; $i++) + for ($i = 1; $i <= 6; $i++) { $slabel="idprof".$i; $_POST[$slabel]=trim($_POST[$slabel]); @@ -378,15 +378,18 @@ if (empty($reshook)) } } - $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) - { - $langs->load("errors"); - $error++; - $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = (($action=='add'||$action=='create')?'create':'edit'); - } + // Check for mandatory prof id (but only if country is than than ours) + if ($mysoc->country_id > 0 && $object->country_id == $mysoc->country_id) + { + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + { + $langs->load("errors"); + $error++; + $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); + $action = (($action=='add'||$action=='create')?'create':'edit'); + } + } } } }