Correction methode select et ajout methode show_documents.
This commit is contained in:
parent
940206ac33
commit
c1e5eea5f8
@ -1143,54 +1143,38 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Affiche liste déroulante
|
* \brief Affiche liste déroulante depuis requete SQL
|
||||||
*
|
* \param Nom de la zone select
|
||||||
|
* \param Requete sql
|
||||||
|
* \param Id présélectionné
|
||||||
*/
|
*/
|
||||||
function select($name, $sql, $id='')
|
function select($name, $sql, $id='')
|
||||||
{
|
{
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
$result = $this->db->query($sql);
|
if ($resql)
|
||||||
if ($result)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<select class="flat" name="'.$name.'">';
|
print '<select class="flat" name="'.$name.'">';
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
$num = $this->db->num_rows();
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if (strlen("$id"))
|
|
||||||
{
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($i);
|
$row = $this->db->fetch_row($resql);
|
||||||
print "<option value=\"$row[0]\" ";
|
print '<option value="'.$row[0].'"';
|
||||||
if ($id == $row[0])
|
if ($id != '' && $id == $row[0])
|
||||||
{
|
{
|
||||||
print ' selected="true"';
|
print ' selected="true"';
|
||||||
}
|
}
|
||||||
print ">$row[1]</option>\n";
|
print '>'.$row[1].'</option>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
print "</select>\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ($i < $num)
|
dolibarr_print_error($this->db);
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($i);
|
|
||||||
print "<option value=\"$row[0]\">$row[1]</option>\n";
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</select>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $this->db->error();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Affiche un select à partir d'un tableau
|
\brief Affiche un select à partir d'un tableau
|
||||||
\param name nom de la zone select
|
\param name nom de la zone select
|
||||||
@ -1368,6 +1352,87 @@ class Form
|
|||||||
print "\n<!-- fin cartouche rapport -->\n\n";
|
print "\n<!-- fin cartouche rapport -->\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Affiche la cartouche de la liste des documents d'une propale, facture...
|
||||||
|
* \param modulepart propal=propal, facture=facture, ...
|
||||||
|
* \param filename Nom fichier
|
||||||
|
* \param filedir Repertoire à scanner
|
||||||
|
* \param urlsource Url page origine
|
||||||
|
* \param genallowed Génération autorisée
|
||||||
|
* \param delallowed Suppression autorisée
|
||||||
|
* \remarks Le fichier de facture détaillée est de la forme
|
||||||
|
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
|
||||||
|
*/
|
||||||
|
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='')
|
||||||
|
{
|
||||||
|
global $langs,$bc;
|
||||||
|
$var=true;
|
||||||
|
|
||||||
|
$filename = sanitize_string($filename);
|
||||||
|
$relativepath = "${filename}/${filename}.pdf";
|
||||||
|
$fullpathfile = $filedir . "/" . $filename . ".pdf";
|
||||||
|
|
||||||
|
if ($genallowed)
|
||||||
|
{
|
||||||
|
print '<form action="'.$urlsource.'" method="post">';
|
||||||
|
print '<input type="hidden" name="action" value="setpdfmodel">';
|
||||||
|
}
|
||||||
|
|
||||||
|
print_titre($langs->trans("Documents"));
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
if ($genallowed)
|
||||||
|
{
|
||||||
|
$liste=array();
|
||||||
|
if ($modulepart == 'propal')
|
||||||
|
{
|
||||||
|
$liste=$this->select("ee","select nom as id, nom as lib from ".MAIN_DB_PREFIX."propal_model_pdf");
|
||||||
|
}
|
||||||
|
elseif ($modulepart == 'facture')
|
||||||
|
{
|
||||||
|
$liste=$this->select("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db,'Bad value for modulepart');
|
||||||
|
}
|
||||||
|
print '<tr '.$bc[$var].'><td>'.$langs->trans('Model').'</td><td align="center">';
|
||||||
|
$this->select_array('modelpdf',$liste,$modelselected);
|
||||||
|
$texte=$langs->trans('Generate');
|
||||||
|
print '</td><td align="center" colspan="2"><input class="button" type="submit" value="'.$texte.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_dir($filedir))
|
||||||
|
{
|
||||||
|
$handle=opendir($filedir);
|
||||||
|
while (($file = readdir($handle))!==false)
|
||||||
|
{
|
||||||
|
if (is_readable($filedir."/".$file) && eregi('\.pdf$',$file))
|
||||||
|
{
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
if (eregi('\-detail\.pdf',$file)) print '<td nowrap>PDF Détaillé</td>';
|
||||||
|
else print '<td nowrap>PDF</td>';
|
||||||
|
|
||||||
|
$relativepathdetail = "${filename}/$file";
|
||||||
|
|
||||||
|
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&file='.urlencode($relativepathdetail).'">'.$file.'</a></td>';
|
||||||
|
print '<td align="right">'.filesize($filedir."/".$file). ' bytes</td>';
|
||||||
|
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file)).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</table>\n";
|
||||||
|
|
||||||
|
if ($genallowed)
|
||||||
|
{
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user