|
|
|
|
@ -178,7 +178,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens";
|
|
|
|
|
$sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
|
|
|
|
|
$sql .= " t.localtax1, t.localtax2, t.revenuestamp,";
|
|
|
|
|
$sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
|
|
|
|
|
$sql .= " WHERE datef between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -190,7 +192,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
|
|
|
|
|
$sql .= " t.localtax1, t.localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
|
|
|
|
|
$sql .= " WHERE datef between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -202,7 +206,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
|
|
|
|
|
$sql .= " WHERE date_fin between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -213,7 +219,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
|
|
|
|
|
$sql .= " WHERE datedon between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -225,7 +233,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
|
|
|
|
|
$sql .= " WHERE datep between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -237,7 +247,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
|
|
|
|
|
$sql .= " WHERE t.date_ech between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -249,7 +261,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t";
|
|
|
|
|
$sql .= " WHERE datep between ".$wheretail;
|
|
|
|
|
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -260,7 +274,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
if (!empty($sql)) {
|
|
|
|
|
$sql .= " UNION ALL";
|
|
|
|
|
}
|
|
|
|
|
$sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat,";
|
|
|
|
|
$sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
|
|
|
|
|
$sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan";
|
|
|
|
|
$sql .= " WHERE datep between ".$wheretail;
|
|
|
|
|
$sql .= " AND l.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
|
|
|
|
@ -368,6 +384,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
$nofile['amount_ht'] = $objd->total_ht;
|
|
|
|
|
$nofile['amount_ttc'] = $objd->total_ttc;
|
|
|
|
|
$nofile['amount_vat'] = $objd->total_vat;
|
|
|
|
|
$nofile['amount_localtax1'] = $objd->localtax1;
|
|
|
|
|
$nofile['amount_localtax2'] = $objd->localtax2;
|
|
|
|
|
$nofile['amount_revenuestamp'] = $objd->revenuestamp;
|
|
|
|
|
$nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
|
|
|
|
|
$nofile['fk'] = $objd->fk_soc;
|
|
|
|
|
$nofile['item'] = $objd->item;
|
|
|
|
|
@ -391,6 +410,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
|
|
|
|
$file['amount_ht'] = $objd->total_ht;
|
|
|
|
|
$file['amount_ttc'] = $objd->total_ttc;
|
|
|
|
|
$file['amount_vat'] = $objd->total_vat;
|
|
|
|
|
$file['amount_localtax1'] = $objd->localtax1;
|
|
|
|
|
$file['amount_localtax2'] = $objd->localtax2;
|
|
|
|
|
$file['amount_revenuestamp'] = $objd->revenuestamp;
|
|
|
|
|
$file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
|
|
|
|
|
$file['fk'] = $objd->fk_soc;
|
|
|
|
|
$file['item'] = $objd->item;
|
|
|
|
|
@ -469,6 +491,9 @@ if ($result && $action == "dl" && !$error) {
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("TotalHT");
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
|
|
|
|
|
$log .= ','.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code);
|
|
|
|
|
$log .= ','.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code);
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("Revenuestamp");
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("Paid");
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("Document");
|
|
|
|
|
$log .= ','.$langs->transnoentitiesnoconv("ItemID");
|
|
|
|
|
@ -511,6 +536,9 @@ if ($result && $action == "dl" && !$error) {
|
|
|
|
|
$log .= ','.$file['amount_ht'];
|
|
|
|
|
$log .= ','.$file['amount_ttc'];
|
|
|
|
|
$log .= ','.$file['amount_vat'];
|
|
|
|
|
$log .= ','.$file['amount_localtax1'];
|
|
|
|
|
$log .= ','.$file['amount_localtax2'];
|
|
|
|
|
$log .= ','.$file['amount_revenuestamp'];
|
|
|
|
|
$log .= ','.$file['paid'];
|
|
|
|
|
$log .= ',"'.$file["name"].'"';
|
|
|
|
|
$log .= ','.$file['fk'];
|
|
|
|
|
@ -698,9 +726,10 @@ if (!empty($date_start) && !empty($date_stop)) {
|
|
|
|
|
print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
|
|
|
|
|
print '<td>'.$langs->trans("Document").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Paid").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$conf->currency.')' : '').'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalHT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalTTC").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("TotalVAT").(isModEnabled('multicurrency') ? ' ('.$langs->getCurrencySymbol($conf->currency).')' : '').'</td>';
|
|
|
|
|
|
|
|
|
|
print '<td>'.$langs->trans("ThirdParty").'</td>';
|
|
|
|
|
print '<td class="center">'.$langs->trans("Code").'</td>';
|
|
|
|
|
print '<td class="center">'.$langs->trans("Country").'</td>';
|
|
|
|
|
@ -755,6 +784,9 @@ if (!empty($date_start) && !empty($date_stop)) {
|
|
|
|
|
$invoice->total_ht = $data['amount_ht'];
|
|
|
|
|
$invoice->total_ttc = $data['amount_ttc'];
|
|
|
|
|
$invoice->total_tva = $data['amount_vat'];
|
|
|
|
|
$invoice->total_localtax1 = $data['amount_localtax1'];
|
|
|
|
|
$invoice->total_localtax2 = $data['amount_localtax2'];
|
|
|
|
|
$invoice->revenuestamp = $data['amount_revenuestamp'];
|
|
|
|
|
$invoice->multicurrency_code = $data['currency'];
|
|
|
|
|
print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
|
|
|
|
|
} elseif ($data['item'] == 'SupplierInvoice') {
|
|
|
|
|
@ -763,6 +795,9 @@ if (!empty($date_start) && !empty($date_stop)) {
|
|
|
|
|
$supplier_invoice->total_ht = $data['amount_ht'];
|
|
|
|
|
$supplier_invoice->total_ttc = $data['amount_ttc'];
|
|
|
|
|
$supplier_invoice->total_tva = $data['amount_vat'];
|
|
|
|
|
$supplier_invoice->total_localtax1 = $data['amount_localtax1'];
|
|
|
|
|
$supplier_invoice->total_localtax2 = $data['amount_localtax2'];
|
|
|
|
|
$supplier_invoice->revenuestamp = $data['amount_revenuestamp'];
|
|
|
|
|
$supplier_invoice->multicurrency_code = $data['currency'];
|
|
|
|
|
print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0);
|
|
|
|
|
} elseif ($data['item'] == 'ExpenseReport') {
|
|
|
|
|
@ -816,10 +851,16 @@ if (!empty($date_start) && !empty($date_stop)) {
|
|
|
|
|
// Paid
|
|
|
|
|
print '<td class="center">'.($data['paid'] ? yn($data['paid']) : '').'</td>';
|
|
|
|
|
|
|
|
|
|
// Total ET
|
|
|
|
|
// Total WOT
|
|
|
|
|
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."</span></td>\n";
|
|
|
|
|
// Total IT
|
|
|
|
|
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."</span></td>\n";
|
|
|
|
|
// Total INCT
|
|
|
|
|
print '<td align="right"><span class="amount">';
|
|
|
|
|
$tooltip = $langs->trans("TotalVAT").' : '.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'));
|
|
|
|
|
if (!empty($data['amount_revenuestamp'])) {
|
|
|
|
|
$tooltip .= '<br>'.$langs->trans("RevenueStamp").' : '.price(price2num($data['sens'] ? $data['amount_revenuestamp'] : -$data['amount_revenuestamp'], 'MT'));
|
|
|
|
|
}
|
|
|
|
|
print '<span class="classfortooltip" title="'.dol_escape_htmltag($tooltip).'">'.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT')).'</span>';
|
|
|
|
|
print "</span></td>\n";
|
|
|
|
|
// Total VAT
|
|
|
|
|
print '<td align="right"><span class="amount">'.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."</span></td>\n";
|
|
|
|
|
|
|
|
|
|
|