FIX refresh of tasks combo must use an ajax page not a full html page
This commit is contained in:
parent
53eef48596
commit
547b3602cc
@ -1166,10 +1166,11 @@ if ($action == 'create')
|
|||||||
print "\n".'<script type="text/javascript">';
|
print "\n".'<script type="text/javascript">';
|
||||||
print '$(document).ready(function () {
|
print '$(document).ready(function () {
|
||||||
$("#projectid").change(function () {
|
$("#projectid").change(function () {
|
||||||
var url = "'.$url.'&projectid="+$("#projectid").val();
|
var url = "'.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
|
||||||
|
console.log("Call url to get new list of tasks: "+url);
|
||||||
$.get(url, function(data) {
|
$.get(url, function(data) {
|
||||||
console.log($( data ).find("#taskid").html());
|
console.log(data);
|
||||||
if (data) $("#taskid").html( $( data ).find("#taskid").html() ).select2();
|
if (data) $("#taskid").html(data).select2();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
})';
|
})';
|
||||||
@ -1345,7 +1346,7 @@ if ($id > 0)
|
|||||||
$object->contact_id = GETPOST("contactid", 'int');
|
$object->contact_id = GETPOST("contactid", 'int');
|
||||||
$object->fk_project = GETPOST("projectid", 'int');
|
$object->fk_project = GETPOST("projectid", 'int');
|
||||||
|
|
||||||
$object_private = GETPOST("note", 'restricthtml');
|
$object->note_private = GETPOST("note", 'restricthtml');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
|
if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
|
||||||
|
|||||||
@ -349,7 +349,7 @@ class FormProjets
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Use select2 selector
|
// Use select2 selector
|
||||||
if (!empty($conf->use_javascript_ajax))
|
if (empty($option_only) && !empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||||
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
|
||||||
|
|||||||
@ -33,10 +33,8 @@ if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHT
|
|||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
$htmlname = GETPOST('htmlname', 'alpha');
|
$htmlname = GETPOST('htmlname', 'aZ09');
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
$action = GETPOST('action', 'aZ09');
|
|
||||||
$id = GETPOST('id', 'int');
|
|
||||||
$discard_closed = GETPOST('discardclosed', 'int');
|
$discard_closed = GETPOST('discardclosed', 'int');
|
||||||
|
|
||||||
|
|
||||||
@ -44,28 +42,31 @@ $discard_closed = GETPOST('discardclosed', 'int');
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dol_syslog(join(',', $_GET));
|
dol_syslog("Call ajax projet/ajax/projects.php");
|
||||||
|
//dol_syslog(join(',', $_GET));
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
|
||||||
$langs->load("main");
|
|
||||||
|
|
||||||
top_httphead();
|
top_httphead();
|
||||||
|
|
||||||
if (empty($htmlname)) return;
|
if (empty($htmlname) && !GETPOST('mode', 'aZ09')) return;
|
||||||
|
|
||||||
$match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
|
|
||||||
sort($match);
|
|
||||||
$idprod = (!empty($match[0]) ? $match[0] : '');
|
|
||||||
|
|
||||||
if (!GETPOST($htmlname) && !GETPOST($idprod)) return;
|
|
||||||
|
|
||||||
|
// Mode to get list of projects
|
||||||
|
if (!GETPOST('mode', 'aZ09') || GETPOST('mode', 'aZ09') != 'gettasks') {
|
||||||
// When used from jQuery, the search term is added as GET param "term".
|
// When used from jQuery, the search term is added as GET param "term".
|
||||||
$searchkey = ((!empty($idprod) && GETPOST($idprod)) ?GETPOST($idprod) : (GETPOST($htmlname) ?GETPOST($htmlname) : ''));
|
$searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
|
||||||
|
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
$arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mode to get list of tasks
|
||||||
|
if (GETPOST('mode', 'aZ09') == 'gettasks') {
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
$formproject->selectTasks((!empty($$socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$form = new FormProjets($db);
|
|
||||||
$arrayresult = $form->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user