Fix: several bugs into document generation (default must be used in

priority when not template defined).
Fix: use first odt file when no odt file defined.
Fix: Must use output translation.
This commit is contained in:
Laurent Destailleur 2014-10-27 19:37:30 +01:00
parent 31d8f792e5
commit 132ddf65d6
9 changed files with 258 additions and 205 deletions

View File

@ -177,16 +177,22 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr
{ {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
if (! empty($conf->global->MAIN_MULTILANGS))
{ {
$outputlangs = new Translate("", $conf); $outputlangs = $langs;
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); $newlang = '';
$outputlangs->setDefaultLang($newlang); if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
if (empty($model)) { $tmp=getListOfModels($db, 'propal'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} else { } else {
$langs->load("errors"); $langs->load("errors");
@ -481,19 +487,26 @@ else if ($action == 'add' && $user->rights->propal->creer)
{ {
$db->commit(); $db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) // Define output language
{ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
// Define output language {
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($conf->global->MAIN_MULTILANGS)) $newlang = '';
{ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$outputlangs = new Translate("", $conf); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); if (! empty($newlang)) {
$outputlangs->setDefaultLang($newlang); $outputlangs = new Translate("", $conf);
} $outputlangs->setDefaultLang($newlang);
$ret = $object->fetch($id); // Reload to get new records }
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $model=$object->modelpdf;
} if (empty($model)) {
$tmp=getListOfModels($db, 'propal'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit(); exit();

View File

@ -908,20 +908,23 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co
if (! $error) { if (! $error) {
$result = $object->valid($user, $idwarehouse); $result = $object->valid($user, $idwarehouse);
if ($result >= 0) { if ($result >= 0)
{
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if (empty($model)) { $tmp=getListOfModels($db, 'order'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} }
} }
@ -954,21 +957,23 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) {
if (! $error) { if (! $error) {
$result = $object->set_draft($user, $idwarehouse); $result = $object->set_draft($user, $idwarehouse);
if ($result >= 0) { if ($result >= 0)
{
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
$ret = $object->fetch($object->id); // Reload to get new records if (empty($model)) { $tmp=getListOfModels($db, 'order'); $keys=array_keys($tmp); $model=$keys[0]; }
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} }
} }

View File

@ -406,21 +406,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
if ($result >= 0) if ($result >= 0)
{ {
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
} }
} else { }
else
{
if (count($object->errors)) setEventMessage($object->errors, 'errors'); if (count($object->errors)) setEventMessage($object->errors, 'errors');
else setEventMessage($object->error, 'errors'); else setEventMessage($object->error, 'errors');
} }
@ -483,20 +487,22 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
$result=$object->set_draft($user, $idwarehouse); $result=$object->set_draft($user, $idwarehouse);
if ($result<0) setEventMessage($object->error,'errors'); if ($result<0) setEventMessage($object->error,'errors');
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang = ''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $outputlangs = $langs;
$newlang = $_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $model=$object->modelpdf;
if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
} }
} }
@ -1308,20 +1314,23 @@ else if ($action == 'addline' && $user->rights->facture->creer)
// Insert line // Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option);
if ($result > 0) { if ($result > 0)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { {
// Define output language // Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs; $outputlangs = $langs;
$newlang = GETPOST('lang_id', 'alpha'); $newlang = '';
if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
$newlang = $object->thirdparty->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) { if (! empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
if (empty($model)) { $tmp=getListOfModels($db, 'invoice'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
unset($_POST['prod_entry_mode']); unset($_POST['prod_entry_mode']);

View File

@ -525,23 +525,22 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
if ($result > 0) if ($result > 0)
{ {
/* // Define output language
// Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$outputlangs = $langs; {
$newlang=''; $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (! empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) $model=$object->modelpdf;
{ if (empty($model)) { $tmp=getListOfModels($db, 'contract'); $keys=array_keys($tmp); $model=$keys[0]; }
$ret=$object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
*/
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);

View File

@ -1341,6 +1341,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'"; $sql.= " WHERE type = '".$type."'";
$sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
$sql.= " ORDER BY description DESC";
dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);

View File

@ -250,26 +250,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->exped
} }
else else
{ {
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$newlang=''; {
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; $newlang = '';
if (! empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
{ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
$outputlangs = new Translate("",$conf); if (! empty($newlang)) {
$outputlangs->setDefaultLang($newlang); $outputlangs = new Translate("", $conf);
} $outputlangs->setDefaultLang($newlang);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) }
{ $model=$object->modelpdf;
$ret=$object->fetch($id); // Reload to get new records if (empty($model)) {
$result = $object->generateDocument($object->modelpdf, $outputlangs); $tmp=getListOfModels($db, 'shipping'); $keys=array_keys($tmp); $model=$keys[0];
} }
if ($result < 0) $ret = $object->fetch($id); // Reload to get new records
{ $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
dol_print_error($db,$result); if ($result < 0) dol_print_error($db,$result);
exit; }
}
} }
} }

View File

@ -341,19 +341,24 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{ {
$ret=$object->fetch($object->id); // Reload to get new records $ret=$object->fetch($object->id); // Reload to get new records
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
// Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=GETPOST('lang_id','alpha'); $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (! empty($newlang)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
} }
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);
@ -438,19 +443,28 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
unset($_POST['date_end']); unset($_POST['date_end']);
unset($localtax1_tx); unset($localtax1_tx);
unset($localtax2_tx); unset($localtax2_tx);
if ($result >= 0) if ($result >= 0)
{ {
$outputlangs = $langs; // Define output language
if (GETPOST('lang_id')) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang(GETPOST('lang_id')); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$ret=$object->fetch($object->id); // Reload to get new records $outputlangs = new Translate("", $conf);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
} }
else else
{ {
@ -496,17 +510,25 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn
$result = $object->valid($user); $result = $object->valid($user);
if ($result >= 0) if ($result >= 0)
{ {
$outputlangs = $langs; // Define output language
if (GETPOST('lang_id')) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang(GETPOST('lang_id')); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
$ret=$object->fetch($object->id); // Reload to get new records $outputlangs = new Translate("", $conf);
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $outputlangs->setDefaultLang($newlang);
} }
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'order_supplier'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
} }
else else
{ {
@ -1760,7 +1782,7 @@ elseif (! empty($object->id))
if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Validate // Validate
if ($object->statut == 0 && $num > 0) if ($object->statut == 0 && $num > 0)
{ {
@ -1770,7 +1792,7 @@ elseif (! empty($object->id))
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';
} }
} }
// Modify // Modify
if ($object->statut == 1) if ($object->statut == 1)
{ {
@ -1779,7 +1801,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>';
} }
} }
// Approve // Approve
if ($object->statut == 1) if ($object->statut == 1)
{ {
@ -1794,7 +1816,7 @@ elseif (! empty($object->id))
print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>'; print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>';
} }
} }
// Send // Send
if (in_array($object->statut, array(2, 3, 4, 5))) if (in_array($object->statut, array(2, 3, 4, 5)))
{ {
@ -1803,7 +1825,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
} }
} }
// Reopen // Reopen
if (in_array($object->statut, array(2, 5, 6, 7, 9))) if (in_array($object->statut, array(2, 5, 6, 7, 9)))
{ {
@ -1812,7 +1834,7 @@ elseif (! empty($object->id))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
} }
} }
// Create bill // Create bill
if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
{ {
@ -1820,13 +1842,13 @@ elseif (! empty($object->id))
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
} }
//if ($user->rights->fournisseur->commande->creer && $object->statut > 2) //if ($user->rights->fournisseur->commande->creer && $object->statut > 2)
//{ //{
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; // print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
//} //}
} }
// Cancel // Cancel
if ($object->statut == 2) if ($object->statut == 2)
{ {
@ -1835,19 +1857,19 @@ elseif (! empty($object->id))
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>';
} }
} }
// Clone // Clone
if ($user->rights->fournisseur->commande->creer) if ($user->rights->fournisseur->commande->creer)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>';
} }
// Delete // Delete
if ($user->rights->fournisseur->commande->supprimer) if ($user->rights->fournisseur->commande->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
} }
print "</div>"; print "</div>";
} }
} }

View File

@ -693,24 +693,25 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer)
{ {
$db->commit(); $db->commit();
// Define output language // Define output language
$outputlangs = $langs; if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$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 = $langs;
$outputlangs->setDefaultLang($newlang); $newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'invoice_supplier'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
} }
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
dol_print_error($db,$result);
exit;
}
}
unset($_POST ['prod_entry_mode']); unset($_POST ['prod_entry_mode']);
@ -774,20 +775,25 @@ elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer)
{ {
$object->set_draft($user); $object->set_draft($user);
$outputlangs = $langs; // Define output language
if (! empty($_REQUEST['lang_id'])) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = $langs;
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if (! empty($newlang)) {
if ($result <= 0) $outputlangs = new Translate("", $conf);
{ $outputlangs->setDefaultLang($newlang);
dol_print_error($db,$result); }
exit; $model=$object->modelpdf;
} if (empty($model)) {
} $tmp=getListOfModels($db, 'invoice_supplier'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
$action=''; $action='';
} }

View File

@ -124,24 +124,23 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->exped
$result = $object->valid($user); $result = $object->valid($user);
// Define output language // 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 $outputlangs = $langs;
$result= $object->generateDocument($_REQUEST['model'],$outputlangs); $newlang = '';
} if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($result < 0) if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
{ if (! empty($newlang)) {
dol_print_error($db,$result); $outputlangs = new Translate("", $conf);
exit; $outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
if (empty($model)) {
$tmp=getListOfModels($db, 'delivery'); $keys=array_keys($tmp); $model=$keys[0];
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
} }
} }