Qual: Uniformize code. No useless redirect. use GETPOST.
This commit is contained in:
parent
c151ef7b87
commit
305c1d63a7
@ -1126,11 +1126,8 @@ else if ($action == 'builddoc') // In get or post
|
|||||||
* define into /core/modules/commande/modules_commande.php
|
* define into /core/modules/commande/modules_commande.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Sauvegarde le dernier modele choisi pour generer un document
|
// Save last template used to generate document
|
||||||
if ($_REQUEST['model'])
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
{
|
|
||||||
$object->setDocModel($user, $_REQUEST['model']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
@ -1149,11 +1146,6 @@ else if ($action == 'builddoc') // In get or post
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove file in doc form
|
// Remove file in doc form
|
||||||
|
|||||||
@ -217,35 +217,28 @@ if ($action == 'set_encaisse')
|
|||||||
*/
|
*/
|
||||||
if ($action == 'builddoc')
|
if ($action == 'builddoc')
|
||||||
{
|
{
|
||||||
$donation = new Don($db);
|
$object = new Don($db);
|
||||||
$donation->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
if ($_REQUEST['model'])
|
// Save last template used to generate document
|
||||||
{
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$donation->setDocModel($user, $_REQUEST['model']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$donation->client->default_lang;
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
if (! empty($newlang))
|
if (! empty($newlang))
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$result=don_create($db, $donation->id, '', $donation->modelpdf, $outputlangs);
|
$result=don_create($db, $object->id, '', $object->modelpdf, $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$donation->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1795,7 +1795,8 @@ else if ($action == 'builddoc') // En get ou en post
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model'));
|
// Save last template used to generate document
|
||||||
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank');
|
if (GETPOST('fk_bank')) $object->fk_bank=GETPOST('fk_bank');
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
@ -1814,11 +1815,6 @@ else if ($action == 'builddoc') // En get ou en post
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove file in doc form
|
// Remove file in doc form
|
||||||
|
|||||||
@ -211,10 +211,8 @@ if ($action == 'builddoc' && $user->rights->banque->cheque)
|
|||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
|
|
||||||
/*if ($_REQUEST['model'])
|
// Save last template used to generate document
|
||||||
{
|
//if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$object->setDocModel($user, $_REQUEST['model']);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
|
|||||||
@ -55,10 +55,10 @@ if ($action == 'builddoc')
|
|||||||
$rap = new pdf_paiement($db);
|
$rap = new pdf_paiement($db);
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (! empty($_REQUEST['lang_id']))
|
if (! empty(GETPOST('lang_id')))
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
$outputlangs->setDefaultLang(GETPOST('lang_id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We save charset_output to restore it because write_file can change it if needed for
|
// We save charset_output to restore it because write_file can change it if needed for
|
||||||
|
|||||||
@ -294,10 +294,9 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl'
|
|||||||
// Build document
|
// Build document
|
||||||
else if ($action == 'builddoc') // En get ou en post
|
else if ($action == 'builddoc') // En get ou en post
|
||||||
{
|
{
|
||||||
if (GETPOST('model','alpha'))
|
|
||||||
{
|
// Save last template used to generate document
|
||||||
$object->setDocModel($user, GETPOST('model','alpha'));
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
}
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
|
|||||||
@ -225,7 +225,7 @@ if ($step == 1 || $action == 'cleanselect')
|
|||||||
if ($action == 'builddoc')
|
if ($action == 'builddoc')
|
||||||
{
|
{
|
||||||
// Build export file
|
// Build export file
|
||||||
$result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected, $array_filtervalue);
|
$result=$objexport->build_file($user, GETPOST('model','alpha'), $datatoexport, $array_selected, $array_filtervalue);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
setEventMessage($objexport->error, 'errors');
|
setEventMessage($objexport->error, 'errors');
|
||||||
|
|||||||
@ -333,10 +333,8 @@ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou
|
|||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
$object->fetch_lines();
|
$object->fetch_lines();
|
||||||
|
|
||||||
if (GETPOST('model','alpha'))
|
// Save last template used to generate document
|
||||||
{
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$object->setDocModel($user, GETPOST('model','alpha'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
|
|||||||
@ -628,12 +628,8 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
|
|||||||
{
|
{
|
||||||
// Build document
|
// Build document
|
||||||
|
|
||||||
// Sauvegarde le dernier module choisi pour generer un document
|
// Save last template used to generate document
|
||||||
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
if (GETPOST('model'))
|
|
||||||
{
|
|
||||||
$object->setDocModel($user, GETPOST('model'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (GETPOST('lang_id'))
|
if (GETPOST('lang_id'))
|
||||||
@ -647,11 +643,6 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file in doc form
|
// Delete file in doc form
|
||||||
|
|||||||
@ -86,7 +86,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Action clone object
|
// Action clone object
|
||||||
if ($action == 'confirm_clone' && $confirm == 'yes')
|
if ($action == 'confirm_clone' && $confirm == 'yes')
|
||||||
@ -903,16 +903,17 @@ elseif ($action == 'builddoc')
|
|||||||
// Save modele used
|
// Save modele used
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
if ($_REQUEST['model'])
|
|
||||||
{
|
// Save last template used to generate document
|
||||||
$object->setDocModel($user, $_REQUEST['model']);
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
}
|
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (! empty($_REQUEST['lang_id']))
|
$newlang=GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
|
if (! empty($newlang))
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
$result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
@ -920,11 +921,6 @@ elseif ($action == 'builddoc')
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file in doc form
|
// Delete file in doc form
|
||||||
|
|||||||
@ -135,7 +135,7 @@ if ($action=='downfield' || $action=='upfield')
|
|||||||
if ($action == 'builddoc')
|
if ($action == 'builddoc')
|
||||||
{
|
{
|
||||||
// Build import file
|
// Build import file
|
||||||
$result=$objimport->build_file($user, $_POST['model'], $datatoimport, $array_match_file_to_database);
|
$result=$objimport->build_file($user, GETPOST('model','alpha'), $datatoimport, $array_match_file_to_database);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$objimport->error.'</div>';
|
$mesg='<div class="error">'.$objimport->error.'</div>';
|
||||||
|
|||||||
@ -184,15 +184,13 @@ if ($action == 'builddoc') // En get ou en post
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
if ($_REQUEST['model'])
|
// Save last template used to generate document
|
||||||
{
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$object->setDocModel($user, $_REQUEST['model']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
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 ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||||
if (! empty($newlang))
|
if (! empty($newlang))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -233,10 +233,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
|
|||||||
// Build doc
|
// Build doc
|
||||||
if ($action == 'builddoc' && $user->rights->projet->creer)
|
if ($action == 'builddoc' && $user->rights->projet->creer)
|
||||||
{
|
{
|
||||||
if (GETPOST('model'))
|
// Save last template used to generate document
|
||||||
{
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$object->setDocModel($user, GETPOST('model'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (GETPOST('lang_id'))
|
if (GETPOST('lang_id'))
|
||||||
@ -250,11 +248,6 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file in doc form
|
// Delete file in doc form
|
||||||
|
|||||||
@ -146,12 +146,10 @@ if (! empty($project_ref) && ! empty($withproject))
|
|||||||
// Build doc
|
// Build doc
|
||||||
if ($action == 'builddoc' && $user->rights->projet->creer)
|
if ($action == 'builddoc' && $user->rights->projet->creer)
|
||||||
{
|
{
|
||||||
if ($object->fetch($id,$ref) >= 0 )
|
$object->fetch($id,$ref);
|
||||||
{
|
|
||||||
if (GETPOST('model'))
|
// Save last template used to generate document
|
||||||
{
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
$object->setDocModel($user, GETPOST('model'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if (GETPOST('lang_id'))
|
if (GETPOST('lang_id'))
|
||||||
@ -165,12 +163,6 @@ if ($action == 'builddoc' && $user->rights->projet->creer)
|
|||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file in doc form
|
// Delete file in doc form
|
||||||
|
|||||||
@ -333,24 +333,19 @@ abstract class ActionsCardCommon
|
|||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id') ) $newlang=GETPOST('lang_id');
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$this->object->default_lang;
|
||||||
if (! empty($newlang))
|
if (! empty($newlang))
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model'), $outputlangs);
|
$result=thirdparty_doc_create($this->db, $this->object->id, '', GETPOST('model','alpha'), $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($this->db,$result);
|
dol_print_error($this->db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?socid='.$this->object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -475,17 +475,12 @@ if (empty($reshook))
|
|||||||
$outputlangs = new Translate("",$conf);
|
$outputlangs = new Translate("",$conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
}
|
}
|
||||||
$result=thirdparty_doc_create($db, $object, '', $_REQUEST['model'], $outputlangs);
|
$result=thirdparty_doc_create($db, $object, '', GETPOST('model','alpha'), $outputlangs);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$result);
|
dol_print_error($db,$result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?socid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user