diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css index d639230564b..bbb03bafde5 100644 --- a/htdocs/cashdesk/css/style.css +++ b/htdocs/cashdesk/css/style.css @@ -337,7 +337,7 @@ p.titre { /* -------------- Boutons --------------------- */ .bouton_ajout_article { margin-top: 10px; - width: 100%; + width: 60%; height: 40px; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e0d08dbc1fa..a1a1d1cc69a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -706,6 +706,11 @@ if (empty($reshook)) $result = $object->validate($user); } + else if ($action == 'reopen' && $user->rights->contrat->creer) + { + $result = $object->reopen($user); + } + // Close all lines else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { @@ -1077,7 +1082,7 @@ if ($action == 'create') else { print ''; - print $form->select_company('','socid','',1); + print $form->select_company('','socid','',1,1); print ''; } print ''."\n"; @@ -1110,12 +1115,13 @@ if ($action == 'create') $form->select_date($datecontrat,'',0,0,'',"contrat"); print ""; + // Project if (! empty($conf->projet->enabled)) { $formproject=new FormProjets($db); print ''.$langs->trans("Project").''; - $formproject->select_projects($soc->id,$projectid,"projectid"); + $formproject->select_projects(($soc->id>0?$soc->id:-1),$projectid,"projectid",0,0,1,1); print ""; } @@ -1325,11 +1331,11 @@ else print ''; 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 { - $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 ""; } @@ -1915,7 +1921,12 @@ else if ($user->rights->contrat->creer) print '
'.$langs->trans("Validate").'
'; else print '
'.$langs->trans("Validate").'
'; } - + if ($object->statut == 1 && $nbofservices) + { + if ($user->rights->contrat->creer) print '
'.$langs->trans("Modify").'
'; + else print '
'.$langs->trans("Modify").'
'; + } + if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { $langs->load("bills"); @@ -1975,6 +1986,12 @@ else print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'contract', $socid); + + print '
'; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 91f96aabf5d..37eaa1db04d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -472,7 +472,71 @@ class Contrat extends CommonObject } + /** + * Unvalidate a contract + * + * @param User $user Objet User + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @return int <0 if KO, >0 if OK + */ + function reopen($user, $notrigger=0) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + global $langs, $conf; + $now=dol_now(); + + $error=0; + dol_syslog(get_class($this).'::reopen user='.$user->id); + + $this->db->begin(); + + $this->fetch_thirdparty(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0"; + //$sql.= ", fk_user_valid = null, date_valid = null"; + $sql .= " WHERE rowid = ".$this->id . " AND statut = 1"; + + dol_syslog(get_class($this)."::validate", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + $this->error=$this->db->lasterror(); + } + + // Trigger calls + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('CONTRACT_REOPEN',$user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + // Set new ref and define current statut + if (! $error) + { + $this->statut=0; + $this->brouillon=1; + $this->date_validation=$now; + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + /** * Load a contract from database * diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 909afda913a..ee5f1465e3f 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -748,8 +748,9 @@ class ExtraFields $out.=''; print ''; print ''; print ''; print '
'; - $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 '
'; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 3b26576b0fa..498604d9307 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -55,13 +55,13 @@ class FormProjets * @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 $disabled Disabled - * @param int $mode 0 for HTML mode and 1 for JSON mode - * @param string $filterkey Key to filter + * @param int $mode 0 for HTML mode and 1 for JSON mode + * @param string $filterkey Key to filter * @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 = '') { - global $langs,$conf; + global $langs,$conf,$form; if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) { @@ -86,6 +86,14 @@ class FormProjets else { 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 { - 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++; continue; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index c1e7a3aaca2..59ea03476c4 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -130,6 +130,7 @@ class Fichinter extends CommonObject $sql.= ", ref"; $sql.= ", entity"; $sql.= ", fk_user_author"; + $sql.= ", fk_user_modif"; $sql.= ", description"; $sql.= ", model_pdf"; $sql.= ", fk_projet"; @@ -144,6 +145,7 @@ class Fichinter extends CommonObject $sql.= ", '".$this->db->escape($this->ref)."'"; $sql.= ", ".$conf->entity; $sql.= ", ".$user->id; + $sql.= ", ".$user->id; $sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null"); $sql.= ", '".$this->db->escape($this->modelpdf)."'"; $sql.= ", ".($this->fk_project ? $this->fk_project : 0); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3b1fa498336..a8ea9f1201d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1981,7 +1981,7 @@ elseif (! empty($object->id)) //print "$object->id, $object->socid, $object->fk_project"; 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 { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ce03c9ba1c8..20ba703e63e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1470,7 +1470,7 @@ if ($action == 'create') $langs->load('projects'); print '' . $langs->trans('Project') . ''; - $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 ''; } @@ -2039,7 +2039,7 @@ else print ''; 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 { diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 4bb6a52af8b..830219f8aeb 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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). 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). +ClosedProjectsAreHidden=Closed projects are not visible. 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). 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. @@ -163,6 +164,7 @@ ProjectsWithThisUserAsContact=Projects with this user as contact TasksWithThisUserAsContact=Tasks assigned to this user ResourceNotAssignedToProject=Not assigned to project ResourceNotAssignedToTask=Not assigned to task +ResourceNotAssignedToTheTask=Not assigned to the task AssignTaskToMe=Assign task to me AssignTask=Assign ProjectOverview=Overview diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dd449bda420..fffd177fe68 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -98,7 +98,7 @@ function test_sql_and_script_inject($val, $type) $sql_inj += preg_match('/