forked from Wavyzz/dolibarr
NEW Closing task
This commit is contained in:
@@ -701,6 +701,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
$taskstatic->duration_effective = $lines[$i]->duration_effective;
|
||||
$taskstatic->budget_amount = $lines[$i]->budget_amount;
|
||||
$taskstatic->billable = $lines[$i]->billable;
|
||||
$taskstatic->fk_statut = $lines[$i]->fk_statut;
|
||||
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
@@ -953,6 +954,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Status
|
||||
if (count($arrayfields) > 0 && !empty($arrayfields['t.fk_statut']['checked'])) {
|
||||
print '<td class="center">';
|
||||
print $taskstatic->getLibStatut(5);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Extra fields
|
||||
$extrafieldsobjectkey = $taskstatic->table_element;
|
||||
$extrafieldsobjectprefix = 'efpt.';
|
||||
|
||||
@@ -765,6 +765,59 @@ class Task extends CommonObjectLine
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close task from database
|
||||
* @param User $user User that close
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function close($user,$notrigger = 0) {
|
||||
|
||||
global $conf;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::close record task", LOG_DEBUG);
|
||||
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."projet_task ";
|
||||
$sql.= "SET fk_statut=".$this::STATUS_CLOSED." WHERE rowid=".(int) $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('TASK_CLOSE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1 * $error;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete task from database
|
||||
*
|
||||
|
||||
@@ -98,6 +98,7 @@ $search_progresscalc = GETPOST('search_progresscalc');
|
||||
$search_progressdeclare = GETPOST('search_progressdeclare');
|
||||
$search_task_budget_amount = GETPOST('search_task_budget_amount');
|
||||
$search_task_billable = GETPOST('search_task_billable');
|
||||
$search_fk_statut = GETPOSTINT('search_fk_statut');
|
||||
|
||||
$search_date_start_startmonth = GETPOSTINT('search_date_start_startmonth');
|
||||
$search_date_start_startyear = GETPOSTINT('search_date_start_startyear');
|
||||
@@ -183,6 +184,8 @@ $arrayfields = array(
|
||||
't.progress_summary' => array('label' => "TaskProgressSummary", 'checked' => 1, 'position' => 10),
|
||||
't.budget_amount' => array('label' => "Budget", 'checked' => 0, 'position' => 11),
|
||||
'c.assigned' => array('label' => "TaskRessourceLinks", 'checked' => 1, 'position' => 12),
|
||||
't.fk_statut' => array('label' => "Status", 'checked' => 1, 'position' => 12),
|
||||
|
||||
);
|
||||
if ($object->usage_bill_time) {
|
||||
$arrayfields['t.tobill'] = array('label' => $langs->trans("TimeToBill"), 'checked' => 0, 'position' => 11);
|
||||
@@ -248,6 +251,7 @@ if (empty($reshook)) {
|
||||
$search_progressdeclare = '';
|
||||
$search_task_budget_amount = '';
|
||||
$search_task_billable = '';
|
||||
$search_fk_statut = '';
|
||||
$toselect = array();
|
||||
$search_array_options = array();
|
||||
$search_date_start_startmonth = "";
|
||||
@@ -332,6 +336,9 @@ if ($search_task_budget_amount) {
|
||||
if ($search_task_billable) {
|
||||
$morewherefilterarray[] = " t.billable = ".($search_task_billable == "yes" ? 1 : 0);
|
||||
}
|
||||
if ($search_fk_statut) {
|
||||
$morewherefilterarray[] = " t.fk_statut = ".$search_fk_statut;
|
||||
}
|
||||
//var_dump($morewherefilterarray);
|
||||
|
||||
$morewherefilter = '';
|
||||
@@ -1082,6 +1089,10 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object-
|
||||
print $form->selectyesno('search_task_billable', $search_task_billable, 0, false, 1);
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['t.fk_statut']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
@@ -1160,6 +1171,10 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object-
|
||||
if (!empty($arrayfields['t.billable']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.billable']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['t.fk_statut']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.fk_statut']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
|
||||
}
|
||||
// Extra fields
|
||||
$disablesortlink = 1;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
|
||||
@@ -208,6 +208,19 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->hasRight('projet'
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_close' && $confirm == "yes" && $user->hasRight('projet', 'creer')) {
|
||||
$result = $projectstatic->fetch($object->fk_project);
|
||||
$projectstatic->fetch_thirdparty();
|
||||
|
||||
if ($object->close($user) > 0) {
|
||||
header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : ''));
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
|
||||
if (!empty($project_ref) && !empty($withproject)) {
|
||||
if ($projectstatic->fetch(0, $project_ref) > 0) {
|
||||
@@ -579,6 +592,14 @@ if ($id > 0 || !empty($ref)) {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneTask"), "confirm_clone", $formquestion, '', 1, 300, 590);
|
||||
}
|
||||
|
||||
if ($action == 'close') {
|
||||
$formquestion = array(
|
||||
'text' => $langs->trans("ConfirmClose"),
|
||||
);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClose"), $langs->trans("ConfirmCloseTask"), "confirm_close", $formquestion, '', 1, 300, 590);
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'merge') {
|
||||
$formquestion = array(
|
||||
array(
|
||||
@@ -701,6 +722,7 @@ if ($id > 0 || !empty($ref)) {
|
||||
print '<span>'.($object->billable ? $langs->trans('Yes') : $langs->trans('No')).'</span>';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Other attributes
|
||||
$cols = 3;
|
||||
$parameters = array('socid' => $socid);
|
||||
@@ -730,11 +752,16 @@ if ($id > 0 || !empty($ref)) {
|
||||
if (empty($reshook)) {
|
||||
// Modify
|
||||
if ($user->hasRight('projet', 'creer')) {
|
||||
if ($object->fk_statut != $object::STATUS_CLOSED)
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Modify').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken().'&withproject='.((int) $withproject).'">'.$langs->trans('Clone').'</a>';
|
||||
print '<a class="butActionDelete classfortooltip" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=merge&token='.newToken().'&withproject='.((int) $withproject).'" title="'.$langs->trans("MergeTasks").'">'.$langs->trans('Merge').'</a>';
|
||||
|
||||
if ($object->fk_statut != $object::STATUS_CLOSED)
|
||||
print '<a class="butAction classfortooltip" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken().'&withproject='.((int) $withproject).'" title="'.$langs->trans("Close").'">'.$langs->trans('Close').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
|
||||
|
||||
}
|
||||
|
||||
// Delete
|
||||
|
||||
Reference in New Issue
Block a user