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 '';
else print '';
}
-
+ if ($object->statut == 1 && $nbofservices)
+ {
+ if ($user->rights->contrat->creer) print '';
+ else print '';
+ }
+
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.='