diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 394742c7d2a..206191f5967 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -319,10 +319,11 @@ if (empty($reshook)) if ($i) $sql.=","; $sql.= $field."="; -// print $keycode.' - '.$_POST[$keycode].'
'; - if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 + //print $keycode.' - '.$_POST[$keycode].'
'; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 + elseif ($keycode == 'position') $sql.=((int) $_POST[$keycode]); else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8834d93d162..0e09e5570e9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1535,6 +1535,7 @@ if (empty($reshook)) { $line->origin = $object->origin; $line->origin_id = $line->id; + $line->fk_prev_id = $line->id; $line->fetch_optionals($line->id); $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note @@ -3250,8 +3251,7 @@ if ($action == 'create') print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid,$origin,'','facture'); - $cntinvoice=count($objectsrc->linkedObjects['facture']); - if ($cntinvoice>=1) + if (is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1) { setEventMessages('WarningBillExist', null, 'warnings'); echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')';