function create_new_project() { global $db, $user; dol_include_once('/projet/class/project.class.php'); // On crée un projet $project = new Project($db); $project->ref = TAssetWorkstationOF::get_next_ref_project(); // On récupère le fk_commande associé if ($_REQUEST['action'] === 'createOFCommande') { $fk_commande = $_REQUEST['fk_commande']; } else { $fk_commande = $this->fk_commande; } if (!empty($fk_commande)) { dol_include_once('/commande/class/commande.class.php'); $commande = new Commande($db); $commande->fetch($fk_commande); // On nomme le projet avec la ref de la commande d'origine if (!empty($commande->ref)) { $project->title .= 'Commande client ' . $commande->ref; } $this->fk_project = $project->create($user); // On associe la commande au projet $project->update_element('commande', $fk_commande); } }