Skip to content
Snippets Groups Projects
Commit 92cfaa42 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: uniformise code

Fix: prepare to compatibility with other module
parent 7123a37d
No related branches found
No related tags found
No related merge requests found
......@@ -49,12 +49,6 @@ print_fiche_titre($langs->trans("NewProp"));
$html=new Form($db);
// Recuperation de l'id de projet
$projetid = 0;
if ($_GET["projetid"])
{
$projetid = $_GET["projetid"];
}
/*
* Creation d'une nouvelle propale
......@@ -102,9 +96,15 @@ if ($_GET["action"] == 'create')
}
}
print "<form name='addprop' action=\"propal.php?socid=".$soc->id."\" method=\"post\">";
print '<form name="addprop" action="propal.php?socid='.$soc->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print '<input type="hidden" name="action" value="add">';
if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"]))
{
print '<input type="hidden" name="origin" value="'.$_GET["origin"].'">';
print '<input type="hidden" name="originid" value="'.$_GET["originid"].'">';
}
print '<table class="border" width="100%">';
......@@ -200,10 +200,13 @@ if ($_GET["action"] == 'create')
// Project
if ($conf->projet->enabled)
{
$projectid = 0;
if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0);
print '<tr>';
print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">';
$numprojet=select_projects($soc->id,$projetid,'projetidp');
$numprojet=select_projects($soc->id,$projectid);
if ($numprojet==0)
{
print ' &nbsp; <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
......
......@@ -250,7 +250,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$propal->remise_absolue = $_POST['remise_absolue'];
$propal->socid = $_POST['socid'];
$propal->contactid = $_POST['contactidp'];
$propal->projetidp = $_POST['projetidp'];
$propal->projectid = $_POST['projectid'];
$propal->modelpdf = $_POST['model'];
$propal->author = $user->id; // deprecated
$propal->note = $_POST['note'];
......@@ -276,7 +276,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
$propal->contactid = $_POST['contactidp'];
$propal->projetidp = $_POST['projetidp'];
$propal->projectid = $_POST['projectid'];
$propal->modelpdf = $_POST['model'];
$propal->author = $user->id; // deprecated
$propal->note = $_POST['note'];
......
......@@ -209,33 +209,37 @@ foreach ($listofreferent as $key => $value)
* Barre d'action
*/
print '<div class="tabsAction">';
if ($project->societe->prospect || $project->societe->client)
{
if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$project->societe->id.'&amp;action=create&amp;projetid='.$project->id.'">'.$langs->trans("AddProp").'</a>';
}
if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;projetid='.$project->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
}
if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$project->societe->id.'&amp;action=create&amp;projetid='.$project->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
}
}
if ($project->societe->fournisseur)
if ($project->statut > 0)
{
if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer)
if ($project->societe->prospect || $project->societe->client)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;projetid='.$project->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddProp").'</a>';
}
if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
}
if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
}
}
if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer)
if ($project->societe->fournisseur)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;projetid='.$project->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
}
if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?socid='.$project->societe->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
}
}
}
print '</div>';
}
}
......
......@@ -56,7 +56,8 @@ class Propal extends CommonObject
var $client; // Objet societe client (a charger par fetch_client)
var $contactid;
var $projetidp;
var $projetidp; // deprecated (for compatibility)
var $projectid;
var $author;
var $ref;
var $ref_client;
......@@ -634,10 +635,10 @@ class Propal extends CommonObject
}
// Affectation au projet
if ($resql && $this->projetidp)
if ($resql && $this->projectid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_projet=".$this->projetidp;
$sql.= " SET fk_projet=".$this->projectid;
$sql.= " WHERE ref='".$this->ref."'";
$sql.= " AND entity = ".$conf->entity;
......@@ -837,7 +838,8 @@ class Propal extends CommonObject
$this->total_tva = $obj->tva;
$this->total_ttc = $obj->total;
$this->socid = $obj->fk_soc;
$this->projetidp = $obj->fk_projet;
$this->projectid = $obj->fk_projet;
$this->projetidp = $obj->fk_projet; // TODO obsolete
$this->modelpdf = $obj->model_pdf;
$this->note = $obj->note;
$this->note_public = $obj->note_public;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment