Skip to content

Commit

Permalink
FIX forced bank account was lost on proposal
Browse files Browse the repository at this point in the history
Fix Invoice was using duplicated bugged code for pdf removal link.
  • Loading branch information
eldy committed Jun 24, 2016
1 parent e8eee05 commit e144df7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 55 deletions.
56 changes: 6 additions & 50 deletions htdocs/compta/facture.php
Expand Up @@ -1790,57 +1790,13 @@
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';


/*
* Generate document
*/
if ($action == 'builddoc') // En get ou en post
{
$object->fetch($id);
$object->fetch_thirdparty();

// Save last template used to generate document
if (GETPOST('model'))
$object->setDocModel($user, GETPOST('model', 'alpha'));
if (GETPOST('fk_bank')) { // this field may come from an external module
$object->fk_bank = GETPOST('fk_bank');
} else {
$object->fk_bank = $object->fk_account;
}

// 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->thirdparty->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}

// Remove file in doc form
else if ($action == 'remove_file') {
if ($object->fetch($id)) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';

$object->fetch_thirdparty();
// Actions to build doc
$upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';


$langs->load("other");
$upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
$action = '';
}
} elseif ($action == 'update_extras') {
if ($action == 'update_extras') {
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/actions_builddoc.inc.php
Expand Up @@ -51,15 +51,15 @@
// Save last template used to generate document
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));

// Special case for invoices
if (property_exists($object, 'fk_bank'))
{
// Special case to force bank account
//if (property_exists($object, 'fk_bank'))
//{
if (GETPOST('fk_bank')) { // this field may come from an external module
$object->fk_bank = GETPOST('fk_bank');
} else {
} else if (! empty($object->fk_account)) {
$object->fk_bank = $object->fk_account;
}
}
//}

$outputlangs = $langs;
$newlang='';
Expand Down

0 comments on commit e144df7

Please sign in to comment.