Skip to content

Commit

Permalink
Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 23, 2019
2 parents eb32e98 + 1229e8b commit 7b08ce9
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 52 deletions.
126 changes: 79 additions & 47 deletions htdocs/categories/traduction.php
Expand Up @@ -62,6 +62,7 @@
/*
* Actions
*/
$error = 0;

// retour a l'affichage des traduction si annulation
if ($cancel == $langs->trans("Cancel"))
Expand All @@ -78,28 +79,44 @@
$object->fetch($id);
$current_lang = $langs->getDefaultLang();

// update de l'objet
if ( $_POST["forcelangprod"] == $current_lang )
{
$object->label = $_POST["libelle"];
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
}
else
{
$object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"];
$object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
}
// check parameters
$forcelangprod = GETPOST('forcelangprod', 'alpha');
$libelle = GETPOST('libelle', 'alpha');
$desc = GETPOST('desc', 'none');

// sauvegarde en base
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
else
{
$action = 'add';
setEventMessages($object->error, $object->errors, 'errors');
}
if (empty($forcelangprod)) {
$error++;
$object->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Translation'));
}

if (!$error) {
if (empty($libelle)) {
$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
$res = $object->setMultiLangs($user);
if ($res < 0) $error++;
}
}

if ($error) {
$action = 'add';
setEventMessages($object->error, $object->errors, 'errors');
} else {
$action = '';
}
}

// Validation de l'edition
Expand All @@ -112,27 +129,34 @@

foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
{
if ( $key == $current_lang )
{
$object->label = $_POST["libelle-".$key];
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
}
else
{
$object->multilangs[$key]["label"] = $_POST["libelle-".$key];
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$libelle = GETPOST('libelle-'. $key, 'alpha');
$desc = GETPOST('desc-' . $key);

if (empty($libelle)) {
$error++;
$object->errors[] = $langs->trans('Language_' . $key) . ' : ' . $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label'));
}

if ( $key == $current_lang ) {
$object->label = $libelle;
$object->description = dol_htmlcleanlastbr($desc);
} else {
$object->multilangs[$key]["label"] = $libelle;
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($desc);
}
}

if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
}
else
{
$action = 'edit';
setEventMessages($object->error, $object->errors, 'errors');
}
if (!$error) {
$res = $object->setMultiLangs($user);
if ($res < 0) $error++;
}

if ($error) {
$action = 'edit';
setEventMessages($object->error, $object->errors, 'errors');
} else {
$action = '';
}
}

$result = $object->fetch($id, $ref);
Expand Down Expand Up @@ -224,8 +248,8 @@
{
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>';
if ($cnt_trans > 0) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&id='.$object->id.'">'.$langs->trans("Update").'</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.'&type='.$type.'">'.$langs->trans('Update').'</a>';
}
}

Expand All @@ -242,16 +266,22 @@
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="type" value="' . $type . '">';

if (! empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>";
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>';
$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();
print '</td></tr>';

Expand Down Expand Up @@ -280,7 +310,7 @@
{
$s=picto_from_langcode($key);
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>'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
if (! empty($conf->global->CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION))
Expand Down Expand Up @@ -308,14 +338,16 @@
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vadd">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="type" value="' . $type . '">';

print '<table class="border" width="100%">';
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 '<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>';
$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();
print '</td></tr>';

Expand Down
15 changes: 12 additions & 3 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -445,7 +445,16 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)
}

// 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
$socid = $this->socid;
Expand Down Expand Up @@ -497,7 +506,7 @@ public function create(User $user, $notrigger = 0, $forceduedate = 0)
$sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".$this->cond_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_counter?"'".$this->db->escape($this->situation_counter)."'":"null");
$sql.= ", ".($this->situation_final?$this->situation_final:0);
Expand Down Expand Up @@ -1652,7 +1661,7 @@ public function update(User $user, $notrigger = 0)
$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_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_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").",";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/card.php
Expand Up @@ -967,7 +967,7 @@
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>';
}

Expand Down
6 changes: 5 additions & 1 deletion htdocs/core/class/html.formmargin.class.php
Expand Up @@ -98,7 +98,11 @@ public function getMarginInfosArray($object, $force_price = false)

$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 = $line->qty * $pa_ht;
if ($object->type == Facture::TYPE_SITUATION) {
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
} else {
$pa = $line->qty * $pa_ht;
}

// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
Expand Down

0 comments on commit 7b08ce9

Please sign in to comment.