set_echeance no in set_date

This commit is contained in:
Anthony Berton 2022-08-23 08:56:00 +02:00
parent 14e7ec8cf4
commit 5a4d5d7f97
2 changed files with 16 additions and 12 deletions

View File

@ -315,10 +315,11 @@ if (empty($reshook)) {
} }
if (!$error) { if (!$error) {
if (isset($object->duree_validite) && !empty($object->fin_validite)) {
$object->fin_validite = $datep + ($object->duree_validite * 24 * 3600);
}
$result = $object->set_date($user, $datep); $result = $object->set_date($user, $datep);
if ($result > 0 && !empty($object->duree_validite) && !empty($object->fin_validite)) {
$datev = $datep + ($object->duree_validite * 24 * 3600);
$result = $object->set_echeance($user, $datev, 1);
}
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} elseif (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { } elseif (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@ -2301,13 +2302,16 @@ if ($action == 'create') {
// Date of proposal // Date of proposal
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; // print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DatePropal'); // print $langs->trans('DatePropal');
print '</td>'; // print '</td>';
if ($action != 'editdate' && $usercancreate && $caneditfield) { // if ($action != 'editdate' && $usercancreate && $caneditfield) {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>'; // print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
} // }
print '</tr></table>';
// print '</tr></table>';
$editenable = $usercancreate && $caneditfield && $object->statut == Propal::STATUS_DRAFT;
print $form->editfieldkey("DatePropal", 'date', '', $object, $editenable);
print '</td><td class="valuefield">'; print '</td><td class="valuefield">';
if ($action == 'editdate' && $usercancreate && $caneditfield) { if ($action == 'editdate' && $usercancreate && $caneditfield) {
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';

View File

@ -384,7 +384,7 @@ class Propal extends CommonObject
$this->socid = $socid; $this->socid = $socid;
$this->id = $propalid; $this->id = $propalid;
$this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION); $this->duree_validite = isset($conf->global->PROPALE_VALIDITY_DURATION)?((int) $conf->global->PROPALE_VALIDITY_DURATION):0;
} }
@ -2066,7 +2066,7 @@ class Propal extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."',fin_validite = '".$this->db->idate($this->fin_validite)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".self::STATUS_DRAFT; $sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".self::STATUS_DRAFT;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);