Look: Les caractéristiques complexes (projet, rib...) au sein des onglets se modifient par le bouton modifier insérer à l'emplacement même de la carac.

This commit is contained in:
Laurent Destailleur 2005-07-15 23:28:38 +00:00
parent 914b28dd5e
commit fa81f25351
8 changed files with 162 additions and 94 deletions

View File

@ -71,7 +71,7 @@ $NBLINES=4;
if ($_POST["action"] == 'classin') if ($_POST["action"] == 'classin')
{ {
$facture = new Facture($db); $facture = new Facture($db);
$facture->fetch($_POST["facid"]); $facture->fetch($_GET["facid"]);
$facture->classin($_POST["projetid"]); $facture->classin($_POST["projetid"]);
} }
@ -884,7 +884,7 @@ else
*/ */
if ($_GET["action"] == 'canceled') if ($_GET["action"] == 'canceled')
{ {
$html->form_confirm($_SERVER["PHP_SELF"]."?facid=$fac->id","Classer la facture à l'état 'Abandonnée'","La totalité du paiement de cette facture n'a pas été réalisée. Etes-vous sûr de vouloir abandonner définitivement cette facture ?","confirm_canceled"); $html->form_confirm($_SERVER["PHP_SELF"]."?facid=$fac->id",$langs->trans("CancelBill"),$langs->trans("ConfirmCancelBill"),"confirm_canceled");
print '<br />'; print '<br />';
} }
@ -916,25 +916,31 @@ else
print "</td></tr>"; print "</td></tr>";
print '<tr>'; print '<tr>';
// Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$langs->load("projects"); $langs->load("projects");
print '<td height=\"10\">'.$langs->trans("Project").'</td><td colspan="3">'; print '<td>';
if ($fac->projetid > 0) print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans("Project");
print '</td>';
if ($_GET["action"] != "classer") print '<td align="right"><a href="facture.php?action=classer&amp;facid='.$fac->id.'">'.img_edit($langs->trans("SetProject")).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET["action"] == "classer")
{ {
$projet = New Project($db); $html->form_project("facture.php?facid=$fac->id",$fac->fk_soc,$fac->projetid,"projetid");
$projet->fetch($fac->projetid);
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->projetid.'">'.$projet->title.'</a>';
} }
else else
{ {
print '<a href="facture.php?facid='.$fac->id.'&amp;action=classer">'.$langs->trans("ClassifyBill").'</a>'; $html->form_project("facture.php?facid=$fac->id",$fac->fk_soc,$fac->projetid,"none");
} }
print "&nbsp;</td>"; print "</td>";
} else { } else {
print '<td height=\"10\">&nbsp;</td><td colspan="3">'; print '<td height=\"10\">&nbsp;</td><td colspan="3">&nbsp;</td>';
print "&nbsp;</td>";
} }
print '<td rowspan="8" colspan="2" valign="top">'; print '<td rowspan="8" colspan="2" valign="top">';
/* /*
@ -1456,27 +1462,6 @@ else
print "</td></tr></table>"; print "</td></tr></table>";
/*
* Choix d'un projet
*/
if ($_GET["action"] == 'classer')
{
print "<p><form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id\">\n";
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="classin">';
print '<table class="border">';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($soc->id));
print "</td></tr>";
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr></table></form></p>';
}
/* /*
* Affiche formulaire mail * Affiche formulaire mail
*/ */

View File

