Filter accounting reports by projects
This commit is contained in:
parent
a9e9f36604
commit
82cfca1a80
@ -47,6 +47,11 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
|
||||
|
||||
if (!empty($conf->project->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
// Constant to define payment sens
|
||||
const PAY_DEBIT = 0;
|
||||
const PAY_CREDIT = 1;
|
||||
@ -64,6 +69,7 @@ $date_stopMonth = GETPOST('date_stopmonth', 'int');
|
||||
$date_stopYear = GETPOST('date_stopyear', 'int');
|
||||
$date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('comptafileslist', 'globallist'));
|
||||
@ -175,6 +181,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$sql .= " WHERE datef between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
||||
$sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT;
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Vendor invoices
|
||||
if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) {
|
||||
@ -186,9 +193,10 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$sql .= " WHERE datef between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
||||
$sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Expense reports
|
||||
if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms'])) {
|
||||
if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) and empty($projectid)) {
|
||||
if (!empty($sql)) {
|
||||
$sql .= " UNION ALL";
|
||||
}
|
||||
@ -208,6 +216,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$sql .= " WHERE datedon between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
||||
$sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT;
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Payments of salaries
|
||||
if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) {
|
||||
@ -219,6 +228,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$sql .= " WHERE datep between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
||||
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Social contributions
|
||||
if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) {
|
||||
@ -230,6 +240,7 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$sql .= " WHERE t.date_ech between ".$wheretail;
|
||||
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
|
||||
//$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Various payments
|
||||
if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) {
|
||||
@ -240,9 +251,10 @@ if (($action == 'searchfiles' || $action == 'dl')) {
|
||||
$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).')';
|
||||
if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid);
|
||||
}
|
||||
// Loan payments
|
||||
if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms'])) {
|
||||
if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) and empty($projectid)) {
|
||||
if (!empty($sql)) {
|
||||
$sql .= " UNION ALL";
|
||||
}
|
||||
@ -460,7 +472,19 @@ if ($result && $action == "dl" && !$error) {
|
||||
$log .= ','.$langs->transnoentitiesnoconv("Country");
|
||||
$log .= ','.$langs->transnoentitiesnoconv("VATIntra");
|
||||
$log .= ','.$langs->transnoentitiesnoconv("Sens")."\n";
|
||||
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip';
|
||||
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel');
|
||||
if(!empty($projectid)) {
|
||||
$sql = 'SELECT t.ref FROM '.MAIN_DB_PREFIX.'projet as t';
|
||||
$sql .= ' WHERE t.rowid = '.((int) $db->sanitize($projectid));
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$zipname .= '_'.$obj->ref;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
$zipname .='_export.zip';
|
||||
|
||||
dol_delete_file($zipname);
|
||||
|
||||
@ -561,11 +585,13 @@ print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', '
|
||||
print "\n";
|
||||
|
||||
// Export is for current company only
|
||||
$socid = 0;
|
||||
if (!empty($conf->multicompany->enabled) && is_object($mc)) {
|
||||
$mc->getInfo($conf->entity);
|
||||
print '<span class="marginleftonly marginrightonly'.(empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES) ? ' opacitymedium' : '').'">('.$langs->trans("Entity").' : ';
|
||||
print "<td>";
|
||||
if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
|
||||
$socid = $mc->id;
|
||||
print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
|
||||
} else {
|
||||
print $mc->label;
|
||||
@ -576,6 +602,16 @@ if (!empty($conf->multicompany->enabled) && is_object($mc)) {
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Project filter
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$formproject = new FormProjets($db);
|
||||
$langs->load('projects');
|
||||
print '<span class="marginrightonly">'.$langs->trans('Project').":</span>";
|
||||
print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, '');
|
||||
print '<span class="classfortooltip" style="padding: 0px; padding: 0px; padding-right: 3px !important;" title="'.$langs->trans('ExportAccountingProjectHelp').'"><span class="fas fa-info-circle em088 opacityhigh" style=" vertical-align: middle; cursor: help"></span></span>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
foreach ($listofchoices as $choice => $val) {
|
||||
if (empty($val['enabled'])) {
|
||||
continue; // list not qualified
|
||||
@ -614,7 +650,7 @@ if (!empty($date_start) && !empty($date_stop)) {
|
||||
|
||||
echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel');
|
||||
|
||||
print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.newToken().'&output=file&file='.urlencode($filename).$param.'"';
|
||||
print '<a class="marginleftonly small'.(empty($TData) ? ' butActionRefused' : ' butAction').'" href="'.$_SERVER["PHP_SELF"].'?action=dl&token='.newToken().'&projectid='.$projectid.'&output=file&file='.urlencode($filename).$param.'"';
|
||||
if (empty($TData)) {
|
||||
print " disabled";
|
||||
}
|
||||
|
||||
@ -48,8 +48,9 @@ CountriesNotInEEC=Countries not in EEC
|
||||
CountriesInEECExceptMe=Countries in EEC except %s
|
||||
CountriesExceptMe=All countries except %s
|
||||
AccountantFiles=Export source documents
|
||||
ExportAccountingSourceDocHelp=With this tool, you can export the source events (list in CSV and PDFs) that are used to generate your accountancy.
|
||||
ExportAccountingSourceDocHelp=With this tool, you can search and export the source events that are used to generate your accountancy. <br>The exported ZIP file will contain the lists of requested items in CSV, as well as their attached files in their original format (PDF, ODT, DOCX...).
|
||||
ExportAccountingSourceDocHelp2=To export your journals, use the menu entry %s - %s.
|
||||
ExportAccountingProjectHelp=Specify a project if you need an accounting report only for a specific project. Expense reports and loan payments are not included in project reports.
|
||||
VueByAccountAccounting=View by accounting account
|
||||
VueBySubAccountAccounting=View by accounting subaccount
|
||||
|
||||
|
||||
@ -293,4 +293,5 @@ LeadPublicFormDesc=You can enable here a public page to allow your prospects to
|
||||
EnablePublicLeadForm=Enable the public form for contact
|
||||
NewLeadbyWeb=Your message or request has been recorded. We will answer or contact your soon.
|
||||
NewLeadForm=New contact form
|
||||
LeadFromPublicForm=Online lead from public form
|
||||
LeadFromPublicForm=Online lead from public form
|
||||
ExportAccountingReportButtonLabel=Get report
|
||||
@ -1280,6 +1280,17 @@ if ($action == 'create' && $user->rights->projet->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
// Accounting Report
|
||||
$accouting_module_activated = !empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled);
|
||||
if ($accouting_module_activated && $object->statut != Project::STATUS_DRAFT) {
|
||||
$start = dol_getdate((int)$object->date_start);
|
||||
$end = dol_getdate((int)$object->date_end);
|
||||
$url = DOL_URL_ROOT.'/compta/accounting-files.php?projectid='.$object->id;
|
||||
if(!empty($object->date_start)) $url .= '&date_startday='.$start['mday'].'&date_startmonth='.$start['mon'].'&date_startyear='.$start['year'];
|
||||
if(!empty($object->date_end)) $url .= '&date_stopday='.$end['mday'].'&date_stopmonth='.$end['mon'].'&date_stopyear='.$end['year'];
|
||||
print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, '');
|
||||
}
|
||||
|
||||
// Modify
|
||||
if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) {
|
||||
if ($userWrite > 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user