Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
aa2ea621c3
@ -72,10 +72,10 @@ $date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$action = GETPOST('action','aZ09');
|
||||
$in_bookkeeping = GETPOST('in_bookkeeping');
|
||||
|
||||
$now = dol_now();
|
||||
$action = GETPOST('action','aZ09');
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0 && empty($id_journal))
|
||||
@ -121,6 +121,8 @@ $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal;
|
||||
$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'";
|
||||
if ($in_bookkeeping == 'yes')
|
||||
$sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
|
||||
$sql .= " ORDER BY b.datev";
|
||||
|
||||
$object = new Account($db);
|
||||
@ -366,6 +368,7 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $val["label"];
|
||||
$bookkeeping->label_compte = $langs->trans("Bank");
|
||||
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||
@ -473,6 +476,17 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$sqlmid = 'SELECT ch.libelle, t.libelle as labelc';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "chargesociales ch ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paych ON paych.fk_charge=ch.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "c_chargesociales as t ON ch.fk_type=t.id";
|
||||
$sqlmid .= " WHERE paych.fk_bank=" . $key;
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->label_compte = $objmid->labelc;
|
||||
$bookkeeping->doc_ref = $objmid->libelle ;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
@ -597,7 +611,6 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
}
|
||||
|
||||
// Export
|
||||
/*
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
|
||||
@ -606,14 +619,10 @@ if ($action == 'export_csv') {
|
||||
$companystatic = new Client($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
|
||||
{
|
||||
$sep = ";";
|
||||
|
||||
// Bank
|
||||
foreach ( $tabpay as $key => $val ) {
|
||||
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
|
||||
|
||||
$date = dol_print_date($db->jdate($val["date"]), 'day');
|
||||
|
||||
$reflabel = $val["ref"];
|
||||
if ($reflabel == '(SupplierInvoicePayment)') {
|
||||
$reflabel = $langs->trans('Supplier');
|
||||
@ -637,88 +646,16 @@ if ($action == 'export_csv') {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
|
||||
$userstatic->id = $tabuser[$key]['id'];
|
||||
$userstatic->lastname = $tabuser[$key]['lastname'];
|
||||
$userstatic->firstname = $tabuser[$key]['firstname'];
|
||||
|
||||
// Bank
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print $langs->trans('Bank')." - ". utf8_decode($val["ref"]) . $sep;
|
||||
} else {
|
||||
print $langs->trans("Bank") .' - '.utf8_decode($companystatic->name) . $sep;
|
||||
}
|
||||
print utf8_decode($reflabel) . $sep;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Third party
|
||||
if (is_array($tabtp[$key])) {
|
||||
foreach ( $tabtp[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $journal . $sep;
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
} else {
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
}
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
|
||||
} else {
|
||||
print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
|
||||
}
|
||||
print utf8_decode($reflabel) . $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ( $tabbq[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print $langs->trans('ThirdParty')." - ". utf8_decode($val["ref"]) . $sep;
|
||||
} else {
|
||||
print $langs->trans('ThirdParty')." - ". utf8_decode($companystatic->name) . $sep;
|
||||
}
|
||||
print utf8_decode($reflabel) . $sep;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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 '"' . $journal . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans('Bank') . " - " . utf8_decode($val["ref"]) . '"' . $sep;
|
||||
print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
@ -734,9 +671,21 @@ if ($action == 'export_csv') {
|
||||
print '"' . $journal . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["type_payment"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
|
||||
if ($tabtype[$key] == 'payment_supplier') {
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
} else if($tabtype[$key] == 'payment') {
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
} else {
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($val["ref"]) . '"' . $sep;
|
||||
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
@ -751,8 +700,10 @@ if ($action == 'export_csv') {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($val["ref"]) . '"' . $sep;
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
@ -763,8 +714,6 @@ if ($action == 'export_csv') {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
@ -802,6 +751,7 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||
print '</div>';
|
||||
|
||||
// TODO Avoid using js. We can use a direct link with $param
|
||||
@ -863,6 +813,9 @@ if (empty($action) || $action == 'view') {
|
||||
if ($reflabel == '(ExpenseReportPayment)') {
|
||||
$reflabel = $langs->trans('Employee');
|
||||
}
|
||||
if ($reflabel == '(payment_salary)') {
|
||||
$reflabel = $langs->trans('Employee');
|
||||
}
|
||||
|
||||
$ref=$reflabel;
|
||||
if ($tabtype[$key] == 'payment')
|
||||
|
||||
@ -43,7 +43,7 @@ $langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action','aZ09');
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
@ -51,6 +51,7 @@ $date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$in_bookkeeping = GETPOST('in_bookkeeping');
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
@ -108,6 +109,8 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
}
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
if ($in_bookkeeping == 'yes')
|
||||
$sql .= " AND (f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice') )";
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/purchasesjournal.php:: $sql=' . $sql);
|
||||
@ -385,69 +388,15 @@ if ($action == 'writebookkeeping') {
|
||||
$form = new Form($db);
|
||||
|
||||
$companystatic = new Fournisseur($db);
|
||||
$invoicestatic = new FactureFournisseur($db);
|
||||
|
||||
// Export
|
||||
/*if ($action == 'export_csv') {
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($val["description"], 32) . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $purchase_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print $companystatic->name . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
@ -468,44 +417,60 @@ $companystatic = new Fournisseur($db);
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
// print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal_label . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
// print '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal_label . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("subledger_account") . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
|
||||
print '"' . $journal_label . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (empty($action) || $action == 'view') {
|
||||
|
||||
@ -548,6 +513,7 @@ if (empty($action) || $action == 'view') {
|
||||
else {
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
}
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||
print '</div>';
|
||||
|
||||
print '
|
||||
|
||||
@ -46,7 +46,7 @@ $langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
$action = GETPOST('action','aZ09');
|
||||
$action = GETPOST('action','alpha');
|
||||
|
||||
$date_startmonth = GETPOST('date_startmonth');
|
||||
$date_startday = GETPOST('date_startday');
|
||||
@ -54,6 +54,7 @@ $date_startyear = GETPOST('date_startyear');
|
||||
$date_endmonth = GETPOST('date_endmonth');
|
||||
$date_endday = GETPOST('date_endday');
|
||||
$date_endyear = GETPOST('date_endyear');
|
||||
$in_bookkeeping = GETPOST('in_bookkeeping');
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
@ -113,6 +114,8 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND fd.product_type IN (0,1)";
|
||||
if ($date_start && $date_end)
|
||||
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
|
||||
if ($in_bookkeeping == 'yes')
|
||||
$sql .= " AND (f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice') )";
|
||||
$sql .= " ORDER BY f.datef";
|
||||
|
||||
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
|
||||
@ -401,76 +404,18 @@ if ($action == 'writebookkeeping') {
|
||||
$form = new Form($db);
|
||||
|
||||
// Export
|
||||
/*if ($action == 'export_csv') {
|
||||
if ($action == 'export_csv') {
|
||||
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
$companystatic = new Client($db);
|
||||
$invoicestatic = new Facture($db);
|
||||
|
||||
// Model Cegid Expert Export
|
||||
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
|
||||
$sep = ";";
|
||||
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
|
||||
$invoicestatic->id = $key;
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
|
||||
$date = dol_print_date($val["date"], '%d%m%Y');
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep;
|
||||
print length_accounta(html_entity_decode($k)) . $sep;
|
||||
print ($mt < 0 ? 'C' : 'D') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount_static = new AccountingAccount($db);
|
||||
if ($accountingaccount_static->fetch(null, $k, true)) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// TVA
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
if ($mt) {
|
||||
print $date . $sep;
|
||||
print $sell_journal . $sep;
|
||||
print length_accountg(html_entity_decode($k)) . $sep;
|
||||
print $sep;
|
||||
print ($mt < 0 ? 'D' : 'C') . $sep;
|
||||
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
|
||||
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
|
||||
// print $langs->trans("VAT") . $sep;
|
||||
print $val["ref"];
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
|
||||
// Model Classic Export
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
foreach ( $tabfac as $key => $val ) {
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
$companystatic->client = $tabcompany[$key]['code_client'];
|
||||
@ -479,49 +424,70 @@ $form = new Form($db);
|
||||
$invoicestatic->ref = $val["ref"];
|
||||
|
||||
$date = dol_print_date($val["date"], 'day');
|
||||
|
||||
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
print "\n";
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
|
||||
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
|
||||
print '"' . utf8_decode (dol_trunc($companystatic->name, 16) ) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||
|
||||
|
||||
|
||||
if ($mt) {
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
print "\n";
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key]. '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ). ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"' ;
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (empty($action) || $action == 'view') {
|
||||
@ -545,12 +511,6 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||
|
||||
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
|
||||
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
|
||||
} else {
|
||||
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||
}*/
|
||||
|
||||
// Button to write into Ledger
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
@ -563,6 +523,7 @@ if (empty($action) || $action == 'view') {
|
||||
else {
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
}
|
||||
print '<input type="button" class="butAction" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
|
||||
print '</div>';
|
||||
|
||||
print '
|
||||
|
||||
@ -559,6 +559,7 @@ print '/>';
|
||||
print '</td><td align="right">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print "</td></tr>\n";
|
||||
print '</form>';
|
||||
// Use services duration
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user