diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 0adee081865..0e46e86de8d 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -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 "
id."\" method=\"post\">"; + print ''; print ''; - print ""; + print ''; + + if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"])) + { + print ''; + print ''; + } print ''; @@ -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 ''; print '
'.$langs->trans("Project").''; - $numprojet=select_projects($soc->id,$projetid,'projetidp'); + $numprojet=select_projects($soc->id,$projectid); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index ab1ee65a68b..1e4cf62fa9e 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -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']; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index fcb189eff6b..f17604b3804 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -209,33 +209,37 @@ foreach ($listofreferent as $key => $value) * Barre d'action */ print '
'; - - if ($project->societe->prospect || $project->societe->client) + + if ($project->statut > 0) { - if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer) + if ($project->societe->prospect || $project->societe->client) { - print ''.$langs->trans("AddProp").''; + if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer) + { + print ''.$langs->trans("AddProp").''; + } + if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer) + { + print ''.$langs->trans("AddCustomerOrder").''; + } + if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer) + { + print ''.$langs->trans("AddCustomerInvoice").''; + } } - if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer) + if ($project->societe->fournisseur) { - print ''.$langs->trans("AddCustomerOrder").''; - } - if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer) - { - print ''.$langs->trans("AddCustomerInvoice").''; - } - } - if ($project->societe->fournisseur) - { - if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("AddSupplierInvoice").''; - } - if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans("AddSupplierOrder").''; + if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("AddSupplierInvoice").''; + } + if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("AddSupplierOrder").''; + } } } + print '
'; } } diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 326d6d591ed..8dda65efae5 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -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;