diff --git a/htdocs/core/ajax/ajaxinvoiceline.php b/htdocs/core/ajax/ajaxinvoiceline.php
new file mode 100644
index 00000000000..432ad15b151
--- /dev/null
+++ b/htdocs/core/ajax/ajaxinvoiceline.php
@@ -0,0 +1,69 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/core/ajax/ajaxinvoiceline.php
+ * \brief File to load contacts combobox
+ */
+
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1'); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+
+// Load Dolibarr environment
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+
+$invoice_id = GETPOST('id', 'int'); // id of thirdparty
+$action = GETPOST('action', 'aZ09');
+$htmlname = GETPOST('htmlname', 'alpha');
+
+
+
+// Security check
+restrictedArea($user, 'facture', $invoice_id, '', '', 'fk_soc', 'rowid');
+
+
+/*
+ * View
+ */
+
+top_httphead();
+
+//print ''."\n";
+
+// Load original field value
+if (!empty($invoice_id) && !empty($action) && !empty($htmlname)) {
+ $formProject = new FormProjets($db);
+
+ $return = array();
+ if (empty($showempty)) {
+ $showempty = 0;
+ }
+
+ $return['value'] = $formProject->selectInvoiceAndLine($invoice_id, 0, 'invoiceid', 'invoicelineid', 'maxwidth500', array(), 1);
+ //$return['num'] = $form->num;
+ //$return['error'] = $form->error;
+
+ echo json_encode($return);
+}
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 4511047b311..1eeb55db969 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -757,67 +757,70 @@ class FormProjets
*
* @param int $selectedInvoiceId Id invoice preselected
* @param int $selectedLineId Id invoice line preselected
- * @param string $htmlNameInvoiceId Name of HTML select for Invoice
- * @param int $htmlNameInvoiceLineId Name of HTML select for Invoice Line
+ * @param string $htmlNameInvoice Name of HTML select for Invoice
+ * @param int $htmlNameInvoiceLine Name of HTML select for Invoice Line
* @param string $morecss More css added to the select component
* @param array $filters Array of filters
+ * @param int $lineOnly return only option for line
* @return int Nbr of project if OK, <0 if KO
*/
- public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoiceId = 'invoiceid', $htmlNameInvoiceLineId = 'invoicelineid', $morecss = 'maxwidth500', $filters = array())
+ public function selectInvoiceAndLine($selectedInvoiceId = 0, $selectedLineId = 0, $htmlNameInvoice = 'invoiceid', $htmlNameInvoiceLine = 'invoicelineid', $morecss = 'maxwidth500', $filters = array(), $lineOnly = 0)
{
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$out = '';
-
- // Search Invoice
- $sql = "SELECT f.rowid, f.ref as fref,";
- $sql .= ' s.nom as name';
- $sql .= ' FROM ' . $this->db->prefix() . 'projet as p';
- $sql .= ' INNER JOIN ' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc';
- $sql .= ' INNER JOIN ' . $this->db->prefix() . 'facture as f ON f.fk_projet = p.rowid';
- $sql .= " WHERE p.entity IN (" . getEntity('project') . ")";
- if (!empty($filters)) {
- foreach ($filters as $key => $value) {
- if ($key == 'p.rowid') {
- $sql .= " AND p.rowid=" . (int) $value;
- }
- if ($key == 'f.rowid') {
- $sql .= " AND f.rowid=" . (int) $value;
- }
- }
- }
- $sql .= " ORDER BY p.ref, f.ref ASC";
-
- $resql = $this->db->query($sql);
- if ($resql) {
- // Use select2 selector
- if (!empty($conf->use_javascript_ajax)) {
- include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
- $comboenhancement = ajax_combobox($htmlNameInvoiceId, '', 0, 0);
- $out .= $comboenhancement;
- $morecss = 'minwidth200imp maxwidth500';
- }
-
- $out .= '