Skip to content

Commit

Permalink
Spaces !!!
Browse files Browse the repository at this point in the history
  • Loading branch information
aspangaro committed Feb 27, 2016
1 parent ba6dadb commit 0136a17
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions htdocs/accountancy/journal/bankjournal.php
Expand Up @@ -23,9 +23,9 @@
*/

/**
* \file htdocs/accountancy/journal/bankjournal.php
* \ingroup Accounting Expert
* \brief Page with bank journal
* \file htdocs/accountancy/journal/bankjournal.php
* \ingroup Advanced accountancy
* \brief Page with bank journal
*/
require '../../main.inc.php';

Expand Down Expand Up @@ -72,7 +72,7 @@
if ($user->societe_id > 0 && empty($id_bank_account))
accessforbidden();

/*
/*
* View
*/
$year_current = strftime("%Y", dol_now());
Expand Down Expand Up @@ -127,30 +127,30 @@
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {

$num = $db->num_rows($result);
// Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$accountancy_account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"));
$accountancy_account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef"));
$accountancy_account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));

$tabpay = array ();
$tabbq = array ();
$tabtp = array ();
$tabtype = array ();

$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);

$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_compta
);

// Controls
$compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)')
Expand All @@ -159,8 +159,8 @@
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
// Variable bookkeeping

// Variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do;
$tabpay[$obj->rowid]["type_payment"] = $obj->fk_type;
$tabpay[$obj->rowid]["ref"] = $obj->label;
Expand All @@ -171,12 +171,12 @@
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
}
$links = $object->get_url($obj->rowid);

// get_url may return -1 which is not traversable
if (is_array($links)) {
foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type'];

if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
Expand All @@ -197,7 +197,7 @@
} else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];

$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
Expand All @@ -208,14 +208,14 @@
}
$chargestatic->ref = $chargestatic->lib;
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);

$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;

dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
Expand Down Expand Up @@ -247,9 +247,9 @@
}*/
}
}

$tabbq[$obj->rowid][$compta_bank] += $obj->amount;

// if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount;

$i ++;
Expand All @@ -265,7 +265,7 @@
// Write bookkeeping
if ($action == 'writebookkeeping') {
$now = dol_now();

$error = 0;
foreach ( $tabpay as $key => $val ) {
// Bank
Expand All @@ -286,9 +286,9 @@
$bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now;

if ($tabtype[$key] == 'payment') {

$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
Expand All @@ -301,7 +301,7 @@
$bookkeeping->doc_ref = $objmid->facnumber;
}
} else if ($tabtype[$key] == 'payment_supplier') {

$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
Expand All @@ -315,7 +315,7 @@
;
}
}

$result = $bookkeeping->create($user);
if ($result < 0) {
$error ++;
Expand All @@ -338,12 +338,12 @@
$bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now;

if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment') {

$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
Expand All @@ -358,7 +358,7 @@
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') {

$sqlmid = 'SELECT facf.ref_supplier,facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
Expand All @@ -373,7 +373,7 @@
$bookkeeping->code_tiers = $k;
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'company') {

$sqlmid = 'SELECT fac.facnumber';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
Expand All @@ -392,41 +392,41 @@
$bookkeeping->doc_ref = $k;
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
}

$result = $bookkeeping->create($user);
if ($result < 0) {
$error ++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

if (empty($error)) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
}
}
// Export
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;

include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';

$companystatic = new Client($db);

// Model Cegid Expert Export
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
{
$sep = ";";

foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');

$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];

$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');

// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print $date . $sep;
Expand All @@ -439,7 +439,7 @@
print $val["ref"] . $sep;
print "\n";
}

// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
Expand Down Expand Up @@ -477,10 +477,10 @@
// Model Classic Export
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');

$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];

// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . $date . '"' . $sep;
Expand All @@ -491,7 +491,7 @@
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
}

// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
Expand Down Expand Up @@ -520,23 +520,23 @@
}
} else {
$form = new Form($db);

llxHeader('', $langs->trans("FinanceJournal"));

$nom = $langs->trans("FinanceJournal") . ' - ' . $journal;
$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);

$varlink = 'id_account=' . $id_bank_account;
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
), '', $varlink);

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 '
<script type="text/javascript">
function launch_export() {
Expand All @@ -550,12 +550,12 @@ function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';

/*
* Show result array
*/
print '<br><br>';

$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
Expand All @@ -566,10 +566,10 @@ function writebookkeeping() {
print "<td>" . $langs->trans("PaymentMode") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td><td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n";

$var = true;
$r = '';

foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');

Expand All @@ -579,8 +579,8 @@ function writebookkeeping() {
if ($val["lib"] == '(CustomerInvoicePayment)') {
$reflabel = $langs->trans('CustomerInvoicePayment');
}
// Bank

// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
Expand All @@ -592,7 +592,7 @@ function writebookkeeping() {
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
}

// Third party
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
Expand Down Expand Up @@ -623,9 +623,9 @@ function writebookkeeping() {
}
$var = ! $var;
}

print "</table>";

llxFooter();
}
$db->close();

0 comments on commit 0136a17

Please sign in to comment.