FIX Selection of project must no show closed project

This commit is contained in:
Laurent Destailleur 2016-01-28 11:59:18 +01:00
parent cf6c06f9e7
commit df4cd3de17
7 changed files with 25 additions and 13 deletions

View File

@ -1077,7 +1077,7 @@ if ($action == 'create')
else else
{ {
print '<td colspan="2">'; print '<td colspan="2">';
print $form->select_company('','socid','',1); print $form->select_company('','socid','',1,1);
print '</td>'; print '</td>';
} }
print '</tr>'."\n"; print '</tr>'."\n";
@ -1110,12 +1110,13 @@ if ($action == 'create')
$form->select_date($datecontrat,'',0,0,'',"contrat"); $form->select_date($datecontrat,'',0,0,'',"contrat");
print "</td></tr>"; print "</td></tr>";
// Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$formproject=new FormProjets($db); $formproject=new FormProjets($db);
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
$formproject->select_projects($soc->id,$projectid,"projectid"); $formproject->select_projects(($soc->id>0?$soc->id:-1),$projectid,"projectid",0,0,1,1);
print "</td></tr>"; print "</td></tr>";
} }
@ -1325,11 +1326,11 @@ else
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == "classify") if ($action == "classify")
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"projectid", 0, 0, 1); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "projectid", 1, 0, 1);
} }
else else
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,"none", 0, 0); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, "none", 0, 0);
} }
print "</td></tr>"; print "</td></tr>";
} }

View File

@ -3444,7 +3444,7 @@ class Form
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id pre-selected project * @param int $selected Id pre-selected project
* @param string $htmlname Name of select field * @param string $htmlname Name of select field
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable)
* @param int $maxlength Max length * @param int $maxlength Max length
* @param int $forcefocus Force focus on field (works with javascript only) * @param int $forcefocus Force focus on field (works with javascript only)
* @return void * @return void
@ -3467,7 +3467,7 @@ class Form
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>'; print '<tr><td>';
$formproject->select_projects($socid,$selected,$htmlname,$maxlength,0,1,$discard_closed, $forcefocus); $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus);
print '</td>'; print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>'; print '</tr></table></form>';

View File

@ -55,13 +55,13 @@ class FormProjets
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only) * @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled * @param int $disabled Disabled
* @param int $mode 0 for HTML mode and 1 for JSON mode * @param int $mode 0 for HTML mode and 1 for JSON mode
* @param string $filterkey Key to filter * @param string $filterkey Key to filter
* @return int Nber of project if OK, <0 if KO * @return int Nber of project if OK, <0 if KO
*/ */
function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '') function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '')
{ {
global $langs,$conf; global $langs,$conf,$form;
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT))
{ {
@ -86,6 +86,14 @@ class FormProjets
else else
{ {
print $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey); print $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey);
if ($discard_closed)
{
if (class_exists('Form'))
{
if (empty($form)) $form=new Form($this->db);
print $form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
}
}
} }
} }
@ -174,7 +182,7 @@ class FormProjets
} }
else else
{ {
if ($discard_closed == 1 && $obj->fk_statut == 2) if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) // We discard closed except if selected
{ {
$i++; $i++;
continue; continue;

View File

@ -137,6 +137,7 @@ class Fichinter extends CommonObject
$sql.= ", ref"; $sql.= ", ref";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ", fk_user_author"; $sql.= ", fk_user_author";
$sql.= ", fk_user_modif";
$sql.= ", description"; $sql.= ", description";
$sql.= ", model_pdf"; $sql.= ", model_pdf";
$sql.= ", fk_projet"; $sql.= ", fk_projet";
@ -151,6 +152,7 @@ class Fichinter extends CommonObject
$sql.= ", '".$this->db->escape($this->ref)."'"; $sql.= ", '".$this->db->escape($this->ref)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", ".$user->id; $sql.= ", ".$user->id;
$sql.= ", ".$user->id;
$sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null"); $sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null");
$sql.= ", '".$this->db->escape($this->modelpdf)."'"; $sql.= ", '".$this->db->escape($this->modelpdf)."'";
$sql.= ", ".($this->fk_project ? $this->fk_project : 0); $sql.= ", ".($this->fk_project ? $this->fk_project : 0);

View File

@ -1985,7 +1985,7 @@ elseif (! empty($object->id))
//print "$object->id, $object->socid, $object->fk_project"; //print "$object->id, $object->socid, $object->fk_project";
if ($action == 'classify') if ($action == 'classify')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $object->fk_project, 'projectid', 0, 0, 1); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', 0, 0, 1);
} }
else else
{ {

View File

@ -1470,7 +1470,7 @@ if ($action == 'create')
$langs->load('projects'); $langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">'; print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:'-1'), $projectid, 'projectid', 0); $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1);
print '</td></tr>'; print '</td></tr>';
} }
@ -2039,7 +2039,7 @@ else
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'classify') if ($action == 'classify')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $object->fk_project, 'projectid', 0, 0, 1); $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', 0, 0, 1);
} }
else else
{ {

View File

@ -14,6 +14,7 @@ ProjectsPublicTaskDesc=This view presents all projects and tasks you are allowed
ProjectsDesc=This view presents all projects (your user permissions grant you permission to view everything). ProjectsDesc=This view presents all projects (your user permissions grant you permission to view everything).
MyTasksDesc=This view is limited to projects or tasks you are a contact for (whatever is the type). MyTasksDesc=This view is limited to projects or tasks you are a contact for (whatever is the type).
OnlyOpenedProject=Only open projects are visible (projects in draft or closed status are not visible). OnlyOpenedProject=Only open projects are visible (projects in draft or closed status are not visible).
ClosedProjectsAreHidden=Closed projects are not visible.
TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksPublicDesc=This view presents all projects and tasks you are allowed to read.
TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything).
AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on. Assign task to you if you want to enter time on it. AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task you are assigned on. Assign task to you if you want to enter time on it.