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

Conflicts:
	htdocs/accountancy/class/bookkeeping.class.php
	htdocs/compta/paiement/cheque/class/remisecheque.class.php
	htdocs/product/class/html.formproduct.class.php
	htdocs/product/stock/index.php
	htdocs/product/stock/list.php
	htdocs/product/stock/mouvement.php
	htdocs/product/stock/product.php
	htdocs/product/stock/valo.php
This commit is contained in:
Laurent Destailleur 2015-09-09 12:45:22 +02:00
commit 7fd01d4aa3
8 changed files with 119 additions and 40 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -225,6 +225,8 @@ class BookKeeping extends CommonObject
*/ */
function create($user='') function create($user='')
{ {
global $conf;
$this->piece_num = 0; $this->piece_num = 0;
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
@ -278,13 +280,45 @@ class BookKeeping extends CommonObject
$this->date_create = $now; $this->date_create = $now;
} }
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (";
$sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,";
$sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)"; $sql .= "doc_date";
$sql .= " VALUES ('" . $this->doc_date . "','" . $this->doc_type . "','" . $this->doc_ref . "'," . $this->fk_doc . ","; $sql .= ", doc_type";
$sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',"; $sql .= ", doc_ref";
$sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '"; $sql .= ", fk_doc";
$sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")"; $sql .= ", fk_docdet";
$sql .= ", code_tiers";
$sql .= ", numero_compte";
$sql .= ", label_compte";
$sql .= ", debit";
$sql .= ", credit";
$sql .= ", montant";
$sql .= ", sens";
$sql .= ", fk_user_author";
$sql .= ", import_key";
$sql .= ", code_journal";
$sql .= ", piece_num";
$sql .= ") VALUES (";
$sql .= "'" . $this->doc_date . "'";
$sql .= ",'" . $this->doc_type . "'";
$sql .= ",'" . $this->doc_ref . "'";
$sql .= "," . $this->fk_doc;
$sql .= "," . $this->fk_docdet;
$sql .= ",'" . $this->code_tiers . "'";
$sql .= ",'" . $this->numero_compte . "'";
$sql .= ",'" . $this->db->escape($this->label_compte) . "'";
$sql .= "," . $this->debit;
$sql .= "," . $this->credit;
$sql .= "," . $this->montant;
$sql .= ",'" . $this->sens . "'";
$sql .= ",'" . $this->fk_user_author."'";
$sql .= ",'" . $this->date_create . "'";
$sql .= ",'" . $this->code_journal . "'";
$sql .= "," . $this->piece_num;
$sql .= ")";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -296,19 +330,19 @@ class BookKeeping extends CommonObject
$result = 0; $result = 0;
} else { } else {
$result = - 2; $result = - 2;
dol_syslog("BookKeeping::Create Erreur $result lecture ID"); dol_syslog("BookKeeping::Create Error $result lecture ID");
} }
} else { } else {
$result = - 1; $result = - 1;
dol_syslog("BookKeeping::Create Erreur $result INSERT Mysql"); dol_syslog("BookKeeping::Create Error $result INSERT Mysql");
} }
} else { } else {
$result = - 3; $result = - 3;
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); dol_syslog("BookKeeping::Create Error $result SELECT Mysql");
} }
} else { } else {
$result = - 5; $result = - 5;
dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); dol_syslog("BookKeeping::Create Error $result SELECT Mysql");
} }
return $result; return $result;

View File

@ -300,6 +300,7 @@ if ($action == 'writeBookKeeping')
$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 = $conf->global->ACCOUNTING_BANK_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
if ($tabtype[$key] == 'payment') { if ($tabtype[$key] == 'payment') {
@ -350,6 +351,7 @@ if ($action == 'writeBookKeeping')
$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 = $conf->global->ACCOUNTING_BANK_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
if ($tabtype[$key] == 'sc') { if ($tabtype[$key] == 'sc') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
@ -414,7 +416,7 @@ if ($action == 'writeBookKeeping')
} }
if (empty($error)) { if (empty($error)) {
setEventMessage($langs->trans('Success'), 'mesgs'); setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
} }
} }
// Export // Export

View File

@ -157,6 +157,7 @@ if ($result) {
// Bookkeeping Write // Bookkeeping Write
if ($action == 'writebookkeeping') { if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0;
foreach ( $tabfac as $key => $val ) { foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
@ -177,8 +178,13 @@ if ($action == 'writebookkeeping') {
$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_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
// Product / Service // Product / Service
@ -202,8 +208,13 @@ if ($action == 'writebookkeeping') {
$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_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
} }
} }
@ -228,11 +239,20 @@ if ($action == 'writebookkeeping') {
$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_PURCHASE_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
} }
} }
if (empty($error)) {
setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
}
} }

View File

@ -192,6 +192,7 @@ if ($result) {
if ($action == 'writebookkeeping') if ($action == 'writebookkeeping')
{ {
$now = dol_now(); $now = dol_now();
$error = 0;
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val)
{ {
@ -212,8 +213,13 @@ if ($action == 'writebookkeeping')
$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_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
// Product / Service // Product / Service
@ -237,8 +243,13 @@ if ($action == 'writebookkeeping')
$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_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
} }
} }
@ -264,11 +275,20 @@ if ($action == 'writebookkeeping')
$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_SELL_JOURNAL; $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->create(); $result = $bookkeeping->create();
if ($result < 0) {
$error ++;
setEventMessage($object->errors, 'errors');
}
} }
} }
} }
if (empty($error)) {
setEventMessage($langs->trans("GeneralLedgerIsWritten"),'mesgs');
}
} }
// Export // Export

View File

@ -2765,15 +2765,16 @@ class Facture extends CommonInvoice
$numref = ""; $numref = "";
$numref = $obj->getNextValue($soc,$this,$mode); $numref = $obj->getNextValue($soc,$this,$mode);
if ($numref != "") /**
{ * $numref can be empty in case we ask for the last value because if there is no invoice created with the
return $numref; * set up mask.
} */
else if ($mode != 'last' && !$numref) {
{
dol_print_error($db,"Facture::getNextNumRef ".$obj->error); dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return ""; return "";
} }
return $numref;
} }
else else
{ {

View File

@ -167,3 +167,4 @@ ValidateHistory=Validate Automatically
ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used
FicheVentilation=Breakdown card FicheVentilation=Breakdown card
GeneralLedgerIsWritten=Operations are written in the general ledger

View File

@ -62,6 +62,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; $sql.= " WHERE e.entity IN (".getEntity('stock', 1).")";
if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref
if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status;