Merge pull request #4101 from aspangaro/3.7-accountancy
Fix #4069 Accountancy - button "export" don't work on finance journal
This commit is contained in:
commit
ae87a270e4
@ -55,7 +55,7 @@ $langs->load("bank");
|
|||||||
$langs->load('bills');
|
$langs->load('bills');
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
|
|
||||||
$id_accountancy_journal = GETPOST('id_account');
|
$id_bank_account = GETPOST('id_account','int');
|
||||||
|
|
||||||
$date_startmonth = GETPOST('date_startmonth');
|
$date_startmonth = GETPOST('date_startmonth');
|
||||||
$date_startday = GETPOST('date_startday');
|
$date_startday = GETPOST('date_startday');
|
||||||
@ -66,17 +66,12 @@ $date_endyear = GETPOST('date_endyear');
|
|||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0 && empty($id_bank_account))
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
if (empty($id_accountancy_journal))
|
|
||||||
{
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = strftime("%Y", dol_now());
|
||||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||||
$pastmonthyear = $year_current;
|
$pastmonthyear = $year_current;
|
||||||
@ -103,7 +98,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
|
|||||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid";
|
||||||
$sql .= " WHERE ba.rowid=".$id_accountancy_journal;
|
$sql .= " WHERE ba.rowid=".$id_bank_account;
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
$sql .= " AND ba.entity = " . $conf->entity;
|
$sql .= " AND ba.entity = " . $conf->entity;
|
||||||
}
|
}
|
||||||
@ -264,7 +259,7 @@ if ($result) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Write bookkeeping
|
// Write bookkeeping
|
||||||
if ($action == 'writeBookKeeping')
|
if ($action == 'writebookkeeping')
|
||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ( $tabpay as $key => $val )
|
foreach ( $tabpay as $key => $val )
|
||||||
@ -406,10 +401,9 @@ if ($action == 'writeBookKeeping')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Export
|
// Export
|
||||||
if ($action == 'export_csv')
|
if ($action == 'export_csv') {
|
||||||
{
|
|
||||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||||
$bank_journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
|
$journal = $conf->global->ACCOUNTING_BANK_JOURNAL;
|
||||||
|
|
||||||
header('Content-Type: text/csv');
|
header('Content-Type: text/csv');
|
||||||
header('Content-Disposition: attachment;filename=journal_banque.csv');
|
header('Content-Disposition: attachment;filename=journal_banque.csv');
|
||||||
@ -421,16 +415,16 @@ if ($action == 'export_csv')
|
|||||||
$sep = ";";
|
$sep = ";";
|
||||||
|
|
||||||
foreach ( $tabpay as $key => $val ) {
|
foreach ( $tabpay as $key => $val ) {
|
||||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
|
||||||
|
|
||||||
|
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
|
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||||
|
|
||||||
|
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||||
|
|
||||||
// Bank
|
// Bank
|
||||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $bank_journal . $sep;
|
print $journal . $sep;
|
||||||
print length_accountg(html_entity_decode($k)) . $sep;
|
print length_accountg(html_entity_decode($k)) . $sep;
|
||||||
print $sep;
|
print $sep;
|
||||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||||
@ -448,7 +442,7 @@ if ($action == 'export_csv')
|
|||||||
if ($mt)
|
if ($mt)
|
||||||
{
|
{
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $bank_journal . $sep;
|
print $journal . $sep;
|
||||||
if ($val["lib"] == '(SupplierInvoicePayment)') {
|
if ($val["lib"] == '(SupplierInvoicePayment)') {
|
||||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||||
} else {
|
} else {
|
||||||
@ -470,8 +464,8 @@ if ($action == 'export_csv')
|
|||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
print $date . $sep;
|
print $date . $sep;
|
||||||
print $bank_journal . $sep;
|
print $journal . $sep;
|
||||||
print $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . $sep;
|
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep;
|
||||||
print $sep;
|
print $sep;
|
||||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||||
@ -482,8 +476,7 @@ if ($action == 'export_csv')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else // Model Classic Export
|
} else { // Model Classic Export
|
||||||
{
|
|
||||||
foreach ( $tabpay as $key => $val ) {
|
foreach ( $tabpay as $key => $val ) {
|
||||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||||
|
|
||||||
@ -525,7 +518,7 @@ if ($action == 'export_csv')
|
|||||||
{
|
{
|
||||||
print '"' . $date . '"' . $sep;
|
print '"' . $date . '"' . $sep;
|
||||||
print '"' . $val["ref"] . '"' . $sep;
|
print '"' . $val["ref"] . '"' . $sep;
|
||||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . '"' . $sep;
|
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||||
print '"' . $langs->trans("Bank") . '"' . $sep;
|
print '"' . $langs->trans("Bank") . '"' . $sep;
|
||||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||||
@ -535,66 +528,21 @@ if ($action == 'export_csv')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
llxHeader('', $langs->trans("BankJournal"));
|
llxHeader('', $langs->trans("FinanceJournal"));
|
||||||
|
|
||||||
$namereport = $langs->trans("BankJournal");
|
$nom = $langs->trans("FinanceJournal");
|
||||||
$description = $langs->trans("DescBankJournal");
|
$builddate = time();
|
||||||
|
$description = $langs->trans("DescFinanceJournal") . '<br>';
|
||||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||||
|
$varlink = 'id_account='.$id_bank_account;
|
||||||
// Report
|
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||||
$h=0;
|
|
||||||
$head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal;
|
|
||||||
$head[$h][1] = $langs->trans("Report");
|
|
||||||
$head[$h][2] = 'report';
|
|
||||||
|
|
||||||
dol_fiche_head($head, $hselected);
|
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">';
|
|
||||||
print '<table width="100%" class="border">';
|
|
||||||
|
|
||||||
// Title
|
|
||||||
print '<tr>';
|
|
||||||
print '<td valign="top" width="110">'.$langs->trans("ReportName").'</td>';
|
|
||||||
print '<td colspan="3">'.$namereport.'</td>';
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Period report
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans("ReportPeriod").'</td>';
|
|
||||||
if (! $periodlink) print '<td colspan="3">';
|
|
||||||
else print '<td>';
|
|
||||||
if ($period) print $period;
|
|
||||||
if ($periodlink) print '</td><td colspan="2">'.$periodlink;
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Description
|
|
||||||
print '<tr>';
|
|
||||||
print '<td valign="top">'.$langs->trans("ReportDescription").'</td>';
|
|
||||||
print '<td colspan="3">'.$description.'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td colspan="4" align="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
// End report
|
|
||||||
|
|
||||||
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||||
|
|
||||||
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writeBookKeeping();" />';
|
print '<input type="button" class="button" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||||
|
|
||||||
print '
|
print '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -603,8 +551,8 @@ else
|
|||||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||||
}
|
}
|
||||||
function writeBookKeeping() {
|
function writebookkeeping() {
|
||||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("writeBookKeeping");
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
|
||||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||||
}
|
}
|
||||||
@ -674,8 +622,9 @@ else
|
|||||||
print "<tr " . $bc[$var] . ">";
|
print "<tr " . $bc[$var] . ">";
|
||||||
print "<td>" . $date . "</td>";
|
print "<td>" . $date . "</td>";
|
||||||
print "<td>" . $reflabel . "</td>";
|
print "<td>" . $reflabel . "</td>";
|
||||||
print "<td>" . $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . "</td>";
|
print "<td>" . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . "</td>";
|
||||||
print "<td>" . $langs->trans('ThirdParty') . "</td>";
|
print "<td>" . $langs->trans('ThirdParty') . "</td>";
|
||||||
|
print "<td> </td>";
|
||||||
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||||
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|||||||
@ -35,22 +35,25 @@
|
|||||||
* @param string $exportlink Link for export or ''
|
* @param string $exportlink Link for export or ''
|
||||||
* @param array $moreparam Array with list of params to add into form
|
* @param array $moreparam Array with list of params to add into form
|
||||||
* @param string $calcmode Calculation mode
|
* @param string $calcmode Calculation mode
|
||||||
|
* @param string $varlink Add a variable into the address of the page
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='')
|
function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
print "\n\n<!-- debut cartouche rapport -->\n";
|
print "\n\n<!-- debut cartouche rapport -->\n";
|
||||||
|
|
||||||
|
if(! empty($varlink)) $varlink = '?'.$varlink;
|
||||||
|
|
||||||
$h=0;
|
$h=0;
|
||||||
$head[$h][0] = $_SERVER["PHP_SELF"];
|
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
|
||||||
$head[$h][1] = $langs->trans("Report");
|
$head[$h][1] = $langs->trans("Report");
|
||||||
$head[$h][2] = 'report';
|
$head[$h][2] = 'report';
|
||||||
|
|
||||||
dol_fiche_head($head, 'report');
|
dol_fiche_head($head, 'report');
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
|
||||||
foreach($moreparam as $key => $value)
|
foreach($moreparam as $key => $value)
|
||||||
{
|
{
|
||||||
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
|
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
|
||||||
|
|||||||
@ -112,10 +112,8 @@ SellsJournal=Sells journal
|
|||||||
PurchasesJournal=Purchases journal
|
PurchasesJournal=Purchases journal
|
||||||
DescSellsJournal=Sells journal
|
DescSellsJournal=Sells journal
|
||||||
DescPurchasesJournal=Purchases journal
|
DescPurchasesJournal=Purchases journal
|
||||||
BankJournal=Bank journal
|
FinanceJournal=Finance journal
|
||||||
DescBankJournal=Bank journal including all the types of payments other than cash
|
DescFinanceJournal=Finance journal including all the types of payments by bank account
|
||||||
CashJournal=Cash journal
|
|
||||||
DescCashJournal=Cash journal including the type of payment cash
|
|
||||||
|
|
||||||
CashPayment=Cash Payment
|
CashPayment=Cash Payment
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user