Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into 16.0
This commit is contained in:
commit
fc91d8fc4e
@ -180,6 +180,16 @@ if (empty($reshook)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
// We check if we're allowed to add this bom
|
||||
$TParentBom=array();
|
||||
$object->getParentBomTreeRecursive($TParentBom);
|
||||
if ($bom_child_id > 0 && !empty($TParentBom) && in_array($bom_child_id, $TParentBom)) {
|
||||
$n_child = new BOM($db);
|
||||
$n_child->fetch($bom_child_id);
|
||||
setEventMessages($langs->transnoentities('BomCantAddChildBom', $n_child->getNomUrl(1), $object->getNomUrl(1)), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$bomline = new BOMLine($db);
|
||||
$bomline->fk_bom = $id;
|
||||
|
||||
@ -1147,6 +1147,38 @@ class BOM extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively retrieves all parent bom in the tree that leads to the $bom_id bom
|
||||
*
|
||||
* @param array $TParentBom We put all found parent bom in $TParentBom
|
||||
* @param int $bom_id ID of bom from which we want to get parent bom ids
|
||||
* @param int $level Protection against infinite loop
|
||||
* @return void
|
||||
*/
|
||||
public function getParentBomTreeRecursive(&$TParentBom, $bom_id = '', $level = 1)
|
||||
{
|
||||
|
||||
// Protection against infinite loop
|
||||
if ($level > 1000) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($bom_id)) $bom_id=$this->id;
|
||||
|
||||
$sql = 'SELECT l.fk_bom, b.label
|
||||
FROM '.MAIN_DB_PREFIX.'bom_bomline l
|
||||
INNER JOIN '.MAIN_DB_PREFIX.$this->table_element.' b ON b.rowid = l.fk_bom
|
||||
WHERE fk_bom_child = '.((int) $bom_id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!empty($resql)) {
|
||||
while ($res = $this->db->fetch_object($resql)) {
|
||||
$TParentBom[$res->fk_bom] = $res->fk_bom;
|
||||
$this->getParentBomTreeRecursive($TParentBom, $res->fk_bom, $level+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -315,8 +315,28 @@ if (empty($reshook)) {
|
||||
|
||||
if (!$error) {
|
||||
$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) {
|
||||
dol_print_error($db, $object->error);
|
||||
} elseif (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$model = $object->model_pdf;
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
if ($ret > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
|
||||
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'setecheance' && $usercancreate) {
|
||||
@ -325,8 +345,8 @@ if (empty($reshook)) {
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
@ -2281,13 +2301,16 @@ if ($action == 'create') {
|
||||
// Date of proposal
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DatePropal');
|
||||
print '</td>';
|
||||
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 '</tr></table>';
|
||||
// print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
// print $langs->trans('DatePropal');
|
||||
// print '</td>';
|
||||
// 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 '</tr></table>';
|
||||
$editenable = $usercancreate && $caneditfield && $object->statut == Propal::STATUS_DRAFT;
|
||||
print $form->editfieldkey("DatePropal", 'date', '', $object, $editenable);
|
||||
print '</td><td class="valuefield">';
|
||||
if ($action == 'editdate' && $usercancreate && $caneditfield) {
|
||||
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
|
||||
|
||||
@ -384,7 +384,7 @@ class Propal extends CommonObject
|
||||
$this->socid = $socid;
|
||||
$this->id = $propalid;
|
||||
|
||||
$this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION);
|
||||
$this->duree_validite = getDolGlobalInt('PROPALE_VALIDITY_DURATION', 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -112,3 +112,4 @@ MOAndLines=Manufacturing Orders and lines
|
||||
MoChildGenerate=Generate Child Mo
|
||||
ParentMo=MO Parent
|
||||
MOChild=MO Child
|
||||
BomCantAddChildBom=The nomenclature %s is already present in the tree leading to the nomenclature %s
|
||||
|
||||
@ -112,3 +112,4 @@ MOAndLines=Ordres de fabrication et lignes
|
||||
MoChildGenerate=Generate Child Mo
|
||||
ParentMo=MO Parent
|
||||
MOChild=MO Child
|
||||
BomCantAddChildBom=La nomenclature %s est déjà présente dans l'arborescence qui mène à la nomenclature %s
|
||||
|
||||
Loading…
Reference in New Issue
Block a user