$var = true; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if ($obj) { $var = !$var; print "<tr " . $bc[$var] . ">"; print "<td>" . $obj->df . "</td>\n"; print '<td align="center">' . $obj->cc . '</td>'; print '<td align="center">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=builddoc&page=' . $page . '&month=' . $obj->month . '&year=' . $obj->year . '">' . img_picto($langs->trans('GenerateReport'), 'filenew') . '</a>'; print '</td>'; $name = "actions-" . $obj->month . "-" . $obj->year . ".pdf"; $relativepath = $name; $file = $conf->agenda->dir_temp . "/" . $name; if (file_exists($file)) { print '<td align="center"><a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?page=' . $page . '&file=' . urlencode($relativepath) . '&modulepart=actionsreport">' . img_pdf() . '</a></td>'; print '<td align="center">' . dol_print_date(dol_filemtime($file), 'dayhour') . '</td>'; print '<td align="center">' . dol_print_size(dol_filesize($file)) . '</td>'; } else { print '<td> </td>'; print '<td> </td>'; print '<td> </td>'; } print "</tr>\n"; } $i++; } print "</table>"; $db->free($resql); } else { dol_print_error($db);
if (is_dir($dir . '/' . $year)) { $handle = opendir($dir . '/' . $year); if ($found) { print '<br>'; } print '<br>'; print '<table width="100%" class="noborder">'; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("Reporting") . '</td>'; print '<td align="right">' . $langs->trans("Size") . '</td>'; print '<td align="right">' . $langs->trans("Date") . '</td>'; print '</tr>'; $var = true; if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { if (preg_match('/^payment/i', $file)) { $var = !$var; $tfile = $dir . '/' . $year . '/' . $file; $relativepath = $year . '/' . $file; print "<tr " . $bc[$var] . ">" . '<td><a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=facture_paiement&file=' . urlencode($relativepath) . '">' . img_pdf() . ' ' . $file . '</a></td>'; print '<td align="right">' . dol_print_size(dol_filesize($tfile)) . '</td>'; print '<td align="right">' . dol_print_date(dol_filemtime($tfile), "dayhour") . '</td></tr>'; } } closedir($handle); } print '</table>'; } } llxFooter(); $db->close();
/** * Show only Document icon with link * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. * @param string $filedir Directory to scan * @return string Output string with HTML link of documents (might be empty string) */ function getDocumentsLink($modulepart, $modulesubdir, $filedir) { if (!function_exists('dol_dir_list')) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; } $out = ''; $this->numoffiles = 0; $file_list = dol_dir_list($filedir, 'files', 0, preg_quote($modulesubdir . '.pdf', '/'), '\\.meta$|\\.png$'); // For ajax treatment $out .= '<div id="gen_pdf_' . $modulesubdir . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n"; if (!empty($file_list)) { // Loop on each file found foreach ($file_list as $file) { // Define relative path for download link (depends on module) $relativepath = $file["name"]; // Cas general if ($modulesubdir) { $relativepath = $modulesubdir . "/" . $file["name"]; } // Cas propal, facture... // Autre cas if ($modulepart == 'donation') { $relativepath = get_exdir($modulesubdir, 2) . $file["name"]; } if ($modulepart == 'export') { $relativepath = $file["name"]; } // Show file name with link to download $out .= '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '"'; $mime = dol_mimetype($relativepath, '', 0); if (preg_match('/text/', $mime)) { $out .= ' target="_blank"'; } $out .= '>'; $out .= img_pdf($file["name"], 2); $out .= '</a>' . "\n"; $this->numoffiles++; } } return $out; }
/** * Return a string to show the box with list of available documents for object. * This also set the property $this->numoffiles * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $filename Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if $filedir is already complete) * @param string $filedir Directory to scan * @param string $urlsource Url of origin page (for return) * @param int $genallowed Generation is allowed (1/0 or array list of templates) * @param int $delallowed Remove is allowed (1/0) * @param string $modelselected Model to preselect by default * @param string $allowgenifempty Allow generation even if list of template ($genallowed) is empty (show however a warning) * @param string $forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined) * @param int $iconPDF Show only PDF icon with link (1/0) * @param int $maxfilenamelength Max length for filename shown * @param string $noform Do not output html form tags * @param string $param More param on http links * @param string $title Title to show on top of form * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled * @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes * @return string Output string with HTML array of documents (might be empty string) */ function showdocuments($modulepart, $filename, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $maxfilenamelength = 28, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $hookmanager = false) { // filedir = conf->...dir_ouput."/".get_exdir(id) include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; global $langs, $bc, $conf; $forname = 'builddoc'; $out = ''; $var = true; // Clean paramaters if ($iconPDF == 1) { $genallowed = ''; $delallowed = 0; $modelselected = ''; $forcenomultilang = 0; } //$filename = dol_sanitizeFileName($filename); //Must be sanitized before calling show_documents $headershown = 0; $showempty = 0; $i = 0; $titletoshow = $langs->trans("Documents"); if (!empty($title)) { $titletoshow = $title; } $out .= "\n" . '<!-- Start show_document -->' . "\n"; //print 'filedir='.$filedir; // Affiche en-tete tableau if ($genallowed) { $modellist = array(); if ($modulepart == 'company') { $showempty = 1; if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php'; $modellist = ModeleThirdPartyDoc::liste_modeles($this->db); } } else { if ($modulepart == 'propal') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php'; $modellist = ModelePDFPropales::liste_modeles($this->db); } } else { if ($modulepart == 'commande') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; $modellist = ModelePDFCommandes::liste_modeles($this->db); } } elseif ($modulepart == 'expedition') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/expedition/modules_expedition.php'; $modellist = ModelePDFExpedition::liste_modeles($this->db); } } elseif ($modulepart == 'livraison') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/livraison/modules_livraison.php'; $modellist = ModelePDFDeliveryOrder::liste_modeles($this->db); } } else { if ($modulepart == 'ficheinter') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/fichinter/modules_fichinter.php'; $modellist = ModelePDFFicheinter::liste_modeles($this->db); } } elseif ($modulepart == 'facture') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; $modellist = ModelePDFFactures::liste_modeles($this->db); } } elseif ($modulepart == 'project') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/project/modules_project.php'; $modellist = ModelePDFProjects::liste_modeles($this->db); } } elseif ($modulepart == 'export') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/export/modules_export.php'; $modellist = ModeleExports::liste_modeles($this->db); } } else { if ($modulepart == 'commande_fournisseur') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php'; $modellist = ModelePDFSuppliersOrders::liste_modeles($this->db); } } else { if ($modulepart == 'facture_fournisseur') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_invoice/modules_facturefournisseur.php'; $modellist = ModelePDFSuppliersInvoices::liste_modeles($this->db); } } else { if ($modulepart == 'remisecheque') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/cheque/pdf/modules_chequereceipts.php'; $modellist = ModeleChequeReceipts::liste_modeles($this->db); } } elseif ($modulepart == 'donation') { if (is_array($genallowed)) { $modellist = $genallowed; } else { include_once DOL_DOCUMENT_ROOT . '/core/modules/dons/modules_don.php'; $modellist = ModeleDon::liste_modeles($this->db); } } else { if ($modulepart == 'unpaid') { $modellist = ''; } else { // Generic feature, for external modules $file = dol_buildpath('/core/modules/' . $modulepart . '/modules_' . $modulepart . '.php', 0); if (file_exists($file)) { $res = (include_once $file); } $class = 'Modele' . ucfirst($modulepart); if (class_exists($class)) { $modellist = call_user_func($class . '::liste_modeles', $this->db); } else { dol_print_error($this->db, 'Bad value for modulepart'); return -1; } } } } } } } } } $headershown = 1; $form = new Form($this->db); $buttonlabeltoshow = $buttonlabel; if (empty($buttonlabel)) { $buttonlabel = $langs->trans('Generate'); } if (empty($noform)) { $out .= '<form action="' . $urlsource . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc') . '" name="' . $forname . '" id="' . $forname . '_form" method="post">'; } $out .= '<input type="hidden" name="action" value="builddoc">'; $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; $out .= '<div class="titre">' . $titletoshow . '</div>'; $out .= '<table class="liste formdoc" summary="listofdocumentstable" width="100%">'; $out .= '<tr class="liste_titre">'; // Model if (!empty($modellist)) { $out .= '<th align="center" class="formdoc liste_titre">'; $out .= $langs->trans('Model') . ' '; if (is_array($modellist) && count($modellist) == 1) { $arraykeys = array_keys($modellist); $modelselected = $arraykeys[0]; } $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0); $out .= '</th>'; } else { $out .= '<th align="left" class="formdoc liste_titre">'; $out .= $langs->trans("Files"); $out .= '</th>'; } // Language code (if multilang) $out .= '<th align="center" class="formdoc liste_titre">'; if (($allowgenifempty || is_array($modellist) && count($modellist) > 0) && $conf->global->MAIN_MULTILANGS && !$forcenomultilang) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($this->db); $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); $out .= $formadmin->select_language($defaultlang); } else { $out .= ' '; } $out .= '</th>'; // Button $out .= '<th align="center" colspan="' . ($delallowed ? '2' : '1') . '" class="formdocbutton liste_titre">'; $out .= '<input class="button" id="' . $forname . '_generatebutton"'; $out .= ' type="submit" value="' . $buttonlabel . '"'; if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) { $out .= ' disabled="disabled"'; } $out .= '>'; if ($allowgenifempty && !is_array($modellist) && empty($modellist) && $modulepart != 'unpaid') { $langs->load("errors"); $out .= ' ' . img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } $out .= '</th>'; $out .= '</tr>'; // Execute hooks $parameters = array('socid' => isset($GLOBALS['socid']) ? $GLOBALS['socid'] : '', 'id' => isset($GLOBALS['id']) ? $GLOBALS['id'] : '', 'modulepart' => $modulepart); if (is_object($hookmanager)) { $out .= $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); } } // Get list of files if ($filedir) { $png = ''; $filter = ''; if ($iconPDF == 1) { $png = '\\.png$'; $filter = $filename . '.pdf'; } $file_list = dol_dir_list($filedir, 'files', 0, $filter, '\\.meta$' . ($png ? '|' . $png : ''), 'date', SORT_DESC); // Affiche en-tete tableau si non deja affiche if (!empty($file_list) && !$headershown && !$iconPDF) { $headershown = 1; $out .= '<div class="titre">' . $titletoshow . '</div>'; $out .= '<table class="border" summary="listofdocumentstable" width="100%">'; } else { if (empty($file_list) && !empty($iconPDF)) { // For ajax treatment $out .= '<div id="gen_pdf_' . $filename . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n"; } } // Loop on each file found foreach ($file_list as $file) { $var = !$var; // Define relative path for download link (depends on module) $relativepath = $file["name"]; // Cas general if ($filename) { $relativepath = $filename . "/" . $file["name"]; } // Cas propal, facture... // Autre cas if ($modulepart == 'donation') { $relativepath = get_exdir($filename, 2) . $file["name"]; } if ($modulepart == 'export') { $relativepath = $file["name"]; } if (!$iconPDF) { $out .= "<tr " . $bc[$var] . ">"; } // Show file name with link to download if (!$iconPDF) { $out .= '<td nowrap="nowrap">'; } $out .= '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '"'; $mime = dol_mimetype($relativepath, '', 0); if (preg_match('/text/', $mime)) { $out .= ' target="_blank"'; } $out .= '>'; if (!$iconPDF) { $out .= img_mime($file["name"], $langs->trans("File") . ': ' . $file["name"]) . ' ' . dol_trunc($file["name"], $maxfilenamelength); } else { $out .= img_pdf($file["name"], 2); } $out .= '</a>' . "\n"; if (!$iconPDF) { $out .= '</td>'; // Show file size $out .= '<td align="right" nowrap="nowrap">' . dol_print_size(dol_filesize($filedir . "/" . $file["name"])) . '</td>'; // Show file date $out .= '<td align="right" nowrap="nowrap">' . dol_print_date(dol_filemtime($filedir . "/" . $file["name"]), 'dayhour') . '</td>'; } if ($delallowed) { $out .= '<td align="right">'; //$out.= '<a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&modulepart='.$modulepart.'&file='.urlencode($relativepath); $out .= '<a href="' . $urlsource . '&action=remove_file&modulepart=' . $modulepart . '&file=' . urlencode($relativepath); $out .= $param ? '&' . $param : ''; $out .= '&urlsource=' . urlencode($urlsource); $out .= '">' . img_delete() . '</a></td>'; } if (!$iconPDF) { $out .= '</tr>'; } $this->numoffiles++; } } if ($headershown) { // Affiche pied du tableau $out .= "</table>\n"; if ($genallowed) { if (empty($noform)) { $out .= '</form>' . "\n"; } } } $out .= '<!-- End show_document -->' . "\n"; //return ($i?$i:$headershown); return $out; }