diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 7e14aaff68e..202d128182f 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -62,6 +62,7 @@ $object = new Categorie($db); /* * Actions */ +$error = 0; // retour a l'affichage des traduction si annulation if ($cancel == $langs->trans("Cancel")) @@ -78,28 +79,44 @@ $cancel != $langs->trans("Cancel") && $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 @@ -112,27 +129,34 @@ $cancel != $langs->trans("Cancel") && 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); @@ -224,8 +248,8 @@ if ($action == '') { if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - if ($cnt_trans > 0) print ''.$langs->trans("Update").''; + print ''.$langs->trans('Add').''; + if ($cnt_trans > 0) print ''.$langs->trans('Update').''; } } @@ -242,6 +266,7 @@ if ($action == 'edit') print ''; print ''; print ''; + print ''; if (! empty($object->multilangs)) { @@ -249,9 +274,14 @@ if ($action == 'edit') { print "
".$langs->trans('Language_'.$key)." :
"; print ''; - print ''; + + // Label + $libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']); + print ''; + // Desc + $desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']); print ''; @@ -280,7 +310,7 @@ elseif ($action != 'add') { $s=picto_from_langcode($key); print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $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 '
'; - print ''; + print ''; print ''; print ''; 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 ''; print ''; print ''; + print ''; print '
'.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '').'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'; print ''; - print ''; + print ''; + print ''; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4204fa0c96b..3bbf150d72f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -445,7 +445,16 @@ class Facture extends CommonInvoice } // 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; @@ -497,7 +506,7 @@ class Facture extends CommonInvoice $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); @@ -1652,7 +1661,7 @@ class Facture extends CommonInvoice $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").","; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 909dfd9e2e2..f013cd7e8aa 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -967,7 +967,7 @@ else print ''; } diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index ea038fa8131..6b7ba7348ff 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -98,7 +98,11 @@ class FormMargin $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
'.$langs->trans('Translation').''; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs); + print $formadmin->select_language(GETPOST('forcelangprod', 'alpha'), 'forcelangprod', 0, $object->multilangs); print '
'.$langs->trans('Label').'
' . $langs->trans('Label') . '
'.$langs->trans('Description').''; - $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 '
'; } - 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 '