From 3fd7c26cf1602fa4aa0d61119c9f3ae0641f3f79 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Jun 2015 07:15:40 +0200 Subject: [PATCH 1/8] Fix: disable hook calling --- htdocs/compta/facture/mergepdftool.php | 4 ++-- htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index ff1bde24466..146ee53736c 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -275,7 +275,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s { $arrayofinclusion=array(); foreach($_POST['toGenerate'] as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/'); - $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC); + $factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true); // liste les fichiers $files = array(); @@ -284,7 +284,7 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s { foreach($factures as $facture) { - if(strstr($facture["name"],$basename)) + if (strstr($facture["name"],$basename)) { $files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"]; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 05fdcc96624..a8eeb8d3214 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -152,7 +152,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - $file_list = array_merge($file_list,dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode)); + $file_list = array_merge($file_list,dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook)); } } else if (! $isdir && (($types == "files") || ($types == "all"))) From a51a8aff592ad3d3ddad906899f1d93877ccb9a2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Jun 2015 09:10:48 +0200 Subject: [PATCH 2/8] Fix: possibility to show pdf, dot, doc, etc... --- htdocs/core/class/html.formfile.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2fea621626e..699060afcfc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -689,7 +689,7 @@ class FormFile $out=''; $this->numoffiles=0; - $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir).'.pdf','/'), '\.meta$|\.png$'); + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // For ajax treatment $out.= '
'.img_picto('', 'refresh').'
'."\n"; @@ -718,7 +718,7 @@ class FormFile $mime=dol_mimetype($relativepath,'',0); if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; $out.= '>'; - $out.= img_pdf($file["name"],2); + $out.= img_mime($relativepath, $file["name"]); $out.= ''."\n"; $this->numoffiles++; From e3d16140045191b9b648be71d488343e9d70f8c8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Jun 2015 09:21:44 +0200 Subject: [PATCH 3/8] Fix: ereg more simple --- htdocs/comm/askpricesupplier/card.php | 4 ++-- htdocs/comm/propal.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/compta/facture.php | 4 ++-- htdocs/expedition/card.php | 4 ++-- htdocs/fichinter/card.php | 4 ++-- htdocs/fourn/commande/card.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php index 72654ac3da4..bfbcc9d4273 100644 --- a/htdocs/comm/askpricesupplier/card.php +++ b/htdocs/comm/askpricesupplier/card.php @@ -1738,7 +1738,7 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/')); + $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language @@ -1764,7 +1764,7 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/')); + $fileparams = dol_most_recent_file($conf->askpricesupplier->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 55b6543c195..8cd48a75f40 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -2340,7 +2340,7 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language @@ -2365,7 +2365,7 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index cc5251e6592..79f752f8355 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2358,7 +2358,7 @@ if ($action == 'create' && $user->rights->commande->creer) dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6b145ffd4f2..a461d1b9c82 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3821,7 +3821,7 @@ if ($action == 'create') $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language @@ -3846,7 +3846,7 @@ if ($action == 'create') dol_print_error($db, $result); exit(); } - $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 06395c89526..47878c7e75f 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1530,7 +1530,7 @@ else if ($id || $ref) { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; // Define output language @@ -1557,7 +1557,7 @@ else if ($id || $ref) dol_print_error($db,$result); exit; } - $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index e6c9c4d00d6..48eaa8c77aa 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1755,7 +1755,7 @@ else if ($id > 0 || ! empty($ref)) { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; // Define output language @@ -1782,7 +1782,7 @@ else if ($id > 0 || ! empty($ref)) dol_print_error($db,$result); exit; } - $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8ae5b6da1ee..b79663445ed 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2265,7 +2265,7 @@ elseif (! empty($object->id)) { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; // Define output language @@ -2292,7 +2292,7 @@ elseif (! empty($object->id)) dol_print_error($db,$result); exit; } - $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; } From 36486d632903377910ccd714c489a29739941ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 11 Jun 2015 10:57:08 +0200 Subject: [PATCH 4/8] FIX #2987: removed dead function moneyMeter() --- htdocs/core/lib/images.lib.php | 158 --------------------------------- 1 file changed, 158 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index f7592c69c08..7e47f755a7e 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -547,161 +547,3 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ return $imgThumbName; } - - -/** - * This function returns the html for the moneymeter. - * - * @param int $actualValue amount of actual money - * @param int $pendingValue amount of money of pending memberships - * @param int $intentValue amount of intended money (that's without the amount of actual money) - * @return string thermometer htmlLegenda - */ -function moneyMeter($actualValue=0, $pendingValue=0, $intentValue=0) -{ - global $langs; - - // variables - $height="200"; - $maximumValue=125000; - - $imageDir = "http://eucd.info/images/therm/"; - - $imageTop = $imageDir . "therm_top.png"; - $imageMiddleActual = $imageDir . "therm_actual.png"; - $imageMiddlePending = $imageDir . "therm_pending.png"; - $imageMiddleIntent = $imageDir . "therm_intent.png"; - $imageMiddleGoal = $imageDir . "therm_goal.png"; - $imageIndex = $imageDir . "therm_index.png"; - $imageBottom = $imageDir . "therm_bottom.png"; - $imageColorActual = $imageDir . "therm_color_actual.png"; - $imageColorPending = $imageDir . "therm_color_pending.png"; - $imageColorIntent = $imageDir . "therm_color_intent.png"; - - $formThermTop = ' - - - -
- - - - - - - - - - - -
- '; - - $formSection = ' - '; - - $formThermbottom = ' -
-
-
'; - - // legenda - - $legendaActual = "€ " . round($actualValue); - $legendaPending = "€ " . round($pendingValue); - $legendaIntent = "€ " . round($intentValue); - $legendaTotal = "€ " . round($actualValue + $pendingValue + $intentValue); - $formLegenda = ' - - - - - - -
 '.$langs->trans("Paid").':
' . $legendaActual . '
 '.$langs->trans("Waiting").':
' . $legendaPending . '
 '.$langs->trans("Promesses").':
' . $legendaIntent . '
 Total:
' . $legendaTotal . '
- - '; - - // check and edit some values - - $error = 0; - if ( $maximumValue <= 0 || $height <= 0 || $actualValue < 0 || $pendingValue < 0 || $intentValue < 0) - { - return "The money meter could not be processed
\n"; - } - if ( $actualValue > $maximumValue ) - { - $actualValue = $maximumValue; - $pendingValue = 0; - $intentValue = 0; - } - else - { - if ( ($actualValue + $pendingValue) > $maximumValue ) - { - $pendingValue = $maximumValue - $actualValue; - $intentValue = 0; - } - else - { - if ( ($actualValue + $pendingValue + $intentValue) > $maximumValue ) - { - $intentValue = $maximumValue - $actualValue - $pendingValue; - } - } - } - - // start writing the html (from bottom to top) - - // bottom - $thermometer = $formThermbottom; - - // actual - $sectionHeight = round(($actualValue / $maximumValue) * $height); - $totalHeight = $sectionHeight; - if ( $sectionHeight > 0 ) - { - $section = $formSection; - $section = str_replace("{image}", $imageMiddleActual, $section); - $section = str_replace("{height}", $sectionHeight, $section); - $thermometer = $section . $thermometer; - } - - // pending - $sectionHeight = round(($pendingValue / $maximumValue) * $height); - $totalHeight += $sectionHeight; - if ( $sectionHeight > 0 ) - { - $section = $formSection; - $section = str_replace("{image}", $imageMiddlePending, $section); - $section = str_replace("{height}", $sectionHeight, $section); - $thermometer = $section . $thermometer; - } - - // intent - $sectionHeight = round(($intentValue / $maximumValue) * $height); - $totalHeight += $sectionHeight; - if ( $sectionHeight > 0 ) - { - $section = $formSection; - $section = str_replace("{image}", $imageMiddleIntent, $section); - $section = str_replace("{height}", $sectionHeight, $section); - $thermometer = $section . $thermometer; - } - - // goal - $sectionHeight = $height- $totalHeight; - if ( $sectionHeight > 0 ) - { - $section = $formSection; - $section = str_replace("{image}", $imageMiddleGoal, $section); - $section = str_replace("{height}", $sectionHeight, $section); - $thermometer = $section . $thermometer; - } - - // top - $thermometer = $formThermTop . $thermometer; - - return $thermometer . $formLegenda; -} - From 42b04102ba58305ca8ff2bb534ce81c1ce1dcef3 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 11 Jun 2015 12:40:16 +0200 Subject: [PATCH 5/8] New: Add due date filter on invoices lists --- htdocs/compta/facture/list.php | 23 +++++++++++++++++++++- htdocs/fourn/facture/list.php | 36 ++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 08a14b75602..6d9a6329d4e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 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 @@ -88,6 +89,9 @@ $search_sale = GETPOST('search_sale','int'); $day = GETPOST('day','int'); $month = GETPOST('month','int'); $year = GETPOST('year','int'); +$day_lim = GETPOST('day_lim','int'); +$month_lim = GETPOST('month_lim','int'); +$year_lim = GETPOST('year_lim','int'); $filtre = GETPOST('filtre'); // Security check @@ -213,6 +217,19 @@ else if ($year > 0) { $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +if ($month_lim > 0) +{ + if ($year_lim > 0 && empty($day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'"; + else if ($year_lim > 0 && ! empty($day_lim)) + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; + else + $sql.= " AND date_format(f.date_lim_reglement, '%m') = '".$month_lim."'"; +} +else if ($year_lim > 0) +{ + $sql.= " AND f.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; +} if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { @@ -322,7 +339,11 @@ if ($resql) print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); + print ''; print ''; print ''; print ' '; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 010e9b95ae6..88a82573d7a 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -8,7 +8,8 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 juanjo Menent * Copyright (C) 2015 Abbes Bahfir - + * Copyright (C) 2015 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 * the Free Software Foundation; either version 3 of the License, or @@ -74,8 +75,12 @@ $search_company = GETPOST("search_company","alpha"); $search_amount_no_tax = GETPOST("search_amount_no_tax","alpha"); $search_amount_all_tax = GETPOST("search_amount_all_tax","alpha"); $search_status=GETPOST('search_status','alpha'); +$day = GETPOST("day","int"); $month = GETPOST("month","int"); $year = GETPOST("year","int"); +$day_lim = GETPOST('day_lim','int'); +$month_lim = GETPOST('month_lim','int'); +$year_lim = GETPOST('year_lim','int'); $filter = GETPOST("filtre"); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test must be present to be compatible with all browsers @@ -163,15 +168,30 @@ if ($search_ref_supplier) } if ($month > 0) { - if ($year > 0) + if ($year > 0 && empty($day)) $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; else - $sql.= " AND date_format(fac.datef, '%m') = '$month'"; + $sql.= " AND date_format(fac.datef, '%m') = '".$month."'"; } else if ($year > 0) { $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +if ($month_lim > 0) +{ + if ($year_lim > 0 && empty($day_lim)) + $sql.= " AND fac.date_lim_reglement BETWEEN '".$db->idate(dol_get_first_day($year_lim,$month_lim,false))."' AND '".$db->idate(dol_get_last_day($year_lim,$month_lim,false))."'"; + else if ($year_lim > 0 && ! empty($day_lim)) + $sql.= " AND fac.date_lim_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_lim, $day_lim, $year_lim))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_lim, $day_lim, $year_lim))."'"; + else + $sql.= " AND date_format(fac.date_lim_reglement, '%m') = '".$month_lim."'"; +} +else if ($year_lim > 0) +{ + $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year_lim,1,false))."' AND '".$db->idate(dol_get_last_day($year_lim,12,false))."'"; +} if ($search_label) { $sql .= natural_search('fac.libelle', $search_label); @@ -260,11 +280,15 @@ if ($resql) print ''; } print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $syear = $year; - $formother->select_year($syear?$syear:-1,'year',1, 20, 5); + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); print ''; - print ' '; print ''; print ''; print ''; From 6465e58032b8f06ed7f11a28e0e08679c1fdbd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 11 Jun 2015 14:50:11 +0200 Subject: [PATCH 6/8] Added tag/categories management to contact card Contact part of #2571 --- htdocs/contact/card.php | 63 +++++++++++++++++++++++++++++++-- htdocs/core/lib/contact.lib.php | 10 ------ 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 742378a2db3..e39c5502b4d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT. '/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $langs->load("companies"); $langs->load("users"); $langs->load("other"); @@ -220,7 +221,17 @@ if (empty($reshook)) { $error++; $errors=array_merge($errors,($object->error?array($object->error):$object->errors)); $action = 'create'; - } + } else { + // Categories association + $contcats = GETPOST( 'contcats', 'array' ); + if (!empty( $contcats )) { + $cat = new Categorie( $db ); + foreach ($contcats as $id_category) { + $cat->fetch( $id_category ); + $cat->add_type( $object, 'contact' ); + } + } + } } if (! $error && $id > 0) @@ -313,8 +324,22 @@ if (empty($reshook)) $result = $object->update($contactid, $user); - if ($result > 0) - { + if ($result > 0) { + // Categories association + // First we delete all categories association + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_contact'; + $sql .= ' WHERE fk_socpeople = ' . $object->id; + $db->query( $sql ); + + // Then we add the associated categories + $categories = GETPOST( 'contcats', 'array' ); + if (!empty( $categories )) { + $cat = new Categorie( $db ); + foreach ($categories as $id_category) { + $cat->fetch( $id_category ); + $cat->add_type( $object, 'contact' ); + } + } $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; @@ -580,6 +605,15 @@ else print $form->selectarray('priv',$selectarray,(GETPOST("priv",'alpha')?GETPOST("priv",'alpha'):$object->priv),0); print ''; + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { + print '' . fieldLabel( 'Categories', 'contcats' ) . ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, 'parent', null, null, 1 ); + print $form->multiselectarray( 'contcats', $cate_arbo, GETPOST( 'contcats', 'array' ), null, null, null, + null, '90%' ); + print ""; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -819,6 +853,20 @@ else print $object->getLibStatut(4); print ''; + // Categories + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { + print '' . fieldLabel( 'Categories', 'contcats' ) . ''; + print ''; + $cate_arbo = $form->select_all_categories( Categorie::TYPE_CONTACT, null, null, null, null, 1 ); + $c = new Categorie( $db ); + $cats = $c->containing( $object->id, Categorie::TYPE_CONTACT ); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray( 'contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); + print ""; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1043,6 +1091,15 @@ else print $object->getLibStatut(4); print ''; print ''."\n"; + + // Categories + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { + print '' . $langs->trans( "Categories" ) . ''; + print ''; + print $form->showCategories( $object->id, 'contact', 1 ); + print ''; + } + // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index 3a50b79edd7..40dab648de1 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -87,16 +87,6 @@ function contact_prepare_head(Contact $object) $head[$tab][2] = 'documents'; $tab++; - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $type = Categorie::TYPE_CONTACT; - $head[$tab][0] = DOL_URL_ROOT.'/categories/categorie.php?id='.$object->id."&type=".$type; - $head[$tab][1] = $langs->trans('Categories'); - $head[$tab][2] = 'category'; - $tab++; - } - // Info $head[$tab][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id; $head[$tab][1] = $langs->trans("Info"); From a337b6f874928cefba4e7e1e2ebff7b8f48e4157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9onard?= Date: Thu, 11 Jun 2015 23:18:29 +0200 Subject: [PATCH 7/8] Rename "duree" property of interventions to "duration" This also fixes the display problem of total duration on the "soleil" document model --- .../modules/fichinter/doc/pdf_soleil.modules.php | 6 +++--- htdocs/fichinter/card.php | 4 ++-- htdocs/fichinter/class/fichinter.class.php | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index c10c24508e8..9fe2eaf7488 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -241,7 +241,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->SetXY($this->marge_gauche, $tab_top + 5); $text=$object->description; - if ($object->duree > 0) + if ($object->duration > 0) { $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY); $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime; @@ -436,9 +436,9 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetXY($this->marge_gauche, $tab_top + 8); $text=$object->description; - if ($object->duree > 0) + if ($object->duration > 0) { - $totaltime=convertSecondToTime($object->duree,'all',$conf->global->MAIN_DURATION_OF_WORKDAY); + $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY); $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime; } $desc=dol_htmlentitiesbr($text,1); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index e6c9c4d00d6..4e609f49269 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -160,7 +160,7 @@ else if ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->fich else if ($action == 'add' && $user->rights->ficheinter->creer) { $object->socid = $socid; - $object->duree = GETPOST('duree','int'); + $object->duration = GETPOST('duration','int'); $object->fk_project = GETPOST('projectid','int'); $object->fk_contrat = GETPOST('contratid','int'); $object->author = $user->id; @@ -1256,7 +1256,7 @@ else if ($id > 0 || ! empty($ref)) { // Duration print ''.$langs->trans("TotalDuration").''; - print ''.convertSecondToTime($object->duree, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; + print ''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).''; print ''; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index b72dec1f6fa..5e88cc94243 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -53,7 +53,7 @@ class Fichinter extends CommonObject var $datec; var $datev; var $datem; - var $duree; + var $duration; var $statut; // 0=draft, 1=validated, 2=invoiced var $description; var $note_private; @@ -116,7 +116,7 @@ class Fichinter extends CommonObject return -1; } } - if (! is_numeric($this->duree)) $this->duree = 0; + if (! is_numeric($this->duration)) $this->duration = 0; if ($this->socid <= 0) { @@ -234,8 +234,8 @@ class Fichinter extends CommonObject */ function update($user, $notrigger=0) { - if (! is_numeric($this->duree)) { - $this->duree = 0; + if (! is_numeric($this->duration)) { + $this->duration = 0; } if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; @@ -245,7 +245,7 @@ class Fichinter extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; $sql.= "description = '".$this->db->escape($this->description)."'"; - $sql.= ", duree = ".$this->duree; + $sql.= ", duree = ".$this->duration; $sql.= ", fk_projet = ".$this->fk_project; $sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); @@ -306,7 +306,7 @@ class Fichinter extends CommonObject $this->description = $obj->description; $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; - $this->duree = $obj->duree; + $this->duration = $obj->duree; $this->datec = $this->db->jdate($obj->datec); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); @@ -951,7 +951,7 @@ class Fichinter extends CommonObject $this->datec = $now; $this->note_private='Private note'; $this->note_public='SPECIMEN'; - $this->duree = 0; + $this->duration = 0; $nbp = 25; $xnbp = 0; while ($xnbp < $nbp) @@ -964,7 +964,7 @@ class Fichinter extends CommonObject $this->lines[$xnbp]=$line; $xnbp++; - $this->duree+=$line->duration; + $this->duration+=$line->duration; } } From 4e143755e8af5ed3ca3d7bc90260b495329b22b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Fri, 12 Jun 2015 15:55:39 +0200 Subject: [PATCH 8/8] Fix: missing categories class in customer/prospect card Also check that the categories module is enabled and user has permissions to see categories --- htdocs/comm/card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 720db118f4b..aba9433cabc 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -469,10 +470,12 @@ if ($id > 0) } // Categories - print '' . $langs->trans( "Categories" ) . ''; - print ''; - print $form->showCategories( $object->id, 'customer', 1 ); - print ""; + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { + print '' . $langs->trans( "Categories" ) . ''; + print ''; + print $form->showCategories( $object->id, 'customer', 1 ); + print ""; + } // Other attributes $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');