diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php new file mode 100644 index 00000000000..4819bd656ae --- /dev/null +++ b/htdocs/accountancy/expensereport/card.php @@ -0,0 +1,162 @@ + + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013-2016 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 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +/** + * \file htdocs/accountancy/supplier/card.php + * \ingroup Accountancy + * \brief Card expense report ventilation + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; + +// Langs +$langs->load("bills"); +$langs->load("accountancy"); +$langs->load("trips"); + +$action = GETPOST('action', 'alpha'); +$codeventil = GETPOST('codeventil'); +$id = GETPOST('id'); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); + +/* + * Actions + */ + +if ($action == 'ventil' && $user->rights->accounting->bind->write) { + if (! GETPOST('cancel', 'alpha')) { + if ($codeventil < 0) $codeventil = 0; + + $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; + $sql .= " SET fk_code_ventilation = " . $codeventil; + $sql .= " WHERE rowid = " . $id; + + $resql = $db->query($sql); + if (! $resql) { + setEventMessages($db->lasterror(), null, 'errors'); + } + else + { + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + } + } else { + header("Location: ./lines.php"); + exit(); + } +} + + + +/* + * View + */ +llxHeader("", "FicheVentilation"); + +if ($cancel == $langs->trans("Cancel")) { + $action = ''; +} + +// Create +$form = new Form($db); +$expensereport_static = new ExpenseReport($db); +$formventilation = new FormVentilation($db); + +if (! empty($id)) { + $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,"; + $sql .= " f.id as fees_id, f.label as fees_label,"; + $sql .= " aa.account_number, aa.label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; + $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id; + $sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + + dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG); + $result = $db->query($sql); + + if ($result) { + $num_lines = $db->num_rows($result); + $i = 0; + + if ($num_lines) { + $objp = $db->fetch_object($result); + + print '
' . "\n"; + print ''; + print ''; + + print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup'); + + dol_fiche_head(); + + print ''; + + // Ref + print ''; + $expensereport_static->ref = $objp->ref; + $expensereport_static->id = $objp->erid; + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print '
' . $langs->trans("ExpenseReport") . '' . $expensereport_static->getNomUrl(1) . '
' . $langs->trans("Line") . '' . stripslashes(nl2br($objp->rowid)) . '
' . $langs->trans("Description") . '' . stripslashes(nl2br($objp->comments)) . '
' . $langs->trans("TypeFees") . '' . dol_trunc($objp->fees_label, 24) . '
' . $langs->trans("Account") . ''; + print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; + } else { + print "Error"; + } + } else { + print "Error"; + } +} else { + print "Error ID incorrect"; +} + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/expensereport/index.html b/htdocs/accountancy/expensereport/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php new file mode 100644 index 00000000000..affb3971c08 --- /dev/null +++ b/htdocs/accountancy/expensereport/index.php @@ -0,0 +1,267 @@ + + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/expensereport/index.php + * \ingroup Advanced accountancy + * \brief Home expense report ventilation + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountancy"); + +// Security check +if (empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->bind->write) + accessforbidden(); + +// Filter +$year = $_GET["year"]; +if ($year == 0) { + $year_current = strftime("%Y", time()); + $year_start = $year_current; +} else { + $year_current = $year; + $year_start = $year; +} + +// Validate History +$action = GETPOST('action'); + + +/* + * Actions + */ + +if ($action == 'validatehistory') { + + $error = 0; + $db->begin(); + + // First clean corrupted data + $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sqlclean .= " SET fd.fk_code_ventilation = 0"; + $sqlclean .= ' WHERE fd.fk_code_ventilation NOT IN '; + $sqlclean .= ' (SELECT accnt.rowid '; + $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; + $sqlclean .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sqlclean .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + $resql = $db->query($sqlclean); + + // Now make the binding + if ($db->type == 'pgsql') { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql1 .= " SET fk_code_ventilation = accnt.rowid"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; + $sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0"; + } else { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; + $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS; + $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; + $sql1 .= " AND fd.fk_code_ventilation = 0"; + } + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + } +} elseif ($action == 'fixaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN '; + $sql1 .= ' (SELECT accnt.rowid '; + $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; + $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } +} elseif ($action == 'cleanaccountancycode') { + $error = 0; + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; + $sql1 .= " SET fd.fk_code_ventilation = 0"; + $sql1 .= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; + $sql1 .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; + $sql1 .= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "')"; + + dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); + + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + $db->rollback(); + setEventMessage($db->lasterror(), 'errors'); + } else { + $db->commit(); + setEventMessage($langs->trans('Done'), 'mesgs'); + } +} + +/* + * View + */ + +llxHeader('', $langs->trans("ExpenseReportsVentilation")); + +$textprevyear = '' . img_previous() . ''; +$textnextyear = ' ' . img_next() . ''; + +print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy'); + +print $langs->trans("DescVentilExpenseReport") . '
'; +print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; +print '
'; + +print '
'; +print '' . $langs->trans("ValidateHistory") . ''; +print '' . $langs->trans("CleanHistory", $year_current) . ''; +// TODO Remove this. Should be done always. +if ($conf->global->MAIN_FEATURES_LEVEL > 0) print '' . $langs->trans("CleanFixHistory", $year_current) . ''; +print '
'; + +$y = $year_current; + +$var = true; + +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') ." AS codecomptable,"; +$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " ROUND(SUM(erd.total_ht),2) 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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " WHERE er.date_create >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND er.fk_statut > 0 "; +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + +$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; + +dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + + $var = ! $var; + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; + +print "
\n"; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " ROUND(SUM(erd.total_ht),2) 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_create >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; +$sql .= " AND er.date_create <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; +$sql .= " AND er.fk_statut > 0 "; +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + +dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); +$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($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php new file mode 100644 index 00000000000..9720aba485d --- /dev/null +++ b/htdocs/accountancy/expensereport/lines.php @@ -0,0 +1,309 @@ + + * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/expensereport/lines.php + * \ingroup Advanced accountancy + * \brief Page of detail of the lines of ventilation of expense reports + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountancy"); +$langs->load("trips"); + +$account_parent = GETPOST('account_parent'); +$changeaccount = GETPOST('changeaccount'); +// Search Getpost +$search_expensereport = GETPOST('search_expensereport', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit') ? 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'); +$page = GETPOST('page', 'int'); +if ($page < 0) $page = 0; +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) + $sortfield = "er.date_create, er.ref, erd.rowid"; +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { + $sortorder = "DESC"; + } +} + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->bind->write) + accessforbidden(); + +$formventilation = new FormVentilation($db); + + +/* + * Actions + */ + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_expensereport = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; +} + +if (is_array($changeaccount) && count($changeaccount) > 0) { + $error = 0; + + $db->begin(); + + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent'); + $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time +} + + +/* + * View + */ + +llxHeader('', $langs->trans("ExpenseReportsVentilation") . ' - ' . $langs->trans("Dispatched")); + +print ''; + +/* + * Expense reports lines + */ +$sql = "SELECT er.ref, er.rowid as erid, erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, aa.label, aa.account_number, "; +$sql .= " f.id as fees_id, f.label as fees_label"; +$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er"; +$sql .= " , " . MAIN_DB_PREFIX . "accounting_account as aa"; +$sql .= " , " . MAIN_DB_PREFIX . "expensereport_det as erd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " WHERE er.rowid = erd.fk_expensereport and er.fk_statut >= 5 AND erd.fk_code_ventilation <> 0 "; +$sql .= " AND aa.rowid = erd.fk_code_ventilation"; +if (strlen(trim($search_expensereport))) { + $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; +} +if (strlen(trim($search_label))) { + $sql .= " AND f.label like '%" . $search_label . "%'"; +} +if (strlen(trim($search_desc))) { + $sql .= " AND er.comments like '%" . $search_desc . "%'"; +} +if (strlen(trim($search_amount))) { + $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; +} +if (strlen(trim($search_account))) { + $sql .= " AND aa.account_number like '%" . $search_account . "%'"; +} +if (strlen(trim($search_vat))) { + $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; +} +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountancy/expensereport/lines.php::list'); +$result = $db->query($sql); + +if ($result) { + $num_lines = $db->num_rows($result); + $i = 0; + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_expensereport) + $param .= "&search_expensereport=" . $search_expensereport; + if ($search_label) + $param .= "&search_label=" . $search_label; + if ($search_desc) + $param .= "&search_desc=" . $search_desc; + if ($search_account) + $param .= "&search_account=" . $search_account; + if ($search_vat) + $param .= "&search_vat=" . $search_vat; + if ($search_country) + $param .= "&search_country=" . $search_country; + if ($search_tvaintra) + $param .= "&search_tvaintra=" . $search_tvaintra; + + print '
' . "\n"; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("ExpenseReportLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + + print $langs->trans("DescVentilDoneExpenseReport") . '
'; + + print '
' . $langs->trans("ChangeAccount") . '
'; + print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1); + print '
'; + + $moreforfilter = ''; + + print ''."\n"; + + print ''; + print_liste_field_titre($langs->trans("ExpenseReport"), $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("TypeFees"), $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "erd.rowid", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre(''); + print_liste_field_titre('', '', '', '', '', 'align="center"'); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $expensereport_static = new ExpenseReport($db); + + $var = True; + while ( $i < min($num_lines, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; + + print ''; + + // Ref Invoice + $expensereport_static->ref = $objp->ref; + $expensereport_static->id = $objp->erid; + print ''; + + print ''; + + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ""; + $i ++; + } +} else { + print $db->error(); +} + +print "
'; + $searchpicto=$form->showFilterAndCheckAddButtons(1); + print $searchpicto; + print '
' . $expensereport_static->getNomUrl(1) . '' . dol_trunc($objp->fees_label, 24) . '' . nl2br(dol_trunc($objp->comments, $trunclength)) . '' . price($objp->total_ht) . '' . price($objp->tva_tx) . '' . $codeCompta . '' . $objp->rowid . ''; + print img_edit(); + print '
"; + +if ($nbtotalofrecords > $limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1); +} + +print '
'; + + +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php new file mode 100644 index 00000000000..943105a00fa --- /dev/null +++ b/htdocs/accountancy/expensereport/list.php @@ -0,0 +1,328 @@ + + * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent s + * Copyright (C) 2016 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/expensereport/list.php + * \ingroup Advanced accountancy + * \brief Ventilation page from expense reports + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("trips"); +$langs->load("main"); +$langs->load("accountancy"); + +$action = GETPOST('action'); + +// Select Box +$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); + +// Search Getpost +$search_expensereport = GETPOST('search_expensereport', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); +$btn_ventil = GETPOST('ventil', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit') ? 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'); +$page = GETPOST('page','int'); +if ($page < 0) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) + $sortfield = "er.date_create, er.ref, erd.rowid"; +if (! $sortorder) { + if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { + $sortorder = "DESC"; + } +} + +// Security check +if ($user->societe_id > 0) + accessforbidden(); +if (! $user->rights->accounting->bind->write) + accessforbidden(); + +$formventilation = new FormVentilation($db); + +// Defaut AccountingAccount RowId Product / Service +// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid +// so we need to get those default value rowid first +$accounting = new AccountingAccount($db); + +/* + * Action + */ + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $search_expensereport = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; +} + +if ($action == 'ventil' && ! empty($btn_ventil)) { + $msg=''; + //print '
' . $langs->trans("Processing") . '...
'; + if (! empty($mesCasesCochees)) { + $msg = '
' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'
'; + $msg.='
'; + $mesCodesVentilChoisis = $codeventil; + $cpt = 0; + $ok=0; + $ko=0; + + foreach ( $mesCasesCochees as $maLigneCochee ) { + // print '
id selectionnee : '.$monChoix."
"; + $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)) { + $ok++; + $msg.= '
' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; + } else { + $ko++; + $msg.= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; + } + } + + $cpt++; + } + $msg.='
'; + } else { + setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings'); + } + $msg.= '
' . $langs->trans("EndProcessing") . '
'; +} + + + +/* + * View + */ +llxHeader('', $langs->trans("ExpenseReportsVentilation")); + +// Expense report lines +$sql = "SELECT er.ref, er.rowid as erid, er.date_debut, erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, "; +$sql .= " f.id as fees_id, f.label as fees_label, f.accountancy_code as code_buy,"; +$sql .= " aa.rowid as aarowid"; +$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport as er"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; +$sql .= " WHERE er.fk_statut > 4 AND erd.fk_code_ventilation <= 0"; +$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR f.accountancy_code IS NULL OR f.accountancy_code ='')"; +// Add search filter like +if (strlen(trim($search_expensereport))) { + $sql .= " AND (er.ref like '%" . $search_expensereport . "%')"; +} +if (strlen(trim($search_label))) { + $sql .= " AND (f.label like '%" . $search_label . "%')"; +} +if (strlen(trim($search_desc))) { + $sql .= " AND (erd.comments like '%" . $search_desc . "%')"; +} +if (strlen(trim($search_amount))) { + $sql .= " AND erd.total_ht like '" . $search_amount . "%'"; +} +if (strlen(trim($search_account))) { + $sql .= " AND aa.account_number like '%" . $search_account . "%'"; +} +if (strlen(trim($search_vat))) { + $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; +} +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountancy/expensereport/list.php'); +$result = $db->query($sql); +if ($result) { + $num_lines = $db->num_rows($result); + $i = 0; + + $arrayofselected=is_array($toselect)?$toselect:array(); + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + + print '
' . "\n"; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + + $center='
'; + + print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, 0, 'title_accountancy', 0, '', '', $limit); + + if ($msg) print $msg.'
'; + + print $langs->trans("DescVentilTodoExpenseReport") . '

'; + + $moreforfilter = ''; + + print ''."\n"; + print ''; + print_liste_field_titre($langs->trans("ExpenseReport"), $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("TypeFees"), $_SERVER["PHP_SELF"], "f.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"'); + print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); + print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "erd.rowid", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre('', '', '', '', '', 'align="center"'); + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $expensereport_static = new ExpenseReport($db); + $form = new Form($db); + + $var = True; + while ( $i < min($num_lines, $limit) ) { + $objp = $db->fetch_object($result); + $var = ! $var; + + $objp->aarowid_suggest = ''; + $objp->aarowid_suggest = $objp->aarowid; + + print ''; + + // Ref Expense report + $expensereport_static->ref = $objp->ref; + $expensereport_static->id = $objp->erid; + print ''; + + // Fees label + print ''; + + // Fees description -- Can be null + // TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; + + print ''; + + // Vat rate + print ''; + + // Accounting account suggested + print ''; + + // Colonne choix du compte + print ''; + + // Line id + print ''; + + // Colonne choix ligne a ventiler + print ''; + + print ""; + $i ++; + } + + print '
'; + $searchpicto=$form->showFilterAndCheckAddButtons(1); + print $searchpicto; + print '
' . $expensereport_static->getNomUrl(1) . ''; + print dol_trunc($objp->fees_label, 24); + print '' . nl2br(dol_trunc($objp->comments, $trunclength)) . ''; + print price($objp->price); + print ''; + print price($objp->tva_tx_line); + print ''; + print length_accountg(html_entity_decode($objp->code_buy)); + print ''; + print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1); + print '' . $objp->rowid . ''; + print 'aarowid ? "checked" : "") . '/>'; + print '
'; + print '
'; +} else { + print $db->error(); +} + +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php new file mode 100644 index 00000000000..1eac3aa504c --- /dev/null +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -0,0 +1,545 @@ + + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/journal/expensereportsjournal.php + * \ingroup Advanced accountancy + * \brief Page with expense reports journal + */ +require '../../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; + +// Langs +$langs->load("compta"); +$langs->load("bills"); +$langs->load("other"); +$langs->load("main"); +$langs->load("accountancy"); + +$date_startmonth = GETPOST('date_startmonth'); +$date_startday = GETPOST('date_startday'); +$date_startyear = GETPOST('date_startyear'); +$date_endmonth = GETPOST('date_endmonth'); +$date_endday = GETPOST('date_endday'); +$date_endyear = GETPOST('date_endyear'); + +$now = dol_now(); + +// Security check +if ($user->societe_id > 0) + accessforbidden(); + +$action = GETPOST('action'); + + +/* + * Actions + */ + +$year_current = strftime("%Y", dol_now()); +$pastmonth = strftime("%m", dol_now()) - 1; +$pastmonthyear = $year_current; +if ($pastmonth == 0) { + $pastmonth = 12; + $pastmonthyear --; +} + +$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); +$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); +} + +$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); +$idpays = $p[0]; + +$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; +$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation,"; +$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_code,"; +$sql .= " f.accountancy_code, ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_valid"; +$sql .= " WHERE er.fk_statut > 0 "; +$sql .= " AND erd.fk_code_ventilation > 0 "; +$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy +if ($date_start && $date_end) + $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; +$sql .= " ORDER BY er.date_debut"; + +dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows($result); + // les variables + $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); + $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); + + $taber = array (); + $tabht = array (); + $tabtva = array (); + $def_tva = array (); + $tabttc = array (); + $tabuser = array (); + + $i = 0; + while ( $i < $num ) { + $obj = $db->fetch_object($result); + + // Controls + $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; + $compta_fees = $obj->compte; + $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); + + // Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); + + $taber[$obj->rowid]["date"] = $db->jdate($obj->de); + $taber[$obj->rowid]["ref"] = $obj->ref; + $taber[$obj->rowid]["comments"] = $obj->comments; + $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; + $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; + $tabht[$obj->rowid][$compta_fees] += $obj->total_ht; + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; + $tabuser[$obj->rowid] = array ( + 'id' => $obj->uid, + 'name' => $obj->firstname.' '.$obj->lastname, + 'user_accountancy_code' => $obj->user_accountancy_account + ); + + $i ++; + } +} else { + dol_print_error($db); +} + +// Bookkeeping Write +if ($action == 'writebookkeeping') { + $now = dol_now(); + $error = 0; + + foreach ($taber as $key => $val) + { + $errorforline = 0; + + foreach ( $tabttc[$key] as $k => $mt ) { + // get compte id and label + + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->label_compte = $tabuser[$key]['name']; + $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt > 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { + // get compte id and label + $accountingaccount = new AccountingAccount($db); + if ($accountingaccount->fetch(null, $k)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + + // VAT + // var_dump($tabtva); + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'expense_report'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + $error++; + $errorforline++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (! $errorforline) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + } + + if (empty($error) && count($tabpay)) { + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + } + elseif (count($tabpay) == $error) + { + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + } + else + { + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + } + + $action=''; +} + +/* + * View + */ + +$form = new Form($db); + +$userstatic = new User($db); + +// Export +if ($action == 'export_csv') { + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $journal = $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL; + + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + + // Model Cegid Expert Export + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; + + foreach ( $taber as $key => $val ) { + $date = dol_print_date($val["date"], '%d%m%Y'); + + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + $userstatic->client = $tabuser[$key]['code_client']; + + if ($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; + print dol_trunc($val["comments"], 32) . $sep; + print $val["ref"]; + print "\n"; + } + } + + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($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; + print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } + } + + foreach ( $tabttc[$key] as $k => $mt ) { + print $date . $sep; + print $journal . $sep; + print length_accountg($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $userstatic->name . $sep; + print $val["ref"]; + print "\n"; + } + } + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + // Model Classic Export + foreach ( $taber as $key => $val ) { + $date = dol_print_date($val["date"], 'day'); + + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + 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($langs->trans("VAT")) . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } + } + + // Third party + foreach ( $tabttc[$key] as $k => $mt ) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($userstatic->name) . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + } + print "\n"; + } + } +} + +if (empty($action) || $action == 'view') { + + llxHeader('', $langs->trans("ExpenseReportsJournal")); + + $nom = $langs->trans("ExpenseReportsJournal"); + $nomlink = ''; + $periodlink = ''; + $exportlink = ''; + $builddate = time(); + $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; + + $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); + report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( + 'action' => '' + )); + + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { + print ''; + } else { + print ''; + } + + print ''; + + print ' + '; + + /* + * Show result array + */ + print '

'; + + $i = 0; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $var = true; + $r = ''; + + $expensereportstatic = new ExpenseReport($db); + $expensereportlinestatic = new ExpenseReportLine($db); + + foreach ( $taber as $key => $val ) { + $expensereportstatic->id = $key; + $expensereportstatic->ref = $val["ref"]; + $expensereportlinestatic->comments = html_entity_decode(dol_trunc($val["comments"], 32)); + + $date = dol_print_date($val["date"], 'day'); + + // Fees + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); + + if ($mt) { + print ""; + print ""; + print ""; + print ""; + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + print ""; + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + print ""; + print '"; + print '"; + print ""; + } + } + + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; + print ""; + } + } + print ""; + + // Third party + foreach ( $tabttc[$key] as $k => $mt ) { + print ""; + print ""; + print ""; + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; + print ""; + print ""; + print '"; + print '"; + } + print ""; + + $var = ! $var; + } + + print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")" . $langs->trans("Account") . "" . $langs->trans("Label") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $expensereportstatic->getNomUrl(1) . ""; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("FeeAccountNotDefined").''; + } + else print $accountoshow; + print "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $expensereportstatic->getNomUrl(1) . ""; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("VatAccountNotDefined").''; + } + else print $accountoshow; + print "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $expensereportstatic->getNomUrl(1) . ""; + $accountoshow = length_accounta($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } + else print $accountoshow; + print "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; + + // End of page + llxFooter(); +} +$db->close(); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 85ade98addf..07b737c8bbf 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -227,6 +227,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'ventil_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?leftmenu=dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && $leftmenu=="dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); -- Journals -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'journal', 2400__+MAX_llx_menu__, '/accountancy/journal/index.php?leftmenu=journal', 'Journaux', 1, 'accountancy', '$user->rights->accounting->comptarapport->lire', '', 0, 7, __ENTITY__); -- General Ledger diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 1b0ff489eba..cd8d5e75645 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -346,6 +346,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM // Add other journal $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire); $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire); + $newmenu->add("/accountancy/journal/expensereportsjournal.php?leftmenu=journal",$langs->trans("ExpenseReportsJournal"),1,$user->rights->accounting->comptarapport->lire); } if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 10c87f06f8b..e64d6318105 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -969,7 +969,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu }*/ if (empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); - // Binding if (empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); if (empty($leftmenu) || preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); @@ -982,6 +981,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier",$langs->trans("Binded"),2,$user->rights->accounting->bind->write); } + if (! empty($conf->expensereport->enabled)) + { + if (empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy",$langs->trans("ExpenseReportsVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); + if (empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/',$leftmenu)) $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); + if (empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/',$leftmenu)) $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport",$langs->trans("Binded"),2,$user->rights->accounting->bind->write); + } + // Journals if(! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { @@ -1013,6 +1019,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Add other journal if (empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); if (empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); + if (empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/expensereportsjournal.php?mainmenu=accountancy&leftmenu=accountancy_journal",$langs->trans("ExpenseReportsJournal"),2,$user->rights->accounting->comptarapport->lire); } // General Ledger diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 0f77a358e84..1685ed5ad3a 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -139,6 +139,7 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); +ALTER TABLE llx_expensereport_det ADD COLUMN fk_code_ventilation integer DEFAULT 0; ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 0a7853d2a8b..069cd534e4f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -46,7 +46,8 @@ CREATE TABLE llx_expensereport_det multicurrency_total_ht double(24,8) DEFAULT 0, multicurrency_total_tva double(24,8) DEFAULT 0, multicurrency_total_ttc double(24,8) DEFAULT 0, - fk_facture integer DEFAULT 0, -- ID of customer invoice line if expense is rebilled to a customer + fk_facture integer DEFAULT 0, -- ID of customer invoice line if expense is rebilled to a customer + fk_code_ventilation integer DEFAULT 0, rang integer DEFAULT 0, -- position of line import_key varchar(14) ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 3077a2ad24d..99131bd5c0c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -58,6 +58,7 @@ ProductsBinding=Products accounts Ventilation=Binding to accounts CustomersVentilation=Customer invoice binding SuppliersVentilation=Supplier invoice binding +ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction WriteBookKeeping=Journalize transactions in General Ledger @@ -65,16 +66,21 @@ Bookkeeping=General ledger AccountBalance=Account balance CAHTF=Total purchase supplier before tax +TotalExpenseReport=Total expense report InvoiceLines=Lines of invoices to bind InvoiceLinesDone=Bound lines of invoices +ExpenseReportLines=Lines of expense reports to bind +ExpenseReportLinesDone=Bound lines of expense reports IntoAccount=Bind line with the accounting account + Ventilate=Bind LineId=Id line Processing=Processing EndProcessing=Process terminated. SelectedLines=Selected lines Lineofinvoice=Line of invoice +LineOfExpenseReport=Line of expense report NoAccountSelected=No accounting account selected VentilatedinAccount=Binded successfully to the accounting account NotVentilatedinAccount=Not bound to the accounting account @@ -126,11 +132,13 @@ ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/o ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger DelBookKeeping=Delete the record of the general ledger FinanceJournal=Finance journal +ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the General Ledger. VATAccountNotDefined=Account for VAT not defined ThirdpartyAccountNotDefined=Account for third party not defined ProductAccountNotDefined=Account for product not defined +FeeAccountNotDefined=Account for fee not defined BankAccountNotDefined=Account for bank not defined CustomerInvoicePayment=Payment of invoice customer ThirdPartyAccount=Thirdparty account @@ -157,6 +165,10 @@ ChangeAccount=Change the product/service accounting account for selected lines w Vide=- DescVentilSupplier=Consult here the list of supplier invoice lines bound or not yet bound to a product accounting account DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account +DescVentilTodoExpenseReport=Bind expense report lines not already bound with a fee accounting account +DescVentilExpenseReport=Consult here the list of expense report lines bound (or not) to a fee accounting account +DescVentilExpenseReportMore=In most cases, if you use configured fees, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still has some lines not bound to any account, you will have to make a manual binding from the menu "%s". +DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 7178ac6df47..6a12588139d 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -8,6 +8,7 @@ TripCard=Expense report card AddTrip=Create expense report ListOfTrips=List of expense reports ListOfFees=List of fees +TypeFees=Types of fees ShowTrip=Show expense report NewTrip=New expense report CompanyVisited=Company/foundation visited diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index eb5c2a2d75d..c4b7084b2d8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2014,7 +2014,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = cd.fk_commande"; $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande_fourniseur', 1).")"; + $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; $sql.= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;