Modify Invoice ODT document name

I would like to change the way the invoice document name is generated. Right now the file name is YY-MM-OOO_odt file name I would like to replace the file name with my Project name. Any help in the right direction would be appreciated.

I managed to get the value for the Project name but it is stopping on the first item. I need it to find the Project name that corresponds to the invoice.

$dom = new DOMDocument();
$dom->loadHTML(My html…
$xpath = new DOMXPath($dom);
$classname = “opacitymedium”;
$elements = $xpath->query(“//*[contains(concat(’ ', normalize-space(@class), ’ '), ’ {$classname} ')]”);
if ($elements->length > 0) {
$value = $elements->item(0)->nodeValue;} // Get the text content of the first found element

Any help would be appreciated - I think I need the query to loop thru the invoices?

Using the DOM Document is not a good approach.
I did a database query joining llx_facture & llx_projet to pull the project title.

// ********** SQL query for Project Title ***********
$servername = “192.168.1.100”;
$username = “dolibarr”;
$password = “xxxxxxxx”;
$dbname = “dolibarr”;
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
die(“Connection failed: " . $conn->connect_error);
$sql = “SELECT llx_projet.title\n”
. “FROM llx_projet\n”
. “INNER JOIN llx_facture\n”
. “ON llx_facture.fk_projet = llx_projet.rowid\n”
// . “WHERE llx_facture.ref = '$objectref';”;
. “WHERE llx_facture.ref = ‘$objectref’;”;
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
// echo $row[‘title’] . “
”;
}
else{
echo"No record found”;
}
$newfiletmp = $objectref . ‘-’ . $row[‘title’];
$conn->close();

This query can be used for different fields to populate the “document file name.ODT”
I wanted the file to have ( yy-mm-001-project.ODT )