@ -52,6 +52,8 @@ class Contrat
var $commercial_signature_id; var $commercial_signature_id;
var $commercial_suivi_id; var $commercial_suivi_id;
var $fk_projet;
var $statuts=array(); var $statuts=array();
@ -274,11 +276,12 @@ class Contrat
*/ */
function fetch($id) function fetch($id)
{ {
$sql = "SELECT rowid, statut, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise"; $sql = "SELECT rowid, statut, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise,";
$sql .= ", fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat"; $sql.= " fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat,";
$sql .= ", fk_user_author"; $sql.= " fk_user_author,";
$sql .= ", fk_commercial_signature, fk_commercial_suivi "; $sql.= " fk_projet,";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id"; $sql.= " fk_commercial_signature, fk_commercial_suivi ";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id";
$resql = $this->db->query($sql) ; $resql = $this->db->query($sql) ;
@ -303,6 +306,8 @@ class Contrat
$this->user_service->id = $result["fk_user_mise_en_service"]; $this->user_service->id = $result["fk_user_mise_en_service"];
$this->user_cloture->id = $result["fk_user_cloture"]; $this->user_cloture->id = $result["fk_user_cloture"];
$this->fk_projet = $result["fk_projet"];
$this->societe->fetch($result["fk_soc"]); $this->societe->fetch($result["fk_soc"]);
$this->db->free($resql); $this->db->free($resql);
@ -541,6 +546,29 @@ class Contrat
} }
/**
* \brief Classe le contrat dans un projet
* \param projid Id du projet dans lequel classer le contrat
*/
function classin($projid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat";
if ($projid) $sql.= " SET fk_projet = $projid";
else $sql.= " SET fk_projet = NULL";
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
/** /**
* \brief Retourne le libellé du statut du contrat * \brief Retourne le libellé du statut du contrat
* \return string Libellé * \return string Libellé
@ -613,5 +641,40 @@ class Contrat
} }
} }
/**
* \brief Récupère les lignes de detail du contrat
* \param statut Statut des lignes detail à récupérer
* \return array Tableau des lignes de details
*/
function array_detail($statut=-1)
{
$tab=array();
$sql = "SELECT cd.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " WHERE fk_contrat =".$this->id;
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($result);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
$tab[$i]=$obj->rowid;
$i++;
}
return $tab;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
} }
?> ?>

View File

@ -534,16 +534,21 @@ else
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; $langs->load("projects");
if ($contrat->projet_id > 0) print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans("Project");
print '</td>';
if ($_GET["action"] != "classer") print '<td align="right"><a href="fiche.php?action=classer&amp;id='.$id.'">'.img_edit($langs->trans("SetProject")).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET["action"] == "classer")
{ {
$projet = New Project($db); $html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"projetid");
$projet->fetch($contrat->projet_id);
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$contrat->projet_id.'">'.$projet->title.'</a>';
} }
else else
{ {
print '<a href="fiche.php?id='.$id.'&amp;action=classer">Classer le contrat</a>'; $html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"none");
} }
print "</td></tr>"; print "</td></tr>";
} }
@ -831,9 +836,8 @@ else
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Valid").'</a>'; print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Valid").'</a>';
} }
// \todo Mettre bouton cloturer que si tous les services sont clos $numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos
$numclos=$num; if ($contrat->statut == 1 && $num == sizeof($numclos))
if ($contrat->statut == 1 && $num == $numclos)
{ {
print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=close">'.$langs->trans("Close").'</a>'; print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=close">'.$langs->trans("Close").'</a>';
} }
@ -846,29 +850,10 @@ else
print "</div>"; print "</div>";
} }
/*
*
*
*/
if ($_GET["action"] == 'classer')
{
$langs->load("project");
print '<p><form method="post" action="fiche.php?id='.$contrat->id.'">';
print '<input type="hidden" name="action" value="classin">';
print '<table class="border">';
print '<tr><td>'.$langs->trans("Project").'</td><td>';
$proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($contrat->soc_id));
print "</td></tr>";
print '<tr><td colspan="2" align="center"><input type="submit" value="Envoyer"></td></tr></table></form>';
}
} }
else else
{ {
/* Contrat non trouvée */ // Contrat non trouvé
print "Contrat inexistant ou accés refusé"; print "Contrat inexistant ou accés refusé";
} }
} }

View File

