Qual: Utilisation de la methode select_projects plutot que code en dur

This commit is contained in:
Laurent Destailleur 2005-09-17 00:50:36 +00:00
parent 7583146b73
commit 01d444febd
2 changed files with 175 additions and 192 deletions

View File

@ -18,7 +18,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -60,10 +59,13 @@ $form=new Form($db);
*/ */
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$soc = new Societe($db); $soc = new Societe($db);
/* TODO Ajouter un test ici */ $result=$soc->fetch($_GET["socidp"]);
$soc->fetch($_GET["socidp"]); if ($result < 0)
{
dolibarr_print_error($db,$soc->error);
exit;
}
$obj = PROPALE_ADDON; $obj = PROPALE_ADDON;
$modPropale = new $obj; $modPropale = new $obj;
@ -149,45 +151,18 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
if ($conf->projet->enabled) { if ($conf->projet->enabled)
{
/* /*
* Projet associé * Projet associ
*/ */
print '<td valign="top">'.$langs->trans("Project").'</td><td>'; print '<td valign="top">'.$langs->trans("Project").'</td><td>';
print '<option value="0"></option>';
$sql = "SELECT p.rowid, p.title FROM ".MAIN_DB_PREFIX."projet as p WHERE p.fk_soc =".$soc->id;
if ( $db->query($sql) )
{
$i = 0 ;
$numprojet = $db->num_rows();
$numprojet=$form->select_projects($soc->id,0,'projetidp');
if ($numprojet==0) if ($numprojet==0)
{ {
print $langs->trans("NoProject").' - '; print ' &nbsp; <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
print '<a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
} }
else
{
print '<select name="projetidp">';
while ($i < $numprojet)
{
$projet = $db->fetch_object();
print "<option value=\"$projet->rowid\">".$projet->title."</option>";
$i++;
}
print '</select>';
}
$db->free();
}
else
{
dolibarr_print_error($db);
}
print '</td>'; print '</td>';
} }
else { else {
@ -233,7 +208,9 @@ if ($_GET["action"] == 'create')
if ($numdest > 0) if ($numdest > 0)
{ {
$langs->load("bills"); $langs->load("bills");
print '<center>';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
print '</center>';
} }
print "</form>"; print "</form>";
} }

View File

@ -123,10 +123,16 @@ if ($_POST['action'] == 'add')
/* /*
* Generation * Generation
*/ */
if ($id) if ($id > 0)
{ {
propale_pdf_create($db, $id, $_POST['modelpdf']); propale_pdf_create($db, $id, $_POST['modelpdf']);
Header ('Location: propal.php?propalid='.$id); Header ('Location: propal.php?propalid='.$id);
exit;
}
else
{
dolibarr_print_error($db,$propal->error);
exit;
} }
} }