diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 0500ac4a0a7..77c9a4a135e 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -27,6 +27,7 @@ require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("accountancy");
@@ -41,12 +42,24 @@ $piece_num = GETPOST("piece_num");
$mesg = '';
-$numero_compte = GETPOST('numero_compte');
+$account_number = GETPOST('account_number');
$code_tiers = GETPOST('code_tiers');
+if ($code_tiers==-1) {
+ $code_tiers=null;
+}
$label_compte = GETPOST('label_compte');
$debit = price2num(GETPOST('debit'));
$credit = price2num(GETPOST('credit'));
+$save=GETPOST('save');
+if (!empty($save)) {
+ $action='add';
+}
+$update=GETPOST('update');
+if (!empty($update)) {
+ $action='confirm_update';
+}
+
if ($action == "confirm_update") {
$error = 0;
@@ -63,7 +76,7 @@ if ($action == "confirm_update") {
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
} else {
- $book->numero_compte = $numero_compte;
+ $book->numero_compte = $account_number;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
$book->debit = $debit;
@@ -92,15 +105,15 @@ if ($action == "confirm_update") {
else if ($action == "add") {
$error = 0;
- if ((intval($debit) != 0) && (intval($credit) != 0)) {
- setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
- $error ++;
- }
+ if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
+ setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
+ $error ++;
+ }
if (empty($error)) {
$book = new BookKeeping($db);
- $book->numero_compte = $numero_compte;
+ $book->numero_compte = $account_number;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
$book->debit = $debit;
@@ -113,11 +126,12 @@ else if ($action == "add") {
$book->fk_doc = GETPOST('fk_doc');
$book->fk_docdet = GETPOST('fk_docdet');
- if (! empty($debit)) {
+ if (floatval($debit) != 0.0) {
$book->montant = $debit;
$book->sens = 'D';
}
- if (! empty($credit)) {
+
+ if (floatval($credit) != 0.0) {
$book->montant = $credit;
$book->sens = 'C';
}
@@ -179,6 +193,7 @@ else if ($action == "confirm_create") {
llxHeader();
$html = new Form($db);
+$formventilation = new FormVentilation($db);
/*
* Confirmation to delete the command
@@ -281,9 +296,21 @@ if ($action == 'create') {
} else {
print load_fiche_titre($langs->trans("ListeMvts"));
+
+ print '
';
}
}
- }
- else {
+ } else {
print load_fiche_titre($langs->trans("NoRecords"));
}
}
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 951a07d3171..84c0661825d 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -19,18 +19,17 @@
*/
/**
- * \file htdocs/accountancy/bookkeeping/list.php
- * \ingroup Accounting Expert
- * \brief List operation of book keeping
+ * \file htdocs/accountancy/bookkeeping/list.php
+ * \ingroup Accounting Expert
+ * \brief List operation of book keeping
*/
-
require '../../main.inc.php';
-
+
// Class
-require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
-require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
+require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs
$langs->load("accountancy");
@@ -58,11 +57,11 @@ $formother = new FormOther($db);
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
- $search_doc_type="";
- $search_doc_ref="";
- $search_account="";
- $search_thirdparty="";
- $search_journal="";
+ $search_piece_num = "";
+ $search_doc_ref = "";
+ $search_account = "";
+ $search_thirdparty = "";
+ $search_journal = "";
}
/*
@@ -80,8 +79,7 @@ if ($action == 'delbookkeeping') {
setEventMessages($object->error, $object->errors, 'errors');
}
}
-}
-elseif ($action == 'delbookkeepingyear') {
+} elseif ($action == 'delbookkeepingyear') {
$delyear = GETPOST('delyear', 'int');
@@ -93,8 +91,7 @@ elseif ($action == 'delbookkeepingyear') {
setEventMessages($object->error, $object->errors, 'errors');
}
}
-}
-elseif ($action == 'delbookkeepingyear') {
+} elseif ($action == 'delbookkeepingyear') {
$delyear = GETPOST('delyear', 'int');
@@ -106,7 +103,7 @@ elseif ($action == 'delbookkeepingyear') {
setEventMessages($object->error, $object->errors, 'errors');
}
}
-}// Export
+} // Export
else if ($action == 'export_csv') {
header('Content-Type: text/csv');
@@ -118,19 +115,55 @@ else if ($action == 'export_csv') {
setEventMessages($object->error, $object->errors, 'errors');
}
- foreach ( $object->linesexport as $line ) {
- print $line->id . ',';
- print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
- print '"' . $line->code_journal . '",';
- print '"' . $line->numero_compte . '",';
- print '"' . substr($line->code_journal, 0, 2) . '",';
- print '"' . substr($line->doc_ref, 0, 40) . '",';
- print '"' . $line->num_piece . '",';
- print '"' . $line->montant . '",';
- print '"' . $line->sens . '",';
- print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
- print '"' . $conf->currency . '",';
- print "\n";
+ // Model classic Export
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
+
+ foreach ( $object->linesexport as $line ) {
+ print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
+ print '"' . $line->code_journal . '",';
+ print '"' . $line->numero_compte . '",';
+ print '"' . substr($line->code_journal, 0, 2) . '",';
+ print '"' . substr($line->doc_ref, 0, 40) . '",';
+ print '"' . $line->num_piece . '",';
+ print '"' . $line->debit . '",';
+ print '"' . $line->credit . '",';
+ print '"' . $conf->currency . '",';
+ print "\n";
+ }
+ }
+ // Model cegid Export
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
+ foreach ( $object->linesexport as $line ) {
+ print $line->id . ',';
+ print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
+ print '"' . $line->code_journal . '",';
+ print '"' . $line->numero_compte . '",';
+ print '"' . substr($line->code_journal, 0, 2) . '",';
+ print '"' . substr($line->doc_ref, 0, 40) . '",';
+ print '"' . $line->num_piece . '",';
+ print '"' . $line->montant . '",';
+ print '"' . $line->sens . '",';
+ print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
+ print '"' . $conf->currency . '",';
+ print "\n";
+ }
+ }
+ // Model Coala Export
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) {
+ foreach ( $object->linesexport as $line ) {
+ print $line->id . ',';
+ print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
+ print '"' . $line->code_journal . '",';
+ print '"' . $line->numero_compte . '",';
+ print '"' . substr($line->code_journal, 0, 2) . '",';
+ print '"' . substr($line->doc_ref, 0, 40) . '",';
+ print '"' . $line->num_piece . '",';
+ print '"' . $line->montant . '",';
+ print '"' . $line->sens . '",';
+ print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",';
+ print '"' . $conf->currency . '",';
+ print "\n";
+ }
}
}
@@ -138,16 +171,16 @@ else {
llxHeader('', $langs->trans("Bookkeeping"));
-/*
- * List
- */
+ /*
+ * List
+ */
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
if (dol_strlen(trim($search_doc_type))) {
- $sql .= " WHERE bk.doc_type LIKE '%" . $search_doc_type . "%'";
+ $sql .= " WHERE bk.piece_num LIKE '%" . $search_piece_num . "%'";
if (dol_strlen(trim($search_doc_ref))) {
$sql .= " AND bk.doc_ref LIKE '%" . $search_doc_ref . "%'";
@@ -177,20 +210,20 @@ else {
print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num);
/*print '';*/
+ print '';
+ print '';
+
+ print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey'));
+
+ print '';
+
+ print '';*/
print '