Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
115f3b712e
12
ChangeLog
12
ChangeLog
@ -31,10 +31,17 @@ Following changes may create regression for some external modules, but were nece
|
||||
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
|
||||
hook specifications so you must return output into "resprint".
|
||||
|
||||
|
||||
***** ChangeLog for 5.0.4 compared to 5.0.3 *****
|
||||
FIX: #6880
|
||||
FIX: #6925
|
||||
FIX: #5640 Prices of a predefined product/service were incorrect under certain circumstances
|
||||
FIX: #6541 since 4.0.4 to 5.0.0 autofill zip/town not working
|
||||
FIX: #6880 #6925
|
||||
FIX: #6885
|
||||
FIX: #6926
|
||||
FIX: #7003
|
||||
FIX: #7012
|
||||
FIX: #7040
|
||||
FIX: #7048 #6075
|
||||
FIX: Can set supplier invoice to billed.
|
||||
FIX: Can't create invoice if PO disapproved
|
||||
FIX: contratligne update
|
||||
@ -46,6 +53,7 @@ FIX: Redirect to payment page from member subscription page failed if a unique s
|
||||
FIX: REST api to get project when user has permission to read all.
|
||||
FIX: situation_progress param default value must be 100 and not 0
|
||||
FIX: SQL injection on user/index.php parameter search_statut.
|
||||
FIX: vat code not saved during product creation.
|
||||
FIX: Warnings
|
||||
|
||||
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// during install process to be used.
|
||||
//
|
||||
//
|
||||
$force_install_noedit=2;
|
||||
$force_install_noedit=2; // 1=To block vars specific to distrib, 2 to block all technical parameters
|
||||
$force_install_message='KeepDefaultValuesWamp';
|
||||
$force_install_main_data_root='WAMPROOT/dolibarr_documents';
|
||||
$force_install_type='mysqli';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$force_install_packager='rpmfedora';
|
||||
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_message='KeepDefaultValuesDeb';
|
||||
$force_install_main_data_root='/var/lib/dolibarr/documents';
|
||||
$force_install_type='mysqli';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$force_install_packager='rpmgeneric';
|
||||
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_message='KeepDefaultValuesDeb';
|
||||
$force_install_main_data_root='/var/lib/dolibarr/documents';
|
||||
$force_install_type='mysqli';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$force_install_packager='rpmmandriva';
|
||||
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_message='KeepDefaultValuesDeb';
|
||||
$force_install_main_data_root='/var/lib/dolibarr/documents';
|
||||
$force_install_type='mysqli';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$force_install_packager='rpmopensuse';
|
||||
$force_install_noedit=1; # 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_noedit=1; // 1 to block var specific to distrib, 2 to block every technical parameters
|
||||
$force_install_message='KeepDefaultValuesDeb';
|
||||
$force_install_main_data_root='/var/lib/dolibarr/documents';
|
||||
$force_install_type='mysqli';
|
||||
|
||||
@ -68,7 +68,7 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -1148,7 +1148,6 @@ else
|
||||
* Show list of dictionary to show
|
||||
*/
|
||||
|
||||
$var=true;
|
||||
$lastlineisempty=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
@ -74,7 +74,7 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.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>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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
|
||||
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/accountancy/admin/index.php
|
||||
* \file htdocs/accountancy/admin/defaultaccounts.php
|
||||
* \ingroup Advanced accountancy
|
||||
* \brief Setup page to configure accounting expert module
|
||||
*/
|
||||
@ -53,10 +53,10 @@ $action = GETPOST('action', 'alpha');
|
||||
$list_account_main = array (
|
||||
'ACCOUNTING_ACCOUNT_CUSTOMER',
|
||||
'ACCOUNTING_ACCOUNT_SUPPLIER',
|
||||
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
|
||||
);
|
||||
|
||||
$list_account = array (
|
||||
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
|
||||
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
|
||||
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
|
||||
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
|
||||
|
||||
@ -58,7 +58,7 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -500,8 +500,7 @@ if ($action == 'create') {
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ( $book->linesmvt as $line ) {
|
||||
$var = ! $var;
|
||||
print '<tr' . $bc[$var] . '>';
|
||||
print '<tr class="oddeven">';
|
||||
$total_debit += $line->debit;
|
||||
$total_credit += $line->credit;
|
||||
|
||||
|
||||
@ -438,7 +438,6 @@ $total_debit = 0;
|
||||
$total_credit = 0;
|
||||
|
||||
foreach ($object->lines as $line ) {
|
||||
$var = ! $var;
|
||||
|
||||
$total_debit += $line->debit;
|
||||
$total_credit += $line->credit;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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
|
||||
@ -40,7 +40,7 @@ $langs->load("accountancy");
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->societe_id > 0)
|
||||
accessforbidden();
|
||||
@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
} else {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
@ -203,10 +203,6 @@ $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' .
|
||||
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
||||
|
||||
|
||||
|
||||
|
||||
$var = true;
|
||||
|
||||
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -269,14 +265,14 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
||||
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
|
||||
$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
@ -296,22 +292,22 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
while ( $row = $db->fetch_row($resql)) {
|
||||
|
||||
print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($resql);
|
||||
print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right">' . price($row[13]) . '</td>';
|
||||
print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
@ -319,101 +315,101 @@ print "</table>\n";
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
|
||||
{
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
print_fiche_titre($langs->trans("OtherInfo"), '', '');
|
||||
print_fiche_titre($langs->trans("OtherInfo"), '', '');
|
||||
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
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 {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM(fd.total_ht) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
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 {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
|
||||
dol_syslog('htdocs/accountancy/customer/index.php');
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
dol_syslog('htdocs/accountancy/customer/index.php');
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
print "<br>\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
||||
}
|
||||
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
||||
|
||||
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
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 {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
||||
}
|
||||
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
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 {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||
}
|
||||
|
||||
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price(price2num($row[$i])) . '</td>';
|
||||
}
|
||||
print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
print '<tr><td>' . $row[0] . '</td>';
|
||||
for($i = 1; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price(price2num($row[$i])) . '</td>';
|
||||
}
|
||||
print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror(); // Show last sql error
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -178,9 +178,6 @@ $buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?ye
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
$var = true;
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
||||
|
||||
@ -52,7 +52,7 @@ $result=restrictedArea($user,'adherent',$id);
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -46,7 +46,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -73,7 +73,7 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -67,7 +67,7 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -225,20 +225,6 @@ asort($orders);
|
||||
//var_dump($modules);
|
||||
|
||||
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc';
|
||||
$head[$h][1] = $langs->trans("Description");
|
||||
$head[$h][2] = 'desc';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature';
|
||||
$head[$h][1] = $langs->trans("TechnicalServicesProvided");
|
||||
$head[$h][2] = 'feature';
|
||||
$h++;
|
||||
|
||||
|
||||
$i=0;
|
||||
foreach($orders as $tmpkey => $tmpvalue)
|
||||
{
|
||||
@ -257,6 +243,28 @@ $special = $objMod->special;
|
||||
$tab=explode('_',$value);
|
||||
$familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
|
||||
|
||||
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc';
|
||||
$head[$h][1] = $langs->trans("Description");
|
||||
$head[$h][2] = 'desc';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature';
|
||||
$head[$h][1] = $langs->trans("TechnicalServicesProvided");
|
||||
$head[$h][2] = 'feature';
|
||||
$h++;
|
||||
|
||||
if ($objMod->isCoreOrExternalModule() == 'external')
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=changelog';
|
||||
$head[$h][1] = $langs->trans("ChangeLog");
|
||||
$head[$h][2] = 'changelog';
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Check filters
|
||||
$modulename=$objMod->getName();
|
||||
$moduledesc=$objMod->getDesc();
|
||||
@ -536,6 +544,13 @@ if ($mode == 'feature')
|
||||
}
|
||||
|
||||
|
||||
if ($mode == 'changelog')
|
||||
{
|
||||
$changelog=$objMod->getChangeLog();
|
||||
if ($changelog) $text.='<div class="moduledesclong">'.$changelog.'<div>';
|
||||
else $text.='<div class="moduledesclong">'.$langs->trans("NotAvailable").'</div>';
|
||||
}
|
||||
|
||||
print $text;
|
||||
|
||||
|
||||
|
||||
@ -207,8 +207,19 @@ if ($action == 'set' && $user->admin)
|
||||
//var_dump($resarray);exit;
|
||||
if ($resarray['nbperms'] > 0)
|
||||
{
|
||||
$msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
|
||||
setEventMessages($msg, null, 'warnings');
|
||||
$tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
|
||||
$resqltmp=$db->query($tmpsql);
|
||||
if ($resqltmp)
|
||||
{
|
||||
$obj=$db->fetch_object($resqltmp);
|
||||
//var_dump($obj->nb);exit;
|
||||
if ($obj && $obj->nb > 1)
|
||||
{
|
||||
$msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
|
||||
setEventMessages($msg, null, 'warnings');
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
}
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
|
||||
|
||||
@ -47,7 +47,7 @@ $langs->load("other");
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -54,7 +54,7 @@ $status = 1;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $listlimit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -1,41 +1,54 @@
|
||||
API REST howto
|
||||
==============
|
||||
API REST
|
||||
========
|
||||
|
||||
This directory contains files to make Dolibarr a server of REST Web Services.
|
||||
It depends on external library Restler.
|
||||
## Integrate your ERP with any other applications using Dolibarr APIs
|
||||
|
||||
This module provides the service to make Dolibarr a server of REST Web Services. It depends on external library Restler.
|
||||
|
||||
Extract any data or push insert, update or delete record using our new REST APIs. Using standard HTTP and Json format, it is compatible with any language (PHP, Java, Ruby, Python, C#, C++, JavaScript, JQuery, Basic, ...). Use the embedded APIs explorer tool to test APIs or get generated URLs to use in your own code.
|
||||
|
||||
|
||||
Explore the api
|
||||
---------------
|
||||
<div align="center">
|
||||
<img class="imgdoc" src="https://www.dolibarr.org//images/doc_apirest.png" alt="Dolibarr API explorer"/>
|
||||
</div>
|
||||
|
||||
You can explore API method by using web interface : https://**yourdolibarr.tld**/mydolibarr/api/admin/explorer.php (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation)
|
||||
|
||||
Access to the API
|
||||
|
||||
Explore the APIs
|
||||
----------------
|
||||
|
||||
You can explore all available APIs by using the API explorer : [**yourdolibarr.tld**/api/index.php/explorer](../api/index.php/explorer) (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation)
|
||||
|
||||
|
||||
Access to an API
|
||||
-----------------
|
||||
|
||||
> **Warning : access to the API should (or better : must!) be secured with SSL connection**
|
||||
> **Warning : access to any API should (or better : must!) be secured with SSL connection**
|
||||
|
||||
To access to the API you need a token to identify. When you access the API for the first time, you need to log in with user name and password to get a token. **Only** this token will allow to access API with.
|
||||
To access to the API you need a token to identify. **Only** this token will allow to access API with.
|
||||
The token is dedicated to a user and it **must** be put into requests as **DOLAPIKEY** parameter in HTTP header (or among URL parameters, but this is less secured).
|
||||
|
||||
To log in with the API, use this uri : https://**yourdolibarr.tld**/mydolibarr/api/index.php/login?login=**username**&password=**password** (replace bold strings with real values)
|
||||
To get a token you can:
|
||||
|
||||
The token will be saved by Dolibarr for next user accesses to the API and it **must** be put into request uri as **api_key** parameter.
|
||||
* Edit the user card to set the value of token. Each user can have a different token.
|
||||
* or Call the *login* API with login and password. This will return the value of token for the user used to login.
|
||||
|
||||
Then call other services with
|
||||
|
||||
https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?api_key=**api_key**
|
||||
https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?DOLAPIKEY=**api_key**
|
||||
|
||||
|
||||
Develop the API
|
||||
---------------
|
||||
Develop an API
|
||||
--------------
|
||||
|
||||
The API uses Lucarast Restler framework. Please check documentation https://www.luracast.com/products/restler and examples http://help.luracast.com/restler/examples/
|
||||
|
||||
Github contains also usefull informations : https://github.com/Luracast/Restler
|
||||
|
||||
To implement it into Dolibarr, we need to create a specific class for object we want to use. A skeleton file is available into /dev directory : *skeleton_api_class.class.php*
|
||||
To implement it into Dolibarr, you need to create a specific class for object we want to use. A skeleton file is available into /modulebuilder/class directory : *api_mymodule_class.class.php*
|
||||
The API class file must be put into object class directory, with specific file name. By example, API class file for '*myobject*' must be put as : /htdocs/*myobject*/class/api_*myobject*.class.php. Class must be named **MyobjectApi**.
|
||||
|
||||
If a module provide several object, use a different name for '*myobject*' and put the file into the same directory.
|
||||
If a module provide several object, use a different name for *'myobject'* and put the file into the same directory.
|
||||
|
||||
**Define url for methods**
|
||||
|
||||
|
||||
@ -42,10 +42,11 @@ class DolibarrApi
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDb $db Database handler
|
||||
* @param string $cachedir Cache dir
|
||||
* @param DoliDb $db Database handler
|
||||
* @param string $cachedir Cache dir
|
||||
* @param boolean $refreshCache Update cache
|
||||
*/
|
||||
function __construct($db, $cachedir='')
|
||||
function __construct($db, $cachedir='', $refreshCache=false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -54,7 +55,7 @@ class DolibarrApi
|
||||
|
||||
$this->db = $db;
|
||||
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
|
||||
$this->r = new Restler($production_mode);
|
||||
$this->r = new Restler($production_mode, $refreshCache);
|
||||
|
||||
$this->r->setAPIVersion(1);
|
||||
}
|
||||
@ -66,7 +67,7 @@ class DolibarrApi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
/* Disabled, most APIs does not share same signature for method index
|
||||
/* Disabled, most APIs does not share same signature for method index
|
||||
function index()
|
||||
{
|
||||
return array(
|
||||
@ -93,9 +94,9 @@ class DolibarrApi
|
||||
unset($object->linkedObjects);
|
||||
|
||||
unset($object->lines); // should be ->lines
|
||||
|
||||
|
||||
unset($object->fields);
|
||||
|
||||
|
||||
unset($object->oldline);
|
||||
|
||||
unset($object->error);
|
||||
@ -175,7 +176,7 @@ class DolibarrApi
|
||||
* @throws RestException
|
||||
*/
|
||||
static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') {
|
||||
|
||||
|
||||
// Features/modules to check
|
||||
$featuresarray = array($resource);
|
||||
if (preg_match('/&/', $resource)) {
|
||||
|
||||
@ -80,25 +80,25 @@ class DolibarrApiAccess implements iAuthenticate
|
||||
{
|
||||
dol_syslog($key.' - '.$val);
|
||||
}*/
|
||||
|
||||
|
||||
// api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx
|
||||
$api_key = '';
|
||||
if (isset($_GET['api_key']))
|
||||
if (isset($_GET['api_key']))
|
||||
{
|
||||
// TODO Add option to disable use of api key on url. Return errors if used.
|
||||
$api_key = $_GET['api_key']; // For backward compatibility
|
||||
}
|
||||
if (isset($_GET['DOLAPIKEY']))
|
||||
if (isset($_GET['DOLAPIKEY']))
|
||||
{
|
||||
// TODO Add option to disable use of api key on url. Return errors if used.
|
||||
$api_key = $_GET['DOLAPIKEY']; // With GET method
|
||||
}
|
||||
if (isset($_SERVER['HTTP_DOLAPIKEY']))
|
||||
if (isset($_SERVER['HTTP_DOLAPIKEY'])) // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY
|
||||
{
|
||||
$api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded)
|
||||
}
|
||||
|
||||
if ($api_key)
|
||||
|
||||
if ($api_key)
|
||||
{
|
||||
$sql = "SELECT u.login, u.datec, u.api_key, ";
|
||||
$sql.= " u.tms as date_modification, u.entity";
|
||||
|
||||
@ -34,25 +34,25 @@ class Login
|
||||
/**
|
||||
* Login
|
||||
*
|
||||
* Request the API token for a couple username / password.
|
||||
* Request the API token for a couple username / password.
|
||||
* Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file).
|
||||
* Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "api_key" into field at the top right of page (Note: "api_key" can be found/set on the user page).
|
||||
*
|
||||
* Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "api_key" into field at the top right of page (Note: "api_key" can be found/set on the user page).
|
||||
*
|
||||
* @param string $login User login
|
||||
* @param string $password User password
|
||||
* @param int $entity Entity (when multicompany module is used). Empty means 1=first company.
|
||||
* @param string $entity Entity (when multicompany module is used). '' means 1=first company.
|
||||
* @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
|
||||
* @return array Response status and user token
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
*
|
||||
* @url GET /
|
||||
* @url POST /
|
||||
*/
|
||||
public function index($login, $password, $entity=0, $reset=0) {
|
||||
public function index($login, $password, $entity='', $reset=0) {
|
||||
|
||||
global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
|
||||
|
||||
|
||||
// Authentication mode
|
||||
if (empty($dolibarr_main_authentication))
|
||||
$dolibarr_main_authentication = 'http,dolibarr';
|
||||
@ -62,6 +62,8 @@ class Login
|
||||
// Set authmode
|
||||
$authmode = explode(',', $dolibarr_main_authentication);
|
||||
|
||||
if ($entity == '') $entity=1;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
|
||||
$login = checkLoginPassEntity($login, $password, $entity, $authmode);
|
||||
if (empty($login))
|
||||
@ -70,21 +72,21 @@ class Login
|
||||
}
|
||||
|
||||
$token = 'failedtogenerateorgettoken';
|
||||
|
||||
|
||||
$tmpuser=new User($this->db);
|
||||
$tmpuser->fetch(0, $login);
|
||||
|
||||
$tmpuser->fetch(0, $login, 0, 0, $entity);
|
||||
|
||||
// Renew the hash
|
||||
if (empty($tmpuser->api_key) || $reset)
|
||||
{
|
||||
// Generate token for user
|
||||
$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
|
||||
|
||||
|
||||
// We store API token into database
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql.= " SET api_key = '".$this->db->escape($token)."'";
|
||||
$sql.= " WHERE login = '".$this->db->escape($login)."'";
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result)
|
||||
@ -96,13 +98,14 @@ class Login
|
||||
{
|
||||
$token = $tmpuser->api_key;
|
||||
}
|
||||
|
||||
|
||||
//return token
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'token' => $token,
|
||||
'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
|
||||
'entity' => $tmpuser->entity,
|
||||
'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -21,13 +21,21 @@
|
||||
* \defgroup api Module DolibarrApi
|
||||
* \brief API loader
|
||||
* Search files htdocs/<module>/class/api_<module>.class.php
|
||||
* \file htdocs/api/indexphp
|
||||
*
|
||||
* @todo User authentication with api_key
|
||||
* \file htdocs/api/index.php
|
||||
*/
|
||||
|
||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1');
|
||||
if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1');
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
|
||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||
|
||||
|
||||
$res=0;
|
||||
if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php';
|
||||
@ -67,7 +75,31 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($
|
||||
}
|
||||
|
||||
|
||||
$api = new DolibarrApi($db);
|
||||
|
||||
|
||||
// Analyze URLs
|
||||
// index.php/explorer do a redirect to index.php/explorer/
|
||||
// index.php/explorer/ called by swagger to build explorer page
|
||||
// index.php/explorer/.../....png|.css|.js called by swagger for resources to build explorer page
|
||||
// index.php/explorer/resources.json called by swagger to get list of all services
|
||||
// index.php/explorer/resources.json/xxx called by swagger to get detail of services xxx
|
||||
// index.php/xxx called by any REST client to run API
|
||||
|
||||
|
||||
preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg);
|
||||
// .../index.php/categories?sortfield=t.rowid&sortorder=ASC
|
||||
|
||||
|
||||
// Set the flag to say to refresh (when we reload the explorer, production must be for API call only)
|
||||
$refreshcache=false;
|
||||
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
|
||||
{
|
||||
$refreshcache=true;
|
||||
}
|
||||
|
||||
|
||||
$api = new DolibarrApi($db, '', $refreshcache);
|
||||
//var_dump($api->r->apiVersionMap);
|
||||
|
||||
// Enable the Restler API Explorer.
|
||||
// See https://github.com/Luracast/Restler-API-Explorer for more info.
|
||||
@ -79,110 +111,82 @@ $api->r->addAuthenticationClass('DolibarrApiAccess','');
|
||||
// Define accepted mime types
|
||||
UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream');
|
||||
|
||||
$listofapis = array();
|
||||
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
foreach ($modulesdir as $dir)
|
||||
|
||||
// Call Explorer file for all APIs definitions
|
||||
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
|
||||
{
|
||||
/*
|
||||
* Search available module
|
||||
*/
|
||||
//dol_syslog("Scan directory ".$dir." for API modules");
|
||||
// Scan all API files to load them
|
||||
|
||||
$handle=@opendir(dol_osencode($dir));
|
||||
if (is_resource($handle))
|
||||
$listofapis = array();
|
||||
|
||||
$modulesdir = dolGetModulesDirs();
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
// Search available module
|
||||
dol_syslog("Scan directory ".$dir." for module descriptor to after search for API files");
|
||||
|
||||
$handle=@opendir(dol_osencode($dir));
|
||||
if (is_resource($handle))
|
||||
{
|
||||
if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$reg))
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
$module = strtolower($reg[1]);
|
||||
$moduledirforclass = $module;
|
||||
$moduleforperm = $module;
|
||||
|
||||
if ($module == 'propale') {
|
||||
$moduledirforclass = 'comm/propal';
|
||||
$moduleforperm='propal';
|
||||
}
|
||||
elseif ($module == 'agenda') {
|
||||
$moduledirforclass = 'comm/action';
|
||||
}
|
||||
elseif ($module == 'adherent') {
|
||||
$moduledirforclass = 'adherents';
|
||||
}
|
||||
elseif ($module == 'banque') {
|
||||
$moduledirforclass = 'compta/bank';
|
||||
}
|
||||
elseif ($module == 'categorie') {
|
||||
$moduledirforclass = 'categories';
|
||||
}
|
||||
elseif ($module == 'facture') {
|
||||
$moduledirforclass = 'compta/facture';
|
||||
}
|
||||
elseif ($module == 'project') {
|
||||
$moduledirforclass = 'projet';
|
||||
}
|
||||
elseif ($module == 'task') {
|
||||
$moduledirforclass = 'projet';
|
||||
}
|
||||
elseif ($module == 'stock') {
|
||||
$moduledirforclass = 'product/stock';
|
||||
}
|
||||
elseif ($module == 'fournisseur') {
|
||||
$moduledirforclass = 'fourn';
|
||||
}
|
||||
//dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass);
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
if (empty($conf->$moduleforperm->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$reg))
|
||||
{
|
||||
/*
|
||||
* If exists, load the API class for enable module
|
||||
*
|
||||
* Search files named api_<object>.class.php into /htdocs/<module>/class directory
|
||||
*
|
||||
* @todo : use getElementProperties() function ?
|
||||
*/
|
||||
$dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
|
||||
$module = strtolower($reg[1]);
|
||||
$moduledirforclass = getModuleDirForApiClass($module);
|
||||
$moduleforperm = $module;
|
||||
if ($module == 'propale') { $moduleforperm='propal'; }
|
||||
|
||||
$handle_part=@opendir(dol_osencode($dir_part));
|
||||
if (is_resource($handle_part))
|
||||
//dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass);
|
||||
|
||||
// Defined if module is enabled
|
||||
$enabled=true;
|
||||
if (empty($conf->$moduleforperm->enabled)) $enabled=false;
|
||||
|
||||
if ($enabled)
|
||||
{
|
||||
while (($file_searched = readdir($handle_part))!==false)
|
||||
{
|
||||
if ($file_searched == 'api_access.class.php') continue;
|
||||
// If exists, load the API class for enable module
|
||||
// Search files named api_<object>.class.php into /htdocs/<module>/class directory
|
||||
// @todo : use getElementProperties() function ?
|
||||
$dir_part = dol_buildpath('/'.$moduledirforclass.'/class/');
|
||||
|
||||
// Support of the deprecated API.
|
||||
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg))
|
||||
$handle_part=@opendir(dol_osencode($dir_part));
|
||||
if (is_resource($handle_part))
|
||||
{
|
||||
while (($file_searched = readdir($handle_part))!==false)
|
||||
{
|
||||
$classname = ucwords($reg[1]).'Api';
|
||||
require_once $dir_part.$file_searched;
|
||||
if (class_exists($classname))
|
||||
if ($file_searched == 'api_access.class.php') continue;
|
||||
|
||||
// Support of the deprecated API.
|
||||
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg))
|
||||
{
|
||||
//dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
|
||||
$api->r->addAPIClass($classname, '/');
|
||||
$classname = ucwords($reg[1]).'Api';
|
||||
require_once $dir_part.$file_searched;
|
||||
if (class_exists($classname))
|
||||
{
|
||||
//dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
|
||||
$api->r->addAPIClass($classname, '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg))
|
||||
{
|
||||
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
|
||||
}
|
||||
}
|
||||
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg))
|
||||
{
|
||||
$classname = ucwords($reg[1]);
|
||||
$classname = str_replace('_', '', $classname);
|
||||
require_once $dir_part.$file_searched;
|
||||
if (class_exists($classname))
|
||||
{
|
||||
//dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
|
||||
$listofapis[] = $classname;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
|
||||
$classname = ucwords($reg[1]);
|
||||
$classname = str_replace('_', '', $classname);
|
||||
require_once $dir_part.$file_searched;
|
||||
if (class_exists($classname))
|
||||
{
|
||||
//dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched);
|
||||
$listofapis[] = $classname;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,20 +195,60 @@ foreach ($modulesdir as $dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the classes before adding them to Restler.
|
||||
// The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted.
|
||||
sort($listofapis);
|
||||
foreach ($listofapis as $classname)
|
||||
{
|
||||
$api->r->addAPIClass($classname);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the classes before adding them to Restler. The Restler API Explorer
|
||||
// shows the classes in the order they are added and it's a mess if they are
|
||||
// not sorted.
|
||||
sort($listofapis);
|
||||
//var_dump($listofapis);
|
||||
foreach ($listofapis as $classname)
|
||||
// Call one APIs or one definition of an API
|
||||
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis))))
|
||||
{
|
||||
$api->r->addAPIClass($classname);
|
||||
$module = $reg[1];
|
||||
if ($module == 'explorer') // If we call page to explore details of a service
|
||||
{
|
||||
$module = $regbis[1];
|
||||
}
|
||||
|
||||
// Load a dedicated API file
|
||||
dol_syslog("Load a dedicated API file");
|
||||
|
||||
$module=strtolower($module);
|
||||
$moduledirforclass = getModuleDirForApiClass($module);
|
||||
|
||||
if (in_array($module, array('category','contact','customer','invoice','order','product','thirdparty','user'))) // Old Apis
|
||||
{
|
||||
$classfile = $module;
|
||||
if ($module == 'customer') { $classfile = 'thirdparty'; }
|
||||
if ($module == 'order') { $classfile = 'commande'; }
|
||||
$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_deprecated_'.$classfile.'.class.php');
|
||||
$classname=ucwords($module);
|
||||
if ($module == 'customer') { $classname='Thirdparty'; }
|
||||
if ($module == 'order') { $classname='Commande'; }
|
||||
//var_dump($classfile);var_dump($classname);exit;
|
||||
|
||||
require_once $dir_part_file;
|
||||
if (class_exists($classname.'Api')) $api->r->addAPIClass($classname.'Api', '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
$classfile = str_replace('_', '', $module);
|
||||
if ($module == 'supplierinvoices') $classfile = 'supplier_invoices';
|
||||
$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php');
|
||||
$classname=ucwords($module);
|
||||
|
||||
require_once $dir_part_file;
|
||||
if (class_exists($classname)) $api->r->addAPIClass($classname);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO If not found, redirect to explorer
|
||||
//var_dump($api);
|
||||
//var_dump($api->r->apiVersionMap);
|
||||
//exit;
|
||||
|
||||
// Call API (we suppose we found it)
|
||||
$api->r->handle();
|
||||
|
||||
@ -80,7 +80,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $limit * $page ;
|
||||
if (! $sortorder)
|
||||
{
|
||||
|
||||
@ -42,7 +42,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $limit * $page ;
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="a.datep";
|
||||
|
||||
@ -108,7 +108,7 @@ $offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortorder) $sortorder='ASC';
|
||||
if (! $sortfield) $sortfield='b.datev';
|
||||
if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid';
|
||||
|
||||
$mode_balance_ok=false;
|
||||
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
|
||||
@ -436,6 +436,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
@ -636,6 +637,7 @@ if ($resql)
|
||||
// print '</td></tr></table>';
|
||||
}
|
||||
|
||||
|
||||
/// ajax to adjust value date with plus and less picto
|
||||
print '
|
||||
<script type="text/javascript">
|
||||
@ -717,6 +719,7 @@ if ($resql)
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
if (! empty($arrayfields['b.rowid']['checked']))
|
||||
{
|
||||
@ -855,7 +858,7 @@ if ($resql)
|
||||
exit;
|
||||
}
|
||||
|
||||
//Loop on each record
|
||||
// Loop on each record before
|
||||
$sign = 1;
|
||||
$i = 0;
|
||||
$sqlforbalance='SELECT SUM(b.amount) as balance';
|
||||
@ -865,7 +868,7 @@ if ($resql)
|
||||
$sqlforbalance.= " WHERE b.fk_account = ba.rowid";
|
||||
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sqlforbalance.= " AND b.fk_account = ".$account;
|
||||
$sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'";
|
||||
$sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))";
|
||||
$resqlforbalance = $db->query($sqlforbalance);
|
||||
//print $sqlforbalance;
|
||||
if ($resqlforbalance)
|
||||
|
||||
@ -2729,9 +2729,9 @@ if ($action == 'create')
|
||||
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
|
||||
print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ if ($id)
|
||||
|
||||
|
||||
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
|
||||
@ -162,21 +162,13 @@ if ($type == 'directory')
|
||||
// Auto area for suppliers invoices
|
||||
else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
|
||||
// Auto area for suppliers invoices
|
||||
else if ($module == 'invoice_supplier')
|
||||
{
|
||||
$relativepath='facture';
|
||||
$upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath;
|
||||
}
|
||||
else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
|
||||
// Auto area for customers orders
|
||||
else if ($module == 'propal') $upload_dir = $conf->propal->dir_output;
|
||||
// Auto area for customers orders
|
||||
else if ($module == 'order') $upload_dir = $conf->commande->dir_output;
|
||||
// Auto area for suppliers orders
|
||||
else if ($module == 'order_supplier')
|
||||
{
|
||||
$relativepath='commande';
|
||||
$upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath;
|
||||
}
|
||||
else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
|
||||
// Auto area for suppliers invoices
|
||||
else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
|
||||
// Auto area for products
|
||||
@ -198,6 +190,8 @@ if ($type == 'directory')
|
||||
$param.='&module='.$module;
|
||||
$textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
|
||||
|
||||
if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
|
||||
|
||||
$filearray=dol_dir_list($upload_dir,"files",1,'', $excludefiles, $sortfield, $sorting,1);
|
||||
$formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname,$url);
|
||||
}
|
||||
|
||||
@ -1486,7 +1486,7 @@ abstract class CommonObject
|
||||
$fieldname = 'multicurrency_code';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"';
|
||||
$sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'";
|
||||
$sql .= ' WHERE rowid='.$this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
|
||||
@ -488,8 +488,8 @@ class Conf
|
||||
// By default, we propagate contacts
|
||||
if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
|
||||
|
||||
// By default, we use the zip town autofill
|
||||
if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1;
|
||||
// By default, we do not use the zip town table but the table of third parties
|
||||
if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0;
|
||||
|
||||
// By default, we open card if one found
|
||||
if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1;
|
||||
|
||||
@ -4473,7 +4473,7 @@ class Form
|
||||
* Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
|
||||
* Sinon la TVA proposee par defaut=0. Fin de regle.
|
||||
* @param bool $options_only Return HTML options lines only (for ajax treatment)
|
||||
* @param int $mode 1=Add code into key in select list
|
||||
* @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key
|
||||
* @return string
|
||||
*/
|
||||
function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $mode=0)
|
||||
|
||||
@ -1002,6 +1002,7 @@ class FormFile
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="modulepart" value="'.$modulepart.'">';
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table width="100%" id="tablelines" class="'.($useinecm?'liste noborder':'liste').'">'."\n";
|
||||
|
||||
@ -1106,8 +1107,6 @@ class FormFile
|
||||
&& $file['name'] != '..'
|
||||
&& ! preg_match('/\.meta$/i',$file['name']))
|
||||
{
|
||||
|
||||
|
||||
if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid'];
|
||||
|
||||
$editline=0;
|
||||
|
||||
@ -528,7 +528,12 @@ class FormMail extends Form
|
||||
{
|
||||
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$out.= $form->multiselectarray("receiver", $tmparray, GETPOST("receiver"), null, null, 'inline-block minwidth500', null, "");
|
||||
$withtoselected=GETPOST("receiver"); // Array of selected value
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action') == 'presend')
|
||||
{
|
||||
$withtoselected = array_keys($tmparray);
|
||||
}
|
||||
$out.= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
|
||||
}
|
||||
}
|
||||
$out.= "</td></tr>\n";
|
||||
@ -556,7 +561,8 @@ class FormMail extends Form
|
||||
{
|
||||
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$out.= $form->multiselectarray("receivercc", $tmparray, GETPOST("receivercc"), null, null, 'inline-block minwidth500',null, "");
|
||||
$withtoccselected=GETPOST("receivercc"); // Array of selected value
|
||||
$out.= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500',null, "");
|
||||
}
|
||||
}
|
||||
$out.= "</td></tr>\n";
|
||||
@ -584,8 +590,8 @@ class FormMail extends Form
|
||||
{
|
||||
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
//$out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1);
|
||||
$out.= $form->multiselectarray("receiverccc", $tmparray, GETPOST("receiverccc"), null, null, null,null, "90%");
|
||||
$withtocccselected=GETPOST("receiverccc"); // Array of selected value
|
||||
$out.= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null,null, "90%");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4159,7 +4159,7 @@ function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
|
||||
* @param Societe $buyer Company object
|
||||
* @param Societe $seller Company object
|
||||
* @param int $firstparamisid 1 if first param is id into table (use this if you can)
|
||||
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
|
||||
* @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type1, rate localtax2, accountancycodecust, accountancycodesupp)
|
||||
* @see getTaxesFromId
|
||||
*/
|
||||
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
|
||||
@ -4197,22 +4197,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
{
|
||||
if (! isOnlyOneLocalTax(1))
|
||||
{
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
}
|
||||
elseif ($local == 2)
|
||||
{
|
||||
if (! isOnlyOneLocalTax(2))
|
||||
{
|
||||
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4221,22 +4221,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
{
|
||||
if(! isOnlyOneLocalTax(2))
|
||||
{
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(! isOnlyOneLocalTax(2))
|
||||
{
|
||||
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type,get_localtax($vatrate, 2, $buyer, $seller) ,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy);
|
||||
return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2121,8 +2121,8 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
|
||||
* Applies the Cartesian product algorithm to an array
|
||||
* Source: http://stackoverflow.com/a/15973172
|
||||
*
|
||||
* @param array $input Array of products
|
||||
* @return array Array of combinations
|
||||
* @param array $input Array of products
|
||||
* @return array Array of combinations
|
||||
*/
|
||||
function cartesianArray(array $input) {
|
||||
// filter out empty values
|
||||
@ -2145,3 +2145,70 @@ function cartesianArray(array $input) {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get name of directory where the api_...class.php file is stored
|
||||
*
|
||||
* @param string $module Module name
|
||||
* @return string Directory name
|
||||
*/
|
||||
function getModuleDirForApiClass($module)
|
||||
{
|
||||
$moduledirforclass=$module;
|
||||
|
||||
if (in_array($module, array('login', 'access', 'status', 'documents'))) {
|
||||
$moduledirforclass = 'api';
|
||||
}
|
||||
if (preg_match('/^dictionary/', $module)) {
|
||||
$moduledirforclass = 'api';
|
||||
}
|
||||
|
||||
if ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
|
||||
$moduledirforclass = 'societe';
|
||||
}
|
||||
if ($module == 'propale' || $module == 'proposals') {
|
||||
$moduledirforclass = 'comm/propal';
|
||||
}
|
||||
elseif ($module == 'agenda' || $module == 'agendaevents') {
|
||||
$moduledirforclass = 'comm/action';
|
||||
}
|
||||
elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
|
||||
$moduledirforclass = 'adherents';
|
||||
}
|
||||
elseif ($module == 'banque' || $module == 'bankaccounts') {
|
||||
$moduledirforclass = 'compta/bank';
|
||||
}
|
||||
elseif ($module == 'category' || $module == 'categorie') {
|
||||
$moduledirforclass = 'categories';
|
||||
}
|
||||
elseif ($module == 'order' || $module == 'orders') {
|
||||
$moduledirforclass = 'commande';
|
||||
}
|
||||
elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
|
||||
$moduledirforclass = 'compta/facture';
|
||||
}
|
||||
elseif ($module == 'products') {
|
||||
$moduledirforclass = 'product';
|
||||
}
|
||||
elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
|
||||
$moduledirforclass = 'projet';
|
||||
}
|
||||
elseif ($module == 'task') {
|
||||
$moduledirforclass = 'projet';
|
||||
}
|
||||
elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
|
||||
$moduledirforclass = 'product/stock';
|
||||
}
|
||||
elseif ($module == 'fournisseur' || $module == 'supplierinvoices') {
|
||||
$moduledirforclass = 'fourn';
|
||||
}
|
||||
elseif ($module == 'expensereports') {
|
||||
$moduledirforclass = 'expensereport';
|
||||
}
|
||||
elseif ($module == 'users') {
|
||||
$moduledirforclass = 'user';
|
||||
}
|
||||
|
||||
return $moduledirforclass;
|
||||
}
|
||||
|
||||
@ -212,6 +212,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
|
||||
-- Setup
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
|
||||
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
|
||||
@ -221,6 +222,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 80, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 90, __ENTITY__);
|
||||
-- Accounting period
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__);
|
||||
-- Binding
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
|
||||
@ -246,8 +249,6 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2447__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 24, __ENTITY__);
|
||||
-- Accounting period
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2400__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=setup', 'FiscalPeriod', 1, 'admin', '', '', 2, 4, __ENTITY__);
|
||||
-- Rapports compta simple
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__);
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__);
|
||||
|
||||
@ -978,7 +978,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
{
|
||||
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47);
|
||||
}*/
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60);
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 60);
|
||||
|
||||
// Fiscal year
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods.
|
||||
{
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
|
||||
}
|
||||
|
||||
// Binding
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
|
||||
@ -1102,12 +1108,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire);
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire);
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire);
|
||||
|
||||
// Fiscal year
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods.
|
||||
{
|
||||
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_periods", $langs->trans("FiscalPeriod"),1,$user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
|
||||
}
|
||||
}
|
||||
|
||||
// Accountancy (simple)
|
||||
|
||||
@ -652,7 +652,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
if ((float) DOL_VERSION >= 6.0)
|
||||
{
|
||||
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
||||
$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath('cabinetmed/doc/', 1)));
|
||||
$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -678,6 +678,55 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md
|
||||
*
|
||||
* @return string Content of ChangeLog
|
||||
*/
|
||||
function getChangeLog()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
|
||||
$filefound= false;
|
||||
|
||||
// Define path to file README.md.
|
||||
// First check README-la_LA.md then README.md
|
||||
$pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0);
|
||||
if (dol_is_file($pathoffile))
|
||||
{
|
||||
$filefound = true;
|
||||
}
|
||||
if (! $filefound)
|
||||
{
|
||||
$pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0);
|
||||
if (dol_is_file($pathoffile))
|
||||
{
|
||||
$filefound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound) // Mostly for external modules
|
||||
{
|
||||
$content = file_get_contents($pathoffile);
|
||||
|
||||
if ((float) DOL_VERSION >= 6.0)
|
||||
{
|
||||
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
||||
$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = nl2br($content);
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the publisher name
|
||||
*
|
||||
|
||||
@ -70,8 +70,8 @@ class modCashDesk extends DolibarrModules
|
||||
$this->phpmin = array(4,1); // Minimum version of PHP required by module
|
||||
$this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module
|
||||
$this->langfiles = array("cashdesk");
|
||||
$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
|
||||
$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
|
||||
//$this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
|
||||
//$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
|
||||
|
||||
// Constants
|
||||
$this->const = array();
|
||||
|
||||
@ -61,11 +61,11 @@ class pdf_standardlabel extends CommonStickerGenerator
|
||||
*/
|
||||
function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
|
||||
{
|
||||
global $mysoc,$conf,$langs;
|
||||
global $forceimgscalewidth,$forceimgscaleheight;
|
||||
global $mysoc, $conf, $langs;
|
||||
global $forceimgscalewidth, $forceimgscaleheight;
|
||||
|
||||
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
|
||||
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
|
||||
$imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight); // Scale of image for height (1=Full height of sticker)
|
||||
|
||||
// We are in a new page, then we must add a page
|
||||
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
|
||||
|
||||
@ -52,7 +52,7 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','fac
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
|
||||
<?php
|
||||
<?php
|
||||
$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines);
|
||||
if ($nolinesbefore) {
|
||||
?>
|
||||
@ -120,10 +120,10 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$coldisplay=2;
|
||||
?>
|
||||
<td class="linecolnum" align="center" width="5">
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
$coldisplay=0;
|
||||
$coldisplay=0;
|
||||
}
|
||||
?>
|
||||
|
||||
@ -278,13 +278,13 @@ else {
|
||||
<td class="nobottom linecoluht" align="right">
|
||||
<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht",'alpha',2):''); ?>">
|
||||
</td>
|
||||
|
||||
|
||||
<?php if (!empty($conf->multicurrency->enabled)) { $colspan++;?>
|
||||
<td class="nobottom linecoluht_currency" align="right">
|
||||
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"])?GETPOST("multicurrency_price_ht",'alpha',2):''); ?>">
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if (! empty($inputalsopricewithtax)) { ?>
|
||||
<td class="nobottom linecoluttc" align="right">
|
||||
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?GETPOST("price_ttc",'alpha',2):''); ?>">
|
||||
@ -738,9 +738,10 @@ function setforfree() {
|
||||
function setforpredef() {
|
||||
console.log("Call setforpredef. We hide some fields");
|
||||
jQuery("#select_type").val(-1);
|
||||
|
||||
jQuery("#prod_entry_mode_free").prop('checked',false).change();
|
||||
jQuery("#prod_entry_mode_predef").prop('checked',true).change();
|
||||
jQuery("#price_ht").hide();
|
||||
jQuery("#price_ht").val('').hide();
|
||||
jQuery("#multicurrency_price_ht").hide();
|
||||
jQuery("#price_ttc").hide(); // May no exists
|
||||
jQuery("#tva_tx").hide();
|
||||
|
||||
@ -49,7 +49,7 @@ class Expedition extends CommonObject
|
||||
public $table_element_line="expeditiondet";
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto = 'sending';
|
||||
|
||||
|
||||
var $socid;
|
||||
var $ref_customer;
|
||||
var $ref_int;
|
||||
@ -399,7 +399,7 @@ class Expedition extends CommonObject
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
$expeditionline = new ExpeditionLigne($this->db);
|
||||
@ -918,7 +918,7 @@ class Expedition extends CommonObject
|
||||
$this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH';
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
||||
// extrafields
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used
|
||||
$line->array_options = $array_options;
|
||||
@ -1319,7 +1319,8 @@ class Expedition extends CommonObject
|
||||
|
||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type";
|
||||
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
|
||||
$sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht";
|
||||
$sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht";
|
||||
$sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc";
|
||||
$sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
||||
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type";
|
||||
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch";
|
||||
@ -1392,8 +1393,10 @@ class Expedition extends CommonObject
|
||||
|
||||
$line->pa_ht = $obj->pa_ht;
|
||||
|
||||
$localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx);
|
||||
|
||||
// For invoicing
|
||||
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0
|
||||
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0
|
||||
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
|
||||
$line->qty = $line->qty_shipped;
|
||||
$line->total_ht = $tabprice[0];
|
||||
@ -1401,6 +1404,7 @@ class Expedition extends CommonObject
|
||||
$line->total_localtax2 = $tabprice[10];
|
||||
$line->total_ttc = $tabprice[2];
|
||||
$line->total_tva = $tabprice[1];
|
||||
$line->vat_src_code = $obj->vat_src_code;
|
||||
$line->tva_tx = $obj->tva_tx;
|
||||
$line->localtax1_tx = $obj->localtax1_tx;
|
||||
$line->localtax2_tx = $obj->localtax2_tx;
|
||||
@ -1414,6 +1418,14 @@ class Expedition extends CommonObject
|
||||
$this->total_localtax1+= $tabprice[9];
|
||||
$this->total_localtax2+= $tabprice[10];
|
||||
|
||||
// Multicurrency
|
||||
$this->fk_multicurrency = $obj->fk_multicurrency;
|
||||
$this->multicurrency_code = $obj->multicurrency_code;
|
||||
$this->multicurrency_subprice = $obj->multicurrency_subprice;
|
||||
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
|
||||
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
|
||||
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
|
||||
|
||||
if ($originline != $obj->fk_origin_line)
|
||||
{
|
||||
$line->detail_batch = array();
|
||||
@ -1482,7 +1494,7 @@ class Expedition extends CommonObject
|
||||
$label = '<u>' . $langs->trans("ShowSending") . '</u>';
|
||||
$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
|
||||
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
|
||||
|
||||
|
||||
$url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id;
|
||||
|
||||
if ($short) return $url;
|
||||
@ -1498,7 +1510,7 @@ class Expedition extends CommonObject
|
||||
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$linkclose.=' class="classfortooltip"';
|
||||
}
|
||||
|
||||
|
||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend='</a>';
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page=GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -601,7 +601,7 @@ if (empty($action))
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page=GETPOST("page",'int');
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
$offset = $limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
@ -66,6 +66,7 @@ if (@file_exists($forcedfile)) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -426,8 +427,8 @@ if (! empty($force_install_message))
|
||||
<input type="password" id="db_pass" autocomplete="off"
|
||||
name="db_pass"
|
||||
value="<?php
|
||||
// We don't want to set password. It will be extracted from the forced install file at step1.
|
||||
$autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : '');
|
||||
// If $force_install_databasepass is on, we don't want to set password, we just show '***'. Real value will be extracted from the forced install file at step1.
|
||||
$autofill = ((!empty($_SESSION['dol_save_pass'])) ? $_SESSION['dol_save_pass'] : str_pad('', strlen($force_install_databasepass), '*'));
|
||||
if (!empty($dolibarr_main_prod)) {
|
||||
$autofill = '';
|
||||
}
|
||||
@ -479,7 +480,7 @@ if (! empty($force_install_message))
|
||||
name="db_user_root"
|
||||
class="needroot"
|
||||
value="<?php print (!empty($force_install_databaserootlogin)) ? $force_install_databaserootlogin : @$db_user_root; ?>"
|
||||
<?php if ($force_install_noedit == 2 && $force_install_databaserootlogin !== null) {
|
||||
<?php if ($force_install_noedit > 0 && ! empty($force_install_databaserootlogin)) {
|
||||
print ' disabled';
|
||||
} ?>
|
||||
>
|
||||
@ -505,20 +506,21 @@ if (! empty($force_install_message))
|
||||
name="db_pass_root"
|
||||
class="needroot"
|
||||
value="<?php
|
||||
// We don't want to set password. It will be extracted from the forced install file at step1.
|
||||
$autofill = ((!empty($force_install_database_rootpass)) ? '' : @$db_pass_root);
|
||||
// If $force_install_databaserootpass is on, we don't want to set password here, we just show '***'. Real value will be extracted from the forced install file at step1.
|
||||
$autofill = ((!empty($force_install_databaserootpass)) ? str_pad('', strlen($force_install_databaserootpass), '*') : @$db_pass_root);
|
||||
if (!empty($dolibarr_main_prod)) {
|
||||
$autofill = '';
|
||||
} // Do not autofill password if instance is a production instance
|
||||
}
|
||||
// Do not autofill password if instance is a production instance
|
||||
if (!empty($_SERVER["SERVER_NAME"]) && !in_array($_SERVER["SERVER_NAME"],
|
||||
array('127.0.0.1', 'localhost'))
|
||||
array('127.0.0.1', 'localhost', 'localhostgit'))
|
||||
) {
|
||||
$autofill = '';
|
||||
} // Do not autofill password for remote access
|
||||
print dol_escape_htmltag($autofill);
|
||||
?>"
|
||||
<?php if ($force_install_noedit == 2 && $force_install_databaserootpass !== null) {
|
||||
print ' disabled';
|
||||
<?php if ($force_install_noedit > 0 && ! empty($force_install_databaserootpass)) {
|
||||
print ' disabled'; // May be removed by javascript
|
||||
} ?>
|
||||
>
|
||||
</td>
|
||||
@ -561,7 +563,10 @@ jQuery(document).ready(function() {
|
||||
if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
|
||||
{
|
||||
jQuery(".hideroot").show();
|
||||
jQuery(".needroot").removeAttr('disabled');
|
||||
<?php
|
||||
if ($force_install_noedit == 0) { ?>
|
||||
jQuery(".needroot").removeAttr('disabled');
|
||||
<?php } ?>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -497,3 +497,6 @@ CREATE TABLE llx_blockedlog_authority
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature);
|
||||
|
||||
-- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid
|
||||
|
||||
|
||||
@ -92,6 +92,9 @@ delete from llx_product_extrafields where fk_object not in (select rowid from ll
|
||||
update llx_product_batch set batch = '' where batch = 'Non défini';
|
||||
update llx_product_batch set batch = '' where batch = 'Non défini';
|
||||
|
||||
update llx_stock_mouvement set batch = null where batch = 'Non défini';
|
||||
update llx_stock_mouvement set batch = null where batch = 'Non défini';
|
||||
|
||||
DELETE FROM llx_product_lot WHERE fk_product NOT IN (select rowid from llx_product);
|
||||
DELETE FROM llx_product_stock WHERE fk_product NOT IN (select rowid from llx_product);
|
||||
DELETE FROM llx_product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM llx_product_batch as pb);
|
||||
|
||||
@ -20,7 +20,7 @@ create table llx_default_values
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
type varchar(10), -- 'createform', 'filters', 'sortorder'
|
||||
type varchar(10), -- 'createform', 'filters', 'sortorder', 'focus', 'transform'
|
||||
user_id integer DEFAULT 0 NOT NULL, -- 0 or user id
|
||||
page varchar(255), -- relative url of page
|
||||
param varchar(255), -- parameter
|
||||
|
||||
@ -88,6 +88,7 @@ if (@file_exists($forcedfile)) {
|
||||
$main_data_dir = detect_dolibarr_main_data_root($main_dir);
|
||||
}
|
||||
$main_url = detect_dolibarr_main_url_root();
|
||||
|
||||
if (!empty($force_install_databaserootlogin)) {
|
||||
$userroot = parse_database_login($force_install_databaserootlogin);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Dolibarr language file - Source file is en_US - salaries
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account by default for salaries payments
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties
|
||||
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Dedicated accounting account defined on user card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated user accouting account on user is not defined
|
||||
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for personnel expenses
|
||||
Salary=Salary
|
||||
Salaries=Salaries
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
Dolibarr Module Template (aka My Module)
|
||||
========================================
|
||||
Module Builder
|
||||
==============
|
||||
|
||||
This is a full featured module template for Dolibarr.
|
||||
It's a tool for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development.
|
||||
This is a module to provide embedded tools to develop your own application/features inside Dolibarr ERP CRM software.
|
||||
It provide tools for module developers to kickstart their project and give an hands-on sample of which features Dolibarr
|
||||
has to offer for module development.
|
||||
|
||||
If you don't need to develop your own module/application, you just don't need this.
|
||||
|
||||
|
||||
After enabling this module, you should find features to generate or edit modules/application from menu *Home - Admin tools - Module builder*
|
||||
|
||||
If you're not a module developer you have no use for this.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
@ -12,204 +17,3 @@ Documentation
|
||||
[Module tutorial](https://wiki.dolibarr.org/index.php/Module_development)
|
||||
|
||||
[Dolibarr development](https://wiki.dolibarr.org/index.php/Developer_documentation)
|
||||
|
||||
### Translations
|
||||
|
||||
Dolibarr uses [Transifex](https://transifex.com) to manage it's translations.
|
||||
|
||||
This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory.
|
||||
|
||||
For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation).
|
||||
|
||||
There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
### Manually
|
||||
|
||||
- Make sure Dolibarr is already installed and configured on your workstation or development server.
|
||||
|
||||
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
|
||||
|
||||
- Find the following lines:
|
||||
```php
|
||||
//$dolibarr_main_url_root_alt ...
|
||||
//$dolibarr_main_document_root_alt ...
|
||||
```
|
||||
|
||||
- Uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
|
||||
|
||||
For example :
|
||||
|
||||
- UNIX:
|
||||
```php
|
||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
|
||||
$dolibarr_main_url_root_alt = '/custom';
|
||||
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
|
||||
```
|
||||
|
||||
- Windows:
|
||||
```php
|
||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
|
||||
$dolibarr_main_url_root_alt = '/custom';
|
||||
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
|
||||
```
|
||||
|
||||
For more information about the ```conf.php``` file take a look at the conf.php.example file.
|
||||
|
||||
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
|
||||
|
||||
*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)*
|
||||
```sh
|
||||
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
|
||||
```
|
||||
|
||||
- Install [Composer](https://getcomposer.org) dependencies:
|
||||
```sh
|
||||
composer install
|
||||
```
|
||||
|
||||
Follow the [final steps](#final_steps).
|
||||
|
||||
### Using [Composer](https://getcomposer.org)
|
||||
Require this repository from Dolibarr's composer:
|
||||
```json
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/dolibarr/dolibarr-module-template"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"dolibarr/mymodule": "dev-master"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run
|
||||
```sh
|
||||
composer update
|
||||
```
|
||||
|
||||
Follow the [final steps](#final_steps).
|
||||
|
||||
### <a name="final_steps"></a>Final steps
|
||||
|
||||
From your browser:
|
||||
|
||||
- Log into Dolibarr as a super-administrator
|
||||
- Under "Setup" -> "Other setup", set ```MAIN_FEATURES_LEVEL``` to ```2```
|
||||
- Go to "Setup" -> "Modules"
|
||||
- The module is under one of the tabs
|
||||
- You should now be able to enable the new module and start coding ;)
|
||||
|
||||
Provided tools
|
||||
--------------
|
||||
|
||||
### Starting a new module
|
||||
|
||||
A [script](dev/newmodule.sh) allows you to rename most of the code to your own module name.
|
||||
It requires ```find```, ```sed``` and ```rename``` commands on your system.
|
||||
Just make sure you provide a CamelCase name.
|
||||
```sh
|
||||
./dev/newmodule.sh [NewName]
|
||||
```
|
||||
|
||||
Some work still has to be done manually:
|
||||
- Rename the directory holding the code
|
||||
- Maybe rename some other bits (Search for 'my' in filenames and code)
|
||||
- Update your module ID in the module descriptor
|
||||
- Update your language files
|
||||
- Keywords based on the module ID
|
||||
- String referencing the template
|
||||
- Remove the features you don't plan to use
|
||||
- Fill the copyright notices at the top of each file
|
||||
- Add your logo: see [images README](dev/img/README.md) for specifications
|
||||
- Start a new GIT history
|
||||
```
|
||||
git checkout --orphan [new_branch_name]
|
||||
```
|
||||
- Build an awesome module ;)
|
||||
|
||||
### Composer scripts
|
||||
|
||||
Only the main commands are listed here.
|
||||
See the [composer comments](composer-comments.md) or the [composer.json](composer.json) itself for more informations.
|
||||
|
||||
#### Check
|
||||
|
||||
Run a linter, a PHP compatibility version checker and checks coding style.
|
||||
```sh
|
||||
composer check
|
||||
```
|
||||
|
||||
#### Test
|
||||
|
||||
Run unit and functional tests.
|
||||
```sh
|
||||
composer test
|
||||
```
|
||||
|
||||
#### Doc
|
||||
Build code and user documentation.
|
||||
|
||||
#### Release
|
||||
|
||||
Run the checks and tests then build a distribution ZIP.
|
||||
```sh
|
||||
composer release
|
||||
```
|
||||
|
||||
#### Git hooks
|
||||
|
||||
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
|
||||
These are just wrappers calling composer scripts.
|
||||
They ensure best practices are followed during module development.
|
||||
|
||||
Install:
|
||||
```sh
|
||||
composer git_hooks_install
|
||||
```
|
||||
|
||||
Remove:
|
||||
```sh
|
||||
composer git_hooks_remove
|
||||
```
|
||||
|
||||
## Publishing the module
|
||||
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
|
||||
Templates for required images and texts are [provided](dev/dolistore).
|
||||
Check the dedicated [README](dev/dolistore/README.md) for more informations.
|
||||
|
||||
|
||||
Licenses
|
||||
--------
|
||||
|
||||
### Main code
|
||||
|
||||

|
||||
|
||||
GPLv3 or (at your option) any later version.
|
||||
|
||||
See [COPYING](COPYING) for more information.
|
||||
|
||||
### Other Licenses
|
||||
|
||||
#### [Parsedown](http://parsedown.org/)
|
||||
|
||||
Used to display this README in the module's about page.
|
||||
Licensed under MIT.
|
||||
|
||||
#### [GNU Licenses logos](https://www.gnu.org/graphics/license-logos.html)
|
||||
|
||||
Public domain
|
||||
|
||||
#### Documentation
|
||||
|
||||
All texts and readmes.
|
||||
|
||||

|
||||
|
||||
@ -4,3 +4,97 @@
|
||||
MyModuleDescription
|
||||
|
||||
Other modules are available on <a href="https://www.dolistore.com" target="_new">Dolistore.com</a>.
|
||||
|
||||
|
||||
|
||||
### Translations
|
||||
|
||||
This module contains a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service.
|
||||
Translations can be define manually by editing files into directories [langs](langs).
|
||||
|
||||
<!--
|
||||
For more informations, see the [translator's documentation](https://wiki.dolibarr.org/index.php/Translator_documentation).
|
||||
|
||||
There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
|
||||
-->
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
### Manually
|
||||
|
||||
- Make sure Dolibarr is already installed and configured on your workstation or development server.
|
||||
|
||||
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
|
||||
|
||||
- Find the following lines:
|
||||
```php
|
||||
//$dolibarr_main_url_root_alt ...
|
||||
//$dolibarr_main_document_root_alt ...
|
||||
```
|
||||
|
||||
- And uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
|
||||
|
||||
For example :
|
||||
|
||||
- UNIX:
|
||||
```php
|
||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
|
||||
$dolibarr_main_url_root_alt = '/custom';
|
||||
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
|
||||
```
|
||||
|
||||
- Windows:
|
||||
```php
|
||||
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
|
||||
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
|
||||
$dolibarr_main_url_root_alt = '/custom';
|
||||
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
|
||||
```
|
||||
|
||||
For more information about the ```conf.php``` file take a look at the conf.php.example file.
|
||||
|
||||
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
|
||||
|
||||
```sh
|
||||
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
|
||||
```
|
||||
|
||||
### <a name="final_steps"></a>Final steps
|
||||
|
||||
From your browser:
|
||||
|
||||
- Log into Dolibarr as a super-administrator
|
||||
- Go to "Setup" -> "Modules"
|
||||
- You should now be able to find and enable the module
|
||||
|
||||
|
||||
|
||||
## Publishing the module
|
||||
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
|
||||
Templates for required images and texts are [provided](dev/dolistore).
|
||||
Check the dedicated [README](dev/dolistore/README.md) for more informations.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
Licenses
|
||||
--------
|
||||
|
||||
### Main code
|
||||
|
||||

|
||||
|
||||
GPLv3 or (at your option) any later version.
|
||||
|
||||
See [COPYING](COPYING) for more information.
|
||||
|
||||
#### Documentation
|
||||
|
||||
All texts and readmes.
|
||||
|
||||

|
||||
|
||||
@ -23,9 +23,18 @@
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
if (false === (@include '../../main.inc.php')) { // From htdocs directory
|
||||
require '../../../main.inc.php'; // From "custom" directory
|
||||
}
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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");
|
||||
|
||||
// Libraries
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
@ -23,9 +23,18 @@
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
if (false === (@include '../../main.inc.php')) { // From htdocs directory
|
||||
require '../../../main.inc.php'; // From "custom" directory
|
||||
}
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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");
|
||||
|
||||
global $langs, $user;
|
||||
|
||||
|
||||
@ -33,15 +33,24 @@ if (! defined('NOLOGIN')) define('NOLOGIN',1); // File must be
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
|
||||
|
||||
session_cache_limiter(FALSE);
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
session_cache_limiter(FALSE);
|
||||
|
||||
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) and load permission if we need to use them in CSS
|
||||
/*if (empty($user->id) && ! empty($_SESSION['dol_login']))
|
||||
{
|
||||
|
||||
15
htdocs/modulebuilder/template/dev/git-hooks/README
Normal file
15
htdocs/modulebuilder/template/dev/git-hooks/README
Normal file
@ -0,0 +1,15 @@
|
||||
# Git hooks
|
||||
|
||||
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
|
||||
These are just wrappers calling composer scripts.
|
||||
They ensure best practices are followed during module development.
|
||||
|
||||
Install:
|
||||
```sh
|
||||
composer git_hooks_install
|
||||
```
|
||||
|
||||
Remove:
|
||||
```sh
|
||||
composer git_hooks_remove
|
||||
```
|
||||
@ -22,4 +22,24 @@
|
||||
* \brief JavaScript file for module MyModule.
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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");
|
||||
|
||||
// Define js type
|
||||
header('Content-Type: application/javascript');
|
||||
// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
|
||||
// You can use CTRL+F5 to refresh your browser cache.
|
||||
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
|
||||
else header('Cache-Control: no-cache');
|
||||
|
||||
|
||||
@ -35,20 +35,25 @@
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||
|
||||
// Change this following line to use the correct relative path (../, ../../, etc)
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
|
||||
if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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");
|
||||
// Change this following line to use the correct relative path from htdocs
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||
dol_include_once('/mymodule/class/myobject.class.php');
|
||||
|
||||
// Load traductions files requiredby by page
|
||||
$langs->load("mymodule");
|
||||
$langs->load("other");
|
||||
$langs->loadLangs(array("mymodule","other"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id','int');
|
||||
|
||||
@ -32,17 +32,23 @@
|
||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
|
||||
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
||||
|
||||
// Change this following lines to use the correct relative path (../, ../../, etc)
|
||||
// Load Dolibarr environment
|
||||
$res=0;
|
||||
if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
|
||||
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
|
||||
if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||
if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
||||
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
|
||||
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
|
||||
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
|
||||
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
|
||||
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
|
||||
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
|
||||
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
|
||||
// Try main.inc.php using relative path
|
||||
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");
|
||||
// Change this following line to use the correct relative path from htdocs
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
@ -51,11 +57,11 @@ dol_include_once('/mymodule/class/myobject.class.php');
|
||||
// Load traductions files requiredby by page
|
||||
$langs->loadLangs(array("mymodule","other"));
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
$massaction=GETPOST('massaction','alpha');
|
||||
$show_files=GETPOST('show_files','int');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$action = GETPOST('action','alpha');
|
||||
$massaction = GETPOST('massaction','alpha');
|
||||
$show_files = GETPOST('show_files','int');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
$backtopage = GETPOST('backtopage');
|
||||
|
||||
@ -221,12 +221,43 @@ if (empty($reshook))
|
||||
else
|
||||
$object->price_min = GETPOST('price_min');
|
||||
|
||||
$object->tva_tx = str_replace('*','',GETPOST('tva_tx'));
|
||||
$object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0;
|
||||
$tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
|
||||
|
||||
// local taxes.
|
||||
$object->localtax1_tx = get_localtax($object->tva_tx,1);
|
||||
$object->localtax2_tx = get_localtax($object->tva_tx,2);
|
||||
// We must define tva_tx, npr and local taxes
|
||||
$vatratecode = '';
|
||||
$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
|
||||
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
|
||||
$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
|
||||
// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
|
||||
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
|
||||
{
|
||||
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
|
||||
$vatratecode=$reg[1];
|
||||
// Get record from code
|
||||
$sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'";
|
||||
$sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
|
||||
$sql.= " AND t.code ='".$vatratecode."'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$npr = $obj->recuperableonly;
|
||||
$localtax1 = $obj->localtax1;
|
||||
$localtax2 = $obj->localtax2;
|
||||
$localtax1_type = $obj->localtax1_type;
|
||||
$localtax2_type = $obj->localtax2_type;
|
||||
}
|
||||
}
|
||||
|
||||
$object->default_vat_code = $vatratecode;
|
||||
$object->tva_tx = $tva_tx;
|
||||
$object->tva_npr = $npr;
|
||||
$object->localtax1_tx = $localtax1;
|
||||
$object->localtax2_tx = $localtax2;
|
||||
$object->localtax1_type = $localtax1_type;
|
||||
$object->localtax2_type = $localtax2_type;
|
||||
|
||||
$object->type = $type;
|
||||
$object->status = GETPOST('statut');
|
||||
@ -1101,7 +1132,8 @@ else
|
||||
|
||||
// VAT
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $form->load_tva("tva_tx",-1,$mysoc,'');
|
||||
$defaultva=get_default_tva($mysoc, $mysoc);
|
||||
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -1437,7 +1437,7 @@ class Product extends CommonObject
|
||||
if (empty($this->price_by_qty)) $this->price_by_qty=0;
|
||||
|
||||
// Add new price
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,";
|
||||
$sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) ";
|
||||
$sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code?("'".$this->default_vat_code."'"):"null").",".$this->tva_npr.",";
|
||||
$sql.= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->localtax1_type."', '".$this->localtax2_type."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null');
|
||||
@ -1876,6 +1876,7 @@ class Product extends CommonObject
|
||||
$this->tva_tx = $obj->tva_tx;
|
||||
//! French VAT NPR
|
||||
$this->tva_npr = $obj->tva_npr;
|
||||
$this->recuperableonly = $obj->tva_npr; // For backward compatibility
|
||||
//! Local taxes
|
||||
$this->localtax1_tx = $obj->localtax1_tx;
|
||||
$this->localtax2_tx = $obj->localtax2_tx;
|
||||
|
||||
@ -113,7 +113,7 @@ if (empty($reshook))
|
||||
// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
|
||||
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
|
||||
{
|
||||
// We look into database using code
|
||||
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in create product.
|
||||
$vatratecode=$reg[1];
|
||||
// Get record from code
|
||||
$sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
|
||||
@ -1823,7 +1823,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
print "<td>" . "</td>";
|
||||
|
||||
print '<td align="center">' . $langs->trans($object->price_base_type) . "</td>";
|
||||
print '<td align="right">' . vatrate($object->tva_tx, true, $object->recuperableonly) . "</td>";
|
||||
print '<td align="right">';
|
||||
print vatrate($object->tva_tx, true, $object->recuperableonly);
|
||||
print $object->default_vat_code?' ('.$object->default_vat_code.')':'';
|
||||
print "</td>";
|
||||
print '<td align="right">' . price($object->price) . "</td>";
|
||||
print '<td align="right">' . price($object->price_ttc) . "</td>";
|
||||
print '<td align="right">' . price($object->price_min) . '</td>';
|
||||
|
||||
@ -141,7 +141,7 @@ else
|
||||
function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_id=null)
|
||||
{
|
||||
global $dateformatinput2;
|
||||
|
||||
|
||||
$start_date = $task["task_start_date"];
|
||||
$end_date = $task["task_end_date"];
|
||||
if (!$end_date) $end_date = $start_date;
|
||||
@ -206,7 +206,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_
|
||||
$s = "\n// Add taks id=".$task["task_id"]." level = ".$level."\n";
|
||||
// $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."', '".$note."'));";
|
||||
// For JSGanttImproved
|
||||
$s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".$task['note']."'));";
|
||||
$s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".dol_escape_js($task['note'])."'));";
|
||||
echo $s;
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,9 @@ class Contacts extends DolibarrApi
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
$this->contact = new Contact($this->db);
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
* API class for thirdparty object
|
||||
*
|
||||
* @smart-auto-routing false
|
||||
* @access protected
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
* @deprecated Use Thirdparties instead (defined in api_thirdparties.class.php)
|
||||
*/
|
||||
@ -30,7 +30,7 @@ class ThirdpartyApi extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'name'
|
||||
@ -49,15 +49,17 @@ class ThirdpartyApi extends DolibarrApi
|
||||
* Constructor <b>Warning: Deprecated</b>
|
||||
*
|
||||
* @url thirdparty/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
$this->company = new Societe($this->db);
|
||||
$this->customer = new Client($this->db);
|
||||
|
||||
|
||||
if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) {
|
||||
static::$FIELDS[] = 'email';
|
||||
}
|
||||
@ -70,21 +72,21 @@ class ThirdpartyApi extends DolibarrApi
|
||||
*
|
||||
* @param int $id ID of customer
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @url GET customer/{id}
|
||||
* @throws RestException
|
||||
*/
|
||||
function getCustomer($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->customer->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Customer not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -94,11 +96,11 @@ class ThirdpartyApi extends DolibarrApi
|
||||
|
||||
/**
|
||||
* Search customer by email <b>Warning: Deprecated</b>
|
||||
*
|
||||
*
|
||||
* @param string $email email id
|
||||
*
|
||||
* @return object client with given email
|
||||
*
|
||||
*
|
||||
* @url GET customer/byemail/{email}
|
||||
*/
|
||||
function getByEmail($email) {
|
||||
@ -117,21 +119,21 @@ class ThirdpartyApi extends DolibarrApi
|
||||
*
|
||||
* @param int $id ID of thirdparty
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @url GET thirdparty/{id}
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -141,10 +143,10 @@ class ThirdpartyApi extends DolibarrApi
|
||||
|
||||
/**
|
||||
* List thirdparties <b>Warning: Deprecated</b>
|
||||
*
|
||||
*
|
||||
* Get a list of thirdparties
|
||||
*
|
||||
* @param int $mode Set to 1 to show only customers
|
||||
*
|
||||
* @param int $mode Set to 1 to show only customers
|
||||
* Set to 2 to show only prospects
|
||||
* Set to 3 to show only those are not customer neither prospect
|
||||
* @param Text $email Search by email filter
|
||||
@ -153,17 +155,17 @@ class ThirdpartyApi extends DolibarrApi
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @return array Array of thirdparty objects
|
||||
*
|
||||
*
|
||||
* @url GET /thirdparty/list
|
||||
*
|
||||
*/
|
||||
function getList($mode=0, $email=NULL, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
||||
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
||||
@ -171,7 +173,7 @@ class ThirdpartyApi extends DolibarrApi
|
||||
$sql = "SELECT s.rowid";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||
@ -183,13 +185,13 @@ class ThirdpartyApi extends DolibarrApi
|
||||
if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
|
||||
|
||||
// Insert sale filter
|
||||
if ($search_sale > 0)
|
||||
{
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
@ -233,47 +235,47 @@ class ThirdpartyApi extends DolibarrApi
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show customers <b>Warning: Deprecated</b>
|
||||
*
|
||||
*
|
||||
* @return array List of customers
|
||||
*
|
||||
*
|
||||
* @url GET /thirdparty/list/customers
|
||||
* @url GET /customer/list
|
||||
*/
|
||||
function getListCustomers() {
|
||||
return $this->getList(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show prospects <b>Warning: Deprecated</b>
|
||||
*
|
||||
*
|
||||
* @return array List of prospects
|
||||
*
|
||||
*
|
||||
* @url GET /thirdparty/list/prospects
|
||||
*/
|
||||
function getListProspects() {
|
||||
return $this->getList(2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show other <b>Warning: Deprecated</b>
|
||||
*
|
||||
*
|
||||
* @return array List of thirpdparties who are not customer neither prospect
|
||||
*
|
||||
*
|
||||
* @url GET /thirdparty/list/others
|
||||
*/
|
||||
function getListOthers() {
|
||||
return $this->getList(3);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create thirdparty object <b>Warning: Deprecated</b>
|
||||
*
|
||||
* @param array $request_data Request datas
|
||||
* @return int ID of thirdparty
|
||||
*
|
||||
*
|
||||
* @url POST thirdparty/
|
||||
*/
|
||||
function post($request_data = NULL)
|
||||
@ -283,7 +285,7 @@ class ThirdpartyApi extends DolibarrApi
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
@ -296,7 +298,7 @@ class ThirdpartyApi extends DolibarrApi
|
||||
*
|
||||
* @param array $request_data Request datas
|
||||
* @return int ID of thirdparty
|
||||
*
|
||||
*
|
||||
* @url POST customer/
|
||||
*/
|
||||
function postCustomer($request_data) {
|
||||
@ -309,9 +311,9 @@ class ThirdpartyApi extends DolibarrApi
|
||||
* Update thirdparty <b>Warning: Deprecated</b>
|
||||
*
|
||||
* @param int $id Id of thirdparty to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*
|
||||
* @url PUT thirdparty/{id}
|
||||
*/
|
||||
function put($id, $request_data = NULL)
|
||||
@ -319,12 +321,12 @@ class ThirdpartyApi extends DolibarrApi
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -333,19 +335,19 @@ class ThirdpartyApi extends DolibarrApi
|
||||
if ($field == 'id') continue;
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->company->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Update customer <b>Warning: Deprecated</b>
|
||||
*
|
||||
* @param int $id Id of thirdparty to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*
|
||||
* @url PUT customer/{id}
|
||||
*/
|
||||
function putClient($id, $request_data = NULL) {
|
||||
@ -363,19 +365,19 @@ class ThirdpartyApi extends DolibarrApi
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->customer->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->customer->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete thirdparty <b>Warning: Deprecated</b>
|
||||
*
|
||||
* @param int $id Thirparty ID
|
||||
* @return integer
|
||||
*
|
||||
*
|
||||
* @url DELETE thirdparty/{id}
|
||||
* @url DELETE customer/{id}
|
||||
*/
|
||||
@ -393,13 +395,13 @@ class ThirdpartyApi extends DolibarrApi
|
||||
}
|
||||
return $this->company->delete($id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
*
|
||||
* @param array $data Datas to validate
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
|
||||
@ -50,6 +50,7 @@ $result = restrictedArea($user,'societe',$socid,'');
|
||||
|
||||
$search_all=trim(GETPOST('sall', 'alphanohtml'));
|
||||
$search_nom=trim(GETPOST("search_nom"));
|
||||
$search_alias=trim(GETPOST("search_alias"));
|
||||
$search_nom_only=trim(GETPOST("search_nom_only"));
|
||||
$search_barcode=trim(GETPOST("sbarcode"));
|
||||
$search_customer_code=trim(GETPOST('search_customer_code'));
|
||||
@ -70,7 +71,7 @@ $search_idprof5=trim(GETPOST('search_idprof5'));
|
||||
$search_idprof6=trim(GETPOST('search_idprof6'));
|
||||
$search_sale=trim(GETPOST("search_sale",'int'));
|
||||
$search_categ=trim(GETPOST("search_categ",'int'));
|
||||
$search_country=GETPOST("search_country",'int');
|
||||
$search_country=GETPOST("search_country",'intcomma');
|
||||
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
|
||||
$search_status=GETPOST("search_status",'int');
|
||||
$search_type=GETPOST('search_type','alpha');
|
||||
@ -151,7 +152,8 @@ $checkedprofid6=0;
|
||||
$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
|
||||
$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
|
||||
$arrayfields=array(
|
||||
's.nom'=>array('label'=>"Company", 'checked'=>1),
|
||||
's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
|
||||
's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
|
||||
's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode),
|
||||
's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
|
||||
@ -210,6 +212,7 @@ if (empty($reshook))
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$search_nom='';
|
||||
$search_alias='';
|
||||
$search_categ=0;
|
||||
$search_sale='';
|
||||
$search_barcode="";
|
||||
@ -406,6 +409,7 @@ if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_c
|
||||
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
if ($search_nom) $sql.= natural_search("s.nom",$search_nom);
|
||||
if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias);
|
||||
if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only);
|
||||
if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code);
|
||||
if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code);
|
||||
@ -488,37 +492,38 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($search_all != '') $param = "&sall=".urlencode($search_all);
|
||||
if ($sall != '') $param .= "&sall=".urlencode($sall);
|
||||
if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ);
|
||||
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
|
||||
if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom);
|
||||
if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
|
||||
if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
|
||||
if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
|
||||
if ($search_email != '') $param.= "&search_email=".urlencode($search_email);
|
||||
if ($search_url != '') $param.= "&search_url=".urlencode($search_url);
|
||||
if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
|
||||
if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
|
||||
if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
|
||||
if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
|
||||
if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
|
||||
if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
|
||||
if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode);
|
||||
if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
|
||||
if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
|
||||
if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
|
||||
if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
|
||||
if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
|
||||
if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
|
||||
if ($search_country != '') $param.='&search_country='.urlencode($search_country);
|
||||
if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
|
||||
if ($search_all != '') $param = "&sall=".urlencode($search_all);
|
||||
if ($sall != '') $param .= "&sall=".urlencode($sall);
|
||||
if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ);
|
||||
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
|
||||
if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom);
|
||||
if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias);
|
||||
if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
|
||||
if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
|
||||
if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
|
||||
if ($search_email != '') $param.= "&search_email=".urlencode($search_email);
|
||||
if ($search_url != '') $param.= "&search_url=".urlencode($search_url);
|
||||
if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
|
||||
if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
|
||||
if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
|
||||
if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
|
||||
if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
|
||||
if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
|
||||
if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode);
|
||||
if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
|
||||
if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
|
||||
if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
|
||||
if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
|
||||
if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
|
||||
if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
|
||||
if ($search_country != '') $param.='&search_country='.urlencode($search_country);
|
||||
if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
|
||||
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
|
||||
if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm;
|
||||
if ($search_level_from != '') $param.='&search_level_from='.$search_level_from;
|
||||
if ($search_level_to != '') $param.='&search_level_to='.$search_level_to;
|
||||
if ($type != '') $param.='&type='.urlencode($type);
|
||||
if ($type != '') $param.='&type='.urlencode($type);
|
||||
// Add $param from extra fields
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
@ -633,6 +638,12 @@ if (! empty($arrayfields['s.nom']['checked']))
|
||||
print '<input class="flat searchstring" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.name_alias']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat searchstring" type="text" name="search_alias" size="8" value="'.dol_escape_htmltag($search_alias).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Barcode
|
||||
if (! empty($arrayfields['s.barcode']['checked']))
|
||||
{
|
||||
@ -882,6 +893,7 @@ print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
|
||||
@ -948,7 +960,6 @@ while ($i < min($num, $limit))
|
||||
$companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
|
||||
|
||||
$companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
|
||||
$companystatic->name_alias=$obj->name_alias;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
if (! empty($arrayfields['s.nom']['checked']))
|
||||
@ -958,6 +969,14 @@ while ($i < min($num, $limit))
|
||||
print "</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['s.name_alias']['checked']))
|
||||
{
|
||||
$companystatic->name_alias=$obj->name_alias; // Added after the getNomUrl
|
||||
print '<td class="tdoverflowmax200">';
|
||||
print $companystatic->name_alias;
|
||||
print "</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Barcode
|
||||
if (! empty($arrayfields['s.barcode']['checked']))
|
||||
{
|
||||
|
||||
@ -42,7 +42,7 @@ if ($sortfield == "")
|
||||
$sortfield="s.nom";
|
||||
}
|
||||
|
||||
if ($page == -1) { $page = 0 ; }
|
||||
if ($page == -1 || $page == null) { $page = 0 ; }
|
||||
|
||||
$offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
|
||||
@ -1372,7 +1372,7 @@ if ($action == 'create')
|
||||
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
||||
$morehtmlref.='<input type="hidden" name="action" value="classin">';
|
||||
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
|
||||
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
||||
$morehtmlref.='</form>';
|
||||
} else {
|
||||
|
||||
@ -666,11 +666,18 @@ div.myavailability {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
|
||||
/* For the long description of module */
|
||||
.moduledesclong p img, .moduledesclong p a img {
|
||||
max-width: 90% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
.imgdoc {
|
||||
margin: 18px;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 1px 1px 25px #aaa;
|
||||
max-width: calc(100% - 56px);
|
||||
}
|
||||
|
||||
|
||||
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
|
||||
|
||||
@ -667,11 +667,18 @@ div.myavailability {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
|
||||
/* For the long description of module */
|
||||
.moduledesclong p img,.moduledesclong p a img {
|
||||
max-width: 90% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
.imgdoc {
|
||||
margin: 18px;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 1px 1px 25px #aaa;
|
||||
max-width: calc(100% - 56px);
|
||||
}
|
||||
|
||||
|
||||
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
|
||||
|
||||
@ -221,7 +221,7 @@ class User extends CommonObject
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
|
||||
else
|
||||
$sql.= " WHERE u.entity IN (0, ".$conf->entity.")";
|
||||
$sql.= " WHERE u.entity IN (0, ".($entity!=''?$entity:$conf->entity).")"; // search in entity provided in parameter
|
||||
}
|
||||
|
||||
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba
|
||||
@ -236,6 +236,7 @@ class User extends CommonObject
|
||||
{
|
||||
$sql.= " AND u.rowid = ".$id;
|
||||
}
|
||||
$sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -310,8 +311,8 @@ class User extends CommonObject
|
||||
$this->fk_member = $obj->fk_member;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
|
||||
// Protection when module multicompany was set, admin was set to first entity and the module disabled,
|
||||
// then this admin user must be admin for all entities.
|
||||
// Protection when module multicompany was set, admin was set to first entity and then, the module was disabled,
|
||||
// in such case, this admin user must be admin for ALL entities.
|
||||
if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0;
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
|
||||
Loading…
Reference in New Issue
Block a user