Browse Source

Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into 13.0

Laurent Destailleur 4 years ago
parent
commit
f1929eb106
3 changed files with 15 additions and 39 deletions
  1. 1 0
      htdocs/comm/action/card.php
  2. 13 39
      htdocs/compta/paiement/rapport.php
  3. 1 0
      htdocs/core/lib/functions.lib.php

+ 1 - 0
htdocs/comm/action/card.php

@@ -1143,6 +1143,7 @@ if ($action == 'create')
 		print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
 		$preselectedids = GETPOST('socpeopleassigned', 'array');
 		if (GETPOST('contactid', 'int')) $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int');
+		if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int');
 		print img_picto('', 'contact', 'class="paddingrightonly"');
 		print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid');
 		print '</td></tr>';

+ 13 - 39
htdocs/compta/paiement/rapport.php

@@ -109,36 +109,18 @@ print '<br>';
 clearstatcache();
 
 // Show link on other years
-$linkforyear = array();
-$found = 0;
-if (is_dir($dir))
+$year_dirs = dol_dir_list($dir, 'directories', 0, '^[0-9]{4}$', '', 'DESC');
+foreach ($year_dirs as $d)
 {
-	$handle = opendir($dir);
-	if (is_resource($handle))
-	{
-		while (($file = readdir($handle)) !== false)
-		{
-			if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file))
-			{
-				$found = 1;
-				$linkforyear[] = $file;
-			}
-		}
-	}
-}
-asort($linkforyear);
-foreach ($linkforyear as $cursoryear)
-{
-	print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$cursoryear.'">'.$cursoryear.'</a> &nbsp;';
+	print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$d['name'].'">'.$d['name'].'</a> &nbsp;';
 }
 
+$found = true;
 if ($year)
 {
 	if (is_dir($dir.'/'.$year))
 	{
-		$handle = opendir($dir.'/'.$year);
-
-		if ($found) print '<br>';
+		if (!empty($year_dirs)) print '<br>';
 		print '<br>';
 		print '<table width="100%" class="noborder">';
 		print '<tr class="liste_titre">';
@@ -147,22 +129,14 @@ if ($year)
 		print '<td class="right">'.$langs->trans("Date").'</td>';
 		print '</tr>';
 
-		if (is_resource($handle))
-		{
-			while (($file = readdir($handle)) !== false)
-			{
-				if (preg_match('/^payment/i', $file))
-				{
-					$tfile = $dir.'/'.$year.'/'.$file;
-					$relativepath = $year.'/'.$file;
-					print '<tr class="oddeven">';
-					print '<td><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a>'.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).'</td>';
-					print '<td class="right">'.dol_print_size(dol_filesize($tfile)).'</td>';
-					print '<td class="right">'.dol_print_date(dol_filemtime($tfile), "dayhour").'</td>';
-					print '</tr>';
-				}
-			}
-			closedir($handle);
+		$files = (dol_dir_list($dir.'/'.$year, 'files', 0, '^payments-[0-9]{4}-[0-9]{2}\.pdf$', '', 'name', 'DESC', 1));
+		foreach ($files as $f) {
+			$relativepath = $f['level1name'].'/'.$f['name'];
+			print '<tr class="oddeven">';
+			print '<td><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$f['name'].'</a>'.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).'</td>';
+			print '<td class="right">'.dol_print_size($f['size']).'</td>';
+			print '<td class="right">'.dol_print_date($f['date'], "dayhour").'</td>';
+			print '</tr>';
 		}
 		print '</table>';
 	}

+ 1 - 0
htdocs/core/lib/functions.lib.php

@@ -8731,6 +8731,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
 	$class = 'butAction';
 	if ($actionType == 'danger' || $actionType == 'delete') {
 		$class = 'butActionDelete';
+		if (strpos($url, 'token=') === false) $url .= '&token='.newToken();
 	}
 
 	$attr = array(