From 5b6d5df159e99ea2ac4da32d6686ebae60c8c6e7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 30 Nov 2016 16:02:55 +0100 Subject: [PATCH 01/17] FIX : delete contract extrafields on contract deletion --- htdocs/contrat/class/contrat.class.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 74ea611dc96..e4bee39c39e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -56,7 +56,7 @@ class Contrat extends CommonObject * @var string */ var $ref_customer; - + /** * Supplier reference of the contract * @var string @@ -536,7 +536,7 @@ class Contrat extends CommonObject return -1; } } - + /** * Load a contract from database * @@ -1134,6 +1134,16 @@ class Contrat extends CommonObject } } + // Removed extrafields + if (! $error) { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } + if (! $error) { // We remove directory @@ -1333,7 +1343,7 @@ class Contrat extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,$mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1356,9 +1366,9 @@ class Contrat extends CommonObject if (empty($pa_ht)) $pa_ht=0; - + // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0) { @@ -1515,7 +1525,7 @@ class Contrat extends CommonObject $localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); $tvatx = preg_replace('/\s*\(.*\)/','',$tvatx); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1539,7 +1549,7 @@ class Contrat extends CommonObject if (empty($pa_ht)) $pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($pu_ht, $remise_percent)) < 0) { @@ -2571,7 +2581,7 @@ class ContratLigne extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { From c17d354367937f9b9271cdc4807ab9ac1a6c350a Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 30 Nov 2016 16:48:27 +0100 Subject: [PATCH 02/17] Fix propal updateline oldcopy extrafields --- htdocs/comm/propal/class/propal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6c5fdcbbec4..d94932d10c8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -651,6 +651,7 @@ class Propal extends CommonObject //Fetch current line from the database and then clone the object and set it in $oldline property $line = new PropaleLigne($this->db); $line->fetch($rowid); + $line->fetch_optionals(); // Fetch extrafields for oldcopy $staticline = clone $line; From 191474a5db73aaa05509cc325776efe82c6080c5 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 2 Dec 2016 11:35:12 +0100 Subject: [PATCH 03/17] FIX : Update intervention lline crash with PgSQL --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 59ea03476c4..f1c2ad16879 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1202,7 +1202,7 @@ class FichinterLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; - $sql.= ",date=".$this->db->idate($this->datei); + $sql.= ",date='".$this->db->idate($this->datei)."'"; $sql.= ",duree=".$this->duration; $sql.= ",rang='".$this->rang."'"; $sql.= " WHERE rowid = ".$this->rowid; From de5ad57af40a432c673070b6dc160bca93e80ffd Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 2 Dec 2016 12:02:08 +0100 Subject: [PATCH 04/17] FIX : export extrafields must not include separe type --- htdocs/core/extrafieldsinexport.inc.php | 62 +++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index 1a608f6bc2e..82c26a91991 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -1,4 +1,4 @@ -db->fetch_object($resql)) { - $fieldname=$keyforaliasextra.'.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $tmp=''; - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) { - $tmpkeys=array_keys($tmpparam['options']); - $tmp=array_shift($tmpkeys); - } - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; - break; + if ($obj->type!='separate') { + $fieldname=$keyforaliasextra.'.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $tmp=''; + $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null + if ($tmpparam['options'] && is_array($tmpparam['options'])) { + $tmpkeys=array_keys($tmpparam['options']); + $tmp=array_shift($tmpkeys); + } + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]=$keyforelement; } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]=$keyforelement; } } // End add axtra fields From 411e82b7a3b528072438143e88cd4c309fa95f38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Dec 2016 14:52:38 +0100 Subject: [PATCH 05/17] Fix button set to paid not always visible when it should. --- htdocs/expensereport/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index d3b25d2277f..9112f8ee99b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1999,7 +1999,8 @@ if ($action != 'create' && $action != 'edit') // If bank module is not used if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5) { - if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) + //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) + if ($object->paid == 0) { print '"; } From 64f76d8cab87e6489aefd1ee73bd666ff7da5683 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 2 Dec 2016 17:02:49 +0100 Subject: [PATCH 06/17] Fix : bad function name --- dev/skeletons/skeleton_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 38aa50cf593..7a3a94da477 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2016 Jean-François Ferry * * 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 @@ -301,7 +301,7 @@ if ($resql) $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
'; if (! empty($moreforfilter)) From a75577516d1bf37c69418258b2dc5e9beec821ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:13:04 +0100 Subject: [PATCH 07/17] Fix pb with multicompany on expense report --- htdocs/expensereport/export_csv.php | 1 + htdocs/expensereport/index.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/expensereport/payment/card.php | 2 +- htdocs/expensereport/payment/payment.php | 5 +++-- htdocs/expensereport/synchro_compta.php | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php index 3cf520c6739..d55e262e2e4 100644 --- a/htdocs/expensereport/export_csv.php +++ b/htdocs/expensereport/export_csv.php @@ -128,6 +128,7 @@ if (isset($_POST['action'])) $sql = "SELECT d.rowid, d.ref, d.total_ht, d.total_tva, d.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; + $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; $sql.= " ORDER BY d.rowid"; $result = $db->query($sql); diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 117ecc5e3c4..83e45d2a1b7 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -147,7 +147,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u" if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE u.rowid = d.fk_user_author"; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND d.fk_user_author IN ('.join(',',$childids).')'; -//$sql.= " AND d.entity = ".$conf->entity; +$sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND d.fk_user_author = ".$socid; $sql.= $db->order($sortfield,$sortorder); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index b857b9c92d4..476ef2224f5 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -133,7 +133,7 @@ $sql.= " d.date_debut, d.date_fin, d.date_valid,"; $sql.= " u.rowid as id_user, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; -$sql.= " WHERE d.entity = ".$conf->entity; +$sql.= ' WHERE d.entity IN ('.getEntity('expensereport', 1).')'; // Search all if (!empty($sall)) { diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 19d5b3206f7..f9ba5af3dc0 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -199,7 +199,7 @@ $disable_delete = 0; $sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; -$sql.= ' AND er.entity = '.$conf->entity; +$sql.= ' AND er.entity IN ('.getEntity('expensereport', 1).')'; $sql.= ' AND per.rowid = '.$id; dol_syslog("expensereport/payment/card.php", LOG_DEBUG); diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index c4351e4d038..e361a9954c0 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -193,8 +193,9 @@ if (GETPOST("action") == 'create') print ''.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).''; $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql.= " WHERE p.fk_expensereport = ".$chid; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; + $sql.= " WHERE p.fk_expensereport = e.rowid AND p.fk_expensereport = ".$chid; + $sql.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/expensereport/synchro_compta.php b/htdocs/expensereport/synchro_compta.php index 31c2d985840..eba616d2620 100644 --- a/htdocs/expensereport/synchro_compta.php +++ b/htdocs/expensereport/synchro_compta.php @@ -139,6 +139,7 @@ else: $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid"; $sql.= " WHERE d.fk_statut = 6"; + $sql.= ' AND d.entity IN ('.getEntity('expensereport', 1).')'; $sql.= " ORDER BY d.date_valid DESC"; $resql=$db->query($sql); From 7a3b3090139e9300504d4f3ad4cd43911523a361 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:22:26 +0100 Subject: [PATCH 08/17] Fix width --- htdocs/compta/paiement/cheque/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index ebfd598ee0b..9ea4d6eb1e0 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -160,7 +160,7 @@ if ($resql) print ''; print ' '; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -179,7 +179,7 @@ if ($resql) print ""; // Num ref cheque - print ''; + print ''; $checkdepositstatic->id=$objp->rowid; $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid); $checkdepositstatic->statut=$objp->statut; From 69b5baebc53450ce9a3fb6c12c3a5da60903266d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 15:54:06 +0100 Subject: [PATCH 09/17] FIX rendering of output of estimated amount on project overview page. --- htdocs/projet/element.php | 55 ++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index cbd22856e4c..1d9ffd61a99 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -812,6 +812,8 @@ foreach ($listofreferent as $key => $value) $warning=''; if (empty($value['disableamount'])) { + $total_ht_by_line=null; + $othermessage=''; if ($tablename == 'don') $total_ht_by_line=$element->amount; elseif ($tablename == 'projet_task') { @@ -828,7 +830,7 @@ foreach ($listofreferent as $key => $value) } else { - print $langs->trans("ModuleDisabled"); + $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); } } else @@ -836,9 +838,13 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line=$element->total_ht; } print ''; - if (! $qualifiedfortotal) print ''; - print (isset($total_ht_by_line)?price($total_ht_by_line):' '); - if (! $qualifiedfortotal) print ''; + if ($othermessage) print $othermessage; + if (isset($total_ht_by_line)) + { + if (! $qualifiedfortotal) print ''; + print price($total_ht_by_line); + if (! $qualifiedfortotal) print ''; + } if ($warning) print ' '.img_warning($warning); print ''; } @@ -847,20 +853,33 @@ foreach ($listofreferent as $key => $value) // Amount inc tax if (empty($value['disableamount'])) { + $total_ttc_by_line=null; if ($tablename == 'don') $total_ttc_by_line=$element->amount; elseif ($tablename == 'projet_task') { - $defaultvat = get_default_tva($mysoc, $mysoc); - $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT'); + if (! empty($conf->salaries->enabled)) + { + // TODO Permission to read daily rate + $defaultvat = get_default_tva($mysoc, $mysoc); + $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)),'MT'); + } + else + { + $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); + } } else { $total_ttc_by_line=$element->total_ttc; } print ''; - if (! $qualifiedfortotal) print ''; - print (isset($total_ttc_by_line)?price($total_ttc_by_line):' '); - if (! $qualifiedfortotal) print ''; + if ($othermessage) print $othermessage; + if (isset($total_ttc_by_line)) + { + if (! $qualifiedfortotal) print ''; + print price($total_ttc_by_line); + if (! $qualifiedfortotal) print ''; + } if ($warning) print ' '.img_warning($warning); print ''; } @@ -923,15 +942,25 @@ foreach ($listofreferent as $key => $value) if ($breakline) print $breakline; + // Total print ''.$langs->trans("Number").': '.$i.''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalHT").' : '.price($total_ht).''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Total").' : '.price($total_ht).''; - if (empty($value['disableamount'])) print ''.$langs->trans("TotalHT").' : '.price($total_ht).''; - else print ''; + print ''; + if (empty($value['disableamount'])) + { + if (! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); + } + print ''; //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''; - if (empty($value['disableamount'])) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; - else print ''; + print ''; + if (empty($value['disableamount'])) + { + + if (! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); + } + print ''; print ' '; print ''; } From fe54673a87157ba4461bab8d942bd9a0a6732b3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 18:13:23 +0100 Subject: [PATCH 10/17] FIX List of people able to validate an expense report was not complete. --- htdocs/expensereport/card.php | 14 +++++++++----- htdocs/expensereport/class/expensereport.class.php | 14 ++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 9112f8ee99b..3f827de3540 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1117,11 +1117,15 @@ if ($action == 'create') print ''; $object = new ExpenseReport($db); $include_users = $object->fetch_users_approver_expensereport(); - $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users - if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; - if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator'); - $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users); - print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport"); + else + { + $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver + if (GETPOST('fk_user_validator') > 0) $defaultselectuser=GETPOST('fk_user_validator'); + $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } print ''; print ''; if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a05805c7f74..9349e0e72e0 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1411,7 +1411,8 @@ class ExpenseReport extends CommonObject /** - * Return list of people with permission to validate trips and expenses + * Return list of people with permission to validate expense reports. + * Search for permission "approve expense report" * * @return array Array of user ids */ @@ -1419,10 +1420,15 @@ class ExpenseReport extends CommonObject { $users_validator=array(); - $sql = "SELECT fk_user"; + $sql = "SELECT DISTINCT ur.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ur.fk_id = rd.id and module = 'expensereport' AND perms = 'approve'"; // Permission 'Approve'; - + $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql.= "UNION"; + $sql.= " SELECT DISTINCT ugu.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve'; + //print $sql; + dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql); $result = $this->db->query($sql); if($result) From 80f2623f9f66ec21ec10e48817007ac8840025f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 18:20:57 +0100 Subject: [PATCH 11/17] FIX bad permission to see contract on home page --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index faa2eb9dcee..ee3c2490aeb 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -173,7 +173,7 @@ if (empty($user->societe_id)) ! empty($conf->propal->enabled) && $user->rights->propale->lire, ! empty($conf->commande->enabled) && $user->rights->commande->lire, ! empty($conf->facture->enabled) && $user->rights->facture->lire, - ! empty($conf->contrat->enabled) && $user->rights->contrat->activer, + ! empty($conf->contrat->enabled) && $user->rights->contrat->lire, ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), From b0ac0624dbf8769ebb1280fd59967f862fcc63a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 18:21:55 +0100 Subject: [PATCH 12/17] FIX bad permission to see contract statistics --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 233bda18542..14e4f2cbf7b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2035,7 +2035,7 @@ class Contrat extends CommonObject $sql = "SELECT count(c.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if (!$user->rights->contrat->activer && !$user->societe_id) + if (!$user->rights->contrat->lire && !$user->societe_id) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; From 6e5a8b6787a12ee0ce4b5f48d10e1d1ded0e9fa7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 19:14:16 +0100 Subject: [PATCH 13/17] FIX Some statistics not compatible with multicompany module. --- htdocs/commande/class/commandestats.class.php | 3 ++- .../class/expensereportstats.class.php | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index e38097e4e3a..81488bdb1d6 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -81,7 +81,8 @@ class CommandeStats extends Stats $this->where.= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= " AND c.entity = ".$conf->entity; + $this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')'; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($this->socid) { diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 57c970b9fc8..deaa386da9d 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -56,14 +56,17 @@ class ExpenseReportStats extends Stats $this->userid = $userid; $object=new ExpenseReport($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element; + $this->from = MAIN_DB_PREFIX.$object->table_element." as e"; $this->field='total_ht'; - $this->where = " fk_statut > 0 and date_valid > '2000-01-01'"; + $this->where = " e.fk_statut > 0"; + //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only approved + $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; + //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) { - $this->where.=" AND fk_soc = ".$this->socid; + $this->where.=" AND e.fk_soc = ".$this->socid; } // Only me and subordinates @@ -71,10 +74,10 @@ class ExpenseReportStats extends Stats { $childids = $user->getAllChildIds(); $childids[]=$user->id; - $this->where.=" AND fk_user_author IN (".(join(',',$childids)).")"; + $this->where.=" AND e.fk_user_author IN (".(join(',',$childids)).")"; } - if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid; } @@ -102,9 +105,9 @@ class ExpenseReportStats extends Stats */ function getNbByMonth($year) { - $sql = "SELECT MONTH(date_valid) as dm, count(*)"; + $sql = "SELECT MONTH(e.date_valid) as dm, count(*)"; $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(date_valid) = ".$year; + $sql.= " WHERE YEAR(e.date_valid) = ".$year; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -123,9 +126,9 @@ class ExpenseReportStats extends Stats */ function getAmountByMonth($year) { - $sql = "SELECT date_format(date_valid,'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -143,9 +146,9 @@ class ExpenseReportStats extends Stats */ function getAverageByMonth($year) { - $sql = "SELECT date_format(date_valid,'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -160,7 +163,7 @@ class ExpenseReportStats extends Stats */ function getAllByYear() { - $sql = "SELECT date_format(date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; From 9c47f3d3fdc9ca64df9dd95c0ec197eca3280e64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 19:41:03 +0100 Subject: [PATCH 14/17] Restore protection to avoid errors --- htdocs/expensereport/class/expensereportstats.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index deaa386da9d..59bcc9841a9 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -60,7 +60,7 @@ class ExpenseReportStats extends Stats $this->field='total_ht'; $this->where = " e.fk_statut > 0"; - //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only approved + $this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; //$this->where.= " AND entity = ".$conf->entity; From 4abd417a6adf0a4713dccb9417ffabb41ce8bbb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Dec 2016 19:50:52 +0100 Subject: [PATCH 15/17] Corrupted data must be fixed by repair not by code hack. --- htdocs/expensereport/class/expensereportstats.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 59bcc9841a9..25ead4de0c1 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -60,7 +60,7 @@ class ExpenseReportStats extends Stats $this->field='total_ht'; $this->where = " e.fk_statut > 0"; - $this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. + //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; //$this->where.= " AND entity = ".$conf->entity; From 0d7ab3301bfd0b04ca355ac0cf21cebe80cc4196 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Dec 2016 11:52:07 +0100 Subject: [PATCH 16/17] FIX in export. Error when using a separate extrafields. --- htdocs/core/extrafieldsinexport.inc.php | 2 +- htdocs/core/modules/modAdherent.class.php | 16 +--- htdocs/core/modules/modProjet.class.php | 89 +++-------------------- htdocs/exports/class/export.class.php | 3 + 4 files changed, 18 insertions(+), 92 deletions(-) diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index 1a608f6bc2e..332a7d0547e 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -8,7 +8,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) } // Add extra fields -$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND entity IN (0, ".$conf->entity.')'; +$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.')'; //print $sql; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index ea611fe947a..871d925e069 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -272,19 +272,11 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount'); - $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Numeric'); + $this->export_TypeFields_array[$r]=array('a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.cotisation'=>'Numeric'); $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription'); - - // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity = ".$conf->entity; - $resql=$this->db->query($sql); - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_entities_array[$r][$fieldname]='member'; - } + // Add extra fields + $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 2d71eaba5a1..73196113751 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -210,101 +210,32 @@ class modProjet extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("projet","export")); - $this->export_dependencies_array[$r]=array('task_time'=>'ptt.rowid'); + $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid'); $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', - 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text", - 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", - 'ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text"); + 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.fk_opp_status'=>"Text",'p.opp_percent'=>'Numeric','p.description'=>"Text", + 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", + 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text"); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', 's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project"); + 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.fk_opp_status'=>"project",'p.opp_percent'=>'project','p.description'=>"project"); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description"); + 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','p.fk_opp_status'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.description'=>"Description"); // Add fields for project $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array()); - // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet'"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $tmp=''; - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; - break; - } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='project'; - } - } - // End add extra fields - + $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // Add fields for tasks $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription")); $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask")); // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task'"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra2.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $tmp=''; - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; - break; - } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='projecttask'; - } - } + $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add extra fields $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote")); $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time")); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 496092b7f73..c2c64f4a9eb 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -377,6 +377,9 @@ class Export case 'Duree': case 'Numeric': case 'Number': + // Must be a string text to allow to use comparison strings like "<= 999" + $szFilterField=''; + break; case 'Status': if (! empty($conf->global->MAIN_ACTIVATE_HTML5)) $szFilterField=''; else $szFilterField=''; From cfff6a8cb80aafcf8981bbba39694924ce837215 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Dec 2016 14:05:43 +0100 Subject: [PATCH 17/17] FIX Export of opportunity status must be code, not id. --- htdocs/core/modules/modProjet.class.php | 9 +++++---- htdocs/projet/card.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 73196113751..5c6616b948b 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -214,17 +214,17 @@ class modProjet extends DolibarrModules $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', 's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', - 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.fk_opp_status'=>"Text",'p.opp_percent'=>'Numeric','p.description'=>"Text", + 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.description'=>"Text", 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text"); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', 's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', - 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.fk_opp_status'=>"project",'p.opp_percent'=>'project','p.description'=>"project"); + 'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'cls.code'=>"project",'p.opp_percent'=>'project','p.description'=>"project"); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country', 's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', - 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','p.fk_opp_status'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.description'=>"Description"); + 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.description'=>"Description"); // Add fields for project $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array()); @@ -243,7 +243,8 @@ class modProjet extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index adc55131a10..ad1d718fc55 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -852,7 +852,7 @@ else /* Change percent of default percent of new status is higher */ if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent)) { - if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->trans("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\'); + if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\'); jQuery("#opp_percent").val(defaultpercent); }