Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop
This commit is contained in:
commit
cfaf4902f2
@ -261,7 +261,7 @@ else if ($id)
|
||||
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
|
||||
print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
|
||||
|
||||
print '<tr><td>' . $langs->trans("Active") . '</td>';
|
||||
print '<tr><td>' . $langs->trans("Activated") . '</td>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
if (empty($accounting->active)) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
@ -48,6 +48,8 @@ $action = GETPOST('action', 'alpha');
|
||||
// Other parameters ACCOUNTING_*
|
||||
$list = array (
|
||||
'ACCOUNTING_LIMIT_LIST_VENTILATION',
|
||||
'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
|
||||
'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
|
||||
'ACCOUNTING_LENGTH_GACCOUNT',
|
||||
'ACCOUNTING_LENGTH_AACCOUNT',
|
||||
'ACCOUNTING_ACCOUNT_CUSTOMER',
|
||||
@ -287,7 +289,6 @@ if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print '<br /><br /><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
|
||||
*
|
||||
* 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
|
||||
@ -19,129 +21,404 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/productaccount.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Onglet de gestion de parametrages des ventilations
|
||||
* \file htdocs/accountancy/admin/productaccount.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Onglet de gestion de parametrages des ventilations
|
||||
*/
|
||||
|
||||
// Dolibarr environment
|
||||
$res = @include ("../main.inc.php");
|
||||
if (! $res && file_exists("../main.inc.php"))
|
||||
$res = @include ("../main.inc.php");
|
||||
if (! $res && file_exists("../../main.inc.php"))
|
||||
$res = @include ("../../main.inc.php");
|
||||
if (! $res && file_exists("../../../main.inc.php"))
|
||||
$res = @include ("../../../main.inc.php");
|
||||
if (! $res)
|
||||
die("Include of main fails");
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
dol_include_once("/core/lib/report.lib.php");
|
||||
dol_include_once("/core/lib/date.lib.php");
|
||||
dol_include_once("/product/class/product.class.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.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("companies");
|
||||
$langs->load("compta");
|
||||
$langs->load("main");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
// Search & action GETPOST
|
||||
$action = GETPOST('action');
|
||||
$codeventil_buy = GETPOST('codeventil_buy', 'array');
|
||||
$codeventil_sell = GETPOST('codeventil_sell', 'array');
|
||||
$mesCasesCochees = GETPOST('mesCasesCochees', 'array');
|
||||
$account_number_buy = GETPOST('account_number_buy');
|
||||
$account_number_sell = GETPOST('account_number_sell');
|
||||
$changeaccount = GETPOST('changeaccount','array');
|
||||
$changeaccount_buy = GETPOST('changeaccount_buy','array');
|
||||
$changeaccount_sell = GETPOST('changeaccount_sell','array');
|
||||
$search_ref = GETPOST('search_ref','alpha');
|
||||
$search_label = GETPOST('search_label','alpha');
|
||||
$search_desc = GETPOST('search_desc','alpha');
|
||||
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
$page = GETPOST('page','int');
|
||||
if ($page < 0) $page = 0;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
//bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed !
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) {
|
||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
||||
//} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
|
||||
// $limit = $conf->liste_limit;
|
||||
} else {
|
||||
$limit = $conf->liste_limit;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
if (! $sortfield) $sortfield="p.ref";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
// TODO after adding menu
|
||||
// if (! $user->rights->accounting->ventilation->dispatch)
|
||||
// accessforbidden();
|
||||
|
||||
$form = 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);
|
||||
//TODO: we should need to check if result is a really exist accountaccount rowid.....
|
||||
$aarowid_servbuy = $accounting->fetch('', ACCOUNTING_SERVICE_BUY_ACCOUNT);
|
||||
$aarowid_prodbuy = $accounting->fetch('', ACCOUNTING_PRODUCT_BUY_ACCOUNT);
|
||||
$aarowid_servsell = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT);
|
||||
$aarowid_prodsell = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
|
||||
|
||||
$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$search_ref='';
|
||||
$search_label='';
|
||||
$search_desc='';
|
||||
}
|
||||
|
||||
//debug move header to top
|
||||
llxHeader('', $langs->trans("Accounts"));
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
print '<input type="button" class="button" style="float: right;" value="Renseigner les comptes comptables produits manquant" onclick="launch_export();" />';
|
||||
//TODO: modify to update all selected product with a sell account
|
||||
if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_sell")) {
|
||||
//print_r ($changeaccount);
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "product as p";
|
||||
$sql1 .= " SET p.accountancy_code_sell=" . $account_number_sell;
|
||||
$sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')';
|
||||
|
||||
dol_syslog('accountancy/customer/lines.php::changeaccount product sell sql= ' . $sql1);
|
||||
print_r ($sql1);
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Save'), 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
|
||||
//TODO: modify to update all selected product with a buy account
|
||||
if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_buy")) {
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "product as p";
|
||||
$sql1 .= " SET p.accountancy_code_buy=" . $account_number_buy;
|
||||
$sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')';
|
||||
print_r ($sql1);
|
||||
dol_syslog('accountancy/customer/lines.php::changeaccount product buy sql= ' . $sql1);
|
||||
$resql1 = $db->query($sql1);
|
||||
if (! $resql1) {
|
||||
$error ++;
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('Save'), 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessage($db->lasterror(), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
//DEBUG elarifr
|
||||
//llxHeader('', $langs->trans("Accounts"));
|
||||
|
||||
//For updating account export
|
||||
print '<script type="text/javascript">
|
||||
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell as codesell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy ";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
||||
$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1";
|
||||
//TODO For select box
|
||||
print '<script type="text/javascript">
|
||||
$(function () {
|
||||
$(\'#select-all\').click(function(event) {
|
||||
// Iterate each checkbox
|
||||
$(\':checkbox\').each(function() {
|
||||
this.checked = true;
|
||||
});
|
||||
});
|
||||
$(\'#unselect-all\').click(function(event) {
|
||||
// Iterate each checkbox
|
||||
$(\':checkbox\').each(function() {
|
||||
this.checked = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
dol_syslog('accountancy/admin/productaccount.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
//TODO
|
||||
/*
|
||||
if ($action == 'ventil') {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (! empty($codeventil_buy) && ! empty($mesCasesCochees)) {
|
||||
if (! empty($codeventil_sell) && ! empty($mesCasesCochees)) {
|
||||
|
||||
/*
|
||||
* view
|
||||
*/
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<td align="left">' . $langs->trans("Ref") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Label") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Description") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
||||
|
||||
$var = true;
|
||||
|
||||
while ( $i < min($num, 250) ) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = ! $var;
|
||||
|
||||
$compta_prodsell = $obj->accountancy_code_sell;
|
||||
if (empty($compta_prodsell)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
else
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
|
||||
$compta_prodbuy = $obj->accountancy_code_buy;
|
||||
if (empty($compta_prodbuy)) {
|
||||
if ($obj->product_type == 0)
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
else
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
|
||||
$product_static = new Product($db);
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
// Ref produit
|
||||
$product_static->ref = $objp->ref;
|
||||
$product_static->id = $objp->rowid;
|
||||
$product_static->type = $objp->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td align="left">' . $obj->ref . '</td>';
|
||||
print '<td align="left">' . $obj->label . '</td>';
|
||||
print '<td align="left">' . $obj->description . '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
||||
print '<td align="left">' . $compta_prodsell . '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i ++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
||||
}
|
||||
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
}
|
||||
*/
|
||||
//do we really need to exclude old product not tosell / tobuy ?
|
||||
//$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy ";
|
||||
//$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1";
|
||||
//$sql .= " WHERE p.accountancy_code_sell ='' AND p.tosell = 1 OR p.accountancy_code_buy ='' AND p.tobuy = 1";
|
||||
$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
||||
//$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa";
|
||||
$sql .= " WHERE (";
|
||||
$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL";
|
||||
|
||||
//Search on correct pcg version
|
||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN
|
||||
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
||||
//(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))";
|
||||
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN
|
||||
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
||||
//(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))";
|
||||
$sql .= ")";
|
||||
//Add search filter like
|
||||
if (strlen(trim($search_ref))) {
|
||||
$sql .= " AND (p.ref like '" . $search_ref . "%')";
|
||||
}
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= " AND (p.label like '" . $search_label . "%')";
|
||||
}
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= " AND (p.description like '%" . $search_desc . "%')";
|
||||
}
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
/*
|
||||
|
||||
|
||||
* View
|
||||
*/
|
||||
print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<td align="left"><b>' . $langs->trans("DescProductAccountingAccount") . '</b></td> ';
|
||||
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder);
|
||||
print ' ';
|
||||
|
||||
|
||||
//DEBUG
|
||||
//print $sql;
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post"><br />';
|
||||
// print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td width="33%">';
|
||||
print '<div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br />';
|
||||
print $langs->trans("Accountancy_code_buy") . ': ' . $form->select_account($account_number_buy, 'account_number_buy', 1,'', 0, 1);
|
||||
print '<input type="submit" class="butAction" name="action" value="' . $langs->trans("Accountancy_code_buy") . '"/></div>';
|
||||
print '</td>';
|
||||
|
||||
print '<td width="33%">';
|
||||
print '<div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br />';
|
||||
print $langs->trans("Accountancy_code_sell") . ': ' . $form->select_account($account_number_sell, 'account_number_sell', 1, '', 0, 1);
|
||||
print '<input type="submit" class="butAction" name="action" value="' . $langs->trans("Accountancy_code_sell") . '"/></div>';
|
||||
print '</td>';
|
||||
print '<td width="33%">';
|
||||
//TODO change button
|
||||
print '<input type="button" class="button" style="float: right;" value="Renseigner les comptes comptables produits manquant" onclick="launch_export();" />';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
// print '<td align="left">' . $langs->trans("Ref") . '</td>';
|
||||
// print '<td align="left">' . $langs->trans("Label") . '</td>';
|
||||
// print '<td align="left">' . $langs->trans("Description") . '</td>';
|
||||
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"p.ref","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"],"p.label","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"],"l.description","",$param,'',$sortfield,$sortorder);
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
||||
print_liste_field_titre('');
|
||||
// print_liste_field_titre('');
|
||||
print '<td align="center" colspan="2">' . $langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>'.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="20" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></td>';
|
||||
|
||||
print '<td class="liste_titre" colspan="3"> </td>';
|
||||
print '<td align="right" colspan="4" class="liste_titre">';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
// print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print ' ';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
// print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
print '</td>';
|
||||
// print '<td class="liste_titre" colspan="2"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$var = true;
|
||||
|
||||
|
||||
while ( $i < min($num_lines, 250) ) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
|
||||
|
||||
$compta_prodsell = $obj->accountancy_code_sell;
|
||||
if (empty($compta_prodsell)) {
|
||||
if ($obj->product_type == 0) {
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$compta_prodsell_id = $aarowid_prodsell;
|
||||
} else {
|
||||
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$compta_prodsell_id = $aarowid_servsell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$compta_prodbuy = $obj->accountancy_code_buy;
|
||||
if (empty($compta_prodbuy)) {
|
||||
if ($obj->product_type == 0) {
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$compta_prodbuy_id = $aarowid_prodbuy;
|
||||
} else {
|
||||
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$compta_prodbuy_id = $aarowid_servbuy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$product_static = new Product($db);
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
//debug
|
||||
print '<td align="left" colspan="6">Compte Suggeres compta_prodbuy=' . $compta_prodbuy . ' -- compta_prodbuy_id' . $compta_prodbuy_id . '-- compta_prodsell:' . $compta_prodsell . '-- compta_prodsell_id' . $compta_prodsell_id . '</td>';
|
||||
|
||||
print "</tr>";
|
||||
print "<tr $bc[$var]>";
|
||||
// Ref produit as link
|
||||
$product_static->ref = $obj->ref;
|
||||
$product_static->id = $obj->rowid;
|
||||
$product_static->type = $obj->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print '- ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->label . '</td>';
|
||||
//TODO ADJUST DESCRIPTION SIZE
|
||||
// print '<td align="left">' . $obj->description . '</td>';
|
||||
//TODO: we shoul set a user defined value to adjust user square / wide screen size
|
||||
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
||||
|
||||
//acountingaccount buy
|
||||
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
//TODO: replace by select
|
||||
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
//TODO: we shoul set a user defined value to adjust user square / wide screen size
|
||||
//$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
||||
print '<td align="center">';
|
||||
print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
|
||||
//acountingaccount sel
|
||||
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
||||
|
||||
//TODO: replace by select
|
||||
//TODO: we shoul set a user defined value to adjust user square / wide screen size
|
||||
//$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
||||
print '<td align="center">';
|
||||
print $form->select_account($compta_prodsell_id, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
//action edit & select box
|
||||
print '<td align="center">' . $obj->rowid . '</td>';
|
||||
print '<td><a href="./card.php?id=' . $obj->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
//Checkbox select
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="changeaccount[]" value="' . $obj->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
|
||||
$db->free($result);
|
||||
} else {
|
||||
// print $db->error();
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@ -18,23 +18,23 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/bookkeeping/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page to show account
|
||||
* \file htdocs/accountancy/bookkeeping/card.php
|
||||
* \ingroup Accounting Expert
|
||||
* \brief Page to show account
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("accounting");
|
||||
$langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id', 'int');
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
$action = GETPOST('action');
|
||||
$piece_num = GETPOST("piece_num");
|
||||
@ -48,132 +48,132 @@ $debit = price2num(GETPOST('debit'));
|
||||
$credit = price2num(GETPOST('credit'));
|
||||
|
||||
if ($action == "confirm_update") {
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->update();
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->update();
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == "add") {
|
||||
|
||||
$error = 0;
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
$book->doc_date = GETPOST('doc_date');
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = $piece_num;
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = GETPOST('fk_doc');
|
||||
$book->fk_docdet = GETPOST('fk_docdet');
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
$error = 0;
|
||||
|
||||
if ((intval($debit) != 0) && (intval($credit) != 0)) {
|
||||
setEventMessage($langs->trans('ErrorDebitCredit'), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->numero_compte = $numero_compte;
|
||||
$book->code_tiers = $code_tiers;
|
||||
$book->label_compte = $label_compte;
|
||||
$book->debit = $debit;
|
||||
$book->credit = $credit;
|
||||
$book->doc_date = GETPOST('doc_date');
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = $piece_num;
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = GETPOST('fk_doc');
|
||||
$book->fk_docdet = GETPOST('fk_docdet');
|
||||
|
||||
if (! empty($debit)) {
|
||||
$book->montant = $debit;
|
||||
$book->sens = 'D';
|
||||
}
|
||||
if (! empty($credit)) {
|
||||
$book->montant = $credit;
|
||||
$book->sens = 'C';
|
||||
}
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == "confirm_delete") {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
|
||||
$piece_num = $book->piece_num;
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$result = $book->delete($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$result = $book->fetch($id);
|
||||
|
||||
$piece_num = $book->piece_num;
|
||||
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
$result = $book->delete($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = '';
|
||||
}
|
||||
|
||||
else if ($action == "confirm_create") {
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->label_compte = '';
|
||||
$book->debit = 0;
|
||||
$book->credit = 0;
|
||||
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = GETPOST('next_num_mvt');
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = 0;
|
||||
$book->fk_docdet = 0;
|
||||
|
||||
$book->montant = 0;
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
$piece_num = $book->piece_num;
|
||||
}
|
||||
$book = new BookKeeping($db);
|
||||
|
||||
$book->label_compte = '';
|
||||
$book->debit = 0;
|
||||
$book->credit = 0;
|
||||
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
|
||||
$book->doc_type = GETPOST('doc_type');
|
||||
$book->piece_num = GETPOST('next_num_mvt');
|
||||
$book->doc_ref = GETPOST('doc_ref');
|
||||
$book->code_journal = GETPOST('code_journal');
|
||||
$book->fk_doc = 0;
|
||||
$book->fk_docdet = 0;
|
||||
|
||||
$book->montant = 0;
|
||||
|
||||
$result = $book->create_std($user);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('Saved'), 'mesgs');
|
||||
$action = '';
|
||||
$piece_num = $book->piece_num;
|
||||
}
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
@ -181,197 +181,194 @@ llxHeader();
|
||||
$html = new Form($db);
|
||||
|
||||
/*
|
||||
* Confirmation to delete the command
|
||||
* Confirmation to delete the command
|
||||
*/
|
||||
if ($action == 'delete') {
|
||||
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
|
||||
print $formconfirm;
|
||||
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
if ($action == 'create') {
|
||||
|
||||
print_fiche_titre($langs->trans("CreateMvts"));
|
||||
|
||||
$code_journal_array = array (
|
||||
$conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL,
|
||||
$conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL,
|
||||
$conf->global->ACCOUNTING_BANK_JOURNAL => $conf->global->ACCOUNTING_BANK_JOURNAL,
|
||||
$conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL
|
||||
);
|
||||
|
||||
$book = new BookKeeping($db);
|
||||
$next_num_mvt = $book->getNextNumMvt();
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
|
||||
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
|
||||
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
|
||||
print_fiche_titre($langs->trans("CreateMvts"));
|
||||
|
||||
dol_fiche_head();
|
||||
$code_journal_array = array (
|
||||
$conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL,
|
||||
$conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL,
|
||||
$conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL,
|
||||
$conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL,
|
||||
$conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
|
||||
);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $next_num_mvt . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>';
|
||||
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
|
||||
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
$book = new BookKeeping($db);
|
||||
$next_num_mvt = $book->getNextNumMvt();
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
|
||||
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
|
||||
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $next_num_mvt . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>';
|
||||
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
|
||||
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
|
||||
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans("Create") . '">';
|
||||
print ' <input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)" />';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$book = new BookKeeping($db);
|
||||
$result = $book->fetch_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
if (! empty($book->piece_num)) {
|
||||
|
||||
print_fiche_titre($langs->trans("UpdateMvts"));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $book->piece_num . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
print '<td>' . $book->code_journal . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td>' . $book->doc_ref . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td>' . $book->doc_type . '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
$result = $book->fetch_all_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
|
||||
print_fiche_titre($langs->trans("ListeMvts"));
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
if (count($book->linesmvt) > 0) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Numerocompte"));
|
||||
print_liste_field_titre($langs->trans("Code_tiers"));
|
||||
print_liste_field_titre($langs->trans("Labelcompte"));
|
||||
print_liste_field_titre($langs->trans("Debit"));
|
||||
print_liste_field_titre($langs->trans("Credit"));
|
||||
print_liste_field_titre($langs->trans("Amount"));
|
||||
print_liste_field_titre($langs->trans("Sens"));
|
||||
print_liste_field_titre('');
|
||||
print '</form>';
|
||||
} else {
|
||||
$book = new BookKeeping($db);
|
||||
$result = $book->fetch_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
}
|
||||
if (! empty($book->piece_num)) {
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $book->linesmvt as $line ) {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
if ($action == 'update' && $line->id == $id) {
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
|
||||
print '<input type="hidden" name="action" value="confirm_update">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $line->numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $line->code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
print '<td>';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Update") . '">';
|
||||
print '</form>';
|
||||
print '</td>';
|
||||
}
|
||||
else {
|
||||
print '<td>' . $line->numero_compte . '</td>';
|
||||
print '<td>' . $line->code_tiers . '</td>';
|
||||
print '<td>' . $line->label_compte . '</td>';
|
||||
print '<td>' . $line->debit . '</td>';
|
||||
print '<td>' . $line->credit . '</td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
|
||||
print '<td>';
|
||||
print '<a href="./card.php?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_edit();
|
||||
print '</a> ';
|
||||
print '<a href="./card.php?action=delete&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($action == "" || $action == 'add') {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">' . "\n";
|
||||
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_ref" value="' . $book->doc_ref . '">' . "\n";
|
||||
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print_fiche_titre($langs->trans("NoRecords"));
|
||||
}
|
||||
print_fiche_titre($langs->trans("UpdateMvts"));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("NumMvts") . '</td>';
|
||||
print '<td>' . $book->piece_num . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docdate") . '</td>';
|
||||
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Codejournal") . '</td>';
|
||||
print '<td>' . $book->code_journal . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="impair">';
|
||||
print '<td>' . $langs->trans("Docref") . '</td>';
|
||||
print '<td>' . $book->doc_ref . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="pair">';
|
||||
print '<td>' . $langs->trans("Doctype") . '</td>';
|
||||
print '<td>' . $book->doc_type . '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
$result = $book->fetch_all_per_mvt($piece_num);
|
||||
if ($result < 0) {
|
||||
setEventMessage($book->errors, 'errors');
|
||||
} else {
|
||||
|
||||
print_fiche_titre($langs->trans("ListeMvts"));
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
if (count($book->linesmvt) > 0) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
print_liste_field_titre($langs->trans("Numerocompte"));
|
||||
print_liste_field_titre($langs->trans("Code_tiers"));
|
||||
print_liste_field_titre($langs->trans("Labelcompte"));
|
||||
print_liste_field_titre($langs->trans("Debit"));
|
||||
print_liste_field_titre($langs->trans("Credit"));
|
||||
print_liste_field_titre($langs->trans("Amount"));
|
||||
print_liste_field_titre($langs->trans("Sens"));
|
||||
print_liste_field_titre('');
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $book->linesmvt as $line ) {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
if ($action == 'update' && $line->id == $id) {
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
|
||||
print '<input type="hidden" name="action" value="confirm_update">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $line->numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $line->code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
print '<td>';
|
||||
print '<input type="submit" class="button" value="' . $langs->trans("Update") . '">';
|
||||
print '</form>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td>' . $line->numero_compte . '</td>';
|
||||
print '<td>' . $line->code_tiers . '</td>';
|
||||
print '<td>' . $line->label_compte . '</td>';
|
||||
print '<td>' . $line->debit . '</td>';
|
||||
print '<td>' . $line->credit . '</td>';
|
||||
print '<td>' . $line->montant . '</td>';
|
||||
print '<td>' . $line->sens . '</td>';
|
||||
|
||||
print '<td>';
|
||||
print '<a href="./card.php?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_edit();
|
||||
print '</a> ';
|
||||
print '<a href="./card.php?action=delete&id=' . $line->id . '&piece_num=' . $line->piece_num . '">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
if ($action == "" || $action == 'add') {
|
||||
$var = ! $var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">' . "\n";
|
||||
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
|
||||
print '<input type="hidden" name="doc_ref" value="' . $book->doc_ref . '">' . "\n";
|
||||
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
|
||||
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
|
||||
print '<td><input type="text" size="6" name="numero_compte" value="' . $numero_compte . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="code_tiers" value="' . $code_tiers . '"/></td>';
|
||||
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="debit" value="' . price($debit) . '"/></td>';
|
||||
print '<td><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
print '<td><input type="submit" class="button" value="' . $langs->trans("Save") . '"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print_fiche_titre($langs->trans("NoRecords"));
|
||||
}
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("accountancy");
|
||||
|
||||
$page = GETPOST("page");
|
||||
$sortorder = GETPOST("sortorder");
|
||||
@ -155,8 +157,6 @@ else {
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<a href="./card.php?action=create" class="butAction">' . $langs->trans("NewAccountingMvt") . '</a></div>';
|
||||
|
||||
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="export_csv">';
|
||||
@ -209,7 +209,7 @@ else {
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td>' . $obj->doc_type . '</td>';
|
||||
print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
|
||||
print '<td align="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
|
||||
print '<td>' . $obj->doc_ref . '</td>';
|
||||
print '<td>' . length_accountg($obj->numero_compte) . '</td>';
|
||||
print '<td>' . length_accounta($obj->code_tiers) . '</td>';
|
||||
@ -224,6 +224,11 @@ else {
|
||||
$i ++;
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="./card.php?action=create">'.$langs->trans("NewAccountingMvt").'</a>';
|
||||
print '</div>';
|
||||
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
|
||||
@ -1431,7 +1431,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
print '<tr>';
|
||||
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
|
||||
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
|
||||
print ' <a href="../projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
|
||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -2300,7 +2300,7 @@ if ($action == 'create')
|
||||
$langs->load('projects');
|
||||
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
|
||||
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
|
||||
print ' <a href="../projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
|
||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ NewAccount=New accounting account
|
||||
Update=Update
|
||||
List=List
|
||||
Create=Create
|
||||
CreateMvts=Create movement
|
||||
UpdateAccount=Modification of an accounting account
|
||||
UpdateMvts=Modification of a movement
|
||||
WriteBookKeeping=Record accounts in general ledger
|
||||
|
||||
Loading…
Reference in New Issue
Block a user