Fix: optimize code
This commit is contained in:
parent
6b21ca442d
commit
b1ad840055
@ -161,18 +161,16 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
|||||||
// reorder lines
|
// reorder lines
|
||||||
if ($result) $object->line_order(true);
|
if ($result) $object->line_order(true);
|
||||||
|
|
||||||
// Define output language
|
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
|
||||||
}
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
|
// Define output language
|
||||||
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
$ret=$object->fetch($id); // Reload to get new records
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
@ -187,20 +185,18 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
|
|||||||
$result=$object->valid($user);
|
$result=$object->valid($user);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
// Define output language
|
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
|
||||||
}
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
$ret=$object->fetch($object->id); // Reload to get new records
|
// Define output language
|
||||||
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -366,17 +362,19 @@ else if ($action == 'add' && $user->rights->propal->creer)
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
// Define output language
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
// Define output language
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
|
||||||
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||||
exit;
|
exit;
|
||||||
@ -600,18 +598,19 @@ if ($action == 'modif' && $user->rights->propal->creer)
|
|||||||
{
|
{
|
||||||
$object->set_draft($user);
|
$object->set_draft($user);
|
||||||
|
|
||||||
// Define output language
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
// Define output language
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == "setabsolutediscount" && $user->rights->propal->creer)
|
else if ($action == "setabsolutediscount" && $user->rights->propal->creer)
|
||||||
@ -795,20 +794,18 @@ else if ($action == "addline" && $user->rights->propal->creer)
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Define output language
|
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate("",$conf);
|
|
||||||
$outputlangs->setDefaultLang($newlang);
|
|
||||||
}
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
$ret=$object->fetch($id); // Reload to get new records
|
// Define output language
|
||||||
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($_POST['qty']);
|
unset($_POST['qty']);
|
||||||
@ -922,15 +919,12 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
|
|||||||
{
|
{
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$object->fetch($id); // Reload to get new records
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
@ -971,15 +965,15 @@ else if ($action == 'builddoc' && $user->rights->propal->creer)
|
|||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
$result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
$result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
@ -1056,17 +1050,19 @@ else if ($action == 'up' && $user->rights->propal->creer)
|
|||||||
{
|
{
|
||||||
$object->line_up(GETPOST('rowid'));
|
$object->line_up(GETPOST('rowid'));
|
||||||
|
|
||||||
// Define output language
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
// Define output language
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
|
||||||
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
|
||||||
exit;
|
exit;
|
||||||
@ -1076,17 +1072,19 @@ else if ($action == 'down' && $user->rights->propal->creer)
|
|||||||
{
|
{
|
||||||
$object->line_down(GETPOST('rowid'));
|
$object->line_down(GETPOST('rowid'));
|
||||||
|
|
||||||
// Define output language
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
$outputlangs = $langs;
|
|
||||||
$newlang='';
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
|
||||||
if (! empty($newlang))
|
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
// Define output language
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs = $langs;
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$ret=$object->fetch($id); // Reload to get new records
|
||||||
|
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
||||||
}
|
}
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
|
|
||||||
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user