Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into 10.0

This commit is contained in:
Laurent Destailleur 2019-12-23 14:01:51 +01:00
commit 7b08ce9fb8
4 changed files with 97 additions and 52 deletions

View File

@ -62,6 +62,7 @@ $object = new Categorie($db);
/* /*
* Actions * Actions
*/ */
$error = 0;
// retour a l'affichage des traduction si annulation // retour a l'affichage des traduction si annulation
if ($cancel == $langs->trans("Cancel")) if ($cancel == $langs->trans("Cancel"))
@ -78,27 +79,43 @@ $cancel != $langs->trans("Cancel") &&
$object->fetch($id); $object->fetch($id);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// update de l'objet // check parameters
if ( $_POST["forcelangprod"] == $current_lang ) $forcelangprod = GETPOST('forcelangprod', 'alpha');
{ $libelle = GETPOST('libelle', 'alpha');
$object->label = $_POST["libelle"]; $desc = GETPOST('desc', 'none');
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
if (empty($forcelangprod)) {
$error++;
$object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation'));
} }
else
{ if (!$error) {
$object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; if (empty($libelle)) {
$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $error++;
$object->errors[] = $langs->trans('Language_' . $forcelangprod) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
}
if (!$error) {
// update de l'objet
if ($forcelangprod == $current_lang) {
$object->label = $libelle;
$object->description = dol_htmlcleanlastbr($desc);
} else {
$object->multilangs[$forcelangprod]["label"] = $libelle;
$object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc);
} }
// sauvegarde en base // sauvegarde en base
if ( $object->setMultiLangs($user) > 0 ) $res = $object->setMultiLangs($user);
{ if ($res < 0) $error++;
$action = '';
} }
else }
{
if ($error) {
$action = 'add'; $action = 'add';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else {
$action = '';
} }
} }
@ -112,26 +129,33 @@ $cancel != $langs->trans("Cancel") &&
foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
{ {
if ( $key == $current_lang ) $libelle = GETPOST('libelle-'. $key, 'alpha');
{ $desc = GETPOST('desc-' . $key);
$object->label = $_POST["libelle-".$key];
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); if (empty($libelle)) {
$error++;
$object->errors[] = $langs->trans('Language_' . $key) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
} }
else
{ if ( $key == $current_lang ) {
$object->multilangs[$key]["label"] = $_POST["libelle-".$key]; $object->label = $libelle;
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->description = dol_htmlcleanlastbr($desc);
} else {
$object->multilangs[$key]["label"] = $libelle;
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($desc);
} }
} }
if ( $object->setMultiLangs($user) > 0 ) if (!$error) {
{ $res = $object->setMultiLangs($user);
$action = ''; if ($res < 0) $error++;
} }
else
{ if ($error) {
$action = 'edit'; $action = 'edit';
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else {
$action = '';
} }
} }
@ -224,8 +248,8 @@ if ($action == '')
{ {
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'">'.$langs->trans("Add").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&type='.$type.'">'.$langs->trans('Add').'</a>';
if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("Update").'</a>'; if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'&type='.$type.'">'.$langs->trans('Update').'</a>';
} }
} }
@ -242,6 +266,7 @@ if ($action == 'edit')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="type" value="' . $type . '">';
if (! empty($object->multilangs)) if (! empty($object->multilangs))
{ {
@ -249,9 +274,14 @@ if ($action == 'edit')
{ {
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>"; print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$object->multilangs[$key]["label"].'"></td></tr>';
// Label
$libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']);
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$libelle.'"></td></tr>';
// Desc
$desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']);
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor = new DolEditor("desc-$key", $desc, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
@ -280,7 +310,7 @@ elseif ($action != 'add')
{ {
$s=picto_from_langcode($key); $s=picto_from_langcode($key);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '').'</a></td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').'</a></td></tr>';
print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>'; print '<tr><td>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION)) if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
@ -308,14 +338,16 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vadd">'; print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="type" value="' . $type . '">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Translation').'</td><td>'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans('Translation').'</td><td>';
print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs); print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs);
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td class="fieldrequired">' . $langs->trans('Label') . '</td>';
print '<td><input name="libelle" size="40" value="' . GETPOST('libelle', 'alpha'). '"></td></tr>';
print '<tr><td>'.$langs->trans('Description').'</td><td>'; print '<tr><td>'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';

View File

@ -445,7 +445,16 @@ class Facture extends CommonInvoice
} }
// Define due date if not already defined // Define due date if not already defined
$datelim=(empty($forceduedate)?$this->calculate_date_lim_reglement():$forceduedate); if (empty($forceduedate)) {
$duedate = $this->calculate_date_lim_reglement();
/*if ($duedate < 0) { Regression, a date can be negative if before 1970.
dol_syslog(__METHOD__ . ' Error in calculate_date_lim_reglement. We got ' . $duedate, LOG_ERR);
return -1;
}*/
$this->date_lim_reglement = $duedate;
} else {
$this->date_lim_reglement = $forceduedate;
}
// Insert into database // Insert into database
$socid = $this->socid; $socid = $this->socid;
@ -497,7 +506,7 @@ class Facture extends CommonInvoice
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->cond_reglement_id;
$sql.= ", ".$this->mode_reglement_id; $sql.= ", ".$this->mode_reglement_id;
$sql.= ", '".$this->db->idate($datelim)."', '".$this->db->escape($this->modelpdf)."'"; $sql.= ", '".$this->db->idate($this->date_lim_reglement)."', '".$this->db->escape($this->modelpdf)."'";
$sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null"); $sql.= ", ".($this->situation_cycle_ref?"'".$this->db->escape($this->situation_cycle_ref)."'":"null");
$sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null"); $sql.= ", ".($this->situation_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0); $sql.= ", ".($this->situation_final?$this->situation_final:0);
@ -1652,7 +1661,7 @@ class Facture extends CommonInvoice
$sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').","; $sql.= " datef=".(strval($this->date)!='' ? "'".$this->db->idate($this->date)."'" : 'null').",";
$sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').","; $sql.= " date_pointoftax=".(strval($this->date_pointoftax)!='' ? "'".$this->db->idate($this->date_pointoftax)."'" : 'null').",";
$sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; $sql.= " date_valid=".(strval($this->date_validation)!='' ? "'".$this->db->idate($this->date_validation)."'" : 'null').",";
$sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):"null").","; $sql.= " paye=".(isset($this->paye)?$this->db->escape($this->paye):0).",";
$sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").","; $sql.= " remise_percent=".(isset($this->remise_percent)?$this->db->escape($this->remise_percent):"null").",";
$sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").","; $sql.= " remise_absolue=".(isset($this->remise_absolue)?$this->db->escape($this->remise_absolue):"null").",";
$sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").","; $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").",";

View File

@ -967,7 +967,7 @@ else
print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">'; print '<tr><td><label for="state_id">'.$langs->trans('State').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
} }
print $formcompany->select_state($object->state_id, isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'state_id'); print $formcompany->select_state(GETPOSTISSET('state_id')?GETPOST('state_id', 'alpha'):$object->state_id, $object->country_code, 'state_id');
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -98,7 +98,11 @@ class FormMargin
$pv = $line->total_ht; $pv = $line->total_ht;
$pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign $pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
if ($object->type == Facture::TYPE_SITUATION) {
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
} else {
$pa = $line->qty * $pa_ht; $pa = $line->qty * $pa_ht;
}
// calcul des marges // calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise