NEW : can add project's task to agenda on create event card
This commit is contained in:
parent
d4ffc5e088
commit
83d3e5ec39
@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
@ -251,6 +252,19 @@ if ($action == 'add')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$object->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0;
|
$object->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0;
|
||||||
|
|
||||||
|
$taskid = GETPOST('taskid','int');
|
||||||
|
if(!empty($taskid)){
|
||||||
|
|
||||||
|
$taskProject = new Task($db);
|
||||||
|
if($taskProject->fetch($taskid)>0){
|
||||||
|
$object->fk_project = $taskProject->fk_project;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->fk_element = $taskid;
|
||||||
|
$object->elementtype = 'task';
|
||||||
|
}
|
||||||
|
|
||||||
$object->datep = $datep;
|
$object->datep = $datep;
|
||||||
$object->datef = $datef;
|
$object->datef = $datef;
|
||||||
$object->percentage = $percentage;
|
$object->percentage = $percentage;
|
||||||
@ -877,10 +891,37 @@ if ($action == 'create')
|
|||||||
// Projet associe
|
// Projet associe
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
|
|
||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td>';
|
$projectid = GETPOST('projectid', 'int');
|
||||||
|
|
||||||
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td id="project-input-container" >';
|
||||||
|
|
||||||
|
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1);
|
||||||
|
|
||||||
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), GETPOST("projectid")?GETPOST("projectid"):'', 'projectid', 0, 0, 1, 1);
|
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||||
|
$urloption='?action=create';
|
||||||
|
$url = dol_buildpath('comm/action/card.php',2).$urloption;
|
||||||
|
|
||||||
|
// update task list
|
||||||
|
print "\n".'<script type="text/javascript">';
|
||||||
|
print '$(document).ready(function () {
|
||||||
|
$("#projectid").change(function () {
|
||||||
|
var url = "'.$url.'&projectid="+$("#projectid").val();
|
||||||
|
$.get(url, function(data) {
|
||||||
|
console.log($( data ).find("#taskid").html());
|
||||||
|
if (data) $("#taskid").html( $( data ).find("#taskid").html() ).select2();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})';
|
||||||
|
print '</script>'."\n";
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("Task").'</td><td id="project-task-input-container" >';
|
||||||
|
|
||||||
|
$projectsListId=false;
|
||||||
|
if(!empty($projectid)){ $projectsListId=$projectid; }
|
||||||
|
$tid=GETPOST("projecttaskid")?GETPOST("projecttaskid"):'';
|
||||||
|
$formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500',$projectsListId);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
if (!empty($origin) && !empty($originid))
|
if (!empty($origin) && !empty($originid))
|
||||||
@ -1270,10 +1311,41 @@ if ($id > 0)
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("LinkedObject").'</td>';
|
print '<td>'.$langs->trans("LinkedObject").'</td>';
|
||||||
print '<td>'.dolGetElementUrl($object->fk_element,$object->elementtype,1);
|
|
||||||
print '<input type="hidden" name="fk_element" value="'.$object->fk_element.'">';
|
if ($object->elementtype == 'task' && ! empty($conf->projet->enabled))
|
||||||
print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
|
{
|
||||||
print '</td>';
|
print '<td id="project-task-input-container" >';
|
||||||
|
|
||||||
|
$urloption='?action=create'; // we use create not edit for more flexibility
|
||||||
|
$url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption;
|
||||||
|
|
||||||
|
// update task list
|
||||||
|
print "\n".'<script type="text/javascript" >';
|
||||||
|
print '$(document).ready(function () {
|
||||||
|
$("#projectid").change(function () {
|
||||||
|
var url = "'.$url.'&projectid="+$("#projectid").val();
|
||||||
|
$.get(url, function(data) {
|
||||||
|
console.log($( data ).find("#fk_element").html());
|
||||||
|
if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})';
|
||||||
|
print '</script>'."\n";
|
||||||
|
|
||||||
|
$formproject->selectTasks((! empty($societe->id)?$societe->id:-1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500',$object->fk_project);
|
||||||
|
print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
|
||||||
|
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print dolGetElementUrl($object->fk_element,$object->elementtype,1);
|
||||||
|
print '<input type="hidden" name="fk_element" value="'.$object->fk_element.'">';
|
||||||
|
print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user