@ -530,22 +530,24 @@ class Facture
} }
/** /**
* \brief Classe la facture * \brief Classe la facture dans un projet
* \param cat_id id de la catégorie dans laquelle classer la facture * \param projid Id du projet dans lequel classer la facture
* */
*/ function classin($projid)
function classin($cat_id)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_projet = $cat_id"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE rowid = $this->id;"; if ($projid) $sql.= " SET fk_projet = $projid";
else $sql.= " SET fk_projet = NULL";
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql) ) if ($this->db->query($sql))
{ {
return 1; return 1;
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
return -1;
} }
} }

View File

@ -398,14 +398,11 @@ class Form
*/ */
function select_projects($socid='', $selected='', $htmlname='projectid') function select_projects($socid='', $selected='', $htmlname='projectid')
{ {
$socid=intVal($socid); // On recherche les projets
if (empty($socid))
return;
// On recherche les societes
$sql = 'SELECT p.rowid, p.title FROM '; $sql = 'SELECT p.rowid, p.title FROM ';
$sql .= MAIN_DB_PREFIX .'projet as p'; $sql.= MAIN_DB_PREFIX .'projet as p';
$sql .= ' WHERE fk_soc='.$socid; $sql.= " WHERE fk_soc='".$socid."'";
$sql .= ' ORDER BY p.title ASC'; $sql.= " ORDER BY p.title ASC";
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
@ -781,6 +778,40 @@ class Form
} }
/**
* \brief Affiche formulaire de selection de projet
* \param page Page
* \param socid Id societe
* \param selected Id projet présélectionné
* \param htmlname Nom du formulaire select
*/
function form_project($page, $socid, $selected='', $htmlname='projectid')
{
global $langs;
$langs->load("project");
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="classin">';
print '<table class="noborder" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_projects($soc_id,$selected,$htmlname);
print '</td>';
print '<td align="left"><input type="submit" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
}
else
{
if ($selected) {
$projet = New Project($this->db);
$projet->fetch($selected);
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$selected.'">'.$projet->title.'</a>';
} else {
print "&nbsp;";
}
}
}
/** /**
* \brief Retourne la liste des devies, dans la langue de l'utilisateur * \brief Retourne la liste des devies, dans la langue de l'utilisateur
* \param selected code devise pré-sélectionnée * \param selected code devise pré-sélectionnée

View File

@ -9,4 +9,5 @@ ConfirmDeleteAProject=Are you sure you want to delete this project ?
LastProjects=Last %s projects LastProjects=Last %s projects
AllProjects=All projects AllProjects=All projects
ShowProject=Show project ShowProject=Show project
SetProject=Set project
NoProject=No project defined NoProject=No project defined

View File

@ -9,4 +9,5 @@ ConfirmDeleteAProject=
LastProjects=Les %s derniers projets LastProjects=Les %s derniers projets
AllProjects=Tous les projets AllProjects=Tous les projets
ShowProject=Afficher projet ShowProject=Afficher projet
SetProject=Définir projet
NoProject=Aucun projet défini NoProject=Aucun projet défini

View File

@ -572,7 +572,7 @@ else
// RIB // RIB
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="noborder" cellpadding="0" cellspacing="0" border="0"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('RIB'); print $langs->trans('RIB');
print '<td><td align="right">'; print '<td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit().'</a>'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit().'</a>';
@ -584,7 +584,7 @@ else
// Maison mère // Maison mère
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="noborder" cellpadding="0" cellspacing="0" border="0"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('ParentCompany'); print $langs->trans('ParentCompany');
print '<td><td align="right">'; print '<td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/societe/lien.php?socid='.$soc->id.'">'.img_edit() .'</a>'; print '<a href="'.DOL_URL_ROOT.'/societe/lien.php?socid='.$soc->id.'">'.img_edit() .'</a>';
@ -604,7 +604,7 @@ else
// Commerciaux // Commerciaux
print '<tr><td>'; print '<tr><td>';
print '<table width="100%" class="noborder" cellpadding="0" cellspacing="0" border="0"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SalesRepresentatives'); print $langs->trans('SalesRepresentatives');
print '<td><td align="right">'; print '<td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">'.img_edit().'</a>'; print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">'.img_edit().'</a>';