--- /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/client_card.php @@ -2,7 +2,7 @@ -/* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2024 Alexandre Spangaro - * Copyright (C) 2013-2014 Olivier Geffroy - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry @@ -37 +37 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -45 +45 @@ -if (!isModEnabled('accounting')) { +if ($user->socid > 0) @@ -47,7 +46,0 @@ -} -if ($user->socid > 0) { - accessforbidden(); -} -if (!$user->hasRight('accounting', 'mouvements', 'lire')) { - accessforbidden(); -} @@ -60,5 +53,5 @@ -if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { - if (!$cancel) { - if ($codeventil < 0) { - $codeventil = 0; - } +if ($action == 'ventil' && $user->rights->accounting->bind->write) +{ + if (!$cancel) + { + if ($codeventil < 0) $codeventil = 0; @@ -67,2 +60,2 @@ - $sql .= " SET fk_code_ventilation = ".((int) $codeventil); - $sql .= " WHERE rowid = ".((int) $id); + $sql .= " SET fk_code_ventilation = ".$codeventil; + $sql .= " WHERE rowid = ".$id; @@ -73 +66,3 @@ - } else { + } + else + { @@ -75 +70,2 @@ - if ($backtopage) { + if ($backtopage) + { @@ -91,3 +87 @@ -$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; - -llxHeader("", $langs->trans('FicheVentilation'), $help_url); +llxHeader("", $langs->trans('FicheVentilation')); @@ -112 +106 @@ - $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".((int) $id); + $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".$id; @@ -115 +109 @@ - dol_syslog("/accounting/expensereport/card.php", LOG_DEBUG); + dol_syslog("/accounting/expensereport/card.php sql=".$sql, LOG_DEBUG); @@ -132 +126 @@ - print dol_get_fiche_head(); + dol_fiche_head(); @@ -157 +151 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -160 +154 @@ - print ''; + print ''; @@ -162 +156 @@ - print ''; + print ''; --- /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/client_index.php @@ -4 +4 @@ - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -34,9 +33,15 @@ -$langs->loadLangs(array("compta", "bills", "other", "accountancy")); - -$validatemonth = GETPOST('validatemonth', 'int'); -$validateyear = GETPOST('validateyear', 'int'); - -$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); -if (GETPOST("year", 'int')) { - $year_start = GETPOST("year", 'int'); -} else { +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->socid > 0) + accessforbidden(); +if (!$user->rights->accounting->bind->write) + accessforbidden(); + +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); +if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); +else +{ @@ -44,3 +49 @@ - if (dol_print_date(dol_now(), '%m') < $month_start) { - $year_start--; // If current month is lower that starting fiscal month, we start last year - } + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year @@ -50 +53,2 @@ -if ($month_end < 1) { +if ($month_end < 1) +{ @@ -61,12 +64,0 @@ -$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version'); - -// Security check -if (!isModEnabled('accounting')) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (!$user->hasRight('accounting', 'mouvements', 'lire')) { - accessforbidden(); -} @@ -79 +71,2 @@ -if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { +if ($action == 'clean' || $action == 'validatehistory') +{ @@ -88,2 +81,2 @@ - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.((int) getDolGlobalInt('CHARTOFACCOUNTS')).' AND accnt.entity = '.((int) $conf->entity).')'; - $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.((int) $conf->entity).')'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.$conf->entity.')'; @@ -105,4 +97,0 @@ - $nbbinddone = 0; - $nbbindfailed = 0; - $notpossible = 0; - @@ -112,9 +101,13 @@ - $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; - $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id"; - $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND accnt.entity =".((int) $conf->entity).","; - $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er"; - $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity); - $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; - if ($validatemonth && $validateyear) { - $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); + if ($db->type == 'pgsql') { + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql1 .= " SET fk_code_ventilation = accnt.rowid"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; + $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; + $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; + } else { + $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; + $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; + $sql1 .= " AND erd.fk_code_ventilation = 0"; @@ -125,2 +118,2 @@ - $result = $db->query($sql1); - if (!$result) { + $resql1 = $db->query($sql1); + if (!$resql1) { @@ -127,0 +121 @@ + $db->rollback(); @@ -130,38 +123,0 @@ - $num_lines = $db->num_rows($result); - - $i = 0; - while ($i < min($num_lines, 10000)) { // No more than 10000 at once - $objp = $db->fetch_object($result); - - $lineid = $objp->rowid; - $suggestedid = $objp->suggestedid; - - if ($suggestedid > 0) { - $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND rowid = ".((int) $lineid); - - $resqlupdate = $db->query($sqlupdate); - if (!$resqlupdate) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - $nbbindfailed++; - break; - } else { - $nbbinddone++; - } - } else { - $notpossible++; - $nbbindfailed++; - } - - $i++; - } - if ($num_lines > 10000) { - $notpossible += ($num_lines - 10000); - } - } - - if ($error) { - $db->rollback(); - } else { @@ -169,4 +125 @@ - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); - if ($nbbindfailed) { - setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); - } + setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); @@ -180,3 +133,2 @@ -$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; - -llxHeader('', $langs->trans("ExpenseReportsVentilation"), $help_url); + +llxHeader('', $langs->trans("ExpenseReportsVentilation")); @@ -186 +137,0 @@ - @@ -197,4 +148,4 @@ -$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; - - -print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind); +$buttonbind = ''.$langs->trans("ValidateHistory").''; + + +print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -205,2 +156,2 @@ -print ''.$langs->trans("Account").''; -print ''.$langs->trans("Label").''; +print ''.$langs->trans("Account").''; +print ''.$langs->trans("Label").''; @@ -208,23 +159,3 @@ - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } - $cursormonth = $j; - if ($cursormonth > 12) { - $cursormonth -= 12; - } - $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; - $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - - print ''; - if (!empty($tmp['mday'])) { - $param = 'search_date_startday=1&search_date_startmonth='.$cursormonth.'&search_date_startyear='.$cursoryear; - $param .= '&search_date_endday='.$tmp['mday'].'&search_date_endmonth='.$tmp['mon'].'&search_date_endyear='.$tmp['year']; - $param .= '&search_month='.$tmp['mon'].'&search_year='.$tmp['year']; - print ''; - } - print $langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)); - if (!empty($tmp['mday'])) { - print ''; - } - print ''; + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''; @@ -234,2 +165,2 @@ -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; -$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; @@ -237,5 +168,3 @@ - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } - $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut)=".$j, "erd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; @@ -249,4 +177,0 @@ -// Define begin binding date -if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; -} @@ -257,3 +182,2 @@ -$sql .= ' ORDER BY aa.account_number'; - -dol_syslog('/accountancy/expensereport/index.php', LOG_DEBUG); + +dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql); @@ -265,6 +189,4 @@ - print ''; - print ''; - if ($row[0] == 'tobind') { - print ''.$langs->trans("Unknown").''; - } else { - print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); @@ -271,0 +194 @@ + else print length_accountg($row[0]); @@ -273,15 +196,4 @@ - print ''; - if ($row[0] == 'tobind') { - $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); - if ($startmonth > 12) { - $startmonth -= 12; - } - $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; - $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11; - if ($endmonth > 12) { - $endmonth -= 12; - } - $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); - } else { - print $row[1]; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); @@ -288,0 +201 @@ + else print $row[1]; @@ -290,28 +203,8 @@ - for ($i = 2; $i <= 13; $i++) { - $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2); - if ($cursormonth > 12) { - $cursormonth -= 12; - } - $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y; - $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); - - print ''; - print price($row[$i]); - // Add link to make binding - if (!empty(price2num($row[$i]))) { - print ''; - print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); - print ''; - } - print ''; - } - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); - - if ($num == 0) { - print ''; - print ''.$langs->trans("NoRecordFound").''; - print ''; - } + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); @@ -319 +212 @@ - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error @@ -328 +221 @@ -print_barre_liste(img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); +print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); @@ -334,2 +227,2 @@ -print ''.$langs->trans("Account").''; -print ''.$langs->trans("Label").''; +print ''.$langs->trans("Account").''; +print ''.$langs->trans("Label").''; @@ -337,4 +230,2 @@ - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; @@ -345 +236 @@ -$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,"; @@ -348,5 +239,3 @@ - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } - $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut)=".$j, "erd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; @@ -360,4 +248,0 @@ -// Define begin binding date -if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; -} @@ -375,6 +260,4 @@ - print ''; - print ''; - if ($row[0] == 'tobind') { - print ''.$langs->trans("Unknown").''; - } else { - print length_accountg($row[0]); + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("Unknown"); @@ -381,0 +265 @@ + else print length_accountg($row[0]); @@ -384,5 +268,4 @@ - print ''; - if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); - } else { - print $row[1]; + print ''; + if ($row[0] == 'tobind') + { + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); @@ -389,0 +273 @@ + else print $row[1]; @@ -391,15 +275,8 @@ - for ($i = 2; $i <= 13; $i++) { - print ''; - print price($row[$i]); - print ''; - } - print ''.price($row[14]).''; - print ''; - } - $db->free($resql); - - if ($num == 0) { - print ''; - print ''.$langs->trans("NoRecordFound").''; - print ''; - } + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; + } + print ''.price($row[13]).''; + print ''.price($row[14]).''; + print ''; + } + $db->free($resql); @@ -407 +284 @@ - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error @@ -414,6 +291,7 @@ -if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? - print '
'; - print '
'; - - print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); - //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); +if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? +{ + print '
'; + print '
'; + + print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1); + //print load_fiche_titre($langs->trans("OtherInfo"), '', ''); @@ -422,51 +300,43 @@ - print ''; - print ''; - for ($i = 1; $i <= 12; $i++) { - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } - print ''; - } - print ''; - - $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,"; - for ($i = 1; $i <= 12; $i++) { - $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1; - if ($j > 12) { - $j -= 12; - } - $sql .= " SUM(".$db->ifsql("MONTH(er.date_create)=".$j, "erd.total_ht", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; - } - $sql .= " SUM(erd.total_ht) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; - $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; - $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; - // Define begin binding date - if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'"; - } - $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; - $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy - - dol_syslog('htdocs/accountancy/expensereport/index.php'); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print ''; - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - print ''; - } - - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; - print ''; + print ''; + print ''; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + print ''; + } + print ''; + + $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) $j -= 12; + $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; + } + $sql .= " SUM(erd.total_ht) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'"; + $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'"; + $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; + $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy + + dol_syslog('htdocs/accountancy/expensereport/index.php'); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for ($i = 1; $i <= 12; $i++) { + print ''; + } + print ''; + print ''; + } + + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
'.$langs->trans("Total").''.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[0].''.price($row[$i]).''.price($row[13]).'
\n"; + print ''; --- /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/github_19.0.3_lines.php +++ /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/client_lines.php @@ -3 +3 @@ - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro @@ -30 +29,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -32,2 +30,0 @@ -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -35,0 +33,2 @@ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -38 +37 @@ -$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch", "hrm")); +$langs->loadLangs(array("compta", "bills", "other", "accountancy", "trips", "productbatch")); @@ -45 +43,0 @@ -$search_login = GETPOST('search_login', 'alpha'); @@ -52,8 +50,3 @@ -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); @@ -62,3 +55,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -66,4 +59 @@ -if (empty($page) || $page < 0) { - $page = 0; -} -$offset = $limit * $page; +if (empty($page) || $page < 0) $page = 0; @@ -72 +62,2 @@ -if (!$sortfield) { +$offset = $limit * $page; +if (!$sortfield) @@ -74 +64,0 @@ -} @@ -76 +66 @@ - if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { @@ -78,2 +67,0 @@ - } else { - $sortorder = "ASC"; @@ -84 +72 @@ -if (!isModEnabled('accounting')) { +if ($user->socid > 0) @@ -86,2 +74 @@ -} -if ($user->socid > 0) { +if (!$user->rights->accounting->bind->write) @@ -89,5 +75,0 @@ -} -if (!$user->hasRight('accounting', 'mouvements', 'lire')) { - accessforbidden(); -} - @@ -103,2 +85,2 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_login = ''; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +{ @@ -111,11 +93,6 @@ - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; -} - -if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) { + $search_day = ''; + $search_month = ''; + $search_year = ''; +} + +if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -124 +101,2 @@ - if (!(GETPOST('account_parent', 'int') >= 0)) { + if (!(GETPOST('account_parent', 'int') >= 0)) + { @@ -129 +107,2 @@ - if (!$error) { + if (!$error) + { @@ -134 +113 @@ - $sql1 .= ' WHERE erd.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; + $sql1 .= ' WHERE erd.rowid IN ('.implode(',', $changeaccount).')'; @@ -144 +123 @@ - setEventMessages($langs->trans("Save"), null, 'mesgs'); + setEventMessages($langs->trans('Save'), null, 'mesgs'); @@ -154,6 +132,0 @@ -if (GETPOST('sortfield') == 'erd.date, erd.rowid') { - $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1); - require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity); -} - @@ -168,3 +141 @@ -$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; - -llxHeader('', $langs->trans("ExpenseReportsVentilation").' - '.$langs->trans("Dispatched"), $help_url); +llxHeader('', $langs->trans("ExpenseReportsVentilation").' - '.$langs->trans("Dispatched")); @@ -194,3 +165,2 @@ -$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,"; -$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,"; -$sql .= " aa.label, aa.labelshort, aa.account_number"; +$sql .= " aa.label, aa.account_number,"; +$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label"; @@ -198,2 +168,2 @@ -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport"; -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " , ".MAIN_DB_PREFIX."accounting_account as aa"; +$sql .= " , ".MAIN_DB_PREFIX."expensereport_det as erd"; @@ -201,8 +171,2 @@ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; -$sql .= " WHERE erd.fk_code_ventilation > 0"; -$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy -$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")"; -// Add search filter like -if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); -} +$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <> 0 "; +$sql .= " AND aa.rowid = erd.fk_code_ventilation"; @@ -216 +180 @@ - $sql .= natural_search("erd.comments", $search_desc); + $sql .= natural_search("er.comments", $search_desc); @@ -227,6 +191 @@ -if ($search_date_start) { - $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'"; -} -if ($search_date_end) { - $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'"; -} +$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); @@ -239,7 +198,9 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; - } +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } @@ -250 +211 @@ -dol_syslog("accountancy/expensereport/lines.php", LOG_DEBUG); +dol_syslog('accountancy/expensereport/lines.php::list'); @@ -251,0 +213 @@ + @@ -257,42 +219,10 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($search_login) { - $param .= '&search_login='.urlencode($search_login); - } - if ($search_expensereport) { - $param .= "&search_expensereport=".urlencode($search_expensereport); - } - if ($search_label) { - $param .= "&search_label=".urlencode($search_label); - } - if ($search_desc) { - $param .= "&search_desc=".urlencode($search_desc); - } - if ($search_account) { - $param .= "&search_account=".urlencode($search_account); - } - if ($search_vat) { - $param .= "&search_vat=".urlencode($search_vat); - } - if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); - } - if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); - } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=".urlencode($search_label); + if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); + if ($search_account) $param .= "&search_account=".urlencode($search_account); + if ($search_vat) $param .= "&search_vat=".urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); @@ -302,3 +232 @@ - if ($optioncss != '') { - print ''; - } + if ($optioncss != '') print ''; @@ -311,0 +240 @@ + @@ -314 +243 @@ - print '
'.$langs->trans("ChangeAccount").' '; + print '
'.$langs->trans("ChangeAccount").'
'; @@ -316 +245 @@ - print '
'; + print '
'; @@ -320 +249 @@ - print '
'; + print '
'; @@ -324 +252,0 @@ - print ''; @@ -327 +255 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -331,6 +259,3 @@ - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year, 'search_year', 1, 20, 5); @@ -343,4 +268,5 @@ - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + print ''; + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; @@ -350 +275,0 @@ - print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); @@ -353 +278 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -361,2 +286,3 @@ - print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); - $checkpicto = $form->showCheckAddButtons(); + print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre(''); + $checkpicto = $form->showCheckAddButtons(); @@ -366,5 +292,2 @@ - $expensereportstatic = new ExpenseReport($db); - $accountingaccountstatic = new AccountingAccount($db); - $userstatic = new User($db); - - $i = 0; + $expensereport_static = new ExpenseReport($db); + @@ -373,19 +296,4 @@ - - $expensereportstatic->ref = $objp->ref; - $expensereportstatic->id = $objp->erid; - - $userstatic->id = $objp->userid; - $userstatic->ref = $objp->label; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; - - $accountingaccountstatic->rowid = $objp->fk_compte; - $accountingaccountstatic->label = $objp->label; - $accountingaccountstatic->labelshort = $objp->labelshort; - $accountingaccountstatic->account_number = $objp->account_number; + $codeCompta = length_accountg($objp->account_number).' - '.$objp->label.''; + + $expensereport_static->ref = $objp->ref; + $expensereport_static->id = $objp->erid; @@ -395,6 +302,0 @@ - // Login - print ''; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; - - // Line id @@ -403,2 +305,2 @@ - // Ref Expense report - print ''.$expensereportstatic->getNomUrl(1).''; + // Ref Invoice + print ''.$expensereport_static->getNomUrl(1).''; @@ -407 +309 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -413 +314,0 @@ - // Fees label @@ -416 +316,0 @@ - // Fees description -- Can be null @@ -418,2 +318,2 @@ - $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1)); - $trunclength = getDolGlobalString('ACCOUNTING_LENGTH_DESCRIPTION', 32); + $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; @@ -423,4 +323,2 @@ - // Amount without taxes - print ''.price($objp->total_ht).''; - - // Vat rate + print ''.price($objp->total_ht).''; + @@ -429,4 +327,3 @@ - // Accounting account affected - print ''; - print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); - print ' '; + print ''.$codeCompta.''; + + print ''; @@ -434,0 +332 @@ + @@ -440,7 +337,0 @@ - if ($num_lines == 0) { - $colspan=10; - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { - $colspan++; - } - print ''.$langs->trans("NoRecordFound").''; - } @@ -452 +343 @@ - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); --- /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/accountancy/expensereport/client_list.php @@ -3 +3 @@ - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro @@ -6 +6 @@ - * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Juanjo Menent s @@ -31 +30,0 @@ -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -33 +31,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -35,0 +34 @@ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -39,3 +38,3 @@ -$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch", "hrm")); - -$action = GETPOST('action', 'aZ09'); +$langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", "trips", "productbatch")); + +$action = GETPOST('action', 'alpha'); @@ -42,0 +42 @@ +$show_files = GETPOST('show_files', 'int'); @@ -45 +45 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountancyexpensereportlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search @@ -53 +52,0 @@ -$search_login = GETPOST('search_login', 'alpha'); @@ -61,13 +60,3 @@ -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); - -// Define begin binding date -if (empty($search_date_start) && getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) { - $search_date_start = $db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING')); -} +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); @@ -76,3 +65,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); @@ -80,3 +69 @@ -if (empty($page) || $page < 0) { - $page = 0; -} +if (empty($page) || $page < 0) { $page = 0; } @@ -86 +73 @@ -if (!$sortfield) { +if (!$sortfield) @@ -88 +74,0 @@ -} @@ -90 +76 @@ - if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_TODO') > 0) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { @@ -92,2 +77,0 @@ - } else { - $sortorder = "ASC"; @@ -97,2 +81,5 @@ -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('accountancyexpensereportlist')); +// Security check +if ($user->socid > 0) + accessforbidden(); +if (!$user->rights->accounting->bind->write) + accessforbidden(); @@ -103,12 +90 @@ -$chartaccountcode = dol_getIdFromCode($db, getDolGlobalInt('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version'); - -// Security check -if (!isModEnabled('accounting')) { - accessforbidden(); -} -if ($user->socid > 0) { - accessforbidden(); -} -if (!$user->hasRight('accounting', 'mouvements', 'lire')) { - accessforbidden(); -} +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); @@ -118 +94 @@ - * Actions + * Action @@ -121,47 +97,26 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers - $search_login = ''; - $search_expensereport = ''; - $search_label = ''; - $search_desc = ''; - $search_amount = ''; - $search_account = ''; - $search_vat = ''; - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_country = ''; - $search_tvaintra = ''; - } - - // Mass actions - $objectclass = 'ExpenseReport'; - $objectlabel = 'ExpenseReport'; - $permissiontoread = $user->hasRight('accounting', 'read'); - $permissiontodelete = $user->hasRight('accounting', 'delete'); - $uploaddir = $conf->expensereport->dir_output; - include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; -} - - -if ($massaction == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) { +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +// Purge search criteria +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers +{ + $search_expensereport = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; +} + +// Mass actions +$objectclass = 'ExpenseReport'; +$objectlabel = 'ExpenseReport'; +$permissiontoread = $user->rights->expensereport->read; +$permissiontodelete = $user->rights->expensereport->delete; +$uploaddir = $conf->expensereport->dir_output; +include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + +if ($massaction == 'ventil') { @@ -169,46 +124,44 @@ - - if (!empty($mesCasesCochees)) { - $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; - $msg .= '
'; - $cpt = 0; - $ok = 0; - $ko = 0; - - foreach ($mesCasesCochees as $maLigneCochee) { - $maLigneCourante = explode("_", $maLigneCochee); - $monId = $maLigneCourante[0]; - $monCompte = GETPOST('codeventil'.$monId); - - if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; - $ko++; - } else { - $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql .= " SET fk_code_ventilation = ".((int) $monCompte); - $sql .= " WHERE rowid = ".((int) $monId); - - $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, '', 1); - - dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); - if ($db->query($sql)) { - $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; - $ok++; - } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; - $ko++; - } - } - - $cpt++; - } - $msg .= '
'; - $msg .= '
'.$langs->trans("EndProcessing").'
'; - } -} - -if (GETPOST('sortfield') == 'erd.date, erd.rowid') { - $value = (GETPOST('sortorder') == 'asc,asc' ? 0 : 1); - require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value, 'yesno', 0, '', $conf->entity); -} + //print '
' . $langs->trans("Processing") . '...
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; + $cpt = 0; + $ok = 0; + $ko = 0; + + foreach ($mesCasesCochees as $maLigneCochee) { + $maLigneCourante = explode("_", $maLigneCochee); + $monId = $maLigneCourante[0]; + $monCompte = GETPOST('codeventil'.$monId); + + if ($monCompte <= 0) + { + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $ko++; + } + else + { + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; + + $accountventilated = new AccountingAccount($db); + $accountventilated->fetch($monCompte, ''); + + dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $ok++; + } else { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $ko++; + } + } + + $cpt++; + } + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; + } +} + @@ -224,5 +177,4 @@ -$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables'; - -llxHeader('', $langs->trans("ExpenseReportsVentilation"), $help_url); - -if (empty($chartaccountcode)) { +llxHeader('', $langs->trans("ExpenseReportsVentilation")); + +if (empty($chartaccountcode)) +{ @@ -231,2 +183,2 @@ - llxFooter(); - $db->close(); + llxFooter(); + $db->close(); @@ -240 +191,0 @@ -$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,"; @@ -242,3 +192,0 @@ -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; @@ -248,2 +196 @@ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; @@ -252,3 +198,0 @@ -if (strlen(trim($search_login))) { - $sql .= natural_search("u.login", $search_login); -} @@ -256 +200 @@ - $sql .= natural_search("er.ref", $search_expensereport); + $sql .= natural_search("er.ref", $search_expensereport); @@ -259 +203 @@ - $sql .= natural_search("f.label", $search_label); + $sql .= natural_search("f.label", $search_label); @@ -262 +206 @@ - $sql .= natural_search("erd.comments", $search_desc); + $sql .= natural_search("erd.comments", $search_desc); @@ -265 +209 @@ - $sql .= natural_search("erd.total_ht", $search_amount, 1); + $sql .= natural_search("erd.total_ht", $search_amount, 1); @@ -268 +212 @@ - $sql .= natural_search("aa.account_number", $search_account); + $sql .= natural_search("aa.account_number", $search_account); @@ -271,8 +215,3 @@ - $sql .= natural_search("erd.tva_tx", $search_vat, 1); -} -if ($search_date_start) { - $sql .= " AND erd.date >= '".$db->idate($search_date_start)."'"; -} -if ($search_date_end) { - $sql .= " AND erd.date <= '".$db->idate($search_date_end)."'"; -} + $sql .= natural_search("erd.tva_tx", $search_vat, 1); +} +$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); @@ -280,5 +218,0 @@ - -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; @@ -290,9 +224,10 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; - } -} -//print $sql; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} @@ -302,7 +237 @@ -dol_syslog("accountancy/expensereport/list.php", LOG_DEBUG); -// MAX_JOIN_SIZE can be very low (ex: 300000) on some limited configurations (ex: https://www.online.net/fr/hosting/online-perso) -// This big SELECT command may exceed the MAX_JOIN_SIZE limit => Therefore we use SQL_BIG_SELECTS=1 to disable the MAX_JOIN_SIZE security -if ($db->type == 'mysqli') { - $db->query("SET SQL_BIG_SELECTS=1"); -} - +dol_syslog('accountancy/expensereport/list.php'); @@ -317,45 +246,11 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($search_login) { - $param .= '&search_login='.urlencode($search_login); - } - if ($search_lineid) { - $param .= '&search_lineid='.urlencode($search_lineid); - } - if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); - } - if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); - } - if ($search_expensereport) { - $param .= '&search_expensereport='.urlencode($search_expensereport); - } - if ($search_label) { - $param .= '&search_label='.urlencode($search_label); - } - if ($search_desc) { - $param .= '&search_desc='.urlencode($search_desc); - } - if ($search_amount) { - $param .= '&search_amount='.urlencode($search_amount); - } - if ($search_vat) { - $param .= '&search_vat='.urlencode($search_vat); - } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_expensereport) $param .= '&search_expensereport='.urlencode($search_expensereport); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); @@ -364 +259 @@ - 'ventil' => img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + 'ventil' => $langs->trans("Ventilate") @@ -367,0 +263 @@ + @@ -370,3 +266 @@ - if ($optioncss != '') { - print ''; - } + if ($optioncss != '') print ''; @@ -383,3 +277,7 @@ - if (!empty($msg)) { - print $msg.'
'; - } + /*$topicmail="Information"; + $modelmail="project"; + $objecttmp=new Project($db); + $trackid='prj'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/ + + if ($msg) print $msg.'
'; @@ -389 +287 @@ - print '
'; + print '
'; @@ -394 +291,0 @@ - print ''; @@ -397 +294 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -400,7 +297,4 @@ - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year, 'search_year', 1, 20, 5); @@ -410,2 +304,2 @@ - print ''; - print ''; + print ''; + print ''; @@ -414 +308 @@ - print ''; + print ''; @@ -421 +314,0 @@ - print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder); @@ -424 +317 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -432,2 +325,2 @@ - print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall '); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', ''); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); + print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', ''); @@ -435,3 +328 @@ - if ($massactionbutton) { - $checkpicto = $form->showCheckAddButtons('checkforselect', 1); - } + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); @@ -443 +333,0 @@ - $userstatic = new User($db); @@ -455,10 +344,0 @@ - $userstatic->id = $objp->userid; - $userstatic->login = $objp->login; - $userstatic->statut = $objp->statut; - $userstatic->email = $objp->email; - $userstatic->gender = $objp->gender; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->employee = $objp->employee; - $userstatic->photo = $objp->photo; - @@ -466,5 +345,0 @@ - - // Login - print ''; - print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); - print ''; @@ -479 +354 @@ - if (getDolGlobalString('ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE')) { + if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { @@ -488 +363 @@ - print($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))); + print ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))); @@ -493,2 +368,2 @@ - $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1)); - $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32); + $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments)); + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; @@ -498,2 +373 @@ - // Amount without taxes - print ''; + print ''; @@ -515 +389 @@ - print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); @@ -525,3 +398,0 @@ - if ($num_lines == 0) { - print ''.$langs->trans("NoRecordFound").''; - } @@ -536,3 +406,0 @@ -if ($db->type == 'mysqli') { - $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation -} @@ -541 +409 @@ -print '