Accountancy

This commit is contained in:
Florian HENRY 2016-02-01 15:07:12 +01:00
parent 72b0f62089
commit fb5aba6de2
31 changed files with 1999 additions and 2075 deletions

View File

@ -21,7 +21,6 @@
* \ingroup Accounting Expert
* \brief List accounting account
*/
require '../../main.inc.php';
// Class
@ -177,8 +176,7 @@ if ($result) {
$accountstatic = new AccountingAccount($db);
while ( $i < min($num, $limit) )
{
while ( $i < min($num, $limit) ) {
$obj = $db->fetch_object($resql);
$accountstatic->id = $obj->rowid;

View File

@ -48,8 +48,7 @@ if (!$user->admin)
$accounting = new AccountingAccount($db);
// Action
if ($action == 'add')
{
if ($action == 'add') {
if (! $cancel) {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
@ -80,9 +79,7 @@ if ($action == 'add')
}
}
Header("Location: account.php");
}
else if ($action == 'edit')
{
} else if ($action == 'edit') {
if (! GETPOST('cancel', 'alpha')) {
$result = $accounting->fetch($id);
@ -111,9 +108,7 @@ else if ($action == 'edit')
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
}
}
else if ($action == 'delete')
{
} else if ($action == 'delete') {
$result = $accounting->fetch($id);
if (! empty($accounting->id)) {
@ -137,8 +132,7 @@ llxheader('', $langs->trans('AccountAccounting'));
$form = new Form($db);
$htmlacc = new FormVentilation($db);
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
@ -177,9 +171,7 @@ if ($action == 'create')
print '</div>';
print '</form>';
}
else if ($id)
{
} else if ($id) {
$rowid = $id;
$account = $accounting->fetch($rowid);
@ -188,8 +180,7 @@ else if ($id)
$head = accounting_prepare_head($accounting);
if ($action == 'update')
{
if ($action == 'update') {
$soc = new Societe($db);
if ($object->socid) {
$soc->fetch($object->socid);
@ -232,9 +223,7 @@ else if ($id)
print '</div>';
print '</form>';
}
else
{
} else {
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
@ -297,9 +286,7 @@ else if ($id)
print '</div>';
}
}
else
{
} else {
dol_print_error($db);
}
}

View File

@ -25,7 +25,6 @@
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
require '../../main.inc.php';
// Class
@ -119,7 +118,6 @@ print load_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'title_
$head = admin_accounting_prepare_head();
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
@ -140,14 +138,11 @@ $var = ! $var;
print '<tr ' . $bc[$var] . '>';
print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
if (! $conf->use_javascript_ajax)
{
if (! $conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
}
else
{
} else {
print '<td>';
$listformat = array (
'csv' => $langs->trans("csv"),
@ -160,8 +155,7 @@ else
print "</td></tr>";
$num = count($main_option);
if ($num)
{
if ($num) {
foreach ( $main_option as $key ) {
$var = ! $var;
@ -195,14 +189,11 @@ $var = ! $var;
print '<tr ' . $bc[$var] . '>';
print '<td width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
if (! $conf->use_javascript_ajax)
{
if (! $conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
}
else
{
} else {
print '<td>';
$listmodelcsv = array (
'1' => $langs->trans("Modelcsv_normal"),
@ -223,13 +214,13 @@ print "<br>\n";
*/
$num2 = count($model_option);
if ($num2)
{
if ($num2) {
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1)
print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
foreach ( $model_option as $key ) {
$var = ! $var;

View File

@ -20,7 +20,6 @@
* \ingroup fiscal year
* \brief Setup page to configure fiscal year
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@ -31,7 +30,8 @@ $action=GETPOST('action');
$langs->load("admin");
$langs->load("compta");
if (! $user->admin) accessforbidden();
if (! $user->admin)
accessforbidden();
$error = 0;
@ -40,8 +40,11 @@ static $tmpstatut2label=array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label=array('');
foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val);
$statut2label = array (
''
);
foreach ( $tmpstatut2label as $key => $val )
$statut2label[$key] = $langs->trans($val);
$errors = array ();
@ -70,8 +73,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
$sql .= " WHERE f.entity = " . $conf->entity;
$result = $db->query($sql);
if ($result)
{
if ($result) {
$var = false;
$num = $db->num_rows($result);
@ -87,12 +89,10 @@ if ($result)
print '<td align="right">' . $langs->trans("Statut") . '</td>';
print '</tr>';
if ($num)
{
if ($num) {
$fiscalyearstatic = new Fiscalyear($db);
while ($i < $num && $i < $max)
{
while ( $i < $num && $i < $max ) {
$obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid;
print '<tr ' . $bc[$var] . '>';
@ -105,17 +105,12 @@ if ($result)
$var = ! $var;
$i ++;
}
}
else
{
} else {
print '<tr ' . $bc[$var] . '><td colspan="5">' . $langs->trans("None") . '</td></tr>';
}
print '</table>';
}
else
{
} else {
dol_print_error($db);
}

View File

@ -19,18 +19,17 @@
* \file htdocs/accountancy/admin/fiscalyear_card.php
* \brief Page to show a fiscal year
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$langs->load("admin");
$langs->load("compta");
// Security check
if (! $user->admin) accessforbidden();
if (! $user->admin)
accessforbidden();
$error = 0;
@ -43,37 +42,33 @@ static $tmpstatut2label=array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label=array('');
foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val);
$statut2label = array (
''
);
foreach ( $tmpstatut2label as $key => $val )
$statut2label[$key] = $langs->trans($val);
$object = new Fiscalyear($db);
$date_start = dol_mktime(0, 0, 0, GETPOST('fiscalyearmonth', 'int'), GETPOST('fiscalyearday', 'int'), GETPOST('fiscalyearyear', 'int'));
$date_end = dol_mktime(0, 0, 0, GETPOST('fiscalyearendmonth', 'int'), GETPOST('fiscalyearendday', 'int'), GETPOST('fiscalyearendyear', 'int'));
/*
* Actions
*/
if ($action == 'confirm_delete' && $confirm == "yes")
{
if ($action == 'confirm_delete' && $confirm == "yes") {
$result = $object->delete($id);
if ($result >= 0)
{
if ($result >= 0) {
header("Location: fiscalyear.php");
exit;
}
else
{
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
else if ($action == 'add')
{
if (! GETPOST('cancel','alpha'))
{
else if ($action == 'add') {
if (! GETPOST('cancel', 'alpha')) {
$error = 0;
$object->date_start = $date_start;
@ -82,55 +77,43 @@ else if ($action == 'add')
$object->statut = GETPOST('statut', 'int');
$object->datec = dol_now();
if (empty($object->date_start) && empty($object->date_end))
{
if (empty($object->date_start) && empty($object->date_end)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error ++;
}
if (empty($object->label))
{
if (empty($object->label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$error ++;
}
if (! $error)
{
if (! $error) {
$db->begin();
$id = $object->create($user);
if ($id > 0)
{
if ($id > 0) {
$db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
exit();
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
}
}
else
{
} else {
$action = 'create';
}
}
else
{
} else {
header("Location: ./fiscalyear.php");
exit;
exit();
}
}
// Update record
else if ($action == 'update')
{
if (! GETPOST('cancel','alpha'))
{
else if ($action == 'update') {
if (! GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id);
$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
@ -140,20 +123,15 @@ else if ($action == 'update')
$result = $object->update($user);
if ($result > 0)
{
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
exit();
}
}
@ -168,8 +146,7 @@ $form = new Form($db);
/*
* Action create
*/
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
@ -211,16 +188,12 @@ if ($action == 'create')
print '</div>';
print '</form>';
}
else if ($id)
{
} else if ($id) {
$result = $object->fetch($id);
if ($result > 0)
{
if ($result > 0) {
$head = fiscalyear_prepare_head($object);
if ($action == 'edit')
{
if ($action == 'edit') {
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
@ -267,16 +240,12 @@ else if ($id)
print '</form>';
dol_fiche_end();
}
else
{
} else {
/*
* Confirm delete
*/
if ($action == 'delete')
{
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
}
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
@ -332,9 +301,7 @@ else if ($id)
print '</div>';
}
}
else
{
} else {
dol_print_error($db);
}
}

View File

@ -19,27 +19,25 @@
* \file htdocs/accountancy/admin/fiscalyear_card.php
* \brief Page to show info of a fiscal year
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$langs->load("admin");
$langs->load("compta");
// Security check
if (! $user->admin) accessforbidden();
if (! $user->admin)
accessforbidden();
$id = GETPOST('id', 'int');
// View
llxHeader();
if ($id)
{
if ($id) {
$object = new Fiscalyear($db);
$object->fetch($id);
$object->info($id);

View File

@ -23,7 +23,6 @@
* \ingroup Accounting Expert
* \brief Page import accounting account
*/
require '../../main.inc.php';
// Class

View File

@ -27,7 +27,6 @@
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
require '../../main.inc.php';
// Class
@ -74,8 +73,7 @@ $list_account = array (
$accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPENSES';
if ($action == 'update')
{
if ($action == 'update') {
$error = 0;
$accounting_modes = array (
@ -121,12 +119,9 @@ if ($action == 'update')
}
}
if (! $error)
{
if (! $error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
@ -163,14 +158,13 @@ if ($action == 'setlistsortdone') {
llxHeader();
$form = new Form($db);
$formaccountancy = New FormVentilation($db);
$formaccountancy = new FormVentilation($db);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
$head = admin_accounting_prepare_head($accounting);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update">';
@ -259,8 +253,7 @@ print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
foreach ($list as $key)
{
foreach ( $list as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';
@ -275,8 +268,7 @@ foreach ($list as $key)
print '</td></tr>';
}
foreach ($list_account as $key)
{
foreach ( $list_account as $key ) {
$var = ! $var;
print '<tr ' . $bc[$var] . ' class="value">';

View File

@ -26,7 +26,6 @@
* \ingroup Accounting Expert
* \brief Setup page to configure accounting expert module
*/
require '../../main.inc.php';
// Class
@ -115,10 +114,8 @@ foreach ( $list as $key ) {
print "</table>\n";
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('JournalFinancial') . '</td>';
@ -132,15 +129,13 @@ $sql.= " AND clos = 0";
$sql .= " ORDER BY label";
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$numr = $db->num_rows($resql);
$i = 0;
if ($numr > 0)
while ($i < $numr)
{
while ( $i < $numr ) {
$objp = $db->fetch_object($resql);
$var = ! $var;
@ -157,8 +152,8 @@ if ($resql)
$i ++;
}
}
else dol_print_error($db);
} else
dol_print_error($db);
$db->free($resql);
print "</table>\n";
@ -169,6 +164,5 @@ print '<div class="center"><input type="submit" class="button" value="' . $langs
print '</form>';
llxFooter();
$db->close();

View File

@ -42,8 +42,12 @@ $langs->load("main");
$langs->load("accountancy");
// Security check
if (!$user->admin) accessforbidden();
if (empty($conf->accounting->enabled)) accessforbidden();
if (! $user->admin) {
accessforbidden();
}
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
// search & action GETPOST
$action = GETPOST('action');
@ -77,10 +81,12 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->
}
$offset = $limit * $page;
if (! $sortfield)
if (! $sortfield) {
$sortfield = "p.ref";
if (! $sortorder)
}
if (! $sortorder) {
$sortorder = "ASC";
}
// Sales or Purchase mode ?
if ($action == 'update') {
@ -146,7 +152,6 @@ if ($action == 'update') {
$msg .= '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
}
$msg .= '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
}
@ -345,8 +350,7 @@ if ($result) {
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
// Accounting account buy
if ($accounting_product_mode == 'ACCOUNTANCY_BUY')
{
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
// TODO: replace by select
// print '<td align="left">' . $compta_prodbuy . '</td>';
@ -355,9 +359,7 @@ if ($result) {
print '<td align="left">';
print $form->select_account($compta_prodbuy_id, 'codeventil_' . $product_static->id, 1);
print '</td>';
}
else
{
} else {
// Accounting account sell
// print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
// TODO: replace by select

View File

@ -24,7 +24,6 @@
* \ingroup Accounting Expert
* \brief Balance by month
*/
require '../../main.inc.php';
// Class

View File

@ -22,7 +22,6 @@
* \ingroup Accounting Expert
* \brief Page to show account
*/
require '../../main.inc.php';
// Class
@ -34,8 +33,9 @@ $langs->load("accountancy");
// Security check
$id = GETPOST('id', 'int');
if ($user->societe_id > 0)
if ($user->societe_id > 0) {
accessforbidden();
}
$action = GETPOST('action');
$piece_num = GETPOST("piece_num");
@ -277,7 +277,7 @@ if ($action == 'create') {
}
if (! empty($book->piece_num)) {
print load_fiche_titre($langs->trans("UpdateMvts"));
print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>');
print '<table class="border" width="100%">';
print '<tr class="pair">';
@ -345,7 +345,6 @@ if ($action == 'create') {
if ($action == 'update' && $line->id == $id) {
print '<td>';
print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print '</td>';
@ -384,7 +383,11 @@ if ($action == 'create') {
}
if ($total_debit != $total_credit) {
setEventMessages(null, array('MvtNotCorrectlyBalanced',$total_credit,$total_debit),'errors');
setEventMessages(null, array (
'MvtNotCorrectlyBalanced',
$total_credit,
$total_debit
), 'errors');
}
if ($action == "" || $action == 'add') {

View File

@ -79,8 +79,6 @@ $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$object = new BookKeeping($db);
@ -117,7 +115,6 @@ if ($sortorder == "")
if ($sortfield == "")
$sortfield = "t.rowid";
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
@ -181,7 +178,6 @@ if (! empty($search_mvt_num)) {
$options .= '&amp;search_mvt_num=' . $search_mvt_num;
}
/*
* Action
*/
@ -238,8 +234,7 @@ if ($action == 'delbookkeeping') {
foreach ( $object->lines as $line ) {
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
{
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
// Model Cegid Expert Export
$date = dol_print_date($line->doc_date, '%d%m%Y');
@ -259,8 +254,7 @@ if ($action == 'delbookkeeping') {
print price($line->credit) . $sep;*/
print "\n";
}
elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Std export
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
@ -332,7 +326,13 @@ else {
}
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$form_question['delyear']=array('name'=>'delyear','type'=>'select','label'=>$langs->trans('DelYear'),'values'=>$year_array,'default'=>$delyear);
$form_question['delyear'] = array (
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1);
print $formconfirm;
@ -359,7 +359,6 @@ else {
print '</div>';
/*print '<div class="liste_titre">';
print $langs->trans('DateStart') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);

View File

@ -23,7 +23,6 @@
* \ingroup Accounting Expert
* \brief Book keeping by year
*/
require '../../main.inc.php';
// Class

View File

@ -33,10 +33,8 @@ class AccountingAccount extends CommonObject
var $db;
var $error;
var $errors;
var $id;
var $rowid;
var $datec; // Creation date
var $fk_pcg_version;
var $pcg_type;
@ -53,8 +51,7 @@ class AccountingAccount extends CommonObject
*
* @param DoliDB $db Database handle
*/
function __construct($db)
{
function __construct($db) {
$this->db = $db;
}
@ -66,8 +63,7 @@ class AccountingAccount extends CommonObject
* @param int $limittocurentchart 1=Do not load record if it is into another accounting system
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid = null, $account_number = null, $limittocurentchart=0)
{
function fetch($rowid = null, $account_number = null, $limittocurentchart = 0) {
global $conf;
if ($rowid || $account_number) {
@ -120,8 +116,7 @@ class AccountingAccount extends CommonObject
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
function create($user, $notrigger = 0)
{
function create($user, $notrigger = 0) {
global $conf;
$error = 0;
$now = dol_now();
@ -221,8 +216,7 @@ class AccountingAccount extends CommonObject
* @param User $user Use making update
* @return int <0 if KO, >0 if OK
*/
function update($user)
{
function update($user) {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
@ -254,8 +248,7 @@ class AccountingAccount extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
function checkUsage()
{
function checkUsage() {
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
@ -288,8 +281,7 @@ class AccountingAccount extends CommonObject
* @param int $notrigger 0=triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
function delete($user, $notrigger = 0) {
$error = 0;
$result = $this->checkUsage();
@ -347,8 +339,7 @@ class AccountingAccount extends CommonObject
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0)
{
function getNomUrl($withpicto = 0) {
global $langs;
$result = '';
@ -360,9 +351,12 @@ class AccountingAccount extends CommonObject
$label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label;
if ($withpicto) $result.=($link.img_object($label,$picto).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$this->account_number.$linkend;
if ($withpicto)
$result .= ($link . img_object($label, $picto) . $linkend);
if ($withpicto && $withpicto != 2)
$result .= ' ';
if ($withpicto != 2)
$result .= $link . $this->account_number . $linkend;
return $result;
}
@ -372,8 +366,7 @@ class AccountingAccount extends CommonObject
* @param int $id of record
* @return void
*/
function info($id)
{
function info($id) {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
$sql .= ' WHERE a.rowid = ' . $id;
@ -410,8 +403,7 @@ class AccountingAccount extends CommonObject
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
function account_desactivate($id)
{
function account_desactivate($id) {
$result = $this->checkUsage();
if ($result > 0) {
@ -443,8 +435,7 @@ class AccountingAccount extends CommonObject
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
function account_activate($id)
{
function account_activate($id) {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";

View File

@ -291,7 +291,6 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
if (! $error) {
if (! $notrigger) {
@ -325,8 +324,7 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, Id of created object if OK
*/
public function createStd(User $user, $notrigger = false)
{
public function createStd(User $user, $notrigger = false) {
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
@ -379,8 +377,6 @@ class BookKeeping extends CommonObject
$this->piece_num = trim($this->piece_num);
}
// Check parameters
// Put here code to add control on parameters values
@ -404,7 +400,6 @@ class BookKeeping extends CommonObject
$sql .= 'code_journal,';
$sql .= 'piece_num';
$sql .= ') VALUES (';
$sql .= ' ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : "'" . $this->db->idate($this->doc_date) . "'") . ',';
@ -424,7 +419,6 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (! isset($this->piece_num) ? 'NULL' : $this->piece_num);
$sql .= ')';
$this->db->begin();
@ -585,8 +579,12 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
@ -1082,8 +1080,7 @@ class BookKeeping extends CommonObject
* @param string $model Model
* @return int Result
*/
function export_bookkeping($model = 'ebp')
{
function export_bookkeping($model = 'ebp') {
$sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
$sql .= " numero_compte, label_compte, debit, credit,";
@ -1123,9 +1120,7 @@ class BookKeeping extends CommonObject
$this->db->free($resql);
return $num;
}
else
{
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR);
return - 1;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
*
* This program is free software; you can redistribute it and/or modify
@ -322,7 +322,6 @@ class FormVentilation extends Form
}
$this->db->free($resql);
// Build select
if (count($aux_account) > 0) {

View File

@ -22,7 +22,6 @@
* \ingroup Accountancy
* \brief Card customer ventilation
*/
require '../../main.inc.php';
// Class
@ -45,8 +44,7 @@ if ($user->societe_id > 0)
* Actions
*/
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if (! GETPOST('cancel', 'alpha'))
{
if (! GETPOST('cancel', 'alpha')) {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;

View File

@ -25,7 +25,6 @@
* \ingroup Accounting Expert
* \brief Home customer ventilation
*/
require '../../main.inc.php';
// Class
@ -88,6 +87,50 @@ if ($action == 'validatehistory') {
$db->commit();
setEventMessages($langs->trans('Dispatched'), null, 'mesgs');
}
} elseif ($action == 'fixaccountancycode') {
$error = 0;
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet 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 . 'accountingaccount 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 . "facturedet as fd";
$sql1 .= " SET fd.fk_code_ventilation = 0";
$sql1 .= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture 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');
}
}
/*
@ -101,7 +144,11 @@ $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
print '<b>' . $langs->trans("DescVentilCustomer") . '</b>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
print '</div>';
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";

View File

@ -25,7 +25,6 @@
* \ingroup Accounting Expert
* \brief Page of detail of the lines of ventilation of invoices customers
*/
require '../../main.inc.php';
// Class
@ -54,7 +53,8 @@ $search_vat = GETPOST('search_vat','alpha');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page < 0) $page = 0;
if ($page < 0)
$page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -67,8 +67,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
}
$offset = $limit * $page;
if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid";
if (! $sortfield)
$sortfield = "f.datef, f.facnumber, l.rowid";
if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
@ -147,7 +147,6 @@ print '<script type="text/javascript">
* Action
*/
/*
* Customer Invoice lines
*/
@ -177,8 +176,7 @@ if (strlen(trim($search_amount))) {
if (strlen(trim($search_account))) {
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
}
if (strlen(trim($search_vat)))
{
if (strlen(trim($search_vat))) {
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
}
if (! empty($conf->multicompany->enabled)) {
@ -186,11 +184,12 @@ if (! empty($conf->multicompany->enabled)) {
}
// Count total nb of records with no order and no limits
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
if ($resql) $nbtotalofrecords = $db->num_rows($resql);
else dol_print_error($db);
if ($resql)
$nbtotalofrecords = $db->num_rows($resql);
else
dol_print_error($db);
}
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
@ -202,12 +201,18 @@ if ($result) {
$i = 0;
$param = "";
if ($search_facture) $param.="&search_facture=".$search_facture;
if ($search_ref) $param.="&search_ref=".$search_ref;
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 ($filter) $param.="&filter=".$filter;
if ($search_facture)
$param .= "&search_facture=" . $search_facture;
if ($search_ref)
$param .= "&search_ref=" . $search_ref;
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 ($filter)
$param .= "&filter=" . $filter;
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords);
print '<td align="left"><b>' . $langs->trans("DescVentilDoneCustomer") . '</b></td>';
@ -292,8 +297,7 @@ if ($result) {
print "</table></form>";
if ($num_lines > $conf->liste_limit)
{
if ($num_lines > $conf->liste_limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '');
}

View File

@ -91,7 +91,6 @@ $accounting = new AccountingAccount($db);
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
$search_ref = '';
@ -282,7 +281,6 @@ if ($result) {
$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
if (! empty($objp->code_sell)) {
$objp->code_sell_p = $objp->code_sell;
} else {
@ -332,7 +330,8 @@ if ($result) {
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
if ($objp->vat_tx_l <> $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" align="center">';
print price($objp->tva_tx_line);
print '</td>';

View File

@ -27,7 +27,6 @@
* \ingroup Accounting Expert
* \brief Page with bank journal
*/
require '../../main.inc.php';
// Class
@ -143,8 +142,7 @@ if ($result) {
$tabtype = array ();
$i = 0;
while ( $i < $num )
{
while ( $i < $num ) {
$obj = $db->fetch_object($result);
$tabcompany[$obj->rowid] = array (
@ -175,39 +173,28 @@ if ($result) {
$links = $object->get_url($obj->rowid);
// get_url may return -1 which is not traversable
if (is_array($links))
{
foreach ( $links as $key => $val )
{
if (is_array($links)) {
foreach ( $links as $key => $val ) {
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment')
{
if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
}
else if ($links[$key]['type'] == 'payment_supplier')
{
} else if ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
}
else if ($links[$key]['type'] == 'company')
{
} else if ($links[$key]['type'] == 'company') {
$societestatic->id = $links[$key]['url_id'];
$societestatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
}
else if ($links[$key]['type'] == 'user')
{
} else if ($links[$key]['type'] == 'user') {
$userstatic->id = $links[$key]['url_id'];
$userstatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
// $tabtp[$obj->rowid][$compta_user] += $obj->amount;
}
else if ($links[$key]['type'] == 'sc')
{
} else if ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
@ -216,9 +203,7 @@ if ($result) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
$chargestatic->lib = $langs->trans($reg[1]);
}
else
{
} else {
$chargestatic->lib = $links[$key]['label'];
}
$chargestatic->ref = $chargestatic->lib;
@ -231,39 +216,29 @@ if ($result) {
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid)
{
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
}
}
else if ($links[$key]['type'] == 'payment_donation')
{
} else if ($links[$key]['type'] == 'payment_donation') {
$paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentDonation");
$tabtp[$obj->rowid][$accountancy_account_pay_donation] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_vat')
{
} else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat");
$tabtp[$obj->rowid][$accountancy_account_pay_vat] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_salary')
{
} else if ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
}
else if ($links[$key]['type'] == 'banktransfert')
{
} else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
}
@ -288,16 +263,13 @@ if ($result) {
*/
// Write bookkeeping
if ($action == 'writebookkeeping')
{
if ($action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
foreach ( $tabpay as $key => $val )
{
foreach ( $tabpay as $key => $val ) {
// Bank
foreach ( $tabbq[$key] as $k => $mt )
{
foreach ( $tabbq[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -339,7 +311,8 @@ if ($action == 'writebookkeeping')
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref_supplier.' ('.$objmid->ref.')';;
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
;
}
}
@ -350,8 +323,7 @@ if ($action == 'writebookkeeping')
}
}
// Third party
foreach ( $tabtp[$key] as $k => $mt )
{
foreach ( $tabtp[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -434,8 +406,7 @@ if ($action == 'writebookkeeping')
}
}
// Export
if ($action == 'export_csv')
{
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -446,8 +417,7 @@ if ($action == 'export_csv')
{
$sep = ";";
foreach ($tabpay as $key => $val)
{
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$companystatic->id = $tabcompany[$key]['id'];
@ -470,12 +440,9 @@ if ($action == 'export_csv')
}
// Third party
if (is_array ( $tabtp[$key]))
{
foreach ( $tabtp[$key] as $k => $mt )
{
if ($mt)
{
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print $date . $sep;
print $journal . $sep;
if ($val["lib"] == '(SupplierInvoicePayment)') {
@ -491,13 +458,9 @@ if ($action == 'export_csv')
print "\n";
}
}
}
else
{
foreach ( $tabbq[$key] as $k => $mt )
{
if (1)
{
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
if (1) {
print $date . $sep;
print $journal . $sep;
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . $sep;
@ -531,10 +494,8 @@ if ($action == 'export_csv')
}
// Third party
if (is_array ( $tabtp[$key]))
{
foreach ( $tabtp[$key] as $k => $mt )
{
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep;
@ -545,13 +506,9 @@ if ($action == 'export_csv')
print "\n";
}
}
}
else
{
foreach ( $tabbq[$key] as $k => $mt )
{
if (1)
{
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
if (1) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
@ -564,9 +521,7 @@ if ($action == 'export_csv')
}
}
}
}
else
{
} else {
$form = new Form($db);
llxHeader('', $langs->trans("FinanceJournal"));
@ -578,7 +533,9 @@ else
$varlink = 'id_account=' . $id_bank_account;
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
), '', $varlink);
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
@ -639,8 +596,7 @@ else
}
// Third party
if (is_array ( $tabtp[$key]))
{
if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') {
print "<tr " . $bc[$var] . ">";
@ -654,11 +610,8 @@ else
print "</tr>";
}
}
}
else
{
foreach ( $tabbq[$key] as $k => $mt )
{
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $reflabel . "</td>";

View File

@ -23,7 +23,6 @@
* \ingroup Accounting Expert
* \brief Index
*/
require '../../main.inc.php';
// Langs

View File

@ -26,7 +26,6 @@
* \ingroup Accounting Expert
* \brief Page with purchases journal
*/
require '../../main.inc.php';
// Class
@ -60,8 +59,6 @@ if ($user->societe_id > 0)
$action = GETPOST('action');
/*
* Actions
*/
@ -257,7 +254,6 @@ if ($action == 'writebookkeeping') {
}
}
/*
* View
*/
@ -265,8 +261,7 @@ if ($action == 'writebookkeeping') {
$companystatic = new Fournisseur($db);
// Export
if ($action == 'export_csv')
{
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
@ -390,7 +385,9 @@ if ($action == 'export_csv')
else
$description .= $langs->trans("DepositsAreIncluded");
$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' => ''));
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';

View File

@ -28,7 +28,6 @@
* \ingroup Accounting Expert
* \brief Page with sells journal
*/
require '../../main.inc.php';
// Class
@ -62,8 +61,6 @@ if ($user->societe_id > 0)
$action = GETPOST('action');
/*
* View
*/
@ -106,8 +103,7 @@ if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
}
else {
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
$sql .= " AND fd.product_type IN (0,1)";
@ -191,15 +187,12 @@ if ($result) {
*/
// Bookkeeping Write
if ($action == 'writebookkeeping')
{
if ($action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
foreach ($tabfac as $key => $val)
{
foreach ($tabttc[$key] as $k => $mt)
{
foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -258,10 +251,8 @@ if ($action == 'writebookkeeping')
// VAT
// var_dump($tabtva);
foreach ($tabtva[$key] as $k => $mt)
{
if ($mt)
{
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@ -294,8 +285,7 @@ if ($action == 'writebookkeeping')
}
// Export
if ($action == 'export_csv')
{
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
@ -356,11 +346,9 @@ if ($action == 'export_csv')
}
}
}
}
else // Model Classic Export
{
foreach ($tabfac as $key => $val)
} else // Model Classic Export
{
foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
@ -378,8 +366,7 @@ if ($action == 'export_csv')
}
// Product / Service
foreach ($tabht[$key] as $k => $mt)
{
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k);
@ -395,8 +382,7 @@ if ($action == 'export_csv')
}
// VAT
foreach ($tabtva[$key] as $k => $mt)
{
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
@ -426,7 +412,9 @@ if ($action == 'export_csv')
else
$description .= $langs->trans("DepositsAreIncluded");
$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' => ''));
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
'action' => ''
));
print '<input type="button" class="button" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
@ -468,8 +456,7 @@ if ($action == 'export_csv')
$invoicestatic = new Facture($db);
$companystatic = new Client($db);
foreach ($tabfac as $key => $val)
{
foreach ( $tabfac as $key => $val ) {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
@ -477,8 +464,7 @@ if ($action == 'export_csv')
$date = dol_print_date($db->jdate($val["date"]), 'day');
// Third party
foreach ($tabttc[$key] as $k => $mt)
{
foreach ( $tabttc[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
@ -494,8 +480,7 @@ if ($action == 'export_csv')
print "</tr>";
// Product / Service
foreach ($tabht[$key] as $k => $mt)
{
foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k);
@ -512,8 +497,7 @@ if ($action == 'export_csv')
}
// VAT
foreach ($tabtva[$key] as $k => $mt)
{
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";

View File

@ -26,7 +26,6 @@
* \ingroup Accountancy
* \brief Card supplier ventilation
*/
require '../../main.inc.php';
// Class
@ -46,8 +45,7 @@ if ($user->societe_id > 0)
accessforbidden();
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if (! GETPOST('cancel', 'alpha'))
{
if (! GETPOST('cancel', 'alpha')) {
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;

View File

@ -23,7 +23,6 @@
* \ingroup Accounting Expert
* \brief Home supplier ventilation
*/
require '../../main.inc.php';
// Class
@ -84,6 +83,50 @@ if ($action == 'validatehistory') {
$db->commit();
setEventMessages($langs->trans('Dispatched'), 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 . 'accountingaccount 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');
}
}
/*
@ -98,7 +141,11 @@ $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_cur
print load_fiche_titre($langs->trans("SuppliersVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear);
print '<b>' . $langs->trans("DescVentilSupplier") . '</b>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=validatehistory">' . $langs->trans("ValidateHistory") . '</a></div>';
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
print '</div>';
$y = $year_current;

View File

@ -24,7 +24,6 @@
* \ingroup Accounting Expert
* \brief Page of detail of the lines of ventilation of invoices suppliers
*/
require '../../main.inc.php';
// Class
@ -56,28 +55,23 @@ $sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page < 0) $page = 0;
if ($page < 0)
$page = 0;
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION))
{
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
}
else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0)
{
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
} else {
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
}
else
{
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
}
if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid";
if (! $sortfield)
$sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder)
{
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0)
{
if (! $sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = " DESC ";
}
}
@ -149,7 +143,6 @@ print '<script type="text/javascript">
});
</script>';
/*
* Supplier Invoice lines
*/
@ -179,8 +172,7 @@ if (strlen(trim($search_amount))) {
if (strlen(trim($search_account))) {
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
}
if (strlen(trim($search_vat)))
{
if (strlen(trim($search_vat))) {
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
}
if (! empty($conf->multicompany->enabled)) {
@ -278,7 +270,6 @@ if ($result) {
print $db->error();
}
print "</table></form>";
llxFooter();

View File

@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$prefix = $conf->global->ACCOUNTING_EXPORT_PREFIX_SPEC;
$format = $conf->global->ACCOUNTING_EXPORT_FORMAT;