Merge remote-tracking branch 'origin/3.7' into 3.8

Conflicts:
	htdocs/accountancy/journal/bankjournal.php
	htdocs/core/lib/report.lib.php
	htdocs/product/stock/class/mouvementstock.class.php
This commit is contained in:
Laurent Destailleur 2015-12-03 12:59:13 +01:00
commit 12702ee128
8 changed files with 78 additions and 112 deletions

View File

@ -56,7 +56,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');
@ -67,17 +67,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;
@ -104,7 +99,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;
} }
@ -121,6 +116,11 @@ $chargestatic = new ChargeSociales($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new PaymentSalary($db);
// Get code of finance journal
$bank_code_journal = new Account($db);
$result=$bank_code_journal->fetch($id_bank_account);
$journal=$bank_code_journal->accountancy_journal;
dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
@ -278,7 +278,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 )
@ -299,7 +299,7 @@ if ($action == 'writeBookKeeping')
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0 ? $mt : 0); $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
$bookkeeping->credit = ($mt < 0 ? - $mt : 0); $bookkeeping->credit = ($mt < 0 ? - $mt : 0);
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
if ($tabtype[$key] == 'payment') { if ($tabtype[$key] == 'payment') {
@ -350,7 +350,7 @@ if ($action == 'writeBookKeeping')
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? - $mt : 0); $bookkeeping->debit = ($mt < 0 ? - $mt : 0);
$bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_BANK_JOURNAL; $bookkeeping->code_journal = $journal;
$bookkeeping->fk_user_author = $user->id; $bookkeeping->fk_user_author = $user->id;
if ($tabtype[$key] == 'sc') { if ($tabtype[$key] == 'sc') {
@ -420,10 +420,8 @@ 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;
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');
@ -434,16 +432,20 @@ 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'); $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;
@ -461,7 +463,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 {
@ -483,8 +485,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;
@ -495,8 +497,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');
@ -538,7 +539,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) : '') . '"';
@ -548,67 +549,25 @@ 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" . ' - ' . $journal);
$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);
// Report
$h=0; $varlink = 'id_account='.$id_bank_account;
$head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal; report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
$head[$h][1] = $langs->trans("Report");
$head[$h][2] = 'card';
dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">';
print '<table width="100%" class="border">';
// Title
print '<tr>';
print '<td 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>'.$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">
function launch_export() { function launch_export() {
@ -616,8 +575,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("");
} }
@ -687,7 +646,7 @@ 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>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";

View File

@ -818,7 +818,7 @@ class ExtraFields
} }
else else
{ {
$sqlwhere.= ' WHERE 1'; $sqlwhere.= ' WHERE 1=1';
} }
if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it.
$sql.=$sqlwhere; $sql.=$sqlwhere;

View File

@ -550,7 +550,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR')
if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates';
$i=0; $i=0;
while ($timestampStart < $timestampEnd && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) while ($timestampStart <= $timestampEnd && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop)
{ {
$ferie=false; $ferie=false;
$countryfound=0; $countryfound=0;

View File

@ -26,33 +26,36 @@
/** /**
* Show header of a VAT report * Show header of a VAT report
* *
* @param string $nom Name of report * @param string $nom Name of report
* @param string $variante Link for alternate report * @param string $variante Link for alternate report
* @param string $period Period of report * @param string $period Period of report
* @param string $periodlink Link to switch period * @param string $periodlink Link to switch period
* @param string $description Description * @param string $description Description
* @param timestamp|integer $builddate Date generation * @param timestamp|integer $builddate Date generation
* @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
* @return void * @param string $varlink Add a variable into the address of the page
* @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;
if (empty($hselected)) $hselected='report'; if (empty($hselected)) $hselected='report';
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.'">';
@ -115,7 +118,8 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
print '</form>'; print '</form>';
print '</div>'; dol_fiche_end();
print "\n<!-- fin cartouche rapport -->\n\n"; print "\n<!-- fin cartouche rapport -->\n\n";
} }

View File

@ -121,10 +121,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

View File

@ -121,4 +121,5 @@ UseTypeFieldToChange=Use field Type to change
OpenIDURL=OpenID URL OpenIDURL=OpenID URL
LoginUsingOpenID=Use OpenID to login LoginUsingOpenID=Use OpenID to login
WeeklyHours=Weekly hours WeeklyHours=Weekly hours
ColorUser=Color of the user ColorUser=Color of the user
DisabledInMonoUserMode=Disabled in maintenance mode

View File

@ -629,17 +629,18 @@ class MouvementStock extends CommonObject
return $result; return $result;
} }
/** /**
* Get origin * Return Url link of origin object
* *
* @param variant $fk_origin id of origin * @param int $fk_origin Id origin
* @param int $origintype origin type * @param int $origintype Type origin
* @return string Url link to object * @return string
*/ */
function get_origin($fk_origin, $origintype) function get_origin($fk_origin, $origintype)
{ {
switch ($origintype) $origin='';
{
switch ($origintype) {
case 'commande': case 'commande':
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$origin = new Commande($this->db); $origin = new Commande($this->db);
@ -676,8 +677,11 @@ class MouvementStock extends CommonObject
if (empty($origin) || ! is_object($origin)) return ''; if (empty($origin) || ! is_object($origin)) return '';
$origin->fetch($fk_origin); if ($origin->fetch($fk_origin) > 0) {
return $origin->getNomUrl(1); return $origin->getNomUrl(1);
}
return '';
} }

View File

@ -2537,7 +2537,7 @@ class Societe extends CommonObject
} }
//Verify duplicate entries //Verify duplicate entries
$sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."'"; $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe',1).")";
if($socid) $sql .= " AND rowid <> ".$socid; if($socid) $sql .= " AND rowid <> ".$socid;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)