Merge remote-tracking branch 'upstream/develop' into 11.0_a4

This commit is contained in:
Alexandre SPANGARO 2019-11-18 06:08:49 +01:00
commit cd018b2b65
874 changed files with 77271 additions and 74959 deletions

23
.gitignore vendored
View File

@ -1,5 +1,7 @@
htdocs/conf/conf.php
htdocs/conf/conf.php.old
htdocs/conf/conf.php.sav
htdocs/conf/conf.php.back
documents/
custom2/
test/report/
@ -8,22 +10,33 @@ default.properties
.settings/
.buildpath
.gitmodules
dolibarr_install.log
upgrade.log
doxygen_warnings.log
/.project
/.pydevproject
/.vscode
.DS_Store
.idea
*.iml
Thumbs.db
/dolibarr_genesis.mp4
# Log files
dolibarr_install.log
upgrade.log
doxygen_warnings.log
# Vagrant generated files
.vagrant
# Composer installed repositories
/htdocs/includes/**/.git
# Composer autoloader and unwanted files
composer.phar
htdocs/includes/autoload.php
htdocs/includes/bin/
htdocs/includes/composer/
/.pydevproject
/dolibarr_genesis.mp4
htdocs/includes/doctrine/
htdocs/includes/jakub-onderka/
htdocs/includes/phpdocumentor/
htdocs/includes/phpspec/
htdocs/includes/phpunit/
htdocs/includes/sebastian/
htdocs/includes/squizlabs/
htdocs/includes/symfony/
htdocs/includes/webmozart/

View File

@ -24,7 +24,7 @@ Following changes may create regressions for some external modules, but were nec
* Removed function dol_micro_time. Use native PHP microtime instead.
* The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE.
* The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS.
* If your logo was visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible agin in menu.
* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again.
* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'.
* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'.
* All properties 'type_libelle' were renamed into 'type_label'.

1
build/.gitignore vendored
View File

@ -5,6 +5,5 @@
/dolibarr-*.tgz
/dolibarr-*.rpm
/dolibarr-*.zip
/dolibarr-*.tgz
/*.exe
/html

29
build/exakat/README.md Normal file
View File

@ -0,0 +1,29 @@
== Install exakat ==
mkdir exakat
cd exakat
curl -o exakat.phar http://dist.exakat.io/index.php?file=latest
curl -o apache-tinkerpop-gremlin-server-3.3.5-bin.zip http://dist.exakat.io/apache-tinkerpop-gremlin-server-3.3.5-bin.zip
unzip apache-tinkerpop-gremlin-server-3.3.5-bin.zip
mv apache-tinkerpop-gremlin-server-3.3.5 tinkergraph
rm -rf apache-tinkerpop-gremlin-server-3.3.5-bin.zip
cd tinkergraph ./bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.3.5
cd ..
php exakat.phar version
php exakat.phar doctor
== Init project ==
php
Edit config.ini file to exclude some dirs:
ignore_dirs[] = "/htdocs/includes";
ignore_dirs[] = "/scripts";
ignore_dirs[] = "/build";
ignore_dirs[] = "/dev";
ignore_dirs[] = "/documents";
== Analyze project ==
php

View File

@ -461,15 +461,18 @@ if ($nboftargetok) {
print "Clean $BUILDROOT\n";
$ret=`rm -f $BUILDROOT/$PROJECT/.buildpath`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.cache`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.editorconfig`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.codeclimate`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.externalToolBuilders`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.git*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.project`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.pydevproject`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.settings`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.scrutinizer.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.stickler.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.travis.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.tx`;
$ret=`rm -f $BUILDROOT/$PROJECT/build.xml`;
$ret=`rm -f $BUILDROOT/$PROJECT/phpstan.neon`;
$ret=`rm -f $BUILDROOT/$PROJECT/pom.xml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/build/html`;

View File

@ -24,10 +24,10 @@
"vendor-dir" : "htdocs/includes"
},
"require" : {
"php" : ">=5.3.0",
"php" : ">=5.5.0",
"ext-curl" : "*",
"ckeditor/ckeditor" : "4.12.1",
"mike42/escpos-php" : "1.2.1",
"mike42/escpos-php" : "2.2",
"mobiledetect/mobiledetectlib" : "2.8.33",
"phpoffice/phpexcel" : "1.8.1",
"restler/framework" : "3.0.0-RC6",
@ -48,13 +48,12 @@
"ext-mssql" : "To use with MSSQL (experimental)",
"ext-pdo_sqlite" : "To use with SQLite (experimental)",
"ext-gd" : "Image manipulation (Required but maybe built-in PHP)",
"ext-imagick" : "Image manipulation (TCPDF)",
"ext-imagick" : "Generation of thumbs from PDF",
"ext-mcrypt" : "(Required but maybe built-in PHP)",
"ext-openssl" : "Secure connections (Emails, SOAP\u2026)",
"ext-mbstring" : "Handle non UTF-8 databases",
"ext-mbstring" : "Handle non UTF-8 characters",
"ext-soap" : "Native SOAP",
"ext-zip" : "ODT and Excel support",
"ext-xml" : "Excel support",
"firephp/firephp-core" : "Logging to Firebug console support"
"ext-zip" : "ODT, Excel and file compression support",
"ext-xml" : "Excel support"
}
}

3
htdocs/.gitignore vendored
View File

@ -16,9 +16,6 @@
/teclib*
/test.php
/ultimatepdf*
/lead
/dolimed*
/allscreens*
/ecommerce/
/cabinetmed*
/webmail*

View File

@ -24,12 +24,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy","salaries"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries"));
$mesg = '';
$action = GETPOST('action', 'aZ09');
@ -37,7 +37,7 @@ $cancel = GETPOST('cancel', 'alpha');
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
$massaction = GETPOST('massaction', 'aZ09');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'accountingaccountlist'; // To manage different context of search
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search
$search_account = GETPOST('search_account', 'alpha');
$search_label = GETPOST('search_label', 'alpha');
@ -58,10 +58,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield = "aa.account_number";
if (! $sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "aa.account_number";
if (!$sortorder) $sortorder = "ASC";
$arrayfields=array(
$arrayfields = array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
@ -78,27 +78,27 @@ $accounting = new AccountingAccount($db);
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha')) { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if (! empty($cancel)) $action = '';
if (!empty($cancel)) $action = '';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{
$search_account = "";
$search_label = "";
$search_accountparent = "";
$search_pcgtype = "";
$search_pcgsubtype = "";
$search_array_options=array();
$search_array_options = array();
}
if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax)))
@ -108,8 +108,8 @@ if (empty($reshook))
if ($chartofaccounts > 0)
{
// Get language code for this $chartofaccounts
$sql ='SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
$sql.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
$sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
$resql = $db->query($sql);
if ($resql)
{
@ -132,7 +132,7 @@ if (empty($reshook))
{
$offsetforchartofaccount += $reg[1];
}
$offsetforchartofaccount+=($conf->entity * 100000000);
$offsetforchartofaccount += ($conf->entity * 100000000);
$result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
@ -146,7 +146,7 @@ if (empty($reshook))
}
}
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
@ -179,12 +179,12 @@ if (empty($reshook))
* View
*/
$form=new Form($db);
$form = new Form($db);
llxHeader('', $langs->trans("ListAccounts"));
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
@ -192,11 +192,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS;
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity;
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity;
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = " . $conf->entity;
$sql .= " WHERE asy.rowid = " . $pcgver;
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
$sql .= " WHERE asy.rowid = ".$pcgver;
//print $sql;
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account);
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
@ -220,24 +220,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_account) $param.= '&search_account='.urlencode($search_account);
if ($search_label) $param.= '&search_label='.urlencode($search_label);
if ($search_accountparent) $param.= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param.= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param.= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
if ($optioncss != '') $param.='&optioncss='.$optioncss;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent);
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print '<!-- Add javascript to update a flag when we select "Change plan" -->
<script type="text/javascript">
@ -256,7 +256,7 @@ if ($resql)
</script>';
}
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -266,17 +266,17 @@ if ($resql)
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton.= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
// Box to select active chart of account
print $langs->trans("Selectchartofaccounts") . " : ";
print $langs->trans("Selectchartofaccounts")." : ";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " WHERE a.active = 1";
dol_syslog('accountancy/admin/account.php $sql='.$sql);
print $sql;
@ -287,9 +287,9 @@ if ($resql)
while ($i < $numbis) {
$obj = $db->fetch_object($resqlchart);
print '<option value="' . $obj->rowid . '"';
print '<option value="'.$obj->rowid.'"';
print ($pcgver == $obj->rowid) ? ' selected' : '';
print '>' . $obj->pcg_version . ' - ' . $obj->label . ' - (' . $obj->country_code . ')</option>';
print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
$i++;
}
@ -303,43 +303,43 @@ if ($resql)
print '<br>';
print '<br>';
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$moreforfilter = '';
$massactionbutton = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for search fields
print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
if (! empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
if (! empty($arrayfields['aa.account_parent']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="' . $search_accountparent . '"></td>';
if (! empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
if (! empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="'.$search_account.'"></td>';
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['aa.account_parent']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="'.$search_accountparent.'"></td>';
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="'.$search_pcgsubtype.'"></td>';
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']);
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$accountstatic = new AccountingAccount($db);
$accountparent = new AccountingAccount($db);
$i=0;
$i = 0;
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
@ -351,27 +351,27 @@ if ($resql)
print '<tr class="oddeven">';
// Account number
if (! empty($arrayfields['aa.account_number']['checked']))
if (!empty($arrayfields['aa.account_number']['checked']))
{
print "<td>";
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Account label
if (! empty($arrayfields['aa.label']['checked']))
if (!empty($arrayfields['aa.label']['checked']))
{
print "<td>";
print $obj->label;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Account parent
if (! empty($arrayfields['aa.account_parent']['checked']))
if (!empty($arrayfields['aa.account_parent']['checked']))
{
if (! empty($obj->account_parent))
if (!empty($obj->account_parent))
{
$accountparent->id = $obj->rowid2;
$accountparent->label = $obj->label2;
@ -380,63 +380,63 @@ if ($resql)
print "<td>";
print $accountparent->getNomUrl(1);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
else
{
print '<td>&nbsp;</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
}
// Chart of accounts type
if (! empty($arrayfields['aa.pcg_type']['checked']))
if (!empty($arrayfields['aa.pcg_type']['checked']))
{
print "<td>";
print $obj->pcg_type;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Chart of accounts subtype
if (! empty($arrayfields['aa.pcg_subtype']['checked']))
if (!empty($arrayfields['aa.pcg_subtype']['checked']))
{
print "<td>";
print $obj->pcg_subtype;
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Activated or not
if (! empty($arrayfields['aa.active']['checked']))
if (!empty($arrayfields['aa.active']['checked']))
{
print '<td>';
if (empty($obj->active)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Action
print '<td class="center">';
if ($user->rights->accounting->chartofaccount) {
print '<a href="./card.php?action=update&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print '<a href="./card.php?action=update&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="./card.php?action=delete&id=' . $obj->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id). '">';
print '<a href="./card.php?action=delete&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?chartofaccounts='.$object->id).'">';
print img_delete();
print '</a>';
}
print '</td>' . "\n";
if (! $i) $totalarray['nbfield']++;
print '</td>'."\n";
if (!$i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;

View File

@ -456,7 +456,7 @@ if ($id)
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
// Form to add a new line
if ($tabname[$id])

View File

@ -24,15 +24,15 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$error = 0;
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$mesg = '';
$action = GETPOST('action', 'aZ09');
@ -55,24 +55,24 @@ $object = new AccountingAccount($db);
if (GETPOST('cancel', 'alpha'))
{
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1);
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
header("Location: ".$urltogo);
exit;
}
if ($action == 'add' && $user->rights->accounting->chartofaccount)
{
if (! $cancel) {
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
if (!$cancel) {
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
$result = $db->query($sql);
$obj = $db->fetch_object($result);
// Clean code
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number', 'string');
}
@ -116,28 +116,28 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
if (! $error)
if (!$error)
{
setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
$urltogo=$backtopage?$backtopage:dol_buildpath('/accountancy/admin/account.php', 1);
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
header("Location: ".$urltogo);
exit;
}
}
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (! $cancel) {
if (!$cancel) {
$result = $object->fetch($id);
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
$result2 = $db->query($sql);
$obj = $db->fetch_object($result2);
// Clean code
// To manage zero or not at the end of the accounting account
if($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
{
$account_number = GETPOST('account_number', 'string');
}
@ -166,21 +166,21 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$result = $object->update($user);
if ($result > 0) {
$urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: " . $urltogo);
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo);
exit();
} else {
$mesg = $object->error;
}
} else {
$urltogo=$backtopage?$backtopage:($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: " . $urltogo);
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo);
exit();
}
} elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {
$result = $object->fetch($id);
if (! empty($object->id)) {
if (!empty($object->id)) {
$result = $object->delete($user);
if ($result > 0) {
@ -205,7 +205,7 @@ $formaccounting = new FormAccounting($db);
$accountsystem = new AccountancySystem($db);
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
$title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card');
$helpurl = '';
llxheader('', $title, $helpurl);
@ -214,50 +214,50 @@ llxheader('', $title, $helpurl);
if ($action == 'create') {
print load_fiche_titre($langs->trans('NewAccountingAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Chart of account
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("Chartofaccounts") . '</span></td>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Chartofaccounts").'</span></td>';
print '<td>';
print $accountsystem->ref;
print '</td></tr>';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $accountingaccount . '"></td></tr>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
print '<td><input name="account_number" size="30" value="'.$accountingaccount.'"></td></tr>';
// Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
print '<td><input name="label" size="70" value="' . $object->label . '"></td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"></td></tr>';
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
print '</td></tr>';
// Category
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Chart of acounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>';
@ -265,9 +265,9 @@ if ($action == 'create') {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -285,24 +285,24 @@ elseif ($id > 0 || $ref) {
{
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="edit">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"</td></tr>';
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
print '<td><input name="account_number" size="30" value="'.$object->account_number.'"</td></tr>';
// Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';
print '<td><input name="label" size="70" value="' . $object->label . '"</td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
print '<td><input name="label" size="70" value="'.$object->label.'"</td></tr>';
// Account parent
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td>';
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
print '</td></tr>';
@ -314,15 +314,15 @@ elseif ($id > 0 || $ref) {
print '</td></tr>';
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type'])?GETPOST('pcg_type', 'alpha'):$object->pcg_type).'">';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(isset($_POST['pcg_type']) ?GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Chart of accounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$object->pcg_subtype).'">';
print '<input type="text" name="pcg_subtype" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype']) ?GETPOST('pcg_subtype', 'alpha') : $object->pcg_subtype).'">';
print '</td></tr>';
print '</table>';
@ -330,15 +330,15 @@ elseif ($id > 0 || $ref) {
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
} else {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
@ -348,30 +348,30 @@ elseif ($id > 0 || $ref) {
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefield">' . $langs->trans("Label") . '</td>';
print '<td colspan="2">' . $object->label . '</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td>';
print '<td colspan="2">'.$object->label.'</td></tr>';
// Account parent
$accp = new AccountingAccount($db);
if (! empty($object->account_parent)) {
if (!empty($object->account_parent)) {
$accp->fetch($object->account_parent, '');
}
print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
print '<td colspan="2">'.$accp->account_number.' - '.$accp->label.'</td></tr>';
// Category
print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$object->account_category_label."</td>";
// Chart of accounts type
print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
print '<td colspan="2">' . $object->pcg_type . '</td></tr>';
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td colspan="2">'.$object->pcg_type.'</td></tr>';
// Chart of accounts subtype
print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
print '<td colspan="2">'.$object->pcg_subtype.'</td></tr>';
print '</table>';
@ -384,16 +384,16 @@ elseif ($id > 0 || $ref) {
*/
print '<div class="tabsAction">';
if (! empty($user->rights->accounting->chartofaccount)) {
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$id.'">'.$langs->trans('Modify').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
}
if (! empty($user->rights->accounting->chartofaccount)) {
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
if (!empty($user->rights->accounting->chartofaccount)) {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Delete').'</a>';
}
print '</div>';

View File

@ -23,14 +23,14 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$error = 0;
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$mesg = '';
$id = GETPOST('id', 'int');
@ -59,16 +59,16 @@ $accountingcategory = new AccountancyCategory($db);
*/
// si ajout de comptes
if (! empty($selectcpt)) {
if (!empty($selectcpt)) {
$cpts = array();
foreach ($selectcpt as $selectedoption) {
if (! array_key_exists($selectedoption, $cpts))
$cpts[$selectedoption] = "'" . $selectedoption . "'";
if (!array_key_exists($selectedoption, $cpts))
$cpts[$selectedoption] = "'".$selectedoption."'";
}
$return= $accountingcategory->updateAccAcc($cat_id, $cpts);
$return = $accountingcategory->updateAccAcc($cat_id, $cpts);
if ($return<0) {
if ($return < 0) {
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
} else {
setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
@ -98,35 +98,35 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?res
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback);
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="display">';
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Select the category
print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>';
print '<tr><td class="titlefield">'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Select").'">';
print '</td></tr>';
// Select the accounts
if (! empty($cat_id))
if (!empty($cat_id))
{
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors');
}
print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
print '<tr><td>'.$langs->trans("AddAccountFromBookKeepingWithNoCategories").'</td>';
print '<td>';
$arraykeyvalue=array();
foreach($accountingcategory->lines_cptbk as $key => $val)
$arraykeyvalue = array();
foreach ($accountingcategory->lines_cptbk as $key => $val)
{
$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte) . ' (' . $val->label_compte . ($val->doc_ref?' '.$val->doc_ref:'').')';
$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')';
}
if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
@ -139,7 +139,7 @@ if (! empty($cat_id))
print '</select><br>';
print ajax_combobox('cpt_bk');
*/
print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
print '<input class="button" type="submit" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
}
print '</td></tr>';
}
@ -158,8 +158,8 @@ if ($action == 'display' || $action == 'delete') {
print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
print "</tr>\n";
if (! empty($cat_id)) {
$return = $accountingcategory->display($cat_id); // This load ->lines_display
if (!empty($cat_id)) {
$return = $accountingcategory->display($cat_id); // This load ->lines_display
if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors');
}
@ -167,10 +167,10 @@ if ($action == 'display' || $action == 'delete') {
if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
foreach ($accountingcategory->lines_display as $cpt) {
print '<tr class="oddeven">';
print '<td>' . length_accountg($cpt->account_number) . '</td>';
print '<td>' . $cpt->label . '</td>';
print '<td>'.length_accountg($cpt->account_number).'</td>';
print '<td>'.$cpt->label.'</td>';
print '<td class="right">';
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=".$cat_id."&cptid=".$cpt->rowid."'>";
print $langs->trans("DeleteFromCat");
print img_picto($langs->trans("DeleteFromCat"), 'unlink');
print "</a>";

View File

@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("errors","admin","companies","resource","holiday","accountancy","hrm"));
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "accountancy", "hrm"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
$confirm=GETPOST('confirm', 'alpha');
$id=32;
$rowid=GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha');
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$id = 32;
$rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha');
// Security access
if (empty($user->rights->accounting->chartofaccount)) {
@ -50,15 +50,15 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ;
$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -71,52 +71,52 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(32);
$taborder = array(32);
// Name of SQL tables of dictionaries
$tabname=array();
$tabname[32]= MAIN_DB_PREFIX."c_accounting_category";
$tabname = array();
$tabname[32] = MAIN_DB_PREFIX."c_accounting_category";
// Dictionary labels
$tablib=array();
$tablib[32]= "DictionaryAccountancyCategory";
$tablib = array();
$tablib[32] = "DictionaryAccountancyCategory";
// Requests to extract data
$tabsql=array();
$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
$tabsql = array();
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[32]="position ASC";
$tabsqlsort = array();
$tabsqlsort[32] = "position ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield[32]= "code,label,range_account,category_type,formula,position,country";
$tabfield = array();
$tabfield[32] = "code,label,range_account,category_type,formula,position,country";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue[32]= "code,label,range_account,category_type,formula,position,country_id";
$tabfieldvalue = array();
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert[32]= "code,label,range_account,category_type,formula,position,fk_country";
$tabfieldinsert = array();
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid[32]= "";
$tabrowid = array();
$tabrowid[32] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[32]= ! empty($conf->accounting->enabled);
$tabcond = array();
$tabcond[32] = !empty($conf->accounting->enabled);
// List of help for fields
$tabhelp=array();
$tabhelp = array();
$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck = array();
$tabfieldcheck[32] = array();
// Complete all arrays with entries found into modules
@ -125,7 +125,7 @@ complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqls
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
$sourceList=array();
$sourceList = array();
@ -141,24 +141,24 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($value == 'formula' && empty($_POST['formula'])) continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue;
if ($value == 'country' || $value == 'country_id') continue;
if (! isset($_POST[$value]) || $_POST[$value]=='')
if (!isset($_POST[$value]) || $_POST[$value] == '')
{
$ok=0;
$fieldnamekey=$listfield[$f];
$ok = 0;
$fieldnamekey = $listfield[$f];
// We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note';
if ($fieldnamekey == 'type') $fieldnamekey = 'Type';
@ -170,23 +170,23 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
}
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
if ($_POST["code"] == '0')
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
}
if (! is_numeric(GETPOST('position', 'alpha')))
if (!is_numeric(GETPOST('position', 'alpha')))
{
$langs->loadLangs(array("errors"));
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha'))
@ -194,13 +194,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -209,32 +209,32 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",active)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'formula') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
$sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
@ -250,16 +250,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -270,18 +270,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'range_account') $sql.="null"; // For range_account, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@ -296,14 +296,14 @@ if (GETPOST('actioncancel', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -319,8 +319,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -339,8 +339,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -359,8 +359,8 @@ if ($action == $acts[1])
// favorite
if ($action == 'activate_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -379,8 +379,8 @@ if ($action == 'activate_favorite')
// disable favorite
if ($action == 'disable_favorite')
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
@ -402,13 +402,13 @@ if ($action == 'disable_favorite')
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader('', $langs->trans('DictionaryAccountancyCategory'));
$titre=$langs->trans($tablib[$id]);
$linkback='';
$titlepicto='title_setup';
$titre = $langs->trans($tablib[$id]);
$linkback = '';
$titlepicto = 'title_setup';
print load_fiche_titre($titre, $linkback, $titlepicto);
@ -417,7 +417,7 @@ print '<span class="opacitymedium">'.$langs->trans("AccountingAccountGroupsDesc"
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id>0?'&search_country_id='.$search_country_id:''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
//var_dump($elementList);
@ -427,36 +427,36 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql = $tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /', $sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
else $sql .= " WHERE ";
$sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
}
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset);
if ($sortfield == 'country') $sortfield = 'country_code';
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
//print $sql;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$alabelisused = 0;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -464,55 +464,55 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$class="left";
if ($fieldlist[$field]=='type') {
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left";
if ($fieldlist[$field] == 'type') {
if ($tabname[$id] == MAIN_DB_PREFIX."c_paiement") {
$valuetoshow=$form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
$valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, ''));
} else {
$valuetoshow=$langs->trans("Type");
$valuetoshow = $langs->trans("Type");
}
}
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='libelle_facture') {
$valuetoshow=$langs->trans("LabelOnDocuments");
if ($fieldlist[$field] == 'libelle_facture') {
$valuetoshow = $langs->trans("LabelOnDocuments");
}
if ($fieldlist[$field]=='country') {
$valuetoshow=$langs->trans("Country");
if ($fieldlist[$field] == 'country') {
$valuetoshow = $langs->trans("Country");
}
if ($fieldlist[$field]=='accountancy_code') {
$valuetoshow=$langs->trans("AccountancyCode");
if ($fieldlist[$field] == 'accountancy_code') {
$valuetoshow = $langs->trans("AccountancyCode");
}
if ($fieldlist[$field]=='accountancy_code_sell') {
$valuetoshow=$langs->trans("AccountancyCodeSell");
if ($fieldlist[$field] == 'accountancy_code_sell') {
$valuetoshow = $langs->trans("AccountancyCodeSell");
}
if ($fieldlist[$field]=='accountancy_code_buy') {
$valuetoshow=$langs->trans("AccountancyCodeBuy");
if ($fieldlist[$field] == 'accountancy_code_buy') {
$valuetoshow = $langs->trans("AccountancyCodeBuy");
}
if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') {
$valuetoshow=$langs->trans("Pcg_version");
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
$valuetoshow = $langs->trans("Pcg_version");
}
if ($fieldlist[$field]=='range_account') {
$valuetoshow=$langs->trans("Comment");
if ($fieldlist[$field] == 'range_account') {
$valuetoshow = $langs->trans("Comment");
}
if ($fieldlist[$field]=='category_type') {
$valuetoshow=$langs->trans("Calculated");
if ($fieldlist[$field] == 'category_type') {
$valuetoshow = $langs->trans("Calculated");
}
if ($valuetoshow != '') {
print '<td class="'.$class.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td>';
@ -533,14 +533,14 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
@ -552,42 +552,42 @@ if ($id)
print '</td>';
print "</tr>";
$colspan=count($fieldlist)+3;
$colspan = count($fieldlist) + 3;
if ($id == 32) $colspan++;
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
// Title line with search boxes
print '<tr class="liste_titre liste_titre_add liste_titre_filter">';
$filterfound=0;
$filterfound = 0;
foreach ($fieldlist as $field => $value)
{
$showfield=1; // By defaut
$showfield = 1; // By defaut
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
if ($showfield)
{
@ -610,7 +610,7 @@ if ($id)
print '<td class="liste_titre center">';
if ($filterfound)
{
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
}
print '</td>';
@ -622,80 +622,80 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$class="left";
$sortable=1;
$valuetoshow='';
$showfield = 1; // By defaut
$class = "left";
$sortable = 1;
$valuetoshow = '';
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='source') {
$valuetoshow=$langs->trans("Contact");
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'source') {
$valuetoshow = $langs->trans("Contact");
}
if ($fieldlist[$field]=='price') {
$valuetoshow=$langs->trans("PriceUHT");
if ($fieldlist[$field] == 'price') {
$valuetoshow = $langs->trans("PriceUHT");
}
if ($fieldlist[$field]=='taux') {
if ($fieldlist[$field] == 'taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") {
$valuetoshow=$langs->trans("Rate");
$valuetoshow = $langs->trans("Rate");
} else {
$valuetoshow=$langs->trans("Amount");
$valuetoshow = $langs->trans("Amount");
}
$class='center';
$class = 'center';
}
if ($fieldlist[$field]=='type') {
$valuetoshow=$langs->trans("Type");
if ($fieldlist[$field] == 'type') {
$valuetoshow = $langs->trans("Type");
}
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='country') {
$valuetoshow=$langs->trans("Country");
if ($fieldlist[$field] == 'country') {
$valuetoshow = $langs->trans("Country");
}
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
$showfield=0;
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
if ($fieldlist[$field]=='accountancy_code') {
$valuetoshow=$langs->trans("AccountancyCode");
if ($fieldlist[$field] == 'accountancy_code') {
$valuetoshow = $langs->trans("AccountancyCode");
}
if ($fieldlist[$field]=='accountancy_code_sell') {
$valuetoshow=$langs->trans("AccountancyCodeSell");
$sortable=0;
if ($fieldlist[$field] == 'accountancy_code_sell') {
$valuetoshow = $langs->trans("AccountancyCodeSell");
$sortable = 0;
}
if ($fieldlist[$field]=='accountancy_code_buy') {
$valuetoshow=$langs->trans("AccountancyCodeBuy");
$sortable=0;
if ($fieldlist[$field] == 'accountancy_code_buy') {
$valuetoshow = $langs->trans("AccountancyCodeBuy");
$sortable = 0;
}
if ($fieldlist[$field]=='fk_pcg_version') {
$valuetoshow=$langs->trans("Pcg_version");
if ($fieldlist[$field] == 'fk_pcg_version') {
$valuetoshow = $langs->trans("Pcg_version");
}
if ($fieldlist[$field]=='account_parent') {
$valuetoshow=$langs->trans("Accountsparent");
if ($fieldlist[$field] == 'account_parent') {
$valuetoshow = $langs->trans("Accountsparent");
}
if ($fieldlist[$field]=='pcg_type') {
$valuetoshow=$langs->trans("Pcg_type");
if ($fieldlist[$field] == 'pcg_type') {
$valuetoshow = $langs->trans("Pcg_type");
}
if ($fieldlist[$field]=='pcg_subtype') {
$valuetoshow=$langs->trans("Pcg_subtype");
if ($fieldlist[$field] == 'pcg_subtype') {
$valuetoshow = $langs->trans("Pcg_subtype");
}
if ($fieldlist[$field]=='type_template') {
$valuetoshow=$langs->trans("TypeOfTemplate");
if ($fieldlist[$field] == 'type_template') {
$valuetoshow = $langs->trans("TypeOfTemplate");
}
if ($fieldlist[$field]=='range_account') {
$valuetoshow=$langs->trans("Comment");
if ($fieldlist[$field] == 'range_account') {
$valuetoshow = $langs->trans("Comment");
}
if ($fieldlist[$field]=='category_type') {
$valuetoshow=$langs->trans("Calculated");
if ($fieldlist[$field] == 'category_type') {
$valuetoshow = $langs->trans("Calculated");
}
// Affiche nom du champ
if ($showfield) {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
@ -709,12 +709,12 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields
if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit');
@ -725,7 +725,7 @@ if ($id)
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
print '<td></td>';
@ -733,71 +733,71 @@ if ($id)
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$class="left";
$valuetoshow=$obj->{$fieldlist[$field]};
$showfield = 1;
$class = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'category_type')
{
$valuetoshow = yn($valuetoshow);
}
elseif ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
}
elseif ($fieldlist[$field]=='country') {
elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code))
{
$valuetoshow='-';
$valuetoshow = '-';
}
else
{
$key=$langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country);
$key = $langs->trans("Country".strtoupper($obj->country_code));
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
}
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') {
$key=$langs->trans("Country".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') {
$langs->loadLangs(array("propal"));
$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
$key = $langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') {
$key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') {
$key = $langs->trans("Action".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') {
$showfield=0;
elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
$class='tddict';
$class = 'tddict';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
// Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
if (isset($obj->code))
{
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; }
}
$canbemodified=$iserasable;
$canbemodified = $iserasable;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param;
$url.='&';
$url .= '&';
// Active
print '<td class="center" class="nowrap">';
@ -865,38 +865,38 @@ $db->close();
*/
function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form, $mysoc;
global $region_id;
global $elementList,$sourceList,$localtax_typeList;
global $elementList, $sourceList, $localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value)
{
if ($fieldlist[$field] == 'country')
{
print '<td>';
$fieldname='country';
$fieldname = 'country';
if ($context == 'add')
{
$fieldname='country_id';
$fieldname = 'country_id';
print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
}
else
{
print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:$mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
}
print '</td>';
}
elseif ($fieldlist[$field] == 'country_id')
{
if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{
$country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>';
@ -904,21 +904,21 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
}
elseif ($fieldlist[$field] == 'category_type') {
print '<td>';
print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1);
print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1);
print '</td>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size=''; $class='';
if ($fieldlist[$field]=='code') $class='maxwidth100';
if ($fieldlist[$field]=='position') $class='maxwidth50';
if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
$size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
if ($fieldlist[$field] == 'position') $class = 'maxwidth50';
if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent';
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>';
}
}

View File

@ -96,7 +96,7 @@ print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'
print '<input type="hidden" name="action" value="update">';
// Define main accounts for closure
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
foreach ($list_account_main as $key) {
print '<tr class="oddeven value">';

View File

@ -30,12 +30,12 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan"));
// Security check
if (empty($user->rights->accounting->chartofaccount))
@ -52,25 +52,40 @@ $list_account_main = array (
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
$list_account = array (
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_VAT_PAY_ACCOUNT',
'ACCOUNTING_ACCOUNT_SUSPENSE',
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'DONATION_ACCOUNTINGACCOUNT',
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT',
'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
);
$list_account = array ();
$list_account[] = '---Product---';
$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT';
if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT';
}
$list_account[] = 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT';
$list_account[] = '---Service---';
$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_ACCOUNT';
if ($mysoc->isInEEC()) {
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT';
}
$list_account[] = 'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT';
$list_account[] = '---Other---';
$list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT';
$list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT';
$list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE';
if ($conf->banque->enabled) {
$list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH';
}
if ($conf->don->enabled) {
$list_account[] = 'DONATION_ACCOUNTINGACCOUNT';
}
if ($conf->adherent->enabled) {
$list_account[] = 'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT';
}
if ($conf->loan->enabled) {
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
$list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
}
/*
* Actions
@ -82,12 +97,12 @@ if (GETPOST('change_chart', 'alpha'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');
if (! empty($chartofaccounts)) {
if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!empty($chartofaccounts)) {
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error ++;
$error++;
}
}
@ -103,7 +118,12 @@ if ($action == 'update') {
}
foreach ($list_account as $constname) {
$constvalue = GETPOST($constname, 'alpha');
$reg=array();
if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator
continue;
}
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
@ -133,27 +153,27 @@ print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_a
print '<span class="opacitymedium">'.$langs->trans("DefaultBindingDesc").'</span><br>';
print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
// Define main accounts for thirdparty
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
foreach ($list_account_main as $key) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
$keydesc=$key.'_Desc';
$keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext);
print '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
@ -167,25 +187,31 @@ print '<br>';
// Define default accounts
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
foreach ($list_account as $key) {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
$reg=array();
if (preg_match('/---(.*)---/', $key, $reg)) {
print '<tr class="liste_titre"><td>'.$langs->trans($reg[1]).'</td><td></td></tr>';
}
else {
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
// Value
print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
}
}
print "</table>\n";
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '</form>';

View File

@ -28,12 +28,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -57,7 +57,7 @@ $listformat = $configuration['format'];
$listcr = $configuration['cr'];
$model_option = array (
$model_option = array(
'1' => array(
'label' => 'ACCOUNTING_EXPORT_FORMAT',
'param' => $listformat,
@ -86,37 +86,37 @@ if ($action == 'update') {
$modelcsv = GETPOST('ACCOUNTING_EXPORT_MODELCSV', 'int');
if (! empty($modelcsv)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!empty($modelcsv)) {
if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
$error++;
}
//if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
// dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
//}
} else {
$error ++;
$error++;
}
foreach ($main_option as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
foreach ($listparam[$modelcsv] as $key => $value) {
$constante = $key;
if (strpos($constante, 'ACCOUNTING')!==false) {
if (strpos($constante, 'ACCOUNTING') !== false) {
$constvalue = GETPOST($key, 'alpha');
if (! dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
}
if (! $error) {
if (!$error) {
// reload
$configuration = AccountancyExport::getTypeConfig();
$listparam = $configuration['param'];
@ -138,7 +138,7 @@ $title = $langs->trans('ConfigAccountingExpert');
llxHeader('', $title);
$linkback='';
$linkback = '';
// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
@ -187,17 +187,17 @@ print ' });'."\n";
print '})'."\n";
print '</script>'."\n";
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
/*
* Main Options
*/
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('Options') . '</td>';
print '<td colspan="3">'.$langs->trans('Options').'</td>';
print "</tr>\n";
$num = count($main_option);
@ -207,11 +207,11 @@ if ($num) {
// Param
$label = $langs->trans($key);
print '<td width="50%">' . $label . '</td>';
print '<td width="50%">'.$label.'</td>';
// Value
print '<td>';
print '<input type="text" size="20" id="'.$key.'" name="' . $key . '" value="' . $conf->global->$key . '">';
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td></tr>';
}
}
@ -223,16 +223,16 @@ print "<br>\n";
/*
* Export model
*/
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
print '<td colspan="2">'.$langs->trans("Modelcsv").'</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
if (! $conf->use_javascript_ajax) {
print '<td width="50%">'.$langs->trans("Selectmodelcsv").'</td>';
if (!$conf->use_javascript_ajax) {
print '<td class="nowrap">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
@ -254,9 +254,9 @@ print "<br>\n";
$num2 = count($model_option);
if ($num2) {
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
foreach ($model_option as $key) {
@ -264,14 +264,14 @@ if ($num2) {
// Param
$label = $key['label'];
print '<td width="50%">' . $langs->trans($label) . '</td>';
print '<td width="50%">'.$langs->trans($label).'</td>';
// Value
print '<td>';
if (is_array($key['param'])) {
print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
} else {
print '<input type="text" size="20" id="'. $label .'" name="' . $key['label'] . '" value="' . $conf->global->$label . '">';
print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
}
print '</td></tr>';
@ -280,7 +280,7 @@ if ($num2) {
print "</table>\n";
}
print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'" name="button"></div>';
print '</form>';

View File

@ -22,13 +22,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
$action = GETPOST('action', 'aZ09');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -36,32 +36,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC";
if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field
if (!$sortorder) $sortorder = "ASC";
// Load translation files required by the page
$langs->loadLangs(array("admin","compta"));
$langs->loadLangs(array("admin", "compta"));
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year.
if (!$user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year.
accessforbidden();
$error = 0;
// List of status
static $tmpstatut2label = array (
static $tmpstatut2label = array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label = array (
$statut2label = array(
''
);
foreach ($tmpstatut2label as $key => $val)
$statut2label[$key] = $langs->trans($val);
$errors = array ();
$errors = array();
$object = new Fiscalyear($db);
@ -85,9 +85,9 @@ $helpurl = "";
llxHeader('', $title, $helpurl);
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
$sql .= " WHERE f.entity = " . $conf->entity;
$sql.=$db->order($sortfield, $sortorder);
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -102,7 +102,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
}
}
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result)
@ -112,7 +112,7 @@ if ($result)
$i = 0;
$addbutton.= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
$addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
$title = $langs->trans('AccountingPeriods');
@ -120,36 +120,36 @@ if ($result)
// Load attribute_label
print '<div class="div-table-responsive">';
print '<table class="tagtable liste" width="100%">';
print '<table class="tagtable liste centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("DateStart") . '</td>';
print '<td>' . $langs->trans("DateEnd") . '</td>';
print '<td class="center">' . $langs->trans("NumberOfAccountancyEntries") . '</td>';
print '<td class="center">' . $langs->trans("NumberOfAccountancyMovements") . '</td>';
print '<td class="right">' . $langs->trans("Statut") . '</td>';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("DateStart").'</td>';
print '<td>'.$langs->trans("DateEnd").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
print '<td class="right">'.$langs->trans("Statut").'</td>';
print '</tr>';
if ($num) {
$fiscalyearstatic = new Fiscalyear($db);
while ( $i < $num && $i < $max ) {
while ($i < $num && $i < $max) {
$obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid;
print '<tr class="oddeven">';
print '<td><a href="fiscalyear_card.php?id=' . $obj->rowid . '">' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '</a></td>';
print '<td class="left">' . $obj->label . '</td>';
print '<td class="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
print '<td class="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
print '<td class="center">' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td class="center">' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td class="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"), "technic").' '.$obj->rowid.'</a></td>';
print '<td class="left">'.$obj->label.'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
print '</tr>';
$i++;
}
} else {
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
print '</div>';

View File

@ -24,11 +24,11 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","compta"));
$langs->loadLangs(array("admin", "compta"));
// Security check
if ($user->socid > 0)
@ -43,11 +43,11 @@ $confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
// List of statut
static $tmpstatut2label = array (
static $tmpstatut2label = array(
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label = array (
$statut2label = array(
''
);
foreach ($tmpstatut2label as $key => $val)
@ -74,7 +74,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
}
elseif ($action == 'add') {
if (! GETPOST('cancel', 'alpha')) {
if (!GETPOST('cancel', 'alpha')) {
$error = 0;
$object->date_start = $date_start;
@ -85,14 +85,14 @@ elseif ($action == 'add') {
if (empty($object->date_start) && empty($object->date_end)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$error ++;
$error++;
}
if (empty($object->label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$error ++;
$error++;
}
if (! $error) {
if (!$error) {
$db->begin();
$id = $object->create($user);
@ -100,7 +100,7 @@ elseif ($action == 'add') {
if ($id > 0) {
$db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
} else {
$db->rollback();
@ -119,7 +119,7 @@ elseif ($action == 'add') {
// Update record
elseif ($action == 'update') {
if (! GETPOST('cancel', 'alpha')) {
if (!GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id);
$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
@ -130,13 +130,13 @@ elseif ($action == 'update') {
$result = $object->update($user);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit();
}
}
@ -149,7 +149,7 @@ elseif ($action == 'update') {
$form = new Form($db);
$title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card");
$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card");
$helpurl = "";
llxHeader("", $title, $helpurl);
@ -157,24 +157,24 @@ if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input name="label" size="32" value="' . GETPOST('label', 'alpha') . '"></td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="32" value="'.GETPOST('label', 'alpha').'"></td></tr>';
// Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear');
print '</td></tr>';
// Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend');
print '</td></tr>';
@ -192,9 +192,9 @@ if ($action == 'create')
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -206,36 +206,36 @@ if ($action == 'create')
if ($action == 'edit') {
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="' . $id . '">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Ref
print "<tr>";
print '<td class="titlefieldcreate titlefield">' . $langs->trans("Ref") . '</td><td>';
print '<td class="titlefieldcreate titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref;
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td>';
print '<input name="label" class="flat" size="32" value="' . $object->label . '">';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
print '<input name="label" class="flat" size="32" value="'.$object->label.'">';
print '</td></tr>';
// Date start
print '<tr><td class="fieldrequired">' . $langs->trans("DateStart") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear');
print '</td></tr>';
// Date end
print '<tr><td class="fieldrequired">' . $langs->trans("DateEnd") . '</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
print '</td></tr>';
// Statut
print '<tr><td>' . $langs->trans("Statut") . '</td><td>';
print '<tr><td>'.$langs->trans("Statut").'</td><td>';
// print $form->selectarray('statut', $statut2label, $object->statut);
print $object->getLibStatut(4);
print '</td></tr>';
@ -243,9 +243,9 @@ if ($action == 'create')
print '</table>';
print '<br><div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -256,17 +256,17 @@ if ($action == 'create')
* Confirm delete
*/
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
}
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
$linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/fiscalyear.php">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/fiscalyear.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td width="50%">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td width="50%">';
print $object->ref;
print '</td><td>';
print $linkback;
@ -294,20 +294,20 @@ if ($action == 'create')
print '</td></tr>';
// Statut
print '<tr><td>' . $langs->trans("Status") . '</td><td colspan="2">' . $object->getLibStatut(4) . '</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(4).'</td></tr>';
print "</table>";
dol_fiche_end();
if (! empty($user->rights->accounting->fiscalyear->write))
if (!empty($user->rights->accounting->fiscalyear->write))
{
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';

View File

@ -29,11 +29,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","admin","accountancy"));
$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -44,9 +44,9 @@ if (empty($user->rights->accounting->chartofaccount))
$action = GETPOST('action', 'aZ09');
// Parameters ACCOUNTING_* and others
$list = array (
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT' ,
'ACCOUNTING_LENGTH_AACCOUNT',
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);
@ -62,13 +62,13 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' :
if ($action == 'update') {
$error = 0;
if (! $error)
if (!$error)
{
foreach ($list as $constname)
{
$constvalue = GETPOST($constname, 'alpha');
if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
@ -77,7 +77,7 @@ if ($action == 'update') {
}
}
if (! $error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
}
@ -85,10 +85,10 @@ if ($action == 'update') {
if ($action == 'setlistsorttodo') {
$setlistsorttodo = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (!$res > 0)
$error++;
if (! $error) {
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -98,9 +98,9 @@ if ($action == 'setlistsorttodo') {
if ($action == 'setlistsortdone') {
$setlistsortdone = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -110,9 +110,9 @@ if ($action == 'setlistsortdone') {
if ($action == 'setmanagezero') {
$setmanagezero = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -122,9 +122,9 @@ if ($action == 'setmanagezero') {
if ($action == 'setdisabledirectinput') {
$setdisabledirectinput = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -134,9 +134,9 @@ if ($action == 'setdisabledirectinput') {
if ($action == 'setenabledraftexport') {
$setenabledraftexport = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -146,9 +146,9 @@ if ($action == 'setenabledraftexport') {
if ($action == 'setenablesubsidiarylist') {
$setenablesubsidiarylist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
if (! $error) {
if (!$res > 0)
$error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'mesgs');
@ -159,20 +159,20 @@ if ($action == 'setenablesubsidiarylist') {
* View
*/
$title= $langs->trans('ConfigAccountingExpert');
$title = $langs->trans('ConfigAccountingExpert');
llxHeader('', $title);
$linkback='';
$linkback = '';
//$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy');
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
// Default mode for calculating turnover (parameter ACCOUNTING_MODE)
/*
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
@ -202,87 +202,87 @@ print '<br>';
// Others params
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
print '<td colspan="2">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
if (! empty($user->admin))
if (!empty($user->admin))
{
// TO DO Mutualize code for yes/no constants
print '<tr class="oddeven">';
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsorttodo&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setlistsortdone&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . '</td>';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").'</td>';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenabledraftexport&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisabledirectinput&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . '</td>';
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=0">';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setenablesubsidiarylist&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setmanagezero&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
@ -295,14 +295,14 @@ foreach ($list as $key)
{
print '<tr class="oddeven value">';
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
// Param
$label = $langs->trans($key);
print '<td>'.$label.'</td>';
// Value
print '<td class="right">';
print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
print '<input type="text" class="maxwidth100" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td>';
print '</tr>';
@ -311,7 +311,7 @@ foreach ($list as $key)
print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '<br>';
print '<br>';

View File

@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","compta","accountancy"));
$langs->loadLangs(array("admin", "compta", "accountancy"));
$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view';
$confirm=GETPOST('confirm', 'alpha');
$id=35;
$rowid=GETPOST('rowid', 'alpha');
$code=GETPOST('code', 'alpha');
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
$confirm = GETPOST('confirm', 'alpha');
$id = 35;
$rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha');
// Security access
if (empty($user->rights->accounting->chartofaccount))
@ -51,19 +51,19 @@ $acts[1] = "disable";
$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off');
$actl[1] = img_picto($langs->trans("Activated"), 'switch_on');
$listoffset=GETPOST('listoffset', 'alpha');
$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000;
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000;
$active = 1;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page ;
$offset = $listlimit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (empty($sortfield)) $sortfield='code';
if (empty($sortorder)) $sortorder='ASC';
if (empty($sortfield)) $sortfield = 'code';
if (empty($sortorder)) $sortorder = 'ASC';
$error = 0;
@ -74,52 +74,52 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(35);
$taborder = array(35);
// Name of SQL tables of dictionaries
$tabname=array();
$tabname[35]= MAIN_DB_PREFIX."accounting_journal";
$tabname = array();
$tabname[35] = MAIN_DB_PREFIX."accounting_journal";
// Dictionary labels
$tablib=array();
$tablib[35]= "DictionaryAccountancyJournal";
$tablib = array();
$tablib[35] = "DictionaryAccountancyJournal";
// Requests to extract data
$tabsql=array();
$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
$tabsql = array();
$tabsql[35] = "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a";
// Criteria to sort dictionaries
$tabsqlsort=array();
$tabsqlsort[35]="code ASC";
$tabsqlsort = array();
$tabsqlsort[35] = "code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
$tabfield[35]= "code,label,nature";
$tabfield = array();
$tabfield[35] = "code,label,nature";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
$tabfieldvalue[35]= "code,label,nature";
$tabfieldvalue = array();
$tabfieldvalue[35] = "code,label,nature";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
$tabfieldinsert[35]= "code,label,nature";
$tabfieldinsert = array();
$tabfieldinsert[35] = "code,label,nature";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
// "nameoffield" if id field is not "rowid" or has not autoincrement on
$tabrowid=array();
$tabrowid[35]= "";
$tabrowid = array();
$tabrowid[35] = "";
// Condition to show dictionary in setup page
$tabcond=array();
$tabcond[35]= ! empty($conf->accounting->enabled);
$tabcond = array();
$tabcond[35] = !empty($conf->accounting->enabled);
// List of help for fields
$tabhelp=array();
$tabhelp = array();
$tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
$tabfieldcheck = array();
$tabfieldcheck[35] = array();
// Complete all arrays with entries found into modules
@ -151,25 +151,25 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x',
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
{
$listfield=explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert=explode(',', $tabfieldinsert[$id]);
$listfieldmodify=explode(',', $tabfieldinsert[$id]);
$listfieldvalue=explode(',', $tabfieldvalue[$id]);
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
$ok = 1;
foreach ($listfield as $f => $value)
{
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal';
}
// Other checks
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
if ($_POST["code"] == '0')
{
$ok=0;
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
@ -178,16 +178,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
}
if (! GETPOST('label', 'alpha'))
if (!GETPOST('label', 'alpha'))
{
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$ok=0;
$ok = 0;
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha'))
@ -195,13 +195,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
$newid = ($obj->newid + 1);
} else {
dol_print_error($db);
}
@ -210,34 +210,34 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active,entity)";
$sql.= " VALUES(";
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $tabrowid[$id].",";
$sql .= $tabfieldinsert[$id];
$sql .= ",active,entity)";
$sql .= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert))
$sql.= $newid.",";
$i=0;
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
$sql .= $newid.",";
$i = 0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1,".$conf->entity.")";
$sql .= ",1,".$conf->entity.")";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
@ -253,16 +253,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify))
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
@ -273,19 +273,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
if ($i) $sql .= ",";
$sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
$sql .= " WHERE ".$rowidcol." = '".$rowid."'";
$sql .= " AND entity = ".$conf->entity;
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->error(), null, 'errors');
}
@ -300,15 +300,15 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
@ -324,8 +324,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
@ -333,7 +333,7 @@ if ($action == $acts[0])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -345,8 +345,8 @@ if ($action == $acts[0])
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; }
else { $rowidcol = "rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
@ -354,7 +354,7 @@ if ($action == $acts[1])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -369,16 +369,16 @@ if ($action == $acts[1])
*/
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
llxHeader();
$titre=$langs->trans("DictionarySetup");
$linkback='';
$titre = $langs->trans("DictionarySetup");
$linkback = '';
if ($id)
{
$titre.=' - '.$langs->trans($tablib[$id]);
$titlepicto='title_accountancy';
$titre .= ' - '.$langs->trans($tablib[$id]);
$titlepicto = 'title_accountancy';
}
print load_fiche_titre($titre, $linkback, $titlepicto);
@ -387,7 +387,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
}
//var_dump($elementList);
@ -397,29 +397,29 @@ if ($action == 'delete')
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
$sql.= " WHERE a.entity = ".$conf->entity;
$sql = $tabsql[$id];
$sql .= " WHERE a.entity = ".$conf->entity;
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($listlimit+1, $offset);
if ($sortfield == 'country') $sortfield = 'country_code';
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset);
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$alabelisused = 0;
$fieldlist=explode(',', $tabfield[$id]);
$fieldlist = explode(',', $tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
@ -427,27 +427,27 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$class="left";
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left";
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='nature') {
$valuetoshow=$langs->trans("NatureOfJournal");
if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal");
}
if ($valuetoshow != '') {
print '<td class="'.$class.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
}
print '<td>';
@ -468,14 +468,14 @@ if ($id)
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
$obj->$val = GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
@ -487,31 +487,31 @@ if ($id)
print '</td>';
print "</tr>";
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch.= '&from='.GETPOST('from', 'alpha');
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td class="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>';
}
@ -536,10 +536,10 @@ if ($id)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$class="left";
$sortable=1;
$valuetoshow='';
$showfield = 1; // By defaut
$class = "left";
$sortable = 1;
$valuetoshow = '';
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
@ -547,24 +547,24 @@ if ($id)
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='code') {
$valuetoshow=$langs->trans("Code");
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code");
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label");
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label");
}
if ($fieldlist[$field]=='nature') {
$valuetoshow=$langs->trans("NatureOfJournal");
if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal");
}
// Affiche nom du champ
if ($showfield) {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "", $sortfield, $sortorder, $class.' ');
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' ');
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
@ -578,12 +578,12 @@ if ($id)
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
{
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields
if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
@ -593,44 +593,44 @@ if ($id)
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '</td>';
}
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook))
{
$langs->load("accountancy");
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$class="left";
$valuetoshow=$obj->{$fieldlist[$field]};
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
$showfield = 1;
$class = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
}
elseif ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]});
elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$key = $langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
}
elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow=$langs->trans($obj->label);
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow = $langs->trans($obj->label);
}
$class='tddict';
$class = 'tddict';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
// Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
if (isset($obj->code) && $id != 10) {
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
$iserasable = 0;
@ -644,11 +644,11 @@ if ($id)
}
}
$canbemodified=$iserasable;
$canbemodified = $iserasable;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param;
$url.='&';
$url .= '&';
// Active
print '<td class="nowrap center">';
@ -708,10 +708,10 @@ $db->close();
*/
function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
{
global $conf,$langs,$db;
global $conf, $langs, $db;
global $form, $mysoc;
global $region_id;
global $elementList,$sourceList,$localtax_typeList;
global $elementList, $sourceList, $localtax_typeList;
global $bc;
$formadmin = new FormAdmin($db);
@ -722,20 +722,20 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
if ($fieldlist[$field] == 'nature')
{
print '<td>';
print $form->selectarray('nature', $sourceList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''));
print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
print '</td>';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td><input type="text" class="flat minwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
print '<td><input type="text" class="flat minwidth100" value="'.(!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
}
else
{
print '<td>';
$size=''; $class='';
if ($fieldlist[$field]=='code') $class='maxwidth100';
if ($fieldlist[$field]=='label') $class='quatrevingtpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" ';
print '<input type="text" '.$size.'class="flat'.($class?' '.$class:'').'" value="'.(isset($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
$size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
if ($fieldlist[$field] == 'label') $class = 'quatrevingtpercent';
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>';
}
}

View File

@ -26,22 +26,22 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies","compta","accountancy","products"));
$langs->loadLangs(array("companies", "compta", "accountancy", "products"));
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
// search & action GETPOST
@ -60,6 +60,8 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_current_account = GETPOST('search_current_account', 'alpha');
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount';
$search_onsell = GETPOST('search_onsell', 'alpha');
$search_onpurchase = GETPOST('search_onpurchase', 'alpha');
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount', 'alpha');
@ -75,23 +77,23 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="p.ref";
if (! $sortorder) $sortorder="ASC";
if (!$sortfield) $sortfield = "p.ref";
if (!$sortorder) $sortorder = "ASC";
if (empty($action)) $action='list';
if (empty($action)) $action = 'list';
$arrayfields=array();
$arrayfields = array();
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Purge search criteria
@ -100,16 +102,18 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_ref = '';
$search_label = '';
$search_desc = '';
$search_onsell = '';
$search_onpurchase = '';
$search_current_account = '';
$search_current_account_valid = '-1';
}
// Sales or Purchase mode ?
if ($action == 'update') {
if (! empty($btn_changetype)) {
if (!empty($btn_changetype)) {
$error = 0;
$accounting_product_modes = array (
$accounting_product_modes = array(
'ACCOUNTANCY_SELL',
'ACCOUNTANCY_SELL_INTRA',
'ACCOUNTANCY_SELL_EXPORT',
@ -117,17 +121,17 @@ if ($action == 'update') {
);
if (in_array($accounting_product_mode, $accounting_product_modes)) {
if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error ++;
if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error ++;
$error++;
}
}
if (! empty($btn_changeaccount)) {
if (!empty($btn_changeaccount)) {
//$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
if (! empty($chk_prod)) {
if (!empty($chk_prod)) {
$accounting = new AccountingAccount($db);
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
@ -136,37 +140,37 @@ if ($action == 'update') {
$cpt = 0; $ok = 0; $ko = 0;
foreach ($chk_prod as $productid)
{
$accounting_account_id = GETPOST('codeventil_' . $productid);
$accounting_account_id = GETPOST('codeventil_'.$productid);
$result = 0;
if ($accounting_account_id > 0)
{
$arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id;
$arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
$result = $accounting->fetch($accounting_account_id, null, 1);
}
if ($result <= 0) {
// setEventMessages(null, $accounting->errors, 'errors');
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++;
} else {
$db->begin();
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
$sql = " UPDATE ".MAIN_DB_PREFIX."product";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " SET accountancy_code_buy = " . $accounting->account_number;
$sql .= " SET accountancy_code_buy = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$sql .= " SET accountancy_code_sell = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$sql .= " SET accountancy_code_sell_export = " . $accounting->account_number;
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
}
$sql .= " WHERE rowid = " . $productid;
$sql .= " WHERE rowid = ".$productid;
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql))
{
$ok++;
@ -196,12 +200,14 @@ $form = new FormAccounting($db);
// Default AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first
// so we need to get those the rowid of those default value first
$accounting = new AccountingAccount($db);
// TODO: we should need to check if result is already exists accountaccount rowid.....
$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1);
$aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1);
$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
$aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1);
$aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1);
@ -209,6 +215,8 @@ $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_P
$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_export = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
@ -219,7 +227,9 @@ $pcgverid = $conf->global->CHARTOFACCOUNTS;
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
if (empty($pcgvercode)) $pcgvercode=$pcgverid;
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,";
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,";
$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,";
$sql.= " p.tms, p.fk_product_type as product_type,";
$sql.= " aa.rowid as aaid";
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
@ -236,7 +246,7 @@ elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
}
else
{
$sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
$sql.=" p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
}
$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
@ -276,6 +286,9 @@ if (strlen(trim($search_label))) {
if (strlen(trim($search_desc))) {
$sql .= natural_search("p.description", $search_desc);
}
if ($search_onsell != '' && $search_onsell != '-1') $sql.= natural_search('p.tosell', $search_onsell, 1);
if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql.= natural_search('p.tobuy', $search_onpurchase, 1);
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
@ -292,24 +305,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid);
if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -325,7 +338,7 @@ if ($result)
print '<br>';
// Select mode
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
print "</tr>\n";
@ -369,9 +382,13 @@ if ($result)
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
// On sell
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print '<td class="liste_titre"></td>';
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
print '<td class="liste_titre">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>';
}
// On buy
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print '<td class="liste_titre"></td>';
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print '<td class="liste_titre">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>';
}
// Current account
print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_current_account" id="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">';
@ -389,6 +406,7 @@ if ($result)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
// On sell / On purchase
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount="p.accountancy_code_sell";
@ -424,20 +442,45 @@ if ($result)
$product_static->status = $obj->tosell;
$product_static->status_buy = $obj->tobuy;
if ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
} elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
} elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
} else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
// Sales
if ($obj->product_type == 0) {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
}
else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
}
}
else {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
}
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
}
else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell;
}
}
// Purchases
if ($obj->product_type == 0) {
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodbuy_id = $aarowid_prodbuy;
@ -454,13 +497,13 @@ if ($result)
print '<td class="left">'.$obj->label.'</td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
{
// TODO ADJUST DESCRIPTION SIZE
// print '<td class="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size
$trunclengh = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print '<td>' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
print '<td>'.nl2br(dol_trunc($obj->description, $trunclengh)).'</td>';
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
@ -486,7 +529,7 @@ if ($result)
}
print '</td>';
// Dedicated account
// New account to set
$defaultvalue='';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// Accounting account buy

View File

@ -28,12 +28,12 @@
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09');
if (GETPOST("exportcsv", 'alpha')) $action = 'export_csv';
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -75,18 +75,18 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
if (empty($search_date_start) && ! GETPOSTISSET('formfilteraction'))
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
{
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1);
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -105,26 +105,26 @@ if ($sortfield == "")
$sortfield = "t.numero_compte";
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$filter = array ();
if (! empty($search_date_start)) {
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
$param .= '&amp;date_startmonth='.GETPOST('date_startmonth', 'int').'&amp;date_startday='.GETPOST('date_startday', 'int').'&amp;date_startyear='.GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
$param .= '&amp;date_endmonth='.GETPOST('date_endmonth', 'int').'&amp;date_endday='.GETPOST('date_endday', 'int').'&amp;date_endyear='.GETPOST('date_endyear', 'int');
}
if (! empty($search_accountancy_code_start)) {
if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
$param .= '&amp;search_accountancy_code_start='.$search_accountancy_code_start;
}
if (! empty($search_accountancy_code_end)) {
if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&amp;search_accountancy_code_end=' . $search_accountancy_code_end;
$param .= '&amp;search_accountancy_code_end='.$search_accountancy_code_end;
}
/*
@ -151,7 +151,7 @@ if ($action == 'export_csv')
$filename = 'balance';
$type_export = 'balance';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter);
if ($result < 0) {
@ -160,11 +160,11 @@ if ($action == 'export_csv')
foreach ($object->lines as $line)
{
print length_accountg($line->numero_compte) . $sep;
print $object->get_compte_desc($line->numero_compte) . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print price($line->debit - $line->credit) . $sep;
print length_accountg($line->numero_compte).$sep;
print $object->get_compte_desc($line->numero_compte).$sep;
print price($line->debit).$sep;
print price($line->credit).$sep;
print price($line->debit - $line->credit).$sep;
print "\n";
}
@ -203,20 +203,20 @@ if ($action != 'export_csv')
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$button = '<input type="submit" name="exportcsv" class="butAction" value="' . $langs->trans("Export") . ' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
$button = '<input type="submit" name="exportcsv" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
$moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateStart') . ': ';
$moreforfilter .= $form->selectDate($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd') . ': ';
$moreforfilter .= $form->selectDate($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateStart').': ';
$moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
$moreforfilter .= $langs->trans('DateEnd').': ';
$moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
$moreforfilter .= '</div>';
if (! empty($moreforfilter)) {
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
$parameters = array();
@ -225,7 +225,7 @@ if ($action != 'export_csv')
print '</div>';
}
print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
@ -236,7 +236,7 @@ if ($action != 'export_csv')
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
print '</td>';
print '<td class="liste_titre right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
@ -265,7 +265,7 @@ if ($action != 'export_csv')
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte);
if (empty($description)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
}
print '<tr class="oddeven">';
@ -291,12 +291,12 @@ if ($action != 'export_csv')
// $object->get_compte_racine($line->numero_compte);
print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . $description . '</td>';
print '<td class="nowraponall right">' . price($line->debit) . '</td>';
print '<td class="nowraponall right">' . price($line->credit) . '</td>';
print '<td class="nowraponall right">' . price($line->debit - $line->credit) . '</td>';
print '<td class="center">' . $link;
print '<td>'.length_accountg($line->numero_compte).'</td>';
print '<td>'.$description.'</td>';
print '<td class="nowraponall right">'.price($line->debit).'</td>';
print '<td class="nowraponall right">'.price($line->credit).'</td>';
print '<td class="nowraponall right">'.price($line->debit - $line->credit).'</td>';
print '<td class="center">'.$link;
print '</td>';
print "</tr>\n";
@ -305,11 +305,11 @@ if ($action != 'export_csv')
$sous_total_credit += $line->credit;
}
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("SubTotal") . ':</td><td class="nowrap right">' . price($sous_total_debit) . '</td><td class="nowrap right">' . price($sous_total_credit) . '</td><td class="nowrap right">' . price(price2num($sous_total_debit - $sous_total_credit)) . '</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';
print '<tr class="liste_total"><td class="right" colspan="2">' . $langs->trans("AccountBalance") . ':</td><td class="nowrap right">' . price($total_debit) . '</td><td class="nowrap right">' . price($total_credit) . '</td><td class="nowrap right">' . price(price2num($total_debit - $total_credit)) . '</td>';
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_debit - $total_credit)).'</td>';
print "<td>&nbsp;</td>\n";
print '</tr>';

View File

@ -26,11 +26,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other"));
$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
// Filter
$year = GETPOST("year", 'int');
@ -49,17 +49,17 @@ if ($year == 0) {
llxHeader('', $langs->trans("Bookkeeping"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("AccountBalanceByMonth") . ' ' . $textprevyear . ' ' . $langs->trans("Year") . ' ' . $year_start . ' ' . $textnextyear);
print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear);
$sql = "SELECT count(*) FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " , " . MAIN_DB_PREFIX . "facture as f";
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql=' . $sql);
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
@ -70,12 +70,12 @@ if ($result) {
$y = $year_current;
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width=150>' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i++)
print '<td width=150>'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++)
{
print '<td class="right">' . $langs->trans("MonthShort".sprintf("%02s", $i)) . '</td>';
print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
}
print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
print '</tr>';
@ -94,9 +94,9 @@ $sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE bk.doc_date >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND bk.doc_date <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
$sql .= " GROUP BY bk.numero_compte";
$resql = $db->query($sql);
@ -104,26 +104,26 @@ if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ( $i < $num ) {
while ($i < $num) {
$row = $db->fetch_row($resql);
print '<tr class="oddeven"><td width="14%">' . length_accountg($row[0]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[1]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[2]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[3]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[4]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[5]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[6]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[7]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[8]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[9]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[10]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[11]) . '</td>';
print '<td class="right" width="6.5%">' . price($row[12]) . '</td>';
print '<td class="right" width="8%"><strong>' . price($row[13]) . '</strong></td>';
print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>';
print '<td class="right" width="6.5%">'.price($row[1]).'</td>';
print '<td class="right" width="6.5%">'.price($row[2]).'</td>';
print '<td class="right" width="6.5%">'.price($row[3]).'</td>';
print '<td class="right" width="6.5%">'.price($row[4]).'</td>';
print '<td class="right" width="6.5%">'.price($row[5]).'</td>';
print '<td class="right" width="6.5%">'.price($row[6]).'</td>';
print '<td class="right" width="6.5%">'.price($row[7]).'</td>';
print '<td class="right" width="6.5%">'.price($row[8]).'</td>';
print '<td class="right" width="6.5%">'.price($row[9]).'</td>';
print '<td class="right" width="6.5%">'.price($row[10]).'</td>';
print '<td class="right" width="6.5%">'.price($row[11]).'</td>';
print '<td class="right" width="6.5%">'.price($row[12]).'</td>';
print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>';
print '</tr>';
$i ++;
$i++;
}
$db->free($resql);
} else {

View File

@ -26,23 +26,23 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy", "bills", "compta"));
$action = GETPOST('action', 'aZ09');
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
$id = GETPOST('id', 'int'); // id of record
$mode = GETPOST('mode', 'aZ09'); // '' or 'tmp'
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
// Security check
if ($user->socid > 0) {
@ -66,14 +66,14 @@ $subledger_account = GETPOST('subledger_account', 'alphanohtml');
if ($subledger_account == - 1) {
$subledger_account = null;
}
$label_operation= GETPOST('label_operation', 'alphanohtml');
$label_operation = GETPOST('label_operation', 'alphanohtml');
$debit = price2num(GETPOST('debit', 'alpha'));
$credit = price2num(GETPOST('credit', 'alpha'));
$save = GETPOST('save', 'alpha');
if (! empty($save)) $action = 'add';
if (!empty($save)) $action = 'add';
$update = GETPOST('update', 'alpha');
if (! empty($update)) $action = 'confirm_update';
if (!empty($update)) $action = 'confirm_update';
$object = new BookKeeping($db);
@ -88,16 +88,16 @@ if ($action == "confirm_update") {
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
$error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action='update';
$action = 'update';
}
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action='update';
$action = 'update';
}
if (! $error)
if (!$error)
{
$object = new BookKeeping($db);
@ -109,7 +109,7 @@ if ($action == "confirm_update") {
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation;
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
@ -147,22 +147,22 @@ elseif ($action == "add") {
{
$error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action='';
$action = '';
}
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
{
$error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action='';
$action = '';
}
if (! $error) {
if (!$error) {
$object = new BookKeeping($db);
$object->numero_compte = $accountingaccount_number;
$object->subledger_account = $subledger_account;
$object->label_compte = $accountingaccount_label;
$object->label_operation= $label_operation;
$object->label_operation = $label_operation;
$object->debit = $debit;
$object->credit = $credit;
$object->doc_date = GETPOST('doc_date', 'alpha');
@ -223,18 +223,18 @@ elseif ($action == "confirm_create") {
$object = new BookKeeping($db);
if (! $journal_code || $journal_code == '-1') {
if (!$journal_code || $journal_code == '-1') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
$action='create';
$action = 'create';
$error++;
}
if (! GETPOST('next_num_mvt', 'alpha'))
if (!GETPOST('next_num_mvt', 'alpha'))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
$error++;
}
if (! $error)
if (!$error)
{
$object->label_compte = '';
$object->debit = 0;
@ -258,7 +258,7 @@ elseif ($action == "confirm_create") {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
$action = 'update';
$id=$object->id;
$id = $object->id;
$piece_num = $object->piece_num;
}
}
@ -329,7 +329,7 @@ llxHeader('', $langs->trans("CreateMvts"));
// Confirmation to delete the command
if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
print $formconfirm;
}
@ -345,16 +345,16 @@ if ($action == 'create')
dol_print_error('', 'Failed to get next piece number');
}
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<input type="hidden" name="mode" value="_tmp">' . "\n";
print '<input type="hidden" name="action" value="confirm_create">'."\n";
print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
print '<input type="hidden" name="mode" value="_tmp">'."\n";
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
/*print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>';
@ -362,19 +362,19 @@ if ($action == 'create')
print '</tr>';*/
print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Docdate") . '</td>';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Docdate").'</td>';
print '<td>';
print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . '</td>';
print '<td class="fieldrequired">'.$langs->trans("Codejournal").'</td>';
print '<td>'.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'</td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Piece") . '</td>';
print '<td>'.$langs->trans("Piece").'</td>';
print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
print '</tr>';
@ -390,9 +390,9 @@ if ($action == 'create')
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">';
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" value="' . $langs->trans("Cancel") . '" class="button" onclick="history.go(-1)" />';
print '<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)" />';
print '</div>';
print '</form>';
@ -403,15 +403,15 @@ if ($action == 'create')
setEventMessages($object->error, $object->errors, 'errors');
}
if (! empty($object->piece_num))
if (!empty($object->piece_num))
{
$backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">' . $langs->trans('BackToList') . '</a>';
$backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
$head=array();
$h=0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode?'&mode='.$mode:'');
$head = array();
$h = 0;
$head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : '');
$head[$h][1] = $langs->trans("Transaction");
$head[$h][2] = 'transaction';
$h++;
@ -428,8 +428,8 @@ if ($action == 'create')
// Account movement
print '<tr>';
print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $object->piece_num . '</td>';
print '<td class="titlefield">'.$langs->trans("NumMvts").'</td>';
print '<td>'.$object->piece_num.'</td>';
print '</tr>';
// Date
@ -438,17 +438,17 @@ if ($action == 'create')
print $langs->trans('Docdate');
print '</td>';
if ($action != 'editdate')
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='. $object->piece_num .'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
@ -462,20 +462,20 @@ if ($action == 'create')
print $langs->trans('Codejournal');
print '</td>';
if ($action != 'editjournal')
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$object->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editjournal') {
print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->code_journal ;
print $object->code_journal;
}
print '</td>';
print '</tr>';
@ -486,20 +486,20 @@ if ($action == 'create')
print $langs->trans('Piece');
print '</td>';
if ($action != 'editdocref')
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$object->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editdocref') {
print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
print $object->doc_ref ;
print $object->doc_ref;
}
print '</td>';
print '</tr>';
@ -514,17 +514,17 @@ if ($action == 'create')
print '<table class="border tableforfield" width="100%">';
// Doc type
if(! empty($object->doc_type))
if (!empty($object->doc_type))
{
print '<tr>';
print '<td class="titlefield">' . $langs->trans("Doctype") . '</td>';
print '<td>' . $object->doc_type . '</td>';
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
print '<td>'.$object->doc_type.'</td>';
print '</tr>';
}
// Date document creation
print '<tr>';
print '<td class="titlefield">' . $langs->trans("DateCreation") . '</td>';
print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td>';
print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
print '</td>';
@ -536,11 +536,11 @@ if ($action == 'create')
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($object->validated)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">';
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">';
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
@ -586,16 +586,16 @@ if ($action == 'create')
} else {
print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n";
print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n";
print '<input type="hidden" name="code_journal" value="' . $object->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $object->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $object->fk_docdet . '">' . "\n";
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n";
print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
print '<input type="hidden" name="doc_ref" value="'.$object->doc_ref.'">'."\n";
print '<input type="hidden" name="code_journal" value="'.$object->code_journal.'">'."\n";
print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'">'."\n";
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
print "<table class=\"noborder\" width=\"100%\">";
if (count($object->linesmvt) > 0) {
@ -620,12 +620,12 @@ if ($action == 'create')
if ($action == 'update' && $line->id == $id) {
print '<td>';
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array (), 1, 1, '');
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
}
@ -634,30 +634,30 @@ if ($action == 'create')
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
}
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . (GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation). '"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="' . (GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)) . '"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="' . (GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)) . '"></td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'"></td>';
print '<td>';
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">';
print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
print '</td>';
} else {
$accountingaccount->fetch(null, $line->numero_compte, true);
print '<td>' . $accountingaccount->getNomUrl(0, 1, 1, '', 0) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_operation. '</td>';
print '<td class="nowrap right">' . price($line->debit) . '</td>';
print '<td class="nowrap right">' . price($line->credit) . '</td>';
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 0).'</td>';
print '<td>'.length_accounta($line->subledger_account).'</td>';
print '<td>'.$line->label_operation.'</td>';
print '<td class="nowrap right">'.price($line->debit).'</td>';
print '<td class="nowrap right">'.price($line->credit).'</td>';
print '<td class="center">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print img_edit();
print '</a> &nbsp;';
$actiontodelete='delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete='confirm_delete';
$actiontodelete = 'delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action='.$actiontodelete.'&id=' . $line->id . '&piece_num=' . $line->piece_num . '&mode='.$mode.'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
print img_delete();
print '</a>';
@ -677,12 +677,12 @@ if ($action == 'create')
if ($action == "" || $action == 'add') {
print '<tr class="oddeven">';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array (), 1, 1, '');
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount('', 'subledger_account', 1);
}
@ -694,19 +694,19 @@ if ($action == 'create')
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>';
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
print '<td><input type="submit" class="button" name="save" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
}
print '</table>';
if ($mode=='_tmp' && $action=='')
if ($mode == '_tmp' && $action == '')
{
print '<br>';
print '<div class="center">';
if ($total_debit == $total_credit)
{
print '<a class="button" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $object->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>';
print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
}
else
{
@ -714,7 +714,7 @@ if ($action == 'create')
}
print ' &nbsp; ';
print '<a class="button" href="' . DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print '<a class="button" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">'.$langs->trans("Cancel").'</a>';
print "</div>";
}

View File

@ -25,14 +25,14 @@
* \brief List operation of book keeping
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
@ -88,7 +88,7 @@ $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -107,12 +107,12 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
{
if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values'))
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
$res = $db->query($query);
if ($res->num_rows > 0) {
@ -120,9 +120,9 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
@ -137,7 +137,7 @@ if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !
}
$arrayfields=array(
$arrayfields = array(
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
@ -155,7 +155,7 @@ $arrayfields=array(
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
$listofformat=AccountancyExport::getType();
$listofformat = AccountancyExport::getType();
$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
if (empty($listofformat[$formatexportset])) $formatexportset = 1;
@ -166,8 +166,8 @@ $error = 0;
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
@ -318,7 +318,7 @@ if (empty($reshook))
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
if (! empty($import_key)) {
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -331,15 +331,15 @@ if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->suppri
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delyear = GETPOST('delyear', 'int');
if ($delyear==-1) {
$delyear=0;
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal==-1) {
$deljournal=0;
if ($deljournal == -1) {
$deljournal = 0;
}
if (! empty($delyear) || ! empty($deljournal))
if (!empty($delyear) || !empty($deljournal))
{
$result = $object->deleteByYearAndJournal($delyear, $deljournal);
if ($result < 0) {
@ -351,7 +351,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: list.php".($param?'?'.$param:''));
header("Location: list.php".($param ? '?'.$param : ''));
exit;
}
else
@ -362,7 +362,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (! empty($mvt_num)) {
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -372,15 +372,15 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
header("Location: list.php?noreset=1".($param?'&'.$param:''));
header("Location: list.php?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
if ($action == 'setreexport') {
$setreexport = GETPOST('value', 'int');
if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
if (! $error) {
if (!$error) {
if ($conf->global->ACCOUNTING_REEXPORT == 1) {
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
} else {
@ -421,27 +421,27 @@ $sql .= " t.piece_num,";
$sql .= " t.date_creation,";
$sql .= " t.tms as date_modification,";
$sql .= " t.date_export";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t';
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
// Manage filter
$sqlwhere = array ();
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.doc_date') {
$sqlwhere[] = $key . '=\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'=\''.$db->idate($value).'\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
$sqlwhere[] = $key . '\'' . $db->escape($value) . '\'';
$sqlwhere[] = $key.'\''.$db->escape($value).'\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value;
$sqlwhere[] = $key.'='.$value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\'';
$sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\'';
} elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.tms>=' || $key == 't.tms<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
$sqlwhere[] = $key . '\'' . $db->idate($value) . '\'';
$sqlwhere[] = $key.'\''.$db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} else {
@ -449,14 +449,14 @@ if (count($filter) > 0) {
}
}
}
$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')';
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
if ($conf->global->ACCOUNTING_REEXPORT == 0) {
$sql .= " AND t.date_export IS NULL";
}
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' AND ', $sqlwhere);
$sql .= ' AND '.implode(' AND ', $sqlwhere);
}
if (! empty($sortfield)) {
if (!empty($sortfield)) {
$sql .= $db->order($sortfield, $sortorder);
}
//print $sql;
@ -478,14 +478,14 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
$accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines, $formatexportset);
if (! empty($accountancyexport->errors))
if (!empty($accountancyexport->errors))
{
setEventMessages('', $accountancyexport->errors, 'errors');
}
else
{
// Specify as export : update field date_export
$error=0;
$error = 0;
$db->begin();
if (is_array($object->lines))
@ -494,13 +494,13 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
{
$now = dol_now();
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql .= " SET date_export = '" . $db->idate($now) . "'";
$sql .= " WHERE rowid = " . $movement->id;
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_export = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=" . $sql, LOG_DEBUG);
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
$error++;
break;
@ -508,7 +508,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
}
}
if (! $error)
if (!$error)
{
$db->commit();
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
@ -550,10 +550,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
}
else
{
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$resql=$db->query($sql);
if (! $resql)
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
@ -574,7 +574,7 @@ if ($action == 'delmouv') {
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
$form_question = array ();
$form_question = array();
$delyear = GETPOST('delyear');
$deljournal = GETPOST('deljournal');
@ -584,16 +584,16 @@ if ($action == 'delbookkeepingyear') {
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delyear'] = array (
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array (
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
@ -604,10 +604,10 @@ if ($action == 'delbookkeepingyear') {
}
//$param=''; param started before
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -620,27 +620,27 @@ if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
else $buttonLabel = $langs->trans("ExportList");
// Button re-export
if (! empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
} else {
$newcardbutton ='<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param?'&'.$param:'').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
}
$newcardbutton.= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export);
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param);
$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
@ -650,52 +650,52 @@ print '<table class="tagtable liste centpercent">';
// Filters lines
print '<tr class="liste_titre_filter">';
// Movement number
if (! empty($arrayfields['t.piece_num']['checked']))
if (!empty($arrayfields['t.piece_num']['checked']))
{
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
}
// Date document
if (! empty($arrayfields['t.doc_date']['checked']))
if (!empty($arrayfields['t.doc_date']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $form->selectDate($search_date_start?$search_date_start:-1, 'search_date_start', 0, 0, 1);
print $langs->trans('From').' ';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $form->selectDate($search_date_end?$search_date_end:-1, 'search_date_end', 0, 0, 1);
print $langs->trans('to').' ';
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Ref document
if (! empty($arrayfields['t.doc_ref']['checked']))
if (!empty($arrayfields['t.doc_ref']['checked']))
{
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
}
// Accountancy account
if (! empty($arrayfields['t.numero_compte']['checked']))
if (!empty($arrayfields['t.numero_compte']['checked']))
{
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '</td>';
}
// Subledger account
if (! empty($arrayfields['t.subledger_account']['checked']))
if (!empty($arrayfields['t.subledger_account']['checked']))
{
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
}
@ -708,7 +708,7 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
print $langs->trans('to').' ';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database.
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
{
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
}
@ -720,111 +720,111 @@ if (! empty($arrayfields['t.subledger_account']['checked']))
print '</td>';
}
// Label operation
if (! empty($arrayfields['t.label_operation']['checked']))
if (!empty($arrayfields['t.label_operation']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
print '</td>';
}
// Debit
if (! empty($arrayfields['t.debit']['checked']))
if (!empty($arrayfields['t.debit']['checked']))
{
print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
print '</td>';
}
// Credit
if (! empty($arrayfields['t.credit']['checked']))
if (!empty($arrayfields['t.credit']['checked']))
{
print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
print '</td>';
}
// Lettering code
if (! empty($arrayfields['t.lettering_code']['checked']))
if (!empty($arrayfields['t.lettering_code']['checked']))
{
print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . $search_lettering_code . '"/>';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '</td>';
}
// Code journal
if (! empty($arrayfields['t.code_journal']['checked']))
if (!empty($arrayfields['t.code_journal']['checked']))
{
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.$search_ledger_code.'"></td>';
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['t.date_creation']['checked']))
if (!empty($arrayfields['t.date_creation']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Date modification
if (! empty($arrayfields['t.tms']['checked']))
if (!empty($arrayfields['t.tms']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Date export
if (! empty($arrayfields['t.date_export']['checked']))
if (!empty($arrayfields['t.date_export']['checked']))
{
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $langs->trans('From') . ' ';
print $langs->trans('From').' ';
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1);
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to') . ' ';
print $langs->trans('to').' ';
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1);
print '</div>';
print '</td>';
}
// Action column
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
if (! empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
@ -833,12 +833,12 @@ $line = new BookKeepingLine();
// Loop on record
// --------------------------------------------------------------------
$i=0;
$totalarray=array();
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) break; // Should not happen
$line->id = $obj->rowid;
$line->doc_date = $db->jdate($obj->doc_date);
@ -1006,8 +1006,8 @@ print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">' . "\n";
print '<a class="butActionDelete" name="button_delmvt" href="' . $_SERVER["PHP_SELF"] . '?action=delbookkeepingyear' . ($param ? '&' . $param : '') . '">' . $langs->trans("DeleteMvt") . '</a>';
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}

View File

@ -27,12 +27,12 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy"));
@ -59,7 +59,7 @@ $search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -81,9 +81,9 @@ if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
@ -112,76 +112,76 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_label_operation = '';
$search_direction = '';
$search_ledger_code = '';
$search_date_start='';
$search_date_end='';
$search_date_startyear='';
$search_date_startmonth='';
$search_date_startday='';
$search_date_endyear='';
$search_date_endmonth='';
$search_date_endday='';
$search_date_start = '';
$search_date_end = '';
$search_date_startyear = '';
$search_date_startmonth = '';
$search_date_startday = '';
$search_date_endyear = '';
$search_date_endmonth = '';
$search_date_endday = '';
$search_debit = '';
$search_credit = '';
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array ();
$filter = array();
if (! empty($search_date_start)) {
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int');
$param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int');
}
if (! empty($search_date_end)) {
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int');
$param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int');
}
if (! empty($search_doc_date)) {
if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date;
$param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int');
$param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int');
}
if (! empty($search_accountancy_code_start)) {
if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start);
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
}
if (! empty($search_accountancy_code_end)) {
if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end);
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
}
if (! empty($search_label_account)) {
if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte=' . urlencode($search_label_account);
$param .= '&search_label_compte='.urlencode($search_label_account);
}
if (! empty($search_doc_ref)) {
if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . urlencode($search_doc_ref);
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
}
if (! empty($search_label_operation)) {
if (!empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation;
$param .= '&search_label_operation=' . urlencode($search_label_operation);
$param .= '&search_label_operation='.urlencode($search_label_operation);
}
if (! empty($search_direction)) {
if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$param .= '&search_direction=' . urlencode($search_direction);
$param .= '&search_direction='.urlencode($search_direction);
}
if (! empty($search_ledger_code)) {
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code=' . urlencode($search_ledger_code);
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
}
if (! empty($search_debit)) {
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . urlencode($search_debit);
$param .= '&search_debit='.urlencode($search_debit);
}
if (! empty($search_credit)) {
if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit;
$param .= '&search_credit=' . urlencode($search_credit);
$param .= '&search_credit='.urlencode($search_credit);
}
if ($action == 'delmouvconfirm') {
$mvt_num = GETPOST('mvt_num', 'int');
if (! empty($mvt_num)) {
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -200,7 +200,7 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting"));
$title_page = $langs->trans("Bookkeeping").' '.strtolower($langs->trans("By")).' '.strtolower($langs->trans("AccountAccounting"));
llxHeader('', $title_page);
@ -236,7 +236,7 @@ if ($action == 'delbookkeepingyear') {
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$form_question['delyear'] = array (
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
@ -278,28 +278,28 @@ print '<tr class="liste_titre">';
print '<td class="liste_titre">';
print '<div class="nowrap">';
print $langs->trans('From').' ';
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '<div class="nowrap">';
print $langs->trans('to').' ';
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
print '</div>';
print '</td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre center">';
print $langs->trans('From') . ': ';
print $langs->trans('From').': ';
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1);
print '<br>';
print $langs->trans('to') . ': ';
print $langs->trans('to').': ';
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1);
print '</td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="' . dol_escape_htmltag($search_doc_ref) . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="' . dol_escape_htmltag($search_label_operation) . '"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . dol_escape_htmltag($search_ledger_code) . '"></td>';
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.dol_escape_htmltag($search_ledger_code).'"></td>';
print '<td class="liste_titre right" colspan="2">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
$searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '</tr>';
@ -321,9 +321,9 @@ $total_debit = 0;
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
$i=0;
$i = 0;
while ($i < min($num, $limit))
{
$line = $object->lines[$i];
@ -361,8 +361,8 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
print '<td>&nbsp;</td>';
print '<td class="right"><a href="./card.php?piece_num=' . $line->piece_num . '">'.$line->piece_num.'</a></td>';
print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
print '<td class="right"><a href="./card.php?piece_num='.$line->piece_num.'">'.$line->piece_num.'</a></td>';
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
// TODO Add a link according to doc_type and fk_doc
print '<td class="nowrap">';

View File

@ -67,7 +67,7 @@ $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
*/
$lettering = GETPOST('lettering', 'alpha');
if (! empty($lettering)) {
if (!empty($lettering)) {
$action = $lettering;
}
@ -127,8 +127,8 @@ if ($action == 'autolettrage') {
$form = new Form($db);
$formaccounting = new FormAccounting($db);
$title=$object->name." - ".$langs->trans('TabLetteringCustomer');
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
$title = $object->name." - ".$langs->trans('TabLetteringCustomer');
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$head = societe_prepare_head($object);
@ -164,13 +164,13 @@ $solde = 0;
// Count total nb of records and calc total sum
$nbtotalofrecords = '';
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
dol_print_error($db);
exit();
}
$nbtotalofrecords = $db->num_rows($resql);
while ( $obj = $db->fetch_object($resql) ) {
while ($obj = $db->fetch_object($resql)) {
$debit += $obj->debit;
$credit += $obj->credit;
@ -181,7 +181,7 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
dol_print_error($db);
exit();
}
@ -205,7 +205,7 @@ if ($resql) {
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
print '<div class="div-table-responsive-no-min">';
print '<table class="liste" width="100%">'."\n";
print '<table class="liste centpercent">'."\n";
/*
print '<tr class="liste_titre">';

View File

@ -89,7 +89,7 @@ $lettering = new Lettering($db);
$object = new Societe($db);
$object->id = $socid;
$result = $object->fetch($socid);
if ($result<0)
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
@ -126,8 +126,8 @@ if ($action == 'autolettrage') {
$form = new Form($db);
$formaccounting = new FormAccounting($db);
$title=$object->name." - ".$langs->trans('TabLetteringSupplier');
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
$title = $object->name." - ".$langs->trans('TabLetteringSupplier');
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$head = societe_prepare_head($object);
@ -159,7 +159,7 @@ $solde = 0;
// Count total nb of records and calc total sum
$nbtotalofrecords = '';
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
dol_print_error($db);
exit;
@ -203,7 +203,7 @@ if ($resql) {
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
print '<div class="div-table-responsive-no-min">';
print '<table class="liste" width="100%">'."\n";
print '<table class="liste centpercent">'."\n";
/*
print '<tr class="liste_titre">';

View File

@ -57,6 +57,12 @@ class AccountancyCategory // extends CommonObject
*/
public $table_element='c_accounting_category';
/**
* @var int ID
* @deprecated
*/
public $rowid;
/**
* @var int ID
*/

View File

@ -31,7 +31,7 @@
* \brief Class accountancy export
*/
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
/**
* Manage the different format accountancy export
@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
class AccountancyExport
{
// Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV
public static $EXPORT_TYPE_AGIRIS = 10;
public static $EXPORT_TYPE_EBP = 15;
public static $EXPORT_TYPE_CEGID = 20;
@ -83,7 +83,7 @@ class AccountancyExport
$this->db = &$db;
$this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?"\n":($conf->global->ACCOUNTING_EXPORT_ENDLINE==1?"\n":"\r\n");
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
}
/**
@ -125,7 +125,7 @@ class AccountancyExport
*/
private static function getFormatCode($type)
{
$formatcode = array (
$formatcode = array(
self::$EXPORT_TYPE_CONFIGURABLE => 'csv',
self::$EXPORT_TYPE_CEGID => 'cegid',
self::$EXPORT_TYPE_COALA => 'coala',
@ -153,14 +153,14 @@ class AccountancyExport
{
global $conf, $langs;
return array (
return array(
'param' => array(
self::$EXPORT_TYPE_CONFIGURABLE => array(
'label' => $langs->trans('Modelcsv_configurable'),
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT)?'txt':$conf->global->ACCOUNTING_EXPORT_FORMAT,
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV)?',':$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?1:$conf->global->ACCOUNTING_EXPORT_ENDLINE,
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE)?'%d%m%Y':$conf->global->ACCOUNTING_EXPORT_DATE,
'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT,
'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV,
'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE,
'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE,
),
self::$EXPORT_TYPE_CEGID => array(
'label' => $langs->trans('Modelcsv_CEGID'),
@ -209,11 +209,11 @@ class AccountancyExport
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
),
),
'cr'=> array (
'cr'=> array(
'1' => $langs->trans("Unix"),
'2' => $langs->trans("Windows")
),
'format' => array (
'format' => array(
'csv' => $langs->trans("csv"),
'txt' => $langs->trans("txt")
),
@ -231,13 +231,13 @@ class AccountancyExport
public function export(&$TData, $formatexportset)
{
global $conf, $langs;
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php
// Define name of file to save
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
switch ($formatexportset) {
@ -303,13 +303,13 @@ class AccountancyExport
$separator = ";";
$end_line = "\n";
print $date . $separator;
print $line->code_journal . $separator;
print length_accountg($line->numero_compte) . $separator;
print length_accounta($line->subledger_account) . $separator;
print $line->sens . $separator;
print price($line->montant) . $separator;
print $line->label_operation . $separator;
print $date.$separator;
print $line->code_journal.$separator;
print length_accountg($line->numero_compte).$separator;
print length_accounta($line->subledger_account).$separator;
print $line->sens.$separator;
print price($line->montant).$separator;
print $line->label_operation.$separator;
print $line->doc_ref;
print $end_line;
}
@ -328,22 +328,22 @@ class AccountancyExport
$separator = ";";
$end_line = "\n";
print $line->code_journal . $separator;
print $date . $separator;
print $line->piece_num . $separator;
print length_accountg($line->numero_compte) . $separator;
print '' . $separator;
print $line->label_operation . $separator;
print $date . $separator;
if ($line->sens=='D') {
print price($line->montant) . $separator;
print '' . $separator;
}elseif ($line->sens=='C') {
print '' . $separator;
print price($line->montant) . $separator;
print $line->code_journal.$separator;
print $date.$separator;
print $line->piece_num.$separator;
print length_accountg($line->numero_compte).$separator;
print ''.$separator;
print $line->label_operation.$separator;
print $date.$separator;
if ($line->sens == 'D') {
print price($line->montant).$separator;
print ''.$separator;
}elseif ($line->sens == 'C') {
print ''.$separator;
print price($line->montant).$separator;
}
print $line->doc_ref . $separator;
print $line->label_operation . $separator;
print $line->doc_ref.$separator;
print $line->label_operation.$separator;
print $end_line;
}
}
@ -362,15 +362,15 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $line->code_journal . $separator;
print length_accountg($line->numero_compte) . $separator;
print $line->piece_num . $separator;
print $line->doc_ref . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print 'E' . $separator;
print length_accountg($line->subledger_account) . $separator;
print $date.$separator;
print $line->code_journal.$separator;
print length_accountg($line->numero_compte).$separator;
print $line->piece_num.$separator;
print $line->doc_ref.$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print 'E'.$separator;
print length_accountg($line->subledger_account).$separator;
print $end_line;
}
}
@ -389,26 +389,26 @@ class AccountancyExport
$end_line = "\n";
foreach ($objectLines as $line) {
print $line->piece_num . $separator;
print $line->piece_num.$separator;
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $date.$separator;
if (empty($line->subledger_account)) {
print 'G' . $separator;
print length_accounta($line->numero_compte) . $separator;
print 'G'.$separator;
print length_accounta($line->numero_compte).$separator;
} else {
if (substr($line->numero_compte, 0, 3) == '411') {
print 'C' . $separator;
print 'C'.$separator;
}
if (substr($line->numero_compte, 0, 3) == '401') {
print 'F' . $separator;
print 'F'.$separator;
}
print length_accountg($line->subledger_account) . $separator;
print length_accountg($line->subledger_account).$separator;
}
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print dol_trunc($line->label_operation, 32) . $separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print dol_trunc($line->label_operation, 32).$separator;
print $end_line;
}
}
@ -423,23 +423,23 @@ class AccountancyExport
{
global $conf;
$end_line ="\r\n";
$end_line = "\r\n";
$i = 1;
$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
foreach ($TData as $data) {
$code_compta = $data->numero_compte;
if (! empty($data->subledger_account))
if (!empty($data->subledger_account))
$code_compta = $data->subledger_account;
$Tab = array ();
$Tab = array();
$Tab['num_ecriture'] = str_pad($i, 5);
$Tab['code_journal'] = str_pad($data->code_journal, 2);
$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . dol_string_unaccent($data->label_operation), 25), 25);
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
$Tab['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18);
@ -449,7 +449,7 @@ class AccountancyExport
$Tab['end_line'] = $end_line;
print implode($Tab);
$i ++;
$i++;
}
}
@ -463,17 +463,17 @@ class AccountancyExport
{
global $conf;
$end_line ="\r\n";
$end_line = "\r\n";
//We should use dol_now function not time however this is wrong date to transfert in accounting
//$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ($TData as $data) {
$code_compta = $data->numero_compte;
if (! empty($data->subledger_account))
if (!empty($data->subledger_account))
$code_compta = $data->subledger_account;
$Tab = array ();
$Tab = array();
$Tab['type_ligne'] = 'M';
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8);
$Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2);
@ -484,19 +484,19 @@ class AccountancyExport
//$Tab['date_ecriture'] = $date_ecriture;
$Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y');
$Tab['filler'] = ' ';
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 20), 20);
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
//elarifr le montant doit etre en centimes sans point decimal !
$Tab['montant'] = str_pad(abs($data->montant*100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
// $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
$Tab['contrepartie'] = str_repeat(' ', 8);
// elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting
if (! empty($data->date_echeance))
if (!empty($data->date_echeance))
//$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
$Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy
else
$Tab['date_echeance'] = '000000';
@ -551,20 +551,20 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->id . $separator;
print $date . $separator;
print $line->code_journal . $separator;
print $line->id.$separator;
print $date.$separator;
print $line->code_journal.$separator;
if (empty($line->subledger_account)) {
print $line->numero_compte . $separator;
print $line->numero_compte.$separator;
} else {
print $line->subledger_account . $separator;
print $line->subledger_account.$separator;
}
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"' . $separator;
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
print price2num(abs($line->montant)).$separator;
print $line->sens.$separator;
print $date . $separator;
print $date.$separator;
//print 'EUR';
print $end_line;
}
@ -586,25 +586,25 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->piece_num . $separator;
print self::toAnsi($line->label_operation) . $separator;
print $date . $separator;
print self::toAnsi($line->label_operation) . $separator;
print $line->piece_num.$separator;
print self::toAnsi($line->label_operation).$separator;
print $date.$separator;
print self::toAnsi($line->label_operation).$separator;
if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte) . $separator;
print self::toAnsi($line->label_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
print self::toAnsi($line->label_compte).$separator;
} else {
print length_accounta($line->subledger_account) . $separator;
print self::toAnsi($line->subledger_label) . $separator;
print length_accounta($line->subledger_account).$separator;
print self::toAnsi($line->subledger_label).$separator;
}
print self::toAnsi($line->doc_ref) . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print price($line->montant) . $separator;
print $line->sens . $separator;
print $line->lettering_code . $separator;
print self::toAnsi($line->doc_ref).$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print price($line->montant).$separator;
print $line->sens.$separator;
print $line->lettering_code.$separator;
print $line->code_journal;
print $end_line;
}
@ -625,17 +625,17 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $separator;
print $line->code_journal . $separator;
print $date.$separator;
print $line->code_journal.$separator;
if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
} else {
print length_accounta($line->subledger_account) . $separator;
print length_accounta($line->subledger_account).$separator;
}
print $line->doc_ref . $separator;
print $line->label_operation . $separator;
print price($line->debit) . $separator;
print price($line->credit) . $separator;
print $line->doc_ref.$separator;
print $line->label_operation.$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print $end_line;
}
@ -668,7 +668,7 @@ class AccountancyExport
$tab[] = price2num($line->montant);
$tab[] = $line->code_journal;
print implode($separator, $tab) . $this->end_line;
print implode($separator, $tab).$this->end_line;
}
}
@ -683,23 +683,23 @@ class AccountancyExport
$separator = "\t";
$end_line = "\n";
print "JournalCode" . $separator;
print "JournalLib" . $separator;
print "EcritureNum" . $separator;
print "EcritureDate" . $separator;
print "CompteNum" . $separator;
print "CompteLib" . $separator;
print "CompAuxNum" . $separator;
print "CompAuxLib" . $separator;
print "PieceRef" . $separator;
print "PieceDate" . $separator;
print "EcritureLib" . $separator;
print "Debit" . $separator;
print "Credit" . $separator;
print "EcritureLet" . $separator;
print "DateLet" . $separator;
print "ValidDate" . $separator;
print "Montantdevise" . $separator;
print "JournalCode".$separator;
print "JournalLib".$separator;
print "EcritureNum".$separator;
print "EcritureDate".$separator;
print "CompteNum".$separator;
print "CompteLib".$separator;
print "CompAuxNum".$separator;
print "CompAuxLib".$separator;
print "PieceRef".$separator;
print "PieceDate".$separator;
print "EcritureLib".$separator;
print "Debit".$separator;
print "Credit".$separator;
print "EcritureLet".$separator;
print "DateLet".$separator;
print "ValidDate".$separator;
print "Montantdevise".$separator;
print "Idevise";
print $end_line;
@ -709,55 +709,55 @@ class AccountancyExport
$date_valid = dol_print_date($line->date_validated, '%d%m%Y');
// FEC:JournalCode
print $line->code_journal . $separator;
print $line->code_journal.$separator;
// FEC:JournalLib
print $line->journal_label . $separator;
print $line->journal_label.$separator;
// FEC:EcritureNum
print $line->piece_num . $separator;
print $line->piece_num.$separator;
// FEC:EcritureDate
print $date_creation . $separator;
print $date_creation.$separator;
// FEC:CompteNum
print $line->numero_compte . $separator;
print $line->numero_compte.$separator;
// FEC:CompteLib
print $line->label_compte . $separator;
print $line->label_compte.$separator;
// FEC:CompAuxNum
print $line->subledger_account . $separator;
print $line->subledger_account.$separator;
// FEC:CompAuxLib
print $line->subledger_label . $separator;
print $line->subledger_label.$separator;
// FEC:PieceRef
print $line->doc_ref . $separator;
print $line->doc_ref.$separator;
// FEC:PieceDate
print $date_doc . $separator;
print $date_doc.$separator;
// FEC:EcritureLib
print $line->label_operation . $separator;
print $line->label_operation.$separator;
// FEC:Debit
print price2num($line->debit) . $separator;
print price2num($line->debit).$separator;
// FEC:Credit
print price2num($line->credit) . $separator;
print price2num($line->credit).$separator;
// FEC:EcritureLet
print $line->lettering_code . $separator;
print $line->lettering_code.$separator;
// FEC:DateLet
print $line->date_lettering . $separator;
print $line->date_lettering.$separator;
// FEC:ValidDate
print $date_valid . $separator;
print $date_valid.$separator;
// FEC:Montantdevise
print $line->multicurrency_amount . $separator;
print $line->multicurrency_amount.$separator;
// FEC:Idevise
print $line->multicurrency_code;
@ -785,121 +785,121 @@ class AccountancyExport
// Print header line
print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
print $this->end_line;
$thisPieceNum= "";
$thisPieceAccountNr= "";
$aSize= count($objectLines);
$thisPieceNum = "";
$thisPieceAccountNr = "";
$aSize = count($objectLines);
foreach ($objectLines as $aIndex=>$line)
{
$sammelBuchung= false;
if ($aIndex-2 >= 0 && $objectLines[$aIndex-2]->piece_num == $line->piece_num)
$sammelBuchung = false;
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
{
$sammelBuchung= true;
$sammelBuchung = true;
}
elseif ($aIndex+2 < $aSize && $objectLines[$aIndex+2]->piece_num == $line->piece_num)
elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
{
$sammelBuchung= true;
$sammelBuchung = true;
}
elseif ($aIndex+1 < $aSize
&& $objectLines[$aIndex+1]->piece_num == $line->piece_num
&& $aIndex-1 < $aSize
&& $objectLines[$aIndex-1]->piece_num == $line->piece_num
elseif ($aIndex + 1 < $aSize
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num
&& $aIndex - 1 < $aSize
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num
)
{
$sammelBuchung= true;
$sammelBuchung = true;
}
//Blg
print $line->piece_num . $this->separator;
print $line->piece_num.$this->separator;
// Datum
$date = dol_print_date($line->doc_date, '%d.%m.%Y');
print $date . $this->separator;
print $date.$this->separator;
// Kto
print length_accountg($line->numero_compte) . $this->separator;
print length_accountg($line->numero_compte).$this->separator;
// S/H
if ($line->sens == 'D')
{
print 'S' . $this->separator;
print 'S'.$this->separator;
}
else
{
print 'H' . $this->separator;
print 'H'.$this->separator;
}
//Grp
print self::trunc($line->code_journal, 1) . $this->separator;
print self::trunc($line->code_journal, 1).$this->separator;
// GKto
if (empty($line->code_tiers))
{
if ($line->piece_num == $thisPieceNum)
{
print length_accounta($thisPieceAccountNr) . $this->separator;
print length_accounta($thisPieceAccountNr).$this->separator;
}
else
{
print "div" . $this->separator;
print "div".$this->separator;
}
}
else
{
print length_accounta($line->code_tiers) . $this->separator;
print length_accounta($line->code_tiers).$this->separator;
}
//SId
print $this->separator;
//SIdx
print "0" . $this->separator;
print "0".$this->separator;
//KIdx
print "0" . $this->separator;
print "0".$this->separator;
//BTyp
print "0" . $this->separator;
print "0".$this->separator;
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ($sammelBuchung)
{
print "2" . $this->separator;
print "2".$this->separator;
}
else
{
print "1" . $this->separator;
print "1".$this->separator;
}
// Code
print '""' . $this->separator;
print '""'.$this->separator;
// Netto
if ($line->montant >= 0)
{
print $line->montant . $this->separator;
print $line->montant.$this->separator;
}
else
{
print $line->montant*-1 . $this->separator;
print ($line->montant * -1).$this->separator;
}
// Steuer
print "0.00" . $this->separator;
print "0.00".$this->separator;
// FW-Betrag
print "0.00" . $this->separator;
print "0.00".$this->separator;
// Tx1
$line1= self::toAnsi($line->label_compte, 29);
$line1 = self::toAnsi($line->label_compte, 29);
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
{
$line1= "";
$line1 = "";
}
$line2= self::toAnsi($line->doc_ref, 29);
$line2 = self::toAnsi($line->doc_ref, 29);
if (strlen($line1) == 0)
{
$line1= $line2;
$line2= "";
$line1 = $line2;
$line2 = "";
}
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
{
$line1= $line1 . ' / ' . $line2;
$line2= "";
$line1 = $line1.' / '.$line2;
$line2 = "";
}
print '"' . self::toAnsi($line1). '"' . $this->separator;
print '"'.self::toAnsi($line1).'"'.$this->separator;
// Tx2
print '"' . self::toAnsi($line2). '"' . $this->separator;
print '"'.self::toAnsi($line2).'"'.$this->separator;
//PkKey
print "0" . $this->separator;
print "0".$this->separator;
//OpId
print $this->separator;
@ -910,8 +910,8 @@ class AccountancyExport
if ($line->piece_num !== $thisPieceNum)
{
$thisPieceNum= $line->piece_num;
$thisPieceAccountNr= $line->numero_compte;
$thisPieceNum = $line->piece_num;
$thisPieceAccountNr = $line->numero_compte;
}
}
}
@ -932,23 +932,23 @@ class AccountancyExport
foreach ($objectLines as $line) {
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
// TYPE
$type_enregistrement = 'E'; // For write movement
print $type_enregistrement . $separator;
print $type_enregistrement.$separator;
// JNAL
print substr($line->code_journal, 0, 2) . $separator;
print substr($line->code_journal, 0, 2).$separator;
// NECR
print $line->id . $separator;
print $line->id.$separator;
// NPIE
print $line->piece_num . $separator;
print $line->piece_num.$separator;
// DATP
print $date_document . $separator;
print $date_document.$separator;
// LIBE
print $line->label_operation . $separator;
print $line->label_operation.$separator;
// DATH
print $line->date_lim_reglement . $separator;
print $line->date_lim_reglement.$separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
@ -965,7 +965,7 @@ class AccountancyExport
} else {
$nature_piece = '';
}
print $nature_piece . $separator;
print $nature_piece.$separator;
// RACI
/*
if (! empty($line->subledger_account)) {
@ -983,28 +983,28 @@ class AccountancyExport
*/
print $separator; // deprecated CPTG & CPTA use instead
// MONT
print price(abs($line->montant), 0, '', 1, 2) . $separator;
print price(abs($line->montant), 0, '', 1, 2).$separator;
// CODC
print $line->sens . $separator;
print $line->sens.$separator;
// CPTG
print length_accountg($line->numero_compte) . $separator;
print length_accountg($line->numero_compte).$separator;
// DATE
print $date_creation . $separator;
print $date_creation.$separator;
// CLET
print $line->lettering_code . $separator;
print $line->lettering_code.$separator;
// DATL
print $line->date_lettering . $separator;
print $line->date_lettering.$separator;
// CPTA
if (! empty($line->subledger_account)) {
print length_accounta($line->subledger_account) . $separator;
if (!empty($line->subledger_account)) {
print length_accounta($line->subledger_account).$separator;
} else {
print $separator;
}
// CNAT
if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) {
print 'F' . $separator;
} elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) {
print 'C' . $separator;
if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
print 'F'.$separator;
} elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
print 'C'.$separator;
} else {
print $separator;
}
@ -1017,17 +1017,17 @@ class AccountancyExport
// DATV
print $separator;
// REFD
print $line->doc_ref . $separator;
print $line->doc_ref.$separator;
// CODH
print $separator;
// NSEQ
print $separator;
// MTDV
print '0' . $separator;
print '0'.$separator;
// CODV
print $separator;
// TXDV
print '0' . $separator;
print '0'.$separator;
// MOPM
print $separator;
// BONP
@ -1066,43 +1066,43 @@ class AccountancyExport
/*
* Charlemagne export need header
*/
print $langs->transnoentitiesnoconv('Date') . $separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator;
print $langs->transnoentitiesnoconv('Amount') . $separator;
print 'S' . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator;
print $langs->transnoentitiesnoconv('Date').$separator;
print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator;
print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator;
print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator;
print $langs->transnoentitiesnoconv('Amount').$separator;
print 'S'.$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator;
print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator;
print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator;
print $end_line;
foreach($objectLines as $line) {
foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%Y%m%d');
print $date . $separator; //Date
print $date.$separator; //Date
print self::trunc($line->code_journal, 6) . $separator; //Journal code
print self::trunc($line->code_journal, 6).$separator; //Journal code
if(!empty($line->subledger_account)) $account = $line->subledger_account;
if (!empty($line->subledger_account)) $account = $line->subledger_account;
else $account = $line->numero_compte;
print self::trunc($account, 15) . $separator;//Account number
print self::trunc($account, 15).$separator; //Account number
print self::trunc($line->label_compte, 60) . $separator;//Account label
print self::trunc($line->doc_ref, 20) . $separator;//Piece
print self::trunc($line->label_operation, 60) . $separator;//Operation label
print price(abs($line->montant)) . $separator;//Amount
print $line->sens . $separator;//Direction
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print $separator;//Analytic
print self::trunc($line->label_compte, 60).$separator; //Account label
print self::trunc($line->doc_ref, 20).$separator; //Piece
print self::trunc($line->label_operation, 60).$separator; //Operation label
print price(abs($line->montant)).$separator; //Amount
print $line->sens.$separator; //Direction
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $separator; //Analytic
print $end_line;
}
}
@ -1129,10 +1129,10 @@ class AccountancyExport
*/
public static function toAnsi($str, $size = -1)
{
$retVal= dol_string_nohtmltag($str, 1, 'Windows-1251');
$retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
if ($retVal >= 0 && $size >= 0)
{
$retVal= mb_substr($retVal, 0, $size, 'Windows-1251');
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
}
return $retVal;
}

View File

@ -36,7 +36,7 @@ class AccountancySystem
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
* @var int ID
@ -48,7 +48,14 @@ class AccountancySystem
*/
public $fk_pcg_version;
/**
* @var string pcg type
*/
public $pcg_type;
/**
* @var string pcg subtype
*/
public $pcg_subtype;
/**
@ -61,7 +68,14 @@ class AccountancySystem
*/
public $label;
/**
* @var string account number
*/
public $account_number;
/**
* @var string account parent
*/
public $account_parent;
/**

View File

@ -154,7 +154,7 @@ class AccountingAccount extends CommonObject
* @param int $rowid Id
* @param string $account_number Account number
* @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account
* @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC'.
* @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code).
* @return int <0 if KO, 0 if not found, Id of record if OK and found
*/
public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '')

View File

@ -29,12 +29,12 @@ class AccountingJournal extends CommonObject
/**
* @var string ID to identify managed object
*/
public $element='accounting_journal';
public $element = 'accounting_journal';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='accounting_journal';
public $table_element = 'accounting_journal';
/**
* @var int Field with ID of parent key if this field has a parent
@ -42,8 +42,7 @@ class AccountingJournal extends CommonObject
public $fk_element = '';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
* @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
@ -57,6 +56,9 @@ class AccountingJournal extends CommonObject
*/
public $rowid;
/**
* @var string Accounting journal code
*/
public $code;
/**
@ -64,9 +66,19 @@ class AccountingJournal extends CommonObject
*/
public $label;
public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
/**
* @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
*/
public $nature;
/**
* @var int is active or not
*/
public $active;
/**
* @var array array of lines
*/
public $lines;
/**
@ -93,29 +105,29 @@ class AccountingJournal extends CommonObject
if ($rowid || $journal_code)
{
$sql = "SELECT rowid, code, label, nature, active";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE";
if ($rowid) {
$sql .= " rowid = " . (int) $rowid;
$sql .= " rowid = ".(int) $rowid;
}
elseif ($journal_code)
{
$sql .= " code = '" . $this->db->escape($journal_code) . "'";
$sql .= " AND entity = " . $conf->entity;
$sql .= " code = '".$this->db->escape($journal_code)."'";
$sql .= " AND entity = ".$conf->entity;
}
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
if ($obj) {
$this->id = $obj->rowid;
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->code = $obj->code;
$this->ref = $obj->code;
$this->ref = $obj->code;
$this->label = $obj->label;
$this->nature = $obj->nature;
$this->active = $obj->active;
@ -127,8 +139,8 @@ class AccountingJournal extends CommonObject
}
else
{
$this->error = "Error " . $this->db->lasterror();
$this->errors[] = "Error " . $this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error ".$this->db->lasterror();
}
}
return -1;
@ -149,38 +161,38 @@ class AccountingJournal extends CommonObject
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.code' || $key == 't.label' || $key == 't.nature') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
$sqlwhere[] = $key.'\''.$this->db->escape($value).'\'';
} elseif ($key == 't.rowid' || $key == 't.active') {
$sqlwhere[] = $key . '=' . $value;
$sqlwhere[] = $key.'='.$value;
}
}
}
$sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$sql .= " AND entity IN (".getEntity('accountancy').")";
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
}
if (! empty($sortfield)) {
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
if (!empty($limit)) {
$sql .= ' '.$this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
while ($obj = $this->db->fetch_object($resql)) {
$line = new self($this->db);
$line->id = $obj->rowid;
@ -196,10 +208,10 @@ class AccountingJournal extends CommonObject
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
return - 1;
return -1;
}
}
@ -217,34 +229,34 @@ class AccountingJournal extends CommonObject
{
global $langs, $conf, $user;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php?id=35';
$url = DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35';
$label = '<u>' . $langs->trans("ShowAccountingJournal") . '</u>';
if (! empty($this->code))
$label .= '<br><b>'.$langs->trans('Code') . ':</b> ' . $this->code;
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $langs->transnoentities($this->label);
if ($moretitle) $label.=' - '.$moretitle;
$label = '<u>'.$langs->trans("ShowAccountingJournal").'</u>';
if (!empty($this->code))
$label .= '<br><b>'.$langs->trans('Code').':</b> '.$this->code;
if (!empty($this->label))
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$langs->transnoentities($this->label);
if ($moretitle) $label .= ' - '.$moretitle;
$linkclose='';
$linkclose = '';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowAccountingJournal");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
$label = $langs->trans("ShowAccountingJournal");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip"';
}
$linkstart='<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
if ($nourl)
{
@ -254,11 +266,11 @@ class AccountingJournal extends CommonObject
}
$label_link = $this->code;
if ($withlabel) $label_link .= ' - ' . $langs->transnoentities($this->label);
if ($withlabel) $label_link .= ' - '.$langs->transnoentities($this->label);
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $label_link;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $label_link;
$result .= $linkend;
return $result;
@ -292,7 +304,7 @@ class AccountingJournal extends CommonObject
if ($mode == 0)
{
$prefix='';
$prefix = '';
if ($nature == 9) return $langs->trans('AccountingJournalType9');
elseif ($nature == 5) return $langs->trans('AccountingJournalType5');
elseif ($nature == 4) return $langs->trans('AccountingJournalType4');

File diff suppressed because it is too large Load Diff

View File

@ -23,12 +23,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear->write)
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -69,54 +69,54 @@ $year_current = $year_start;
llxHeader('', $langs->trans("Closure"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("Closure") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("Closure")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescClosure") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescClosure").'</span><br>';
print '<br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="./validate.php">' . $langs->trans("ValidateMovements") . '</a>';
$buttonbind = '<a class="butAction" href="./validate.php">'.$langs->trans("ValidateMovements").'</a>';
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT COUNT(b.rowid) as detail,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " COUNT(b.rowid) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven">';
for($i = 1; $i <= 12; $i ++) {
print '<td class="right">' . $row[$i] . '</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="right">'.$row[$i].'</td>';
}
print '<td class="right"><b>' . $row[13] . '</b></td>';
print '<td class="right"><b>'.$row[13].'</b></td>';
print '</tr>';
}

View File

@ -23,12 +23,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -36,16 +36,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear->write)
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -68,14 +68,14 @@ if ($action == 'validate')
// Update database
$db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '" . $db->idate($now) . "'";
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '".$db->idate($now)."'";
$sql .= ' WHERE b.date_validated IS NULL';
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -91,13 +91,13 @@ if ($action == 'validate')
llxHeader('', $langs->trans("ValidateMovements"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("ValidateMovements") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print $langs->trans("DescValidateMovements") . '<br>';
print $langs->trans("DescValidateMovements").'<br>';
print '<br>';
@ -106,40 +106,40 @@ $y = $year_current;
print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="oddeven">';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td class="center">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td class="center">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td><b>'.$langs->trans("Total").'</b></td></tr>';
print '<tr class="oddeven">';
$sql = "SELECT COUNT(b.rowid) as detail,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(b.doc_date)=' . $j, '1', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " COUNT(b.rowid) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND b.doc_date <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND b.entity IN (" . getEntity('bookkeeping', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/closure/index.php sql=' . $sql, LOG_DEBUG);
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
for($i = 1; $i <= 12; $i ++) {
print '<td class="nowrap center">' . $row[$i] . '<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected?' checked="checked"':'').'>';
print '</td>' ;
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap center">'.$row[$i].'<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
print '</td>';
}
print '<td class="valigntop"><b>' . $row[13] . '</b></td>';
print '<td class="valigntop"><b>'.$row[13].'</b></td>';
}
$db->free($resql);
@ -149,7 +149,7 @@ if ($resql) {
print '</tr>';
print "</table>\n";
print '<br><div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?month=' . $year_current . '&action=validate"">' . $langs->trans("ValidateMovements") . '</a></div>';
print '<br><div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?month='.$year_current.'&action=validate"">'.$langs->trans("ValidateMovements").'</a></div>';
print '</div>';
// End of page

View File

@ -24,11 +24,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
@ -48,16 +48,16 @@ if ($user->socid > 0)
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
if (!$cancel)
{
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$codeventil;
$sql .= " WHERE rowid = ".$id;
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors');
}
else
@ -93,18 +93,18 @@ $form = new Form($db);
$facture_static = new Facture($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
if (!empty($id)) {
$sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,";
$sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, p.accountancy_code_sell as code_sell,";
$sql .= " l.fk_code_ventilation, aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id;
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accounting/customer/card.php sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@ -114,8 +114,8 @@ if (! empty($id)) {
if ($num_lines) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
@ -123,18 +123,18 @@ if (! empty($id)) {
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Ref facture
print '<tr><td>' . $langs->trans("Invoice") . '</td>';
print '<tr><td>'.$langs->trans("Invoice").'</td>';
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
print '<td>' . $facture_static->getNomUrl(1) . '</td>';
print '<td>'.$facture_static->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . nl2br($objp->description) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print '<tr><td width="20%">'.$langs->trans("Line").'</td>';
print '<td>'.nl2br($objp->description).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Account").'</td><td>';
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
@ -142,9 +142,9 @@ if (! empty($id)) {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';

View File

@ -27,13 +27,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory')
{
// Clean database
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd";
$sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')';
$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -121,26 +121,26 @@ if ($action == 'validatehistory') {
// Customer Invoice lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
dol_syslog('htdocs/accountancy/customer/index.php');
$result = $db->query($sql);
if (! $result) {
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -172,12 +172,12 @@ if ($action == 'validatehistory') {
if ($objp->aarowid_suggest > 0)
{
$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate)
if (!$resqlupdate)
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
@ -206,64 +206,64 @@ if ($action == 'validatehistory') {
llxHeader('', $langs->trans("CustomersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("CustomersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("CustomersVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer").'<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND f.fk_statut > 0";
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL";
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 . ")";
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 .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG);
dol_syslog('htdocs/accountancy/customer/index.php sql='.$sql, LOG_DEBUG);
$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 class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -278,11 +278,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -300,35 +300,35 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') . " AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
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 .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
$sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
@ -338,7 +338,7 @@ $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 class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -355,11 +355,11 @@ if ($resql) {
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -379,32 +379,32 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" class="left">' . $langs->trans("TotalVente") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("TotalVente").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, 'fd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT '".$langs->trans("TotalVente")."' AS total,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 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($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$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($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
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 .= " 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');
@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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 class="nowrap right">' . price($row[$i]) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right"><b>' . price($row[13]) . '</b></td>';
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -428,35 +428,35 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '</div>';
if (! empty($conf->margin->enabled)) {
if (!empty($conf->margin->enabled)) {
print "<br>\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT '".$langs->trans("Vide")."' AS marge,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 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($search_date_start) . "'";
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$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($search_date_start)."'";
$sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
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 .= " 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');
@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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 class="nowrap right">' . price(price2num($row[$i])) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price(price2num($row[$i])).'</td>';
}
print '<td class="nowrap right"><b>' . price(price2num($row[13])) . '</b></td>';
print '<td class="nowrap right"><b>'.price(price2num($row[13])).'</b></td>';
print '</tr>';
}
$db->free($resql);

View File

@ -26,16 +26,16 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","productbatch"));
$langs->loadLangs(array("bills", "compta", "accountancy", "productbatch"));
$account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount');
@ -48,14 +48,14 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -63,9 +63,9 @@ if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
$offset = $limit * $page;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, fd.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC";
}
@ -74,7 +74,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$formaccounting = new FormAccounting($db);
@ -105,27 +105,27 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
if (! (GETPOST('account_parent', 'int') >= 0))
if (!(GETPOST('account_parent', 'int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
if (!$error)
{
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')';
dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1);
dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error) {
if (!$error) {
$db->commit();
setEventMessages($langs->trans('Save'), null, 'mesgs');
} else {
@ -133,7 +133,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
setEventMessages($db->lasterror(), null, 'errors');
}
$account_parent = ''; // Protection to avoid to mass apply it a second time
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
}
@ -145,7 +145,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$form = new Form($db);
$formother = new FormOther($db);
llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched"));
llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched"));
print '<script type="text/javascript">
$(function () {
@ -168,28 +168,28 @@ print '<script type="text/javascript">
* Customer Invoice lines
*/
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type, f.datef, f.ref_client,";
$sql.= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql.= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
$sql.= " fd.situation_percent,";
$sql.= " co.code as country_code, co.label as country,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " WHERE fd.fk_code_ventilation > 0";
$sql.= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql.= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
$sql .= " fd.situation_percent,";
$sql .= " co.code as country_code, co.label as country,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
if ($search_lineid) {
$sql .= natural_search("fd.rowid", $search_lineid, 1);
@ -215,25 +215,25 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("fd.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
@ -257,22 +257,22 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref);
if ($search_label) $param .= "&search_label=" . urlencode($search_label);
if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc);
if ($search_account) $param .= "&search_account=" . urlencode($search_account);
if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
if ($search_account) $param .= "&search_account=".urlencode($search_account);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -282,40 +282,40 @@ if ($result) {
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer").'</span><br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
}
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print "</td></tr>\n";
@ -331,15 +331,15 @@ if ($result) {
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center ');
$clickpicto=$form->showCheckAddButtons();
$clickpicto = $form->showCheckAddButtons();
print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
$facture_static = new Facture($db);
$product_static = new Product($db);
while ( $objp = $db->fetch_object($result) ) {
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
while ($objp = $db->fetch_object($result)) {
$codecompta = length_accountg($objp->account_number).' - '.$objp->label_compte;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@ -353,13 +353,13 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facture_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facture_static->getNomUrl(1).'</td>';
// Date invoice
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product
print '<td>';
@ -374,30 +374,30 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
print '</td>';
print '<td class="nowrap right">' . price($objp->total_ht) . '</td>';
print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
print '<td class="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Country
print '<td>';
if ($objp->country_code)
{
print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')';
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
}
print '</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">';
print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit();
print '</a>';
print '</td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
print "</tr>";
$i ++;
$i++;
}
print "</table>";

View File

@ -27,22 +27,22 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch"));
$action=GETPOST('action', 'alpha');
$massaction=GETPOST('massaction', 'alpha');
$show_files=GETPOST('show_files', 'int');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box
@ -57,16 +57,16 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC";
}
@ -85,7 +85,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -100,11 +100,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -128,7 +128,7 @@ if (empty($reshook))
}
// Mass actions
$objectclass='AccountingAccount';
$objectclass = 'AccountingAccount';
$permissiontoread = $user->rights->accounting->read;
$permissiontodelete = $user->rights->accounting->delete;
$uploaddir = $conf->accounting->dir_output;
@ -137,15 +137,15 @@ if (empty($reshook))
if ($massaction == 'ventil') {
$msg='';
$msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
$msg.='<div class="detail">';
if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">';
$cpt = 0;
$ok=0;
$ko=0;
$ok = 0;
$ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee);
@ -154,32 +154,32 @@ if ($massaction == 'ventil') {
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog("accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++;
} else {
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br> <pre>' . $sql . '</pre></font></div>';
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br> <pre>'.$sql.'</pre></font></div>';
$ko++;
}
}
$cpt++;
}
$msg.='</div>';
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
$msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
}
}
@ -205,25 +205,25 @@ if (empty($chartaccountcode))
// Customer Invoice lines
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
// Add search filter like
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);
@ -249,35 +249,35 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
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 . ")";
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 .= " 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('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
@ -297,38 +297,43 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
dol_syslog("accountancy/customer/list.php", LOG_DEBUG);
// MAX_JOIN_SIZE can be very low (ex: 300000) on some limited configurations (ex: https://www.online.net/fr/hosting/online-perso)
// This big SELECT command may exceed the MAX_JOIN_SIZE limit => Therefore we use SQL_BIG_SELECTS=1 to disable the MAX_JOIN_SIZE security
if ($db->type == 'mysqli') {
$db->query("SET SQL_BIG_SELECTS=1");
}
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid);
if ($search_day) $param.='&search_day='.urlencode($search_day);
if ($search_month) $param.='&search_month='.urlencode($search_month);
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
if ($search_country) $param.= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param.= "&search_tvaintra=".urlencode($search_tvaintra);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array(
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -339,7 +344,7 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer") . '</span></br><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
@ -352,33 +357,33 @@ if ($result) {
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
}
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="center liste_titre">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
@ -396,15 +401,17 @@ if ($result) {
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto='';
if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
$facture_static = new Facture($db);
$product_static = new Product($db);
$isSellerInEEC = isInEEC($mysoc);
$isSellerInEEC = isInEEC($mysoc);
$accountingaccount_codetotid_cache = array();
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);
@ -422,39 +429,39 @@ if ($result) {
$facture_static->type = $objp->ftype;
$code_sell_p_notset = '';
$objp->aarowid_suggest = ''; // Will be set later
$objp->aarowid_suggest = ''; // Will be set later
$isBuyerInEEC = isInEEC($objp);
$suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
} else { // Foreign sale
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'export';
}
}
} elseif ($objp->type_l == 0) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
} else {
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : '');
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'export';
}
}
}
if ($objp->code_sell_l == -1) $objp->code_sell_l='';
if ($objp->code_sell_l == -1) $objp->code_sell_l = '';
// Search suggested account for product/service
$suggestedaccountingaccountfor = '';
@ -474,8 +481,8 @@ if ($result) {
}
}
if (! empty($objp->code_sell)) {
//$objp->code_sell_p = $objp->code_sell; // Code on product
if (! empty($objp->code_sell_p)) {
// Value was defined previously
} else {
$code_sell_p_notset = 'color:orange';
}
@ -487,12 +494,12 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facture_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facture_static->getNomUrl(1).'</td>';
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product
print '<td>';
@ -514,44 +521,59 @@ if ($result) {
// Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '<td style="'.$code_vat_differ.'" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
print '</td>';
// Country
print '<td>';
$labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label;
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry;
print '</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
// Current account
print '<td class="center" style="' . $code_sell_p_notset . '">';
$s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': ';
print '<td class="center" style="'.$code_sell_p_notset.'">';
$s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport");
$s.= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined"));
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined"));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0)
{
print '<br>';
$s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': ';
$s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s.= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p));
$s .= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print '</td>';
// Suggested accounting account
// $objp->code_sell_l = default (it takes the country into consideration), $objp->code_sell_p is value for product (it takes the country into consideration too)
print '<td>';
$suggestedid = $objp->aarowid_suggest;
if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && ! empty($conf->global->ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC))
/*var_dump($suggestedid);
var_dump($objp->code_sell_p);
var_dump($objp->code_sell_l);*/
if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
{
//$suggestedid = // id of $objp->code_sell_l
if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l]))
{
$tmpaccount = new AccountingAccount($db);
$tmpaccount->fetch(0, $objp->code_sell_l, 1);
if ($tmpaccount->id > 0) {
$suggestedid = $tmpaccount->id;
}
$accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id;
}
else {
$suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l];
}
}
print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';
@ -560,11 +582,11 @@ if ($result) {
print '<td class="center">';
//var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest);
$ischecked = $objp->aarowid_suggest;
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>';
print '</td>';
print '</tr>';
$i ++;
$i++;
}
print '</table>';
print "</div>";
@ -573,6 +595,9 @@ if ($result) {
} else {
print $db->error();
}
if ($db->type == 'mysqli') {
$db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
}
// Add code to auto check the box when we select an account
print '<script type="text/javascript" language="javascript">

View File

@ -28,11 +28,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy","trips"));
$langs->loadLangs(array("bills", "accountancy", "trips"));
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
@ -52,16 +52,16 @@ if ($user->socid > 0)
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
if (!$cancel)
{
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
$sql .= " SET fk_code_ventilation = ".$codeventil;
$sql .= " WHERE rowid = ".$id;
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors');
}
else
@ -95,18 +95,18 @@ $form = new Form($db);
$expensereport_static = new ExpenseReport($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
if (!empty($id)) {
$sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
$sql .= " aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".$id;
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accounting/expensereport/card.php sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@ -116,8 +116,8 @@ if (! empty($id)) {
if ($num_lines) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
@ -125,25 +125,25 @@ if (! empty($id)) {
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Ref
print '<tr><td class="titlefield">' . $langs->trans("ExpenseReport") . '</td>';
print '<tr><td class="titlefield">'.$langs->trans("ExpenseReport").'</td>';
$expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid;
print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td>' . $langs->trans("Line") . '</td>';
print '<td>' . stripslashes(nl2br($objp->rowid)) . '</td></tr>';
print '<tr><td>'.$langs->trans("Line").'</td>';
print '<td>'.stripslashes(nl2br($objp->rowid)).'</td></tr>';
print '<tr><td>' . $langs->trans("Description") . '</td>';
print '<td>' . stripslashes(nl2br($objp->comments)) . '</td></tr>';
print '<tr><td>'.$langs->trans("Description").'</td>';
print '<td>'.stripslashes(nl2br($objp->comments)).'</td></tr>';
print '<tr><td>' . $langs->trans("TypeFees") . '</td>';
print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
print '<tr><td>'.$langs->trans("TypeFees").'</td>';
print '<td>'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
print '<tr><td>' . $langs->trans("Account") . '</td><td>';
print '<tr><td>'.$langs->trans("Account").'</td><td>';
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
@ -151,9 +151,9 @@ if (! empty($id)) {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';

View File

@ -25,12 +25,12 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -38,15 +38,15 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -72,19 +72,19 @@ if ($action == 'clean' || $action == 'validatehistory')
{
// Clean database
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE erd.fk_code_ventilation NOT IN';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'expensereport WHERE entity = '.$conf->entity.')';
$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'expensereport WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -99,16 +99,16 @@ if ($action == 'validatehistory') {
// Now make the binding
if ($db->type == 'pgsql') {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det";
$sql1 .= " SET fk_code_ventilation = accnt.rowid";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 .= " WHERE " . MAIN_DB_PREFIX . "expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
$sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst";
$sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
$sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number";
$sql1 .= " AND " . MAIN_DB_PREFIX . "expensereport_det.fk_code_ventilation = 0";
$sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0";
} else {
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd, " . MAIN_DB_PREFIX . "c_type_fees as t, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst";
$sql1 .= " SET erd.fk_code_ventilation = accnt.rowid";
$sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
$sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity;
$sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number";
$sql1 .= " AND erd.fk_code_ventilation = 0";
}
@ -116,8 +116,8 @@ if ($action == 'validatehistory') {
dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -133,59 +133,59 @@ if ($action == 'validatehistory') {
llxHeader('', $langs->trans("ExpenseReportsVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("ExpenseReportsVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("ExpenseReportsVentilation")."&nbsp;".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport") . '<br>';
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport").'<br>';
print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -200,11 +200,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -223,31 +223,31 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " ROUND(SUM(erd.total_ht),2) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
@ -256,7 +256,7 @@ $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 class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -272,11 +272,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -297,28 +297,28 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" class="left">' . $langs->trans("Total") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '" . $langs->trans("TotalExpenseReport") . "' AS label,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $j, 'erd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql);
@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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 class="nowrap right">' . price($row[$i]) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right"><b>' . price($row[13]) . '</b></td>';
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>';
}

View File

@ -27,20 +27,20 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other","trips","productbatch"));
$langs->loadLangs(array("bills", "compta", "accountancy", "other", "trips", "productbatch"));
$action=GETPOST('action', 'alpha');
$massaction=GETPOST('massaction', 'alpha');
$show_files=GETPOST('show_files', 'int');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box
@ -53,14 +53,14 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -68,9 +68,9 @@ if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
$sortfield = "erd.date, erd.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC";
}
@ -79,7 +79,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$formaccounting = new FormAccounting($db);
@ -92,8 +92,8 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Action
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
@ -110,23 +110,23 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
}
// Mass actions
$objectclass='ExpenseReport';
$objectlabel='ExpenseReport';
$objectclass = 'ExpenseReport';
$objectlabel = 'ExpenseReport';
$permissiontoread = $user->rights->expensereport->read;
$permissiontodelete = $user->rights->expensereport->delete;
$uploaddir = $conf->expensereport->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') {
$msg='';
$msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
$msg.='<div class="detail">';
if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
$ok=0;
$ko=0;
$ok = 0;
$ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee);
@ -135,32 +135,32 @@ if ($massaction == 'ventil') {
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG);
dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '<div><font color="green">' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
$msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++;
} else {
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++;
}
}
$cpt++;
}
$msg.='</div>';
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
$msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
}
}
@ -186,14 +186,14 @@ if (empty($chartaccountcode))
// Expense report lines
$sql = "SELECT er.ref, er.rowid as erid, er.date_debut,";
$sql.= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,";
$sql.= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
$sql.= " aa.rowid as aarowid";
$sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
$sql .= " aa.rowid as aarowid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
// Add search filter like
if (strlen(trim($search_expensereport))) {
$sql .= natural_search("er.ref", $search_expensereport);
@ -213,8 +213,8 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("erd.tva_tx", $search_vat, 1);
}
$sql.=dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
$sql.= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder);
@ -239,32 +239,32 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid);
if ($search_day) $param.='&search_day='.urlencode($search_day);
if ($search_month) $param.='&search_month='.urlencode($search_month);
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_expensereport) $param.='&search_expensereport='.urlencode($search_expensereport);
if ($search_label) $param.='&search_label='.urlencode($search_label);
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_expensereport) $param .= '&search_expensereport='.urlencode($search_expensereport);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat);
$arrayofmassactions = array(
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -275,7 +275,7 @@ if ($result) {
print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport") . '</span></br><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
@ -288,25 +288,25 @@ if ($result) {
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="' . dol_escape_htmltag($search_expensereport) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="center" class="liste_titre">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
@ -321,8 +321,8 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center ');
$checkpicto='';
if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
@ -330,7 +330,7 @@ if ($result) {
$expensereport_static = new ExpenseReport($db);
$form = new Form($db);
while ( $i < min($num_lines, $limit) ) {
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);
$objp->aarowid_suggest = '';
@ -342,13 +342,13 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Expense report
print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
// Date
print '<td class="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
// Fees label
print '<td>';
@ -368,7 +368,7 @@ if ($result) {
// Vat rate
print '<td class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
print '</td>';
// Current account
@ -382,11 +382,11 @@ if ($result) {
print '</td>';
print '<td class="center">';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($objp->aarowid ? "checked" : "").'/>';
print '</td>';
print "</tr>";
$i ++;
$i++;
}
print '</table>';

View File

@ -24,12 +24,12 @@
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict"));
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
// Security check
if ($user->socid > 0)
@ -45,12 +45,12 @@ $hookmanager->initHooks(array('accountancyindex'));
if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone=GETPOST('areacode', 'aZ09');
$userid=GETPOST('userid', 'int');
$boxorder=GETPOST('boxorder', 'aZ09');
$boxorder.=GETPOST('boxcombo', 'aZ09');
$zone = GETPOST('areacode', 'aZ09');
$userid = GETPOST('userid', 'int');
$boxorder = GETPOST('boxorder', 'aZ09');
$boxorder .= GETPOST('boxcombo', 'aZ09');
$result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
}
@ -64,16 +64,16 @@ if ($conf->accounting->enabled)
{
$step = 0;
$resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
$helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default.
$helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default.
$showtutorial = '';
if (! $helpisexpanded)
if (!$helpisexpanded)
{
$showtutorial = '<div align="right"><a href="#" id="show_hide">';
$showtutorial .= img_picto('', 'chevron-down');
$showtutorial .= ' ' . $langs->trans("ShowTutorial");
$showtutorial .= ' '.$langs->trans("ShowTutorial");
$showtutorial .= '</a></div>';
$showtutorial .= '<script type="text/javascript" language="javascript">
@ -127,7 +127,7 @@ if ($conf->accounting->enabled)
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy">'.'<strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>'.'</a>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink);
print "<br>\n";
if (! empty($conf->tax->enabled))
if (!empty($conf->tax->enabled))
{
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy">'.'<strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>'.'</a>';
$step++;
@ -142,7 +142,7 @@ if ($conf->accounting->enabled)
print "<br>\n";
print "<br>\n";
}*/
if (! empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy">'.'<strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong>'.'</a>');
@ -186,26 +186,26 @@ if ($conf->accounting->enabled)
$langs->loadLangs(array('bills', 'trips'));
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>'.'</a>')."\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>'.'</a>')."\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>'.'</a>')."\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>'.'</a>')."\n";
print "<br>\n";
if (! empty($conf->expensereport->enabled) || ! empty($conf->deplacement->enabled))
if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled))
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>'.'</a>')."\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php">'.'<strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>'.'</a>')."\n";
print "<br>\n";
}
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
print "<br>\n";
print '<br>';
@ -219,27 +219,27 @@ if ($conf->accounting->enabled)
/*
* Show boxes
*/
$boxlist.='<div class="twocolumns">';
$boxlist .= '<div class="twocolumns">';
$boxlist.='<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
if(!empty($nbworkboardcount))
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
if (!empty($nbworkboardcount))
{
$boxlist.=$boxwork;
$boxlist .= $boxwork;
}
$boxlist.=$resultboxes['boxlista'];
$boxlist .= $resultboxes['boxlista'];
$boxlist.= '</div>';
$boxlist .= '</div>';
$boxlist.= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
$boxlist.=$boxstat;
$boxlist.=$resultboxes['boxlistb'];
$boxlist .= $boxstat;
$boxlist .= $resultboxes['boxlistb'];
$boxlist.= '</div>';
$boxlist.= "\n";
$boxlist .= '</div>';
$boxlist .= "\n";
$boxlist.='</div>';
$boxlist .= '</div>';
print $boxlist;

View File

@ -29,17 +29,17 @@
* \brief Page with expense reports journal
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors"));
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "trips", "errors"));
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action', 'aZ09');
@ -75,13 +75,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@ -91,62 +91,62 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, ";
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
$sql .= " JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
$sql .= " WHERE er.fk_statut > 0";
$sql .= " AND erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
if ($date_start && $date_end)
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
$sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'";
// Already in bookkeeping or not
if ($in_bookkeeping == 'already')
{
$sql .= " AND er.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
$sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
}
if ($in_bookkeeping == 'notyet')
{
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
}
$sql .= " ORDER BY er.date_debut";
dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$taber = array ();
$tabht = array ();
$tabtva = array ();
$def_tva = array ();
$tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabuser = array ();
$taber = array();
$tabht = array();
$tabtva = array();
$def_tva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabuser = array();
$num = $db->num_rows($result);
// Variables
$account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined';
$account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$account_salary = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined';
$account_vat = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$i = 0;
while ( $i < $num ) {
while ($i < $num) {
$obj = $db->fetch_object($result);
// Controls
$compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
$compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
$compta_fees = $obj->compte;
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat);
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
$taber[$obj->rowid]["date"] = $db->jdate($obj->de);
@ -155,24 +155,24 @@ if ($result) {
$taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid;
// Avoid warnings
if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0;
if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
if (!isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0;
if (!isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
$tabuser[$obj->rowid] = array (
$tabuser[$obj->rowid] = array(
'id' => $obj->uid,
'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'user_accountancy_code' => $obj->user_accountancy_account
);
$i ++;
$i++;
}
} else {
dol_print_error($db);
@ -193,7 +193,7 @@ if ($action == 'writebookkeeping') {
$db->begin();
// Thirdparty
if (! $errorforline)
if (!$errorforline)
{
foreach ($tabttc[$key] as $k => $mt) {
if ($mt) {
@ -244,7 +244,7 @@ if ($action == 'writebookkeeping') {
}
// Fees
if (! $errorforline)
if (!$errorforline)
{
foreach ($tabht[$key] as $k => $mt) {
if ($mt) {
@ -295,10 +295,10 @@ if ($action == 'writebookkeeping') {
}
// VAT
if (! $errorforline)
if (!$errorforline)
{
$listoftax=array(0, 1, 2);
foreach($listoftax as $numtax)
$listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax)
{
$arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1;
@ -362,7 +362,7 @@ if ($action == 'writebookkeeping') {
setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
}
if (! $errorforline)
if (!$errorforline)
{
$db->commit();
}
@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') {
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
break; // Break in the foreach
}
}
}
@ -392,21 +392,21 @@ if ($action == 'writebookkeeping') {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
$action = '';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookkeeping='.$in_bookkeeping;
$param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth;
$param .= '&date_startyear='.$date_startyear;
$param .= '&date_endday='.$date_endday;
$param .= '&date_endmonth='.$date_endmonth;
$param .= '&date_endyear='.$date_endyear;
$param .= '&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
exit;
}
}
@ -426,15 +426,15 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$filename = 'journal';
$type_export = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
// CSV header line
print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep;
print '"' . $langs->transnoentitiesnoconv("Piece") . '"' . $sep;
print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep;
print '"' . $langs->transnoentitiesnoconv("LabelOperation") . '"' . $sep;
print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep;
print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep;
print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep;
print '"'.$langs->transnoentitiesnoconv("Piece").'"'.$sep;
print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep;
print '"'.$langs->transnoentitiesnoconv("LabelOperation").'"'.$sep;
print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep;
print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep;
print "\n";
foreach ($taber as $key => $val) {
@ -486,18 +486,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("ExpenseReportsJournal"));
$nom = $langs->trans("ExpenseReportsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nom = $langs->trans("ExpenseReportsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate=dol_now();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$builddate = dol_now();
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
$varlink = 'id_journal='.$id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
@ -508,13 +508,13 @@ if (empty($action) || $action == 'view') {
}
print '<div class="tabsAction tabsActionNoBottom">';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
}
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
print '</div>';
@ -543,13 +543,13 @@ if (empty($action) || $action == 'view') {
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("LabelOperation") . "</td>";
print '<td class="right">' . $langs->trans("Debit") . "</td>";
print '<td class="right">' . $langs->trans("Credit") . "</td>";
print "<td>".$langs->trans("Date")."</td>";
print "<td>".$langs->trans("Piece").' ('.$langs->trans("ExpenseReportRef").")</td>";
print "<td>".$langs->trans("AccountAccounting")."</td>";
print "<td>".$langs->trans("SubledgerAccount")."</td>";
print "<td>".$langs->trans("LabelOperation")."</td>";
print '<td class="right">'.$langs->trans("Debit")."</td>";
print '<td class="right">'.$langs->trans("Credit")."</td>";
print "</tr>\n";
$r = '';
@ -572,8 +572,8 @@ if (empty($action) || $action == 'view') {
if ($mt) {
print '<tr class="oddeven">';
print "<!-- Fees -->";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
// Account
@ -590,9 +590,9 @@ if (empty($action) || $action == 'view') {
print '</td>';
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
}
}
@ -604,8 +604,8 @@ if (empty($action) || $action == 'view') {
print '<tr class="oddeven">';
print "<!-- Thirdparty -->";
print "<td>" . $date . "</td>";
print "<td>" . $expensereportstatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$expensereportstatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
@ -624,9 +624,9 @@ if (empty($action) || $action == 'view') {
}
else print $accountoshow;
print '</td>';
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? -price(-$mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
}

View File

@ -29,17 +29,17 @@
* \brief Page with purchases journal
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors"));
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action', 'aZ09');
@ -60,12 +60,12 @@ if ($user->socid > 0)
accessforbidden();
$hookmanager->initHooks(array('purchasesjournal'));
$parameters=array();
$parameters = array();
/*
* Actions
*/
$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
$accountingaccount = new AccountingAccount($db);
@ -80,13 +80,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@ -96,53 +96,53 @@ $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_sup
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.fk_statut > 0";
$sql .= " AND fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")";
} else {
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")";
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")";
}
if ($date_start && $date_end)
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
// Already in bookkeeping or not
if ($in_bookkeeping == 'already')
{
$sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
$sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
}
if ($in_bookkeeping == 'notyet')
{
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
}
$sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
$def_tva = array ();
$tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabcompany = array ();
$tabfac = array();
$tabht = array();
$tabtva = array();
$def_tva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabcompany = array();
$tabother = array();
$num = $db->num_rows($result);
// Variables
$cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined';
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined';
$i = 0;
while ( $i < $num ) {
while ($i < $num) {
$obj = $db->fetch_object($result);
// Controls
@ -151,21 +151,21 @@ if ($result) {
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
}
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_counterpart_tva_npr = (! empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined';
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
$compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
$compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined';
// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
$line = new SupplierInvoiceLine($db);
@ -173,31 +173,31 @@ if ($result) {
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr);
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')';
$tabfac[$obj->rowid]["refsologest"] = $obj->ref;
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->description;
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
//$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
// Avoid warnings
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
if (! empty($line->tva_npr)) // Add an entry for counterpart
if (!empty($line->tva_npr)) // Add an entry for counterpart
{
$tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
}
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
$tabcompany[$obj->rowid] = array (
$tabcompany[$obj->rowid] = array(
'id' => $obj->socid,
'name' => $obj->name,
'code_fournisseur' => $obj->code_fournisseur,
@ -215,16 +215,16 @@ $errorforinvoice = array();
// Loop in invoices to detect lines with not binding lines
foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql = "SELECT COUNT(fd.rowid) as nb";
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql.= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd";
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj->nb > 0)
{
$errorforinvoice[$key]='somelinesarenotbound';
$errorforinvoice[$key] = 'somelinesarenotbound';
}
}
else dol_print_error($db);
@ -271,7 +271,7 @@ if ($action == 'writebookkeeping') {
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -291,7 +291,7 @@ if ($action == 'writebookkeeping') {
}
// Thirdparty
if (! $errorforline)
if (!$errorforline)
{
foreach ($tabttc[$key] as $k => $mt) {
$bookkeeping = new BookKeeping($db);
@ -473,7 +473,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'supplier_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
@ -497,14 +497,14 @@ if ($action == 'writebookkeeping') {
{
$error++;
$errorforline++;
$errorforinvoice[$key]='alreadyjournalized';
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
$errorforinvoice[$key]='other';
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -513,15 +513,15 @@ if ($action == 'writebookkeeping') {
}
// Protection against a bug on lines before
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit)))
{
$error++;
$errorforline++;
$errorforinvoice[$key]='amountsnotbalanced';
$errorforinvoice[$key] = 'amountsnotbalanced';
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
if (! $errorforline)
if (!$errorforline)
{
$db->commit();
}
@ -532,7 +532,7 @@ if ($action == 'writebookkeeping') {
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
break; // Break in the foreach
}
}
}
@ -551,20 +551,20 @@ if ($action == 'writebookkeeping') {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
$action = '';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
$param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth;
$param .= '&date_startyear='.$date_startyear;
$param .= '&date_endday='.$date_endday;
$param .= '&date_endmonth='.$date_endmonth;
$param .= '&date_endyear='.$date_endyear;
$param .= '&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
exit;
}
}
@ -581,7 +581,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$filename = 'journal';
$type_export = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
@ -610,7 +610,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -623,18 +623,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
// Third party
foreach ($tabttc[$key] as $k => $mt) {
//if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsologest"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["refsologest"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
//}
}
@ -644,18 +644,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
//if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsologest"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["refsologest"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$sep;
print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
//}
}
@ -669,18 +669,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsologest"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["refsologest"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$sep;
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
}
}
@ -690,18 +690,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
{
foreach ($tabother[$key] as $k => $mt) {
if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["refsologest"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep;
print '"' . $journal . '"' ;
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["refsologest"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
}
}
@ -713,23 +713,23 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("PurchasesJournal"));
$nom = $langs->trans("PurchasesJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nom = $langs->trans("PurchasesJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate=dol_now();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$builddate = dol_now();
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("DepositsAreNotIncluded");
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
$varlink = 'id_journal='.$id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
@ -740,13 +740,13 @@ if (empty($action) || $action == 'view') {
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}
print '<div class="tabsAction tabsActionNoBottom">';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
}
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
print '</div>';
@ -775,13 +775,13 @@ if (empty($action) || $action == 'view') {
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("LabelOperation") . "</td>";
print '<td class="center">' . $langs->trans("Debit") . "</td>";
print '<td class="center">' . $langs->trans("Credit") . "</td>";
print "<td>".$langs->trans("Date")."</td>";
print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
print "<td>".$langs->trans("AccountAccounting")."</td>";
print "<td>".$langs->trans("SubledgerAccount")."</td>";
print "<td>".$langs->trans("LabelOperation")."</td>";
print '<td class="center">'.$langs->trans("Debit")."</td>";
print '<td class="center">'.$langs->trans("Credit")."</td>";
print "</tr>\n";
$r = '';
@ -813,7 +813,7 @@ if (empty($action) || $action == 'view') {
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -822,8 +822,8 @@ if (empty($action) || $action == 'view') {
{
print '<tr class="oddeven">';
print "<!-- Replaced invoice -->";
print "<td>" . $date . "</td>";
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
print "<td>".$date."</td>";
print "<td><strike>".$invoicestatic->getNomUrl(1)."</strike></td>";
// Account
print "<td>";
print $langs->trans("Replaced");
@ -843,8 +843,8 @@ if (empty($action) || $action == 'view') {
{
print '<tr class="oddeven">';
print "<!-- Some lines are not bound -->";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
@ -929,8 +929,8 @@ if (empty($action) || $action == 'view') {
if ($mt) {
print '<tr class="oddeven">';
print "<!-- VAT -->";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg($k);
@ -944,10 +944,10 @@ if (empty($action) || $action == 'view') {
print "<td>";
print '</td>';
print "<td>";
print $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
print $companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
print "</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
}
}
@ -960,8 +960,8 @@ if (empty($action) || $action == 'view') {
if ($mt) {
print '<tr class="oddeven">';
print "<!-- VAT counterpart NPR -->";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg($k);
@ -974,9 +974,9 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT") . " NPR (counterpart)</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT")." NPR (counterpart)</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
}
}

View File

@ -31,17 +31,17 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors"));
$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors"));
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action', 'aZ09');
@ -62,13 +62,13 @@ if ($user->socid > 0)
accessforbidden();
$hookmanager->initHooks(array('sellsjournal'));
$parameters=array();
$parameters = array();
/*
* Actions
*/
$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks
$accountingaccount = new AccountingAccount($db);
@ -83,13 +83,13 @@ $pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
$pastmonth = 12;
$pastmonthyear --;
$pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
@ -132,45 +132,45 @@ $sql .= " ORDER BY f.datef";
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
$def_tva = array ();
$tabttc = array ();
$tablocaltax1 = array ();
$tablocaltax2 = array ();
$tabcompany = array ();
$tabfac = array();
$tabht = array();
$tabtva = array();
$def_tva = array();
$tabttc = array();
$tablocaltax1 = array();
$tablocaltax2 = array();
$tabcompany = array();
$num = $db->num_rows($result);
// Variables
$cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
$cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
$i = 0;
while ( $i < $num ) {
while ($i < $num) {
$obj = $db->fetch_object($result);
// Controls
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
else
$compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
}
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
$compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0);
$compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
$compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code))
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
}
$line = new FactureLigne($db);
@ -196,29 +196,29 @@ if ($result) {
$tabfac[$obj->rowid]["ref"] = $obj->ref;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
$tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries)
//$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
// Avoid warnings
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0;
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0;
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
$tabcompany[$obj->rowid] = array (
$tabcompany[$obj->rowid] = array(
'id' => $obj->socid,
'name' => $obj->name,
'code_client' => $obj->code_client,
'code_compta' => $compta_soc
);
$i ++;
$i++;
}
} else {
dol_print_error($db);
@ -229,16 +229,16 @@ $errorforinvoice = array();
// Loop in invoices to detect lines with not binding lines
foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql = "SELECT COUNT(fd.rowid) as nb";
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql.= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj->nb > 0)
{
$errorforinvoice[$key]='somelinesarenotbound';
$errorforinvoice[$key] = 'somelinesarenotbound';
}
}
else dol_print_error($db);
@ -282,7 +282,7 @@ if ($action == 'writebookkeeping') {
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -302,7 +302,7 @@ if ($action == 'writebookkeeping') {
}
// Thirdparty
if (! $errorforline)
if (!$errorforline)
{
foreach ($tabttc[$key] as $k => $mt) {
$bookkeeping = new BookKeeping($db);
@ -367,7 +367,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_client;
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
@ -392,14 +392,14 @@ if ($action == 'writebookkeeping') {
{
$error++;
$errorforline++;
$errorforinvoice[$key]='alreadyjournalized';
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
$errorforinvoice[$key]='other';
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -454,14 +454,14 @@ if ($action == 'writebookkeeping') {
{
$error++;
$errorforline++;
$errorforinvoice[$key]='alreadyjournalized';
$errorforinvoice[$key] = 'alreadyjournalized';
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
}
else
{
$error++;
$errorforline++;
$errorforinvoice[$key]='other';
$errorforinvoice[$key] = 'other';
setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
}
}
@ -471,15 +471,15 @@ if ($action == 'writebookkeeping') {
}
// Protection against a bug on lines before
if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit)))
if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit)))
{
$error++;
$errorforline++;
$errorforinvoice[$key]='amountsnotbalanced';
$errorforinvoice[$key] = 'amountsnotbalanced';
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
}
if (! $errorforline)
if (!$errorforline)
{
$db->commit();
}
@ -490,7 +490,7 @@ if ($action == 'writebookkeeping') {
if ($error >= 10)
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach
break; // Break in the foreach
}
}
}
@ -509,20 +509,20 @@ if ($action == 'writebookkeeping') {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action='';
$action = '';
// Must reload data, so we make a redirect
if (count($tabpay) != $error)
{
$param='id_journal='.$id_journal;
$param.='&date_startday='.$date_startday;
$param.='&date_startmonth='.$date_startmonth;
$param.='&date_startyear='.$date_startyear;
$param.='&date_endday='.$date_endday;
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
$param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth;
$param .= '&date_startyear='.$date_startyear;
$param .= '&date_endday='.$date_endday;
$param .= '&date_endmonth='.$date_endmonth;
$param .= '&date_endyear='.$date_endyear;
$param .= '&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
exit;
}
}
@ -541,7 +541,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$filename = 'journal';
$type_export = 'journal';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db);
$invoicestatic = new Facture($db);
@ -568,7 +568,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -581,18 +581,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
// Third party
foreach ($tabttc[$key] as $k => $mt) {
//if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . $journal . '"';
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$langs->trans("Thirdparty").'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
//}
}
@ -602,18 +602,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true);
//if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $journal . '"';
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$sep;
print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
//}
}
@ -627,18 +627,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) {
print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""' . $sep;
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $journal . '"';
print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$sep;
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.$journal.'"';
print "\n";
}
}
@ -651,22 +651,22 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if (empty($action) || $action == 'view') {
llxHeader('', $langs->trans("SellsJournal"));
$nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nom = $langs->trans("SellsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1);
$nomlink = '';
$periodlink = '';
$exportlink = '';
$builddate=dol_now();
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$builddate = dol_now();
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$description .= $langs->trans("DepositsAreNotIncluded");
else
$description .= $langs->trans("DepositsAreIncluded");
$listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal=' . $id_journal;
$varlink = 'id_journal='.$id_journal;
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
@ -677,13 +677,13 @@ if (empty($action) || $action == 'view') {
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
}
print '<div class="tabsAction tabsActionNoBottom">';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
}
else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>';
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
print '</div>';
@ -712,13 +712,13 @@ if (empty($action) || $action == 'view') {
print '<div class="div-table-responsive">';
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
print "<td>" . $langs->trans("LabelOperation") . "</td>";
print '<td class="center">' . $langs->trans("Debit") . "</td>";
print '<td class="center">' . $langs->trans("Credit") . "</td>";
print "<td>".$langs->trans("Date")."</td>";
print "<td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
print "<td>".$langs->trans("AccountAccounting")."</td>";
print "<td>".$langs->trans("SubledgerAccount")."</td>";
print "<td>".$langs->trans("LabelOperation")."</td>";
print '<td class="center">'.$langs->trans("Debit")."</td>";
print '<td class="center">'.$langs->trans("Credit")."</td>";
print "</tr>\n";
$r = '';
@ -748,7 +748,7 @@ if (empty($action) || $action == 'view') {
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED)
{
$replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2;
}
@ -757,8 +757,8 @@ if (empty($action) || $action == 'view') {
{
print '<tr class="oddeven">';
print "<!-- Replaced invoice -->";
print "<td>" . $date . "</td>";
print "<td><strike>" . $invoicestatic->getNomUrl(1) . "</strike></td>";
print "<td>".$date."</td>";
print "<td><strike>".$invoicestatic->getNomUrl(1)."</strike></td>";
// Account
print "<td>";
print $langs->trans("Replaced");
@ -778,8 +778,8 @@ if (empty($action) || $action == 'view') {
{
print '<tr class="oddeven">';
print "<!-- Some lines are not bound -->";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
print '<span class="error">'.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).'</span>';
@ -867,8 +867,8 @@ if (empty($action) || $action == 'view') {
if ($mt) {
print '<tr class="oddeven">';
print "<!-- VAT -->";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>".$date."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
// Account
print "<td>";
$accountoshow = length_accountg($k);
@ -881,10 +881,10 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '');
print "</td>";
print '<td class="right nowraponall">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
print '<td class="right nowraponall">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
}
}

View File

@ -28,11 +28,11 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","accountancy"));
$langs->loadLangs(array("bills", "accountancy"));
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
@ -52,16 +52,16 @@ if ($user->socid > 0)
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
if (!$cancel)
{
if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " SET fk_code_ventilation = ".$codeventil;
$sql .= " WHERE rowid = ".$id;
$resql = $db->query($sql);
if (! $resql) {
if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors');
}
else
@ -95,18 +95,18 @@ $form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db);
$formaccounting = new FormAccounting($db);
if (! empty($id)) {
if (!empty($id)) {
$sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
$sql .= ", aa.account_number, aa.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".$id;
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
dol_syslog("/accounting/supplier/card.php sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@ -116,8 +116,8 @@ if (! empty($id)) {
if ($num_lines) {
$objp = $db->fetch_object($result);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
@ -125,20 +125,20 @@ if (! empty($id)) {
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// ref invoice
print '<tr><td>' . $langs->trans("BillsSuppliers") . '</td>';
print '<tr><td>'.$langs->trans("BillsSuppliers").'</td>';
$facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid;
print '<td>' . $facturefournisseur_static->getNomUrl(1) . '</td>';
print '<td>'.$facturefournisseur_static->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . stripslashes(nl2br($objp->description)) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print '<tr><td width="20%">'.$langs->trans("Line").'</td>';
print '<td>'.stripslashes(nl2br($objp->description)).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("ProductLabel").'</td>';
print '<td>'.dol_trunc($objp->product_label, 24).'</td>';
print '<tr><td width="20%">'.$langs->trans("Account").'</td><td>';
print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>';
print '</table>';
@ -146,9 +146,9 @@ if (! empty($id)) {
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';

View File

@ -25,13 +25,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -39,16 +39,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -75,19 +75,19 @@ if ($action == 'clean' || $action == 'validatehistory')
{
// Clean database
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd";
$sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture_fourn WHERE entity = '.$conf->entity.')';
$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -118,24 +118,24 @@ if ($action == 'validatehistory') {
// Supplier Invoice Lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql.= " aa.rowid as aarowid,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql .= " aa.rowid as aarowid,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
dol_syslog('htdocs/accountancy/supplier/index.php');
$result = $db->query($sql);
if (! $result) {
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -171,12 +171,12 @@ if ($action == 'validatehistory') {
if ($objp->aarowid_suggest > 0)
{
$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate)
if (!$resqlupdate)
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
@ -205,49 +205,49 @@ if ($action == 'validatehistory') {
llxHeader('', $langs->trans("SuppliersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("SuppliersVentilation")." ".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier").'<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
@ -256,7 +256,7 @@ $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 class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -271,11 +271,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -293,31 +293,31 @@ print_barre_liste($langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '',
//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
print '<td width="200" class="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>';
print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number') ." AS codecomptable,";
$sql .= " " . $db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label') . " AS intitule,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
$sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
@ -326,7 +326,7 @@ $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 class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -341,11 +341,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -366,28 +366,28 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="400" class="left">' . $langs->trans("Total") . '</td>';
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
print '<td width="60" class="right">' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '</td>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td width="60" class="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
$sql = "SELECT '" . $langs->trans("CAHTF") . "' AS label,";
for($i = 1; $i <= 12; $i ++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START?$conf->global->SOCIETE_FISCAL_MONTH_START:1) - 1;
if ($j > 12) $j-=12;
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $j, 'ffd.total_ht', '0') . ") AS month" . str_pad($j, 2, '0', STR_PAD_LEFT) . ",";
$sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " SUM(ffd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
$sql .= " AND ff.datef <= '".$db->idate($search_date_end)."'";
$sql .= " AND ff.fk_statut > 0";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/supplier/index.php');
$resql = $db->query($sql);
@ -395,11 +395,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$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 class="nowrap right">' . price($row[$i]) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right"><b>' . price($row[13]) . '</b></td>';
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>';
}
$db->free($resql);

View File

@ -26,18 +26,18 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","accountancy","productbatch"));
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch"));
$account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount');
@ -50,14 +50,14 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -65,9 +65,9 @@ if (empty($page) || $page < 0) $page = 0;
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC";
}
@ -76,7 +76,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$formaccounting = new FormAccounting($db);
@ -107,28 +107,28 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
if (! (GETPOST('account_parent', 'int') >= 0))
if (!(GETPOST('account_parent', 'int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
if (!$error)
{
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')';
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error) {
if (!$error) {
$db->commit();
setEventMessages($langs->trans('Save'), null, 'mesgs');
} else {
@ -136,7 +136,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
setEventMessages($db->lasterror(), null, 'errors');
}
$account_parent = ''; // Protection to avoid to mass apply it a second time
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
}
@ -148,7 +148,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$form = new Form($db);
$formother = new FormOther($db);
llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched"));
llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"));
print '<script type="text/javascript">
$(function () {
@ -171,21 +171,21 @@ print '<script type="text/javascript">
* Supplier Invoice lines
*/
$sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
$sql.= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql.= " aa.label, aa.account_number, ";
$sql.= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,";
$sql.= " co.code as country_code, co.label as country,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql .= " aa.label, aa.account_number, ";
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,";
$sql .= " co.code as country_code, co.label as country,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);
}
@ -210,30 +210,30 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
@ -259,22 +259,22 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref);
if ($search_label) $param .= "&search_label=" . urlencode($search_label);
if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc);
if ($search_account) $param .= "&search_account=" . urlencode($search_account);
if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
if ($search_account) $param .= "&search_account=".urlencode($search_account);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -285,39 +285,39 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'" /></div>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
// print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
@ -335,7 +335,7 @@ if ($result) {
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center ');
$checkpicto=$form->showCheckAddButtons();
$checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
@ -345,7 +345,7 @@ if ($result) {
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
$codecompta = length_accountg($objp->account_number).' - '.$objp->label;
$facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid;
@ -358,17 +358,17 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facturefournisseur_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).'</td>';
print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label;
print '</td>';
// Date invoice
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref product
print '<td>';
@ -384,27 +384,27 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
print '</td>';
print '<td class="nowrap right">' . price($objp->total_ht) . '</td>';
print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
print '<td class="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
print '<td>';
if ($objp->country_code)
{
print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')';
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
}
print '</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">';
print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit();
print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
print '</tr>';
$i ++;
$i++;
}
print '</table>';
print "</div>";

View File

@ -27,22 +27,22 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch"));
$action=GETPOST('action', 'alpha');
$massaction=GETPOST('massaction', 'alpha');
$show_files=GETPOST('show_files', 'int');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box
@ -57,16 +57,16 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC";
}
@ -85,7 +85,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -104,11 +104,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -132,7 +132,7 @@ if (empty($reshook))
}
// Mass actions
$objectclass='AccountingAccount';
$objectclass = 'AccountingAccount';
$permissiontoread = $user->rights->accounting->read;
$permissiontodelete = $user->rights->accounting->delete;
$uploaddir = $conf->accounting->dir_output;
@ -141,15 +141,15 @@ if (empty($reshook))
if ($massaction == 'ventil') {
$msg='';
$msg = '';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
$msg.='<div class="detail">';
if (!empty($mesCasesCochees)) {
$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
$msg .= '<div class="detail">';
$cpt = 0;
$ok=0;
$ko=0;
$ok = 0;
$ko = 0;
foreach ($mesCasesCochees as $maLigneCochee) {
$maLigneCourante = explode("_", $maLigneCochee);
@ -158,32 +158,32 @@ if ($massaction == 'ventil') {
if ($monCompte <= 0)
{
$msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
$ko++;
}
else
{
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " SET fk_code_ventilation = ".$monCompte;
$sql .= " WHERE rowid = ".$monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
if ($db->query($sql)) {
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
$msg .= '<div><font color="green">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
$ok++;
} else {
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
$ko++;
}
}
$cpt++;
}
$msg.='</div>';
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
$msg .= '</div>';
$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
}
}
@ -209,22 +209,22 @@ if (empty($chartaccountcode))
// Supplier Invoice Lines
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql.= " aa.rowid as aarowid,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql .= " aa.rowid as aarowid,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
// Add search filter like
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);
@ -250,35 +250,35 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")";
} else {
$sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")";
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")";
}
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
@ -304,34 +304,34 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid);
if ($search_day) $param.='&search_day='.urlencode($search_day);
if ($search_month) $param.='&search_month='.urlencode($search_month);
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_label) $param.='&search_label='.urlencode($search_label);
if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
if ($search_country) $param.="&search_country=".urlencode($search_country);
if ($search_tvaintra) $param.="&search_tvaintra=".urlencode($search_tvaintra);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
$arrayofmassactions = array(
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -342,7 +342,7 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer") . '</span></br><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
@ -355,31 +355,31 @@ if ($result) {
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="center liste_titre">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
@ -398,8 +398,8 @@ if ($result) {
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto='';
if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
@ -429,18 +429,18 @@ if ($result) {
$objp->aarowid_suggest = $objp->aarowid;
if ($objp->type_l == 1) {
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : '');
$objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : '');
if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_s;
} elseif ($objp->type_l == 0) {
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : '');
$objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : '');
if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_p;
}
if ($objp->code_buy_l == -1) $objp->code_buy_l='';
if ($objp->code_buy_l == -1) $objp->code_buy_l = '';
if (! empty($objp->code_buy)) {
$objp->code_buy_p = $objp->code_buy; // Code on product
if (!empty($objp->code_buy)) {
$objp->code_buy_p = $objp->code_buy; // Code on product
} else {
$code_buy_p_notset = 'color:orange';
}
@ -452,16 +452,16 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facturefourn_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).'</td>';
print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label;
print '</td>';
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product
print '<td>';
@ -484,35 +484,35 @@ if ($result) {
// Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
print '<td style="'.$code_vat_differ.'" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
print '</td>';
// Country
print '<td>';
$labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label;
$labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label;
print $labelcountry;
print '</td>';
// VAT Num
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
// Current account
print '<td class="center" style="' . $code_buy_p_notset . '">';
$s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': ';
print '<td class="center" style="'.$code_buy_p_notset.'">';
$s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport");
$s.= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined"));
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
$s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined"));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0)
{
print '<br>';
$s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': ';
$s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s.= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p));
$s .= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print '</td>';
@ -526,11 +526,11 @@ if ($result) {
// Column with checkbox
print '<td class="center">';
$ischecked = $objp->aarowid_suggest;
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>';
print '</td>';
print '</tr>';
$i ++;
$i++;
}
print '</table>';

View File

@ -154,7 +154,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateall">';
print load_fiche_titre($langs->trans("MemberMainOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
@ -212,7 +212,7 @@ if ($conf->facture->enabled)
{
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
print '<td>';
$form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS');
$form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
print '</td>';
}
print "</tr>\n";

View File

@ -31,11 +31,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","members"));
$langs->loadLangs(array("admin", "members"));
$action=GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
/*
@ -50,22 +50,22 @@ if ($action == 'setMEMBER_ENABLE_PUBLIC')
if ($action == 'update')
{
$public=GETPOST('MEMBER_ENABLE_PUBLIC');
$amount=GETPOST('MEMBER_NEWFORM_AMOUNT');
$editamount=GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
$payonline=GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype=GETPOST('MEMBER_NEWFORM_FORCETYPE');
$public = GETPOST('MEMBER_ENABLE_PUBLIC');
$amount = GETPOST('MEMBER_NEWFORM_AMOUNT');
$editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT');
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE');
$res=dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
if ($forcetype < 0) $res=dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
else $res=dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
else $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -80,13 +80,13 @@ if ($action == 'update')
* View
*/
$form=new Form($db);
$form = new Form($db);
$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
llxHeader('', $langs->trans("MembersSetup"), $help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
$head = member_admin_prepare_head();
@ -142,28 +142,28 @@ $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
{
// Button off, click to enable
$enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
$enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml.='</a>';
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml .= '</a>';
}
else
{
// Button on, click to disable
$enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
$enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml.='</a>';
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMEMBER_ENABLE_PUBLIC&value=0'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml .= '</a>';
}
print $enabledisablehtml;
print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC)?0:1).'">';
print '<input type="hidden" id="MEMBER_ENABLE_PUBLIC" name="MEMBER_ENABLE_PUBLIC" value="'.(empty($conf->global->MEMBER_ENABLE_PUBLIC) ? 0 : 1).'">';
print '<br>';
if (! empty($conf->global->MEMBER_ENABLE_PUBLIC))
if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
{
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
@ -221,20 +221,20 @@ dol_fiche_end();
print '</form>';
if (! empty($conf->global->MEMBER_ENABLE_PUBLIC))
if (!empty($conf->global->MEMBER_ENABLE_PUBLIC))
{
print '<br>';
//print $langs->trans('FollowingLinksArePublic').'<br>';
print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':<br>';
if ($conf->multicompany->enabled) {
$entity_qr='?entity='.$conf->entity;
$entity_qr = '?entity='.$conf->entity;
} else {
$entity_qr='';
$entity_qr = '';
}
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
print '<a target="_blank" href="'.$urlwithroot.'/public/members/new.php'.$entity_qr.'">'.$urlwithroot.'/public/members/new.php'.$entity_qr.'</a>';

View File

@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
// Load translation files required by the page
$langs->loadLangs(array("companies","members"));
$langs->loadLangs(array("companies", "members"));
$id = GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('rowid', 'int');
$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('rowid', 'int');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -46,31 +46,31 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='a.datep,a.id';
if (! $sortorder) $sortorder='DESC';
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC';
if (GETPOST('actioncode', 'array'))
{
$actioncode=GETPOST('actioncode', 'array', 3);
if (! count($actioncode)) $actioncode='0';
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
}
else
{
$actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
$search_agenda_label=GETPOST('search_agenda_label');
$search_agenda_label = GETPOST('search_agenda_label');
// Security check
$result=restrictedArea($user, 'adherent', $id);
$result = restrictedArea($user, 'adherent', $id);
$object = new Adherent($db);
$result=$object->fetch($id);
$result = $object->fetch($id);
if ($result > 0)
{
$object->fetch_thirdparty();
$adht = new AdherentType($db);
$result=$adht->fetch($object->typeid);
$result = $adht->fetch($object->typeid);
}
@ -78,14 +78,14 @@ if ($result > 0)
* Actions
*/
$parameters=array('id'=>$id, 'objcanvas'=>$objcanvas);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('id'=>$id, 'objcanvas'=>$objcanvas);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Cancel
if (GETPOST('cancel', 'alpha') && ! empty($backtopage))
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
header("Location: ".$backtopage);
exit;
@ -94,8 +94,8 @@ if (empty($reshook))
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{
$actioncode='';
$search_agenda_label='';
$actioncode = '';
$search_agenda_label = '';
}
}
@ -110,7 +110,7 @@ $contactstatic = new Contact($db);
$form = new Form($db);
/*
* Fiche categorie de client et/ou fournisseur
* Customer and/or supplier category sheet
*/
if ($object->id > 0)
{
@ -119,11 +119,11 @@ if ($object->id > 0)
$langs->load("companies");
$title=$langs->trans("Member") . " - " . $langs->trans("Agenda");
$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
$title = $langs->trans("Member")." - ".$langs->trans("Agenda");
$helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
llxHeader("", $title, $helpurl);
if (! empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) $langs->load("mails");
$head = member_prepare_head($object);
dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');

File diff suppressed because it is too large Load Diff

View File

@ -99,9 +99,9 @@ class AdherentType extends CommonObject
public $mail_valid;
/** @var array Array of members */
public $members=array();
public $members = array();
public $multilangs=array();
public $multilangs = array();
/**
@ -127,8 +127,8 @@ class AdherentType extends CommonObject
$current_lang = $langs->getDefaultLang();
$sql = "SELECT lang, label, description, email";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$result = $this->db->query($sql);
if ($result) {
@ -138,7 +138,7 @@ class AdherentType extends CommonObject
if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales.
{
$this->label = $obj->label;
$this->description = $obj->description;
$this->description = $obj->description;
$this->email = $obj->email;
}
$this->multilangs["$obj->lang"]["label"] = $obj->label;
@ -149,7 +149,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error="Error: ".$this->db->lasterror()." - ".$sql;
$this->error = "Error: ".$this->db->lasterror()." - ".$sql;
return -1;
}
}
@ -171,75 +171,75 @@ class AdherentType extends CommonObject
{
if ($key == $current_lang) {
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'";
$result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET ";
$sql2.= " label='".$this->db->escape($this->label)."',";
$sql2.= " description='".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'";
$sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->label)."',";
$sql2 .= " description='".$this->db->escape($this->description)."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->other)."'";
}
$sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
}
else
{
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email";
}
$sql2.= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',";
$sql2.= " '".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'";
$sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
$sql2 .= " '".$this->db->escape($this->description)."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'";
}
$sql2.= ")";
$sql2 .= ")";
}
dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (! $this->db->query($sql2)) {
$this->error=$this->db->lasterror();
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
}
elseif (isset($this->multilangs[$key])) {
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql .= " WHERE fk_type=".$this->id;
$sql .= " AND lang='".$key."'";
$result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language
{
$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET ";
$sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'";
$sql2 .= " SET ";
$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'";
}
$sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
}
else
{
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email";
}
$sql2.= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'";
$sql2 .= ")";
$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'";
}
$sql2.= ")";
$sql2 .= ")";
}
// We do not save if main fields are empty
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
if (! $this->db->query($sql2)) {
$this->error=$this->db->lasterror();
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
}
@ -272,7 +272,7 @@ class AdherentType extends CommonObject
public function delMultiLangs($langtodelete, $user)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
$sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
$result = $this->db->query($sql);
@ -289,7 +289,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
return -1;
}
@ -306,22 +306,22 @@ class AdherentType extends CommonObject
{
global $langs, $conf;
$error=0;
$error = 0;
$this->statut=(int) $this->statut;
$this->label=trim($this->label);
$this->statut = (int) $this->statut;
$this->label = trim($this->label);
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= " morphy";
$sql.= ", libelle";
$sql.= ", entity";
$sql.= ") VALUES (";
$sql.= "'".$this->db->escape($this->morphy)."'";
$sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity;
$sql.= ")";
$sql .= " morphy";
$sql .= ", libelle";
$sql .= ", entity";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->morphy)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", ".$conf->entity;
$sql .= ")";
dol_syslog("Adherent_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
@ -336,15 +336,15 @@ class AdherentType extends CommonObject
return -3;
}
if (! $notrigger)
if (!$notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_CREATE', $user);
$result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return $this->id;
@ -358,7 +358,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -375,23 +375,23 @@ class AdherentType extends CommonObject
{
global $langs, $conf, $hookmanager;
$error=0;
$error = 0;
$this->label=trim($this->label);
$this->label = trim($this->label);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET ";
$sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "morphy = '".$this->db->escape($this->morphy) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',";
$sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = ".(integer) $this->db->escape($this->vote).",";
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql.= " WHERE rowid =".$this->id;
$sql .= "SET ";
$sql .= "statut = ".$this->statut.",";
$sql .= "libelle = '".$this->db->escape($this->label)."',";
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
$sql .= "note = '".$this->db->escape($this->note)."',";
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
$sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql .= " WHERE rowid =".$this->id;
$result = $this->db->query($sql);
if ($result)
@ -399,34 +399,34 @@ class AdherentType extends CommonObject
$this->description = $this->db->escape($this->note);
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) {
if (!empty($conf->global->MAIN_MULTILANGS)) {
if ($this->setMultiLangs($user) < 0) {
$this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
$this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
return -2;
}
}
$action='update';
$action = 'update';
// Actions on extra fields
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
if (!$error && !$notrigger)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user);
$result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
if (!$error)
{
$this->db->commit();
return 1;
@ -440,7 +440,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
@ -458,13 +458,13 @@ class AdherentType extends CommonObject
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE rowid = ".$this->id;
$sql .= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('MEMBER_TYPE_DELETE', $user);
$result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers
@ -474,7 +474,7 @@ class AdherentType extends CommonObject
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -489,13 +489,13 @@ class AdherentType extends CommonObject
{
global $langs, $conf;
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".(int) $rowid;
dol_syslog("Adherent_type::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
@ -506,9 +506,10 @@ class AdherentType extends CommonObject
$this->ref = $obj->rowid;
$this->label = $obj->label;
$this->morphy = $obj->morphy;
$this->statut = $obj->statut;
$this->statut = $obj->status; // deprecated
$this->status = $obj->status;
$this->duration = $obj->duration;
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1);
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
$this->duration_unit = substr($obj->duration, -1);
$this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid;
@ -516,7 +517,7 @@ class AdherentType extends CommonObject
$this->vote = $obj->vote;
// multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) {
if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->getMultiLangs();
}
}
@ -525,7 +526,7 @@ class AdherentType extends CommonObject
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -539,15 +540,15 @@ class AdherentType extends CommonObject
public function liste_array()
{
// phpcs:enable
global $conf,$langs;
global $conf, $langs;
$adherenttypes = array();
$sql = "SELECT rowid, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('member_type').")";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql .= " WHERE entity IN (".getEntity('member_type').")";
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
@ -584,13 +585,13 @@ class AdherentType extends CommonObject
{
global $conf, $user;
$ret=array();
$ret = array();
$sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.entity IN (".getEntity('member').")";
$sql.= " AND a.fk_adherent_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql .= " WHERE a.entity IN (".getEntity('member').")";
$sql .= " AND a.fk_adherent_type = ".$this->id;
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -598,31 +599,31 @@ class AdherentType extends CommonObject
{
while ($obj = $this->db->fetch_object($resql))
{
if (! array_key_exists($obj->rowid, $ret))
if (!array_key_exists($obj->rowid, $ret))
{
if ($mode < 2)
{
$memberstatic=new Adherent($this->db);
$memberstatic = new Adherent($this->db);
if ($mode == 1) {
$memberstatic->fetch($obj->rowid, '', '', '', false, false);
} else {
$memberstatic->fetch($obj->rowid);
}
$ret[$obj->rowid]=$memberstatic;
$ret[$obj->rowid] = $memberstatic;
}
else $ret[$obj->rowid]=$obj->rowid;
else $ret[$obj->rowid] = $obj->rowid;
}
}
$this->db->free($resql);
$this->members=$ret;
$this->members = $ret;
return $ret;
}
else
{
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@ -654,28 +655,57 @@ class AdherentType extends CommonObject
{
global $langs;
$result='';
$label=$langs->trans("ShowTypeCard", $this->label);
$result = '';
$label = $langs->trans("ShowTypeCard", $this->label);
$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label);
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
$result .= $linkend;
return $result;
}
/**
* getLibStatut
*
* @return string Return status of a type of member
*/
public function getLibStatut()
{
return '';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return label of status (activity, closed)
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->status, $mode);
}
/**
* Return the label of a given status
*
* @param int $status Status id
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Status label
*/
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
$langs->load('companies');
$statusType = 'status4';
if ($status == 0) $statusType = 'status5';
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
$this->labelStatus[0] = $langs->trans("ActivityCeased");
$this->labelStatus[1] = $langs->trans("InActivity");
$this->labelStatusShort[0] = $langs->trans("ActivityCeased");
$this->labelStatusShort[1] = $langs->trans("InActivity");
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -693,10 +723,10 @@ class AdherentType extends CommonObject
{
// phpcs:enable
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
$dn = '';
if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
return $dn;
}
@ -711,27 +741,27 @@ class AdherentType extends CommonObject
public function _load_ldap_info()
{
// phpcs:enable
global $conf,$langs;
global $conf, $langs;
$info=array();
$info = array();
// Object classes
$info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
$info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
// Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1);
if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{
$valueofldapfield=array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
$valueofldapfield = array();
foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database.
{
$member=new Adherent($this->db);
$member = new Adherent($this->db);
$member->fetch($val->id, '', '', '', false, false);
$info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2);
}
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
$info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : '');
}
return $info;
}
@ -750,18 +780,18 @@ class AdherentType extends CommonObject
// Initialise parametres
$this->id = 0;
$this->ref = 'MTSPEC';
$this->specimen=1;
$this->specimen = 1;
$this->label='MEMBERS TYPE SPECIMEN';
$this->note='This is a note';
$this->mail_valid='This is welcome email';
$this->subscription=1;
$this->vote=0;
$this->label = 'MEMBERS TYPE SPECIMEN';
$this->note = 'This is a note';
$this->mail_valid = 'This is welcome email';
$this->subscription = 1;
$this->vote = 0;
$this->statut=1;
$this->statut = 1;
// Members of this member type is just me
$this->members=array(
$this->members = array(
$user->id => $user
);
}
@ -775,7 +805,7 @@ class AdherentType extends CommonObject
{
global $conf;
if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
{
return $this->mail_valid;
}
@ -793,7 +823,7 @@ class AdherentType extends CommonObject
global $conf;
// mail_subscription not defined so never used
if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined
{
return $this->mail_subscription;
}
@ -811,7 +841,7 @@ class AdherentType extends CommonObject
global $conf;
// NOTE mail_resiliate not defined so never used
if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined
{
return $this->mail_resiliate;
}

View File

@ -36,10 +36,10 @@ $hookmanager = new HookManager($db);
$hookmanager->initHooks(array('membersindex'));
// Load translation files required by the page
$langs->loadLangs(array("companies","members"));
$langs->loadLangs(array("companies", "members"));
// Security check
$result=restrictedArea($user, 'adherent');
$result = restrictedArea($user, 'adherent');
/*
@ -117,7 +117,7 @@ if ($result)
while ($i < $num)
{
$objp = $db->fetch_object($result);
$MemberUpToDate[$objp->fk_adherent_type]=$objp->somme;
$MemberUpToDate[$objp->fk_adherent_type] = $objp->somme;
$i++;
}
$db->free();
@ -128,12 +128,12 @@ if ($result)
print '<div class="fichecenter"><div class="fichethirdleft">';
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
// Search contact/address
if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire)
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire)
{
$listofsearchfields['search_member']=array('text'=>'Member');
$listofsearchfields['search_member'] = array('text'=>'Member');
}
if (count($listofsearchfields))
@ -142,8 +142,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
$i=0;
foreach($listofsearchfields as $key => $value)
$i = 0;
foreach ($listofsearchfields as $key => $value)
{
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr class="oddeven">';
@ -167,37 +167,37 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
if ($conf->use_javascript_ajax)
{
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover" width="100%">';
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr><td class="center" colspan="2">';
$SommeA=0;
$SommeB=0;
$SommeC=0;
$SommeD=0;
$total=0;
$dataval=array();
$datalabels=array();
$i=0;
$SommeA = 0;
$SommeB = 0;
$SommeC = 0;
$SommeD = 0;
$total = 0;
$dataval = array();
$datalabels = array();
$i = 0;
foreach ($AdherentType as $key => $adhtype)
{
$datalabels[]=array($i,$adhtype->getNomUrl(0, dol_size(16)));
$dataval['draft'][]=array($i,isset($MemberToValidate[$key])?$MemberToValidate[$key]:0);
$dataval['notuptodate'][]=array($i,isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0);
$dataval['uptodate'][]=array($i,isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0);
$dataval['resiliated'][]=array($i,isset($MembersResiliated[$key])?$MembersResiliated[$key]:0);
$SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
$SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0;
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
$datalabels[] = array($i, $adhtype->getNomUrl(0, dol_size(16)));
$dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0);
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0);
$dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0);
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
$SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0;
$SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0;
$SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0;
$SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
$i++;
}
$total = $SommeA + $SommeB + $SommeC + $SommeD;
$dataseries=array();
$dataseries[]=array($langs->trans("MenuMembersNotUpToDate"), round($SommeB));
$dataseries[]=array($langs->trans("MenuMembersUpToDate"), round($SommeC));
$dataseries[]=array($langs->trans("MembersStatusResiliated"), round($SommeD));
$dataseries[]=array($langs->trans("MembersStatusToValid"), round($SommeA));
$dataseries = array();
$dataseries[] = array($langs->trans("MenuMembersNotUpToDate"), round($SommeB));
$dataseries[] = array($langs->trans("MenuMembersUpToDate"), round($SommeC));
$dataseries[] = array($langs->trans("MembersStatusResiliated"), round($SommeD));
$dataseries[] = array($langs->trans("MembersStatusToValid"), round($SommeA));
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
@ -207,11 +207,11 @@ if ($conf->use_javascript_ajax)
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total?0:1);
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
print $SommeA+$SommeB+$SommeC+$SommeD;
print $SommeA + $SommeB + $SommeC + $SommeD;
print '</td></tr>';
print '</table>';
print '</div>';
@ -239,17 +239,17 @@ if ($result)
while ($i < $num)
{
$objp = $db->fetch_object($result);
$year=dol_print_date($db->jdate($objp->dateh), "%Y");
$Total[$year]=(isset($Total[$year])?$Total[$year]:0)+$objp->subscription;
$Number[$year]=(isset($Number[$year])?$Number[$year]:0)+1;
$tot+=$objp->subscription;
$numb+=1;
$year = dol_print_date($db->jdate($objp->dateh), "%Y");
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
$tot += $objp->subscription;
$numb += 1;
$i++;
}
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Year").'</th>';
print '<th class="right">'.$langs->trans("Subscriptions").'</th>';
@ -275,7 +275,7 @@ foreach ($Total as $key=>$value)
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
print "<td class=\"right\">".$Number[$key]."</td>";
print "<td class=\"right\">".price($value)."</td>";
print "<td class=\"right\">".price(price2num($value/$Number[$key], 'MT'))."</td>";
print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>";
print "</tr>\n";
$i++;
}
@ -285,7 +285,7 @@ print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print "<td class=\"right\">".$numb."</td>";
print '<td class="right">'.price($tot)."</td>";
print "<td class=\"right\">".price(price2num($numb>0?($tot/$numb):0, 'MT'))."</td>";
print "<td class=\"right\">".price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT'))."</td>";
print "</tr>\n";
print "</table></div>";
print "<br>\n";
@ -296,22 +296,22 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Latest modified members
*/
$max=5;
$max = 5;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql.= " a.tms as datem, datefin as date_end_subscription,";
$sql.= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND a.fk_adherent_type = ta.rowid";
$sql.= $db->order("a.tms", "DESC");
$sql.= $db->plimit($max, 0);
$sql .= " a.tms as datem, datefin as date_end_subscription,";
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql .= " WHERE a.entity IN (".getEntity('adherent').")";
$sql .= " AND a.fk_adherent_type = ta.rowid";
$sql .= $db->order("a.tms", "DESC");
$sql .= $db->plimit($max, 0);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="4">'.$langs->trans("LastMembersModified", $max).'</th></tr>';
@ -359,22 +359,22 @@ else
/*
* Last modified subscriptions
*/
$max=5;
$max = 5;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql.= " datefin as date_end_subscription,";
$sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " WHERE a.entity IN (".getEntity('adherent').")";
$sql.= " AND c.fk_adherent = a.rowid";
$sql.= $db->order("c.tms", "DESC");
$sql.= $db->plimit($max, 0);
$sql .= " datefin as date_end_subscription,";
$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " WHERE a.entity IN (".getEntity('adherent').")";
$sql .= " AND c.fk_adherent = a.rowid";
$sql .= $db->order("c.tms", "DESC");
$sql .= $db->plimit($max, 0);
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="5">'.$langs->trans("LastSubscriptionsModified", $max).'</th></tr>';
@ -386,25 +386,25 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
$subscriptionstatic->id=$obj->cid;
$subscriptionstatic->ref=$obj->cid;
$staticmember->id=$obj->rowid;
$staticmember->lastname=$obj->lastname;
$staticmember->firstname=$obj->firstname;
if (! empty($obj->fk_soc)) {
$subscriptionstatic->id = $obj->cid;
$subscriptionstatic->ref = $obj->cid;
$staticmember->id = $obj->rowid;
$staticmember->lastname = $obj->lastname;
$staticmember->firstname = $obj->firstname;
if (!empty($obj->fk_soc)) {
$staticmember->fk_soc = $obj->fk_soc;
$staticmember->fetch_thirdparty();
$staticmember->name=$staticmember->thirdparty->name;
$staticmember->name = $staticmember->thirdparty->name;
} else {
$staticmember->name=$obj->company;
$staticmember->name = $obj->company;
}
$staticmember->ref=$staticmember->getFullName($langs);
$staticmember->ref = $staticmember->getFullName($langs);
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
print '<td>'.$staticmember->getNomUrl(1, 32, 'subscription').'</td>';
print '<td>'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';
print '<td class="right">'.price($obj->subscription).'</td>';
//print '<td class="right">'.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->datem?$obj->datem:$obj->datec), 'dayhour').'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour').'</td>';
print '</tr>';
$i++;
}
@ -420,7 +420,7 @@ else
// Summary of members by type
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("MembersTypes").'</th>';
print '<th class=right>'.$langs->trans("MembersStatusToValid").'</th>';
@ -433,10 +433,10 @@ foreach ($AdherentType as $key => $adhtype)
{
print '<tr class="oddeven">';
print '<td>'.$adhtype->getNomUrl(1, dol_size(32)).'</td>';
print '<td class="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).'</td>';
print '<td class="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0) > 0) ? $MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):'').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).'</td>';
print '<td class="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).'</td>';
print '<td class="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'</td>';
print '<td class="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).'</td>';
print '<td class="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).'</td>';
print '<td class="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).'</td>';
print '<td class="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'</td>';
print "</tr>\n";
}
print '<tr class="liste_total">';

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,7 @@ else
}
// Print array
print '<table class="liste" width="100%">';
print '<table class="liste centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Nature").'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").'</td>';

View File

@ -294,7 +294,7 @@ if (count($arrayjs) && $mode == 'memberbycountry')
if ($mode)
{
// Print array / Affiche le tableau
print '<table class="liste" width="100%">';
print '<table class="liste centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$label.'</td>';
if ($label2) print '<td class="center">'.$label2.'</td>';

View File

@ -145,7 +145,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// Show filter box
/*print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
print '<tr><td>'.$langs->trans("Member").'</td><td>';
print $form->select_company($id,'memberid','',1);
@ -211,7 +211,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border" width="100%"><tr class="pair nohover"><td class="center">';
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
if ($mesg) { print $mesg; }
else {
print $px1->show();

View File

@ -24,7 +24,7 @@
/**
* \file htdocs/adherents/subscription.php
* \ingroup member
* \brief Onglet d'ajout, edition, suppression des adhesions d'un adherent
* \brief tab for Adding, editing, deleting a member's memberships
*/
require '../main.inc.php';
@ -38,15 +38,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->loadLangs(array("companies","bills","members","users","mails",'other'));
$langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other'));
$action=GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$rowid=GETPOST('rowid', 'int')?GETPOST('rowid', 'int'):GETPOST('id', 'int');
$typeid=GETPOST('typeid', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$rowid = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
$typeid = GETPOST('typeid', 'int');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -56,12 +56,12 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
// Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="c.rowid";
if (! $sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield = "c.rowid";
if (!$sortorder) $sortorder = "DESC";
// Security check
$result=restrictedArea($user, 'adherent', $rowid, '', 'cotisation');
$result = restrictedArea($user, 'adherent', $rowid, '', 'cotisation');
$object = new Adherent($db);
$extrafields = new ExtraFields($db);
@ -70,11 +70,11 @@ $adht = new AdherentType($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$errmsg='';
$errmsgs=array();
$errmsg = '';
$errmsgs = array();
$defaultdelay=1;
$defaultdelayunit='y';
$defaultdelay = 1;
$defaultdelayunit = 'y';
if ($rowid)
{
@ -86,7 +86,7 @@ if ($rowid)
// Define variables to know what current user can do on properties of user linked to edited member
if ($object->user_id)
{
// $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite
// $user is the user editing, $object->user_id is the user's id linked to the edited member
$caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer)
|| (($user->id != $object->user_id) && $user->rights->user->user->creer) );
$caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password)
@ -122,7 +122,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
{
// Creation of thirdparty
$company = new Societe($db);
$result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha'));
$result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha'));
if ($result < 0)
{
@ -131,7 +131,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
}
else
{
$action='addsubscription';
$action = 'addsubscription';
}
}
else
@ -142,7 +142,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
{
$error=0;
$error = 0;
if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only
{
if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
@ -152,56 +152,56 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
}
}
if (! $error)
if (!$error)
{
if ($_POST["userid"] != $object->user_id) // If link differs from currently in database
{
$result=$object->setUserId($_POST["userid"]);
$result = $object->setUserId($_POST["userid"]);
if ($result < 0) dol_print_error('', $object->error);
$_POST['action']='';
$action='';
$_POST['action'] = '';
$action = '';
}
}
}
if ($action == 'setsocid')
{
$error=0;
if (! $error)
$error = 0;
if (!$error)
{
if (GETPOST('socid', 'int') != $object->fk_soc) // If link differs from currently in database
{
$sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
$sql.=" WHERE fk_soc = '".GETPOST('socid', 'int')."'";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'";
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj && $obj->rowid > 0)
{
$othermember=new Adherent($db);
$othermember = new Adherent($db);
$othermember->fetch($obj->rowid);
$thirdparty=new Societe($db);
$thirdparty = new Societe($db);
$thirdparty->fetch(GETPOST('socid', 'int'));
$error++;
setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
}
}
if (! $error)
if (!$error)
{
$result=$object->setThirdPartyId(GETPOST('socid', 'int'));
$result = $object->setThirdPartyId(GETPOST('socid', 'int'));
if ($result < 0) dol_print_error('', $object->error);
$_POST['action']='';
$action='';
$_POST['action'] = '';
$action = '';
}
}
}
}
if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $_POST["cancel"])
if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$_POST["cancel"])
{
$error=0;
$error = 0;
$langs->load("banks");
@ -209,114 +209,114 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$result = $adht->fetch($object->typeid);
// Subscription informations
$datesubscription=0;
$datesubend=0;
$paymentdate=0;
$datesubscription = 0;
$datesubend = 0;
$paymentdate = 0;
if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"])
{
$datesubscription=dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
}
if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"])
{
$datesubend=dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
$datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
}
if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
{
$paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
$paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
}
$amount=price2num(GETPOST("subscription", 'alpha')); // Amount of subscription
$label=$_POST["label"];
$amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription
$label = $_POST["label"];
// Payment informations
$accountid=$_POST["accountid"];
$operation=$_POST["operation"]; // Payment mode
$num_chq=$_POST["num_chq"];
$emetteur_nom=$_POST["chqemetteur"];
$emetteur_banque=$_POST["chqbank"];
$option=$_POST["paymentsave"];
if (empty($option)) $option='none';
$sendalsoemail=GETPOST("sendmail", 'alpha');
$accountid = $_POST["accountid"];
$operation = $_POST["operation"]; // Payment mode
$num_chq = $_POST["num_chq"];
$emetteur_nom = $_POST["chqemetteur"];
$emetteur_banque = $_POST["chqbank"];
$option = $_POST["paymentsave"];
if (empty($option)) $option = 'none';
$sendalsoemail = GETPOST("sendmail", 'alpha');
// Check parameters
if (! $datesubscription)
if (!$datesubscription)
{
$error++;
$langs->load("errors");
$errmsg=$langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription"));
$errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription"));
setEventMessages($errmsg, null, 'errors');
$action='addsubscription';
$action = 'addsubscription';
}
if (GETPOST('end') && ! $datesubend)
if (GETPOST('end') && !$datesubend)
{
$error++;
$langs->load("errors");
$errmsg=$langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription"));
$errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription"));
setEventMessages($errmsg, null, 'errors');
$action='addsubscription';
$action = 'addsubscription';
}
if (! $datesubend)
if (!$datesubend)
{
$datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
$datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd');
}
if (($option == 'bankviainvoice' || $option == 'bankdirect') && ! $paymentdate)
if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate)
{
$error++;
$errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
setEventMessages($errmsg, null, 'errors');
$action='addsubscription';
$action = 'addsubscription';
}
// Check if a payment is mandatory or not
if (! $error && $adht->subscription) // Member type need subscriptions
if (!$error && $adht->subscription) // Member type need subscriptions
{
if (! is_numeric($amount))
if (!is_numeric($amount))
{
// If field is '' or not a numeric value
$errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
setEventMessages($errmsg, null, 'errors');
$error++;
$action='addsubscription';
$action = 'addsubscription';
}
else
{
if (! empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none')
if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none')
{
if ($_POST["subscription"])
{
if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
if ($_POST["paymentsave"] != 'invoiceonly' && ! ($_POST["accountid"] > 0)) $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
}
else
{
if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
}
if ($errmsg)
{
$error++;
setEventMessages($errmsg, null, 'errors');
$error++;
$action='addsubscription';
$action = 'addsubscription';
}
}
}
}
// Record the subscription then complementary actions
if (! $error && $action=='subscription')
if (!$error && $action == 'subscription')
{
$db->begin();
// Create subscription
$crowid=$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
$crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend);
if ($crowid <= 0)
{
$error++;
$errmsg=$object->error;
$errmsg = $object->error;
setEventMessages($object->error, $object->errors, 'errors');
}
if (! $error)
if (!$error)
{
$result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque);
if ($result < 0)
@ -330,7 +330,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
}
}
if (! $error)
if (!$error)
{
$db->commit();
}
@ -340,23 +340,23 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$action = 'addsubscription';
}
if (! $error)
if (!$error)
{
setEventMessages("SubscriptionRecorded", null, 'mesgs');
}
// Send email
if (! $error)
if (!$error)
{
// Send confirmation Email
if ($object->email && $sendalsoemail) // $object is 'Adherent'
{
$subject = '';
$msg= '';
$msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
$formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
@ -364,44 +364,44 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
$arraydefaultmessage=null;
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
// Attach a file ?
$file='';
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
$file = '';
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
if (is_object($object->invoice))
{
$invoicediroutput = $conf->facture->dir_output;
$fileparams = dol_most_recent_file($invoicediroutput . '/' . $object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
$fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
$listofpaths=array($file);
$listofnames=array(basename($file));
$listofmimes=array(dol_mimetype($file));
$listofpaths = array($file);
$listofnames = array(basename($file));
$listofmimes = array(dol_mimetype($file));
}
$moreinheader='X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n";
$moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n";
$result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1, '', $moreinheader);
$result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$errmsg=$object->error;
$errmsg = $object->error;
setEventMessages($object->error, $object->errors, 'errors');
}
else
@ -416,13 +416,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
}
// Clean some POST vars
if (! $error)
if (!$error)
{
$_POST["subscription"]='';
$_POST["accountid"]='';
$_POST["operation"]='';
$_POST["label"]='';
$_POST["num_chq"]='';
$_POST["subscription"] = '';
$_POST["accountid"] = '';
$_POST["operation"] = '';
$_POST["label"] = '';
$_POST["num_chq"] = '';
}
}
}
@ -435,34 +435,34 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$form = new Form($db);
$now=dol_now();
$now = dol_now();
$title=$langs->trans("Member") . " - " . $langs->trans("Subscriptions");
$helpurl="EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
$title = $langs->trans("Member")." - ".$langs->trans("Subscriptions");
$helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros";
llxHeader("", $title, $helpurl);
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
$param.= '&id='.$rowid;
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
$param .= '&id='.$rowid;
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
if ($rowid > 0)
{
$res=$object->fetch($rowid);
$res = $object->fetch($rowid);
if ($res < 0) { dol_print_error($db, $object->error); exit; }
$adht->fetch($object->typeid);
$head = member_prepare_head($object);
$rowspan=10;
$rowspan = 10;
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
if (!empty($conf->societe->enabled)) $rowspan++;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -504,10 +504,10 @@ if ($rowid > 0)
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
if ((! empty($object->pass) || ! empty($object->pass_crypted)) && empty($object->user_id))
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id))
{
$langs->load("errors");
$htmltext=$langs->trans("WarningPasswordSetWithNoAccount");
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
}
print '</td></tr>';
@ -528,17 +528,17 @@ if ($rowid > 0)
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
{
print '<tr><td>' . $langs->trans("Categories") . '</td>';
print '<tr><td>'.$langs->trans("Categories").'</td>';
print '<td colspan="2">';
print $form->showCategories($object->id, 'member', 1);
print '</td></tr>';
}
// Other attributes
$cols=2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$cols = 2;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Date end subscription
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
@ -551,21 +551,21 @@ if ($rowid > 0)
}
else
{
if (! $adht->subscription)
if (!$adht->subscription)
{
print $langs->trans("SubscriptionNotRecorded");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
}
else
{
print $langs->trans("SubscriptionNotReceived");
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
}
}
print '</td></tr>';
// Third party Dolibarr
if (! empty($conf->societe->enabled))
if (!empty($conf->societe->enabled))
{
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -576,7 +576,7 @@ if ($rowid > 0)
print '</td><td colspan="2" class="valeur">';
if ($action == 'editthirdparty')
{
$htmlname='socid';
$htmlname = 'socid';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
print '<input type="hidden" name="action" value="set'.$htmlname.'">';
@ -592,8 +592,8 @@ if ($rowid > 0)
{
if ($object->fk_soc)
{
$company=new Societe($db);
$result=$company->fetch($object->fk_soc);
$company = new Societe($db);
$result = $company->fetch($object->fk_soc);
print $company->getNomUrl(1);
}
else
@ -668,28 +668,28 @@ if ($rowid > 0)
if ($action != 'addsubscription' && $action != 'create_thirdparty')
{
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
$sql.= " c.rowid as crowid, c.subscription,";
$sql.= " c.datec, c.fk_type as cfk_type,";
$sql.= " c.dateadh as dateh,";
$sql.= " c.datef,";
$sql.= " c.fk_bank,";
$sql.= " b.rowid as bid,";
$sql.= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
$sql.= $db->order($sortfield, $sortorder);
$sql .= " c.rowid as crowid, c.subscription,";
$sql .= " c.datec, c.fk_type as cfk_type,";
$sql .= " c.dateadh as dateh,";
$sql .= " c.datef,";
$sql .= " c.fk_bank,";
$sql .= " b.rowid as bid,";
$sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
$sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql);
if ($result)
{
$subscriptionstatic=new Subscription($db);
$subscriptionstatic = new Subscription($db);
$num = $db->num_rows($result);
$i = 0;
print '<table class="noborder" width="100%">'."\n";
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
@ -698,13 +698,13 @@ if ($rowid > 0)
print '<td class="center">'.$langs->trans("DateStart").'</td>';
print '<td class="center">'.$langs->trans("DateEnd").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>';
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td class="right">'.$langs->trans("Account").'</td>';
}
print "</tr>\n";
$accountstatic=new Account($db);
$accountstatic = new Account($db);
$adh = new Adherent($db);
$adht = new AdherentType($db);
@ -715,8 +715,8 @@ if ($rowid > 0)
$adh->id = $objp->rowid;
$adh->typeid = $objp->type;
$subscriptionstatic->ref=$objp->crowid;
$subscriptionstatic->id=$objp->crowid;
$subscriptionstatic->ref = $objp->crowid;
$subscriptionstatic->id = $objp->crowid;
$typeid = ($objp->cfk_type > 0 ? $objp->cfk_type : $adh->typeid);
if ($typeid > 0)
@ -735,18 +735,18 @@ if ($rowid > 0)
print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n";
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n";
print '<td class="right">'.price($objp->subscription).'</td>';
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<td class="right">';
if ($objp->bid)
{
$accountstatic->label=$objp->label;
$accountstatic->id=$objp->baid;
$accountstatic->number=$objp->number;
$accountstatic->account_number=$objp->account_number;
$accountstatic->currency_code=$objp->currency_code;
$accountstatic->label = $objp->label;
$accountstatic->id = $objp->baid;
$accountstatic->number = $objp->number;
$accountstatic->account_number = $objp->account_number;
$accountstatic->currency_code = $objp->currency_code;
if (! empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0)
if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0)
{
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objp->fk_accountancy_journal);
@ -754,7 +754,7 @@ if ($rowid > 0)
$accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
$accountstatic->ref=$objp->ref;
$accountstatic->ref = $objp->ref;
print $accountstatic->getNomUrl(1);
}
else
@ -778,7 +778,7 @@ if ($rowid > 0)
if (($action != 'addsubscription' && $action != 'create_thirdparty'))
{
// Shon online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
if ($useonlinepayment)
{
@ -800,20 +800,20 @@ if ($rowid > 0)
print load_fiche_titre($langs->trans("NewCotisation"));
// Define default choice for complementary actions
$bankdirect=0; // 1 means option by default is write to bank direct with no invoice
$invoiceonly=0; // 1 means option by default is invoice only
$bankviainvoice=0; // 1 means option by default is write to bank via invoice
$bankdirect = 0; // 1 means option by default is write to bank direct with no invoice
$invoiceonly = 0; // 1 means option by default is invoice only
$bankviainvoice = 0; // 1 means option by default is write to bank via invoice
if (GETPOST('paymentsave'))
{
if (GETPOST('paymentsave') == 'bankdirect') $bankdirect=1;
if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly=1;
if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice=1;
if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1;
if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1;
if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1;
}
else
{
if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $bankviainvoice=1;
elseif (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1;
elseif (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $invoiceonly=1;
if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1;
elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1;
elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1;
}
print "\n\n<!-- Form add subscription -->\n";
@ -823,7 +823,7 @@ if ($rowid > 0)
//var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE));
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$(".bankswitchclass, .bankswitchclass2").'.(($bankdirect||$bankviainvoice)?'show()':'hide()').';
$(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').';
$("#none, #invoiceonly").click(function() {
$(".bankswitchclass").hide();
$(".bankswitchclass2").hide();
@ -857,33 +857,33 @@ if ($rowid > 0)
// Confirm create third party
if ($action == 'create_thirdparty')
{
$companyalias='';
$companyalias = '';
$fullname = $object->getFullName($langs);
if ($object->morphy == 'mor')
{
$companyname=$object->company;
if (! empty($fullname)) $companyalias=$fullname;
$companyname = $object->company;
if (!empty($fullname)) $companyalias = $fullname;
}
else
{
$companyname=$fullname;
if (! empty($object->company)) $companyalias=$object->company;
$companyname = $fullname;
if (!empty($object->company)) $companyalias = $object->company;
}
// Create a form array
$formquestion=array(
$formquestion = array(
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'),
array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"')
);
// If customer code was forced to "required", we ask it at creation to avoid error later
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
{
$tmpcompany = new Societe($db);
$tmpcompany->name=$companyname;
$tmpcompany->name = $companyname;
$tmpcompany->get_codeclient($tmpcompany, 0);
$customercode = $tmpcompany->code_client;
$formquestion[]=array(
$formquestion[] = array(
'label' => $langs->trans("CustomerCode"),
'type' => 'text',
'name' => 'customercode',
@ -910,15 +910,15 @@ if ($rowid > 0)
print "<table class=\"border\" width=\"100%\">\n";
print '<tbody>';
$today=dol_now();
$datefrom=0;
$dateto=0;
$paymentdate=-1;
$today = dol_now();
$datefrom = 0;
$dateto = 0;
$paymentdate = -1;
// Date payment
if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday'))
{
$paymentdate=dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
$paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
}
print '<tr>';
@ -926,14 +926,14 @@ if ($rowid > 0)
print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
if (GETPOST('reday'))
{
$datefrom=dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
}
if (! $datefrom)
if (!$datefrom)
{
$datefrom=$object->datevalid;
$datefrom = $object->datevalid;
if ($object->datefin > 0)
{
$datefrom=dol_time_plus_duree($object->datefin, 1, 'd');
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
}
}
print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1);
@ -942,11 +942,11 @@ if ($rowid > 0)
// Date end subscription
if (GETPOST('endday'))
{
$dateto=dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
$dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
}
if (! $dateto)
if (!$dateto)
{
$dateto=-1; // By default, no date is suggested
$dateto = -1; // By default, no date is suggested
}
print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0);
@ -960,16 +960,16 @@ if ($rowid > 0)
// Label
print '<tr><td>'.$langs->trans("Label").'</td>';
print '<td><input name="label" type="text" size="32" value="';
if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom?$datefrom:time()), "%Y");
if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y");
print '"></td></tr>';
// Complementary action
if (! empty($conf->banque->enabled) || ! empty($conf->facture->enabled))
if (!empty($conf->banque->enabled) || !empty($conf->facture->enabled))
{
$company=new Societe($db);
$company = new Societe($db);
if ($object->fk_soc)
{
$result=$company->fetch($object->fk_soc);
$result = $company->fetch($object->fk_soc);
}
// Title payments
@ -979,17 +979,17 @@ if ($rowid > 0)
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('MoreActions');
print '</td>';
print '<td>';
print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice)?' checked':'').'> '.$langs->trans("None").'<br>';
print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ? ' checked' : '').'> '.$langs->trans("None").'<br>';
// Add entry into bank accoun
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(! empty($bankdirect)?' checked':'');
print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ? ' checked' : '');
print '> '.$langs->trans("MoreActionBankDirect").'<br>';
}
// Add invoice with no payments
if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled))
{
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(! empty($invoiceonly)?' checked':'');
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : '');
//if (empty($object->fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionInvoiceOnly");
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
@ -1003,18 +1003,18 @@ if ($rowid > 0)
print '</a>)';
}
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0);
if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled)))
{
$prodtmp=new Product($db);
$prodtmp = new Product($db);
$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
}
print '<br>';
}
// Add invoice with payments
if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled))
{
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(! empty($bankviainvoice)?' checked':'');
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : '');
//if (empty($object->fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionBankViaInvoice");
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
@ -1028,11 +1028,11 @@ if ($rowid > 0)
print '</a>)';
}
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0);
if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled)))
{
$prodtmp=new Product($db);
$prodtmp = new Product($db);
$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
}
print '<br>';
}
@ -1050,23 +1050,23 @@ if ($rowid > 0)
// Date of payment
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->selectDate(isset($paymentdate)?$paymentdate:-1, 'payment', 0, 0, 1, 'subscription', 1, 1);
print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1);
print "</td></tr>\n";
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(! GETPOST('num_chq')?'':GETPOST('num_chq')).'"></td></tr>';
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>';
print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
print '</td>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(! GETPOST('chqemetteur')?'':GETPOST('chqemetteur')).'"></td></tr>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>';
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
print ' <em>('.$langs->trans("ChequeBank").')</em>';
print '</td>';
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(! GETPOST('chqbank')?'':GETPOST('chqbank')).'"></td></tr>';
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>';
}
}
@ -1074,7 +1074,7 @@ if ($rowid > 0)
print '<tr><td width="30%">'.$langs->trans("SendAcknowledgementByMail").'</td>';
print '<td>';
if (! $object->email)
if (!$object->email)
{
print $langs->trans("NoEMail");
}
@ -1085,42 +1085,42 @@ if ($rowid > 0)
// Send subscription email
$subject = '';
$msg= '';
$msg = '';
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail=new FormMail($db);
$formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
$arraydefaultmessage=null;
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (! empty($labeltouse)) $arraydefaultmessage=$formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (! empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
{
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
$tmp='<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha')?' checked':(! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>';
$helpcontent='';
$helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
$helpcontent.=$subjecttosend."\n";
$helpcontent.="<br>";
$helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
$tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>';
$helpcontent = '';
$helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
$helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
$helpcontent .= $subjecttosend."\n";
$helpcontent .= "<br>";
$helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>';
$helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
}

View File

@ -27,29 +27,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
if (! empty($conf->banque->enabled)) {
if (!empty($conf->banque->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("companies","members","bills","users"));
$langs->loadLangs(array("companies", "members", "bills", "users"));
$adh = new Adherent($db);
$adht = new AdherentType($db);
$object = new Subscription($db);
$errmsg='';
$errmsg = '';
$action=GETPOST("action", 'alpha');
$rowid=GETPOST("rowid", "int")?GETPOST("rowid", "int"):GETPOST("id", "int");
$typeid=GETPOST("typeid", "int");
$cancel=GETPOST('cancel', 'alpha');
$confirm=GETPOST('confirm');
$action = GETPOST("action", 'alpha');
$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int");
$typeid = GETPOST("typeid", "int");
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm');
if (! $user->rights->adherent->cotisation->lire)
if (!$user->rights->adherent->cotisation->lire)
accessforbidden();
$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php
@ -57,60 +57,60 @@ $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the i
* Actions
*/
if ($cancel) $action='';
if ($cancel) $action = '';
//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel)
if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel)
{
// Load current object
$result=$object->fetch($rowid);
$result = $object->fetch($rowid);
if ($result > 0)
{
$db->begin();
$errmsg='';
$errmsg = '';
if ($object->fk_bank)
{
$accountline=new AccountLine($db);
$result=$accountline->fetch($object->fk_bank);
$accountline = new AccountLine($db);
$result = $accountline->fetch($object->fk_bank);
// If transaction consolidated
if ($accountline->rappro)
{
$errmsg=$langs->trans("SubscriptionLinkedToConciliatedTransaction");
$errmsg = $langs->trans("SubscriptionLinkedToConciliatedTransaction");
}
else
{
$accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->amount=$_POST["amount"];
$result=$accountline->update($user);
$accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->amount = $_POST["amount"];
$result = $accountline->update($user);
if ($result < 0)
{
$errmsg=$accountline->error;
$errmsg = $accountline->error;
}
}
}
if (! $errmsg)
if (!$errmsg)
{
// Modify values
$object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
$object->fk_type=$_POST["typeid"];
$object->note=$_POST["note"];
$object->amount=$_POST["amount"];
$object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
$object->fk_type = $_POST["typeid"];
$object->note = $_POST["note"];
$object->amount = $_POST["amount"];
//print 'datef='.$object->datef.' '.$_POST['datesubendday'];
$result=$object->update($user);
if ($result >= 0 && ! count($object->errors))
$result = $object->update($user);
if ($result >= 0 && !count($object->errors))
{
$db->commit();
@ -123,17 +123,17 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc
if ($object->error)
{
$errmsg=$object->error;
$errmsg = $object->error;
}
else
{
foreach($object->errors as $error)
foreach ($object->errors as $error)
{
if ($errmsg) $errmsg.='<br>';
$errmsg.=$error;
if ($errmsg) $errmsg .= '<br>';
$errmsg .= $error;
}
}
$action='';
$action = '';
}
}
else
@ -145,8 +145,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer)
{
$result=$object->fetch($rowid);
$result=$object->delete($user);
$result = $object->fetch($rowid);
$result = $object->delete($user);
if ($result > 0)
{
header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent);
@ -154,7 +154,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent-
}
else
{
$mesg=$adh->error;
$mesg = $adh->error;
}
}
@ -182,7 +182,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
********************************************/
$object->fetch($rowid);
$result=$adh->fetch($object->fk_adherent);
$result = $adh->fetch($object->fk_adherent);
$head = subscription_prepare_head($object);
@ -197,7 +197,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
print "\n";
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Ref
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>';
@ -206,7 +206,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print '</td></tr>';
// Member
$adh->ref=$adh->getFullName($langs);
$adh->ref = $adh->getFullName($langs);
print '<tr>';
print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
@ -214,7 +214,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
// Type
print '<tr>';
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"]) ? $_POST["typeid"] : $object->fk_type));
print'</td></tr>';
// Date start subscription
@ -238,15 +238,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>';
// Bank line
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)
{
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
if ($object->fk_bank)
{
$bankline=new AccountLine($db);
$result=$bankline->fetch($object->fk_bank);
$bankline = new AccountLine($db);
$result = $bankline->fetch($object->fk_bank);
print $bankline->getNomUrl(1, 0, 'showall');
}
else
@ -279,8 +279,8 @@ if ($rowid && $action != 'edit')
*
********************************************/
$result=$object->fetch($rowid);
$result=$adh->fetch($object->fk_adherent);
$result = $object->fetch($rowid);
$result = $adh->fetch($object->fk_adherent);
$head = subscription_prepare_head($object);
@ -291,8 +291,8 @@ if ($rowid && $action != 'edit')
{
//$formquestion=array();
//$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
$text=$langs->trans("ConfirmDeleteSubscription");
if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
$text = $langs->trans("ConfirmDeleteSubscription");
if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
}
@ -307,10 +307,10 @@ if ($rowid && $action != 'edit')
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// Member
$adh->ref=$adh->getFullName($langs);
$adh->ref = $adh->getFullName($langs);
print '<tr>';
print '<td class="titlefield">'.$langs->trans("Member").'</td><td class="valeur">'.$adh->getNomUrl(1, 0, 'subscription').'</td>';
print '</tr>';
@ -345,15 +345,15 @@ if ($rowid && $action != 'edit')
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>';
// Bank line
if (! empty($conf->banque->enabled))
if (!empty($conf->banque->enabled))
{
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)
{
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
if ($object->fk_bank)
{
$bankline=new AccountLine($db);
$result=$bankline->fetch($object->fk_bank);
$bankline = new AccountLine($db);
$result = $bankline->fetch($object->fk_bank);
print $bankline->getNomUrl(1, 0, 'showall');
}
else
@ -379,7 +379,7 @@ if ($rowid && $action != 'edit')
if ($user->rights->adherent->cotisation->creer)
{
if (! $bankline->rappro)
if (!$bankline->rappro)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id."&action=edit\">".$langs->trans("Modify")."</a></div>";
}

View File

@ -29,37 +29,37 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->loadLangs(array("members","companies"));
$langs->loadLangs(array("members", "companies"));
$action=GETPOST('action', 'aZ09');
$massaction=GETPOST('massaction', 'alpha');
$confirm=GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$filter=GETPOST("filter", "alpha");
$statut=(GETPOSTISSET("statut")?GETPOST("statut", "alpha"):1);
$search_ref=GETPOST('search_ref', 'alpha');
$search_type=GETPOST('search_type', 'alpha');
$search_lastname=GETPOST('search_lastname', 'alpha');
$search_firstname=GETPOST('search_firstname', 'alpha');
$search_login=GETPOST('search_login', 'alpha');
$search_note=GETPOST('search_note', 'alpha');
$search_account=GETPOST('search_account', 'int');
$search_amount=GETPOST('search_amount', 'alpha');
$filter = GETPOST("filter", "alpha");
$statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1);
$search_ref = GETPOST('search_ref', 'alpha');
$search_type = GETPOST('search_type', 'alpha');
$search_lastname = GETPOST('search_lastname', 'alpha');
$search_firstname = GETPOST('search_firstname', 'alpha');
$search_login = GETPOST('search_login', 'alpha');
$search_note = GETPOST('search_note', 'alpha');
$search_account = GETPOST('search_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$date_select=GETPOST("date_select", 'alpha');
$date_select = GETPOST("date_select", 'alpha');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="c.dateadh"; }
if (!$sortorder) { $sortorder = "DESC"; }
if (!$sortfield) { $sortfield = "c.dateadh"; }
$object = new Subscription($db);
@ -70,19 +70,19 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
);
$arrayfields=array(
$arrayfields = array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'd.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
't.libelle'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'd.bank'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'enabled'=>(! empty($conf->banque->enabled))),
'd.bank'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled))),
/*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
'c.dateadh'=>array('label'=>$langs->trans("DateSubscription"), 'checked'=>1, 'position'=>100),
@ -94,18 +94,18 @@ $arrayfields=array(
);
// Security check
$result=restrictedArea($user, 'adherent', '', '', 'cotisation');
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; }
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -116,17 +116,17 @@ if (empty($reshook))
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search="";
$search_type="";
$search_ref="";
$search_lastname="";
$search_firstname="";
$search_login="";
$search_note="";
$search_amount="";
$search_account="";
$toselect='';
$search_array_options=array();
$search = "";
$search_type = "";
$search_ref = "";
$search_lastname = "";
$search_firstname = "";
$search_login = "";
$search_note = "";
$search_amount = "";
$search_account = "";
$toselect = '';
$search_array_options = array();
}
}
@ -135,50 +135,50 @@ if (empty($reshook))
* View
*/
$form=new Form($db);
$subscription=new Subscription($db);
$adherent=new Adherent($db);
$accountstatic=new Account($db);
$form = new Form($db);
$subscription = new Subscription($db);
$adherent = new Adherent($db);
$accountstatic = new Account($db);
$now=dol_now();
$now = dol_now();
// List of subscriptions
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,";
$sql.= " c.rowid as crowid, c.fk_type, c.subscription,";
$sql.= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
$sql.= " c.fk_bank as bank, c.note,";
$sql.= " b.fk_account";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
$sql.= " WHERE d.rowid = c.fk_adherent";
$sql.= " AND d.entity IN (".getEntity('adherent').")";
$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
$sql .= " c.fk_bank as bank, c.note,";
$sql .= " b.fk_account";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
$sql .= " WHERE d.rowid = c.fk_adherent";
$sql .= " AND d.entity IN (".getEntity('adherent').")";
if (isset($date_select) && $date_select != '')
{
$sql.= " AND c.dateadh >= '".$date_select."-01-01 00:00:00'";
$sql.= " AND c.dateadh < '".($date_select+1)."-01-01 00:00:00'";
$sql .= " AND c.dateadh >= '".$date_select."-01-01 00:00:00'";
$sql .= " AND c.dateadh < '".($date_select + 1)."-01-01 00:00:00'";
}
if ($search_ref)
{
if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")";
else $sql.=" AND 1 = 2"; // Always wrong
if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")";
else $sql .= " AND 1 = 2"; // Always wrong
}
if ($search_type) $sql.= natural_search(array('c.fk_type'), $search_type);
if ($search_lastname) $sql.= natural_search(array('d.lastname','d.societe'), $search_lastname);
if ($search_firstname) $sql.= natural_search(array('d.firstname'), $search_firstname);
if ($search_login) $sql.= natural_search('d.login', $search_login);
if ($search_note) $sql.= natural_search('c.note', $search_note);
if ($search_account > 0) $sql.= " AND b.fk_account = ".urldecode($search_account);
if ($search_amount) $sql.= natural_search('c.subscription', $search_amount, 1);
if ($search_type) $sql .= natural_search(array('c.fk_type'), $search_type);
if ($search_lastname) $sql .= natural_search(array('d.lastname', 'd.societe'), $search_lastname);
if ($search_firstname) $sql .= natural_search(array('d.firstname'), $search_firstname);
if ($search_login) $sql .= natural_search('d.login', $search_login);
if ($search_note) $sql .= natural_search('c.note', $search_note);
if ($search_account > 0) $sql .= " AND b.fk_account = ".urldecode($search_account);
if ($search_amount) $sql .= natural_search('c.subscription', $search_amount, 1);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql.= $db->order($sortfield, $sortorder);
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records with no order and no limits
$nbtotalofrecords = '';
@ -194,10 +194,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
}
}
// Add limit
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if (! $result)
if (!$result)
{
dol_print_error($db);
exit;
@ -205,9 +205,9 @@ if (! $result)
$num = $db->num_rows($result);
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
@ -219,36 +219,36 @@ llxHeader('', $langs->trans("ListOfSubscriptions"), 'EN:Module_Foundations|FR:Mo
$i = 0;
$title=$langs->trans("ListOfSubscriptions");
if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')';
$title = $langs->trans("ListOfSubscriptions");
if (!empty($date_select)) $title .= ' ('.$langs->trans("Year").' '.$date_select.')';
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($statut != '') $param.="&statut=".urlencode($statut);
if ($search_type) $param.="&search_type=".urlencode($search_type);
if ($date_select) $param.="&date_select=".urlencode($date_select);
if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname);
if ($search_login) $param.="&search_login=".urlencode($search_login);
if ($search_account) $param.="&search_account=".urlencode($search_account);
if ($search_amount) $param.="&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($statut != '') $param .= "&statut=".urlencode($statut);
if ($search_type) $param .= "&search_type=".urlencode($search_type);
if ($date_select) $param .= "&date_select=".urlencode($date_select);
if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname);
if ($search_login) $param .= "&search_login=".urlencode($search_login);
if ($search_account) $param .= "&search_account=".urlencode($search_account);
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->adherent->cotisation->creer)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
@ -264,95 +264,95 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit);
$topicmail="Information";
$modelmail="subscription";
$objecttmp=new Subscription($db);
$trackid='sub'.$object->id;
$topicmail = "Information";
$modelmail = "subscription";
$objecttmp = new Subscription($db);
$trackid = 'sub'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
$moreforfilter = '';
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
print '<div class="div-table-responsive">';
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for filters fields
print '<tr class="liste_titre_filter">';
// Line numbering
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
{
print '<td class="liste_titre">&nbsp;</td>';
}
// Ref
if (! empty($arrayfields['d.ref']['checked']))
if (!empty($arrayfields['d.ref']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
}
// Type
if (! empty($arrayfields['d.fk_type']['checked']))
if (!empty($arrayfields['d.fk_type']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth50" type="text" name="search_type" value="'.dol_escape_htmltag($search_type).'">';
print'</td>';
}
if (! empty($arrayfields['d.lastname']['checked']))
if (!empty($arrayfields['d.lastname']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth75" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>';
}
if (! empty($arrayfields['d.firstname']['checked']))
if (!empty($arrayfields['d.firstname']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth75" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>';
}
if (! empty($arrayfields['d.login']['checked']))
if (!empty($arrayfields['d.login']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
}
if (! empty($arrayfields['t.libelle']['checked']))
if (!empty($arrayfields['t.libelle']['checked']))
{
print '<td class="liste_titre">';
print '';
print '</td>';
}
if (! empty($arrayfields['d.bank']['checked']))
if (!empty($arrayfields['d.bank']['checked']))
{
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>';
}
if (! empty($arrayfields['c.dateadh']['checked']))
if (!empty($arrayfields['c.dateadh']['checked']))
{
print '<td class="liste_titre">&nbsp;</td>';
}
if (! empty($arrayfields['c.datef']['checked']))
if (!empty($arrayfields['c.datef']['checked']))
{
print '<td class="liste_titre">&nbsp;</td>';
}
if (! empty($arrayfields['d.amount']['checked']))
if (!empty($arrayfields['d.amount']['checked']))
{
print '<td class="liste_titre right">';
print '<input class="flat" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'" size="4">';
@ -362,17 +362,17 @@ if (! empty($arrayfields['d.amount']['checked']))
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['c.datec']['checked']))
if (!empty($arrayfields['c.datec']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Date modification
if (! empty($arrayfields['c.tms']['checked']))
if (!empty($arrayfields['c.tms']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
@ -380,7 +380,7 @@ if (! empty($arrayfields['c.tms']['checked']))
// Action column
print '<td class="liste_titre right">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
@ -388,43 +388,43 @@ print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['d.ref']['checked']))
if (!empty($arrayfields['d.ref']['checked']))
{
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['d.fk_type']['checked']))
if (!empty($arrayfields['d.fk_type']['checked']))
{
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['d.lastname']['checked']))
if (!empty($arrayfields['d.lastname']['checked']))
{
print_liste_field_titre("LastName", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['d.firstname']['checked']))
if (!empty($arrayfields['d.firstname']['checked']))
{
print_liste_field_titre("FirstName", $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['d.login']['checked']))
if (!empty($arrayfields['d.login']['checked']))
{
print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['t.libelle']['checked']))
if (!empty($arrayfields['t.libelle']['checked']))
{
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
}
if (! empty($arrayfields['d.bank']['checked']))
if (!empty($arrayfields['d.bank']['checked']))
{
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder);
}
if (! empty($arrayfields['c.dateadh']['checked']))
if (!empty($arrayfields['c.dateadh']['checked']))
{
print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
}
if (! empty($arrayfields['c.datef']['checked']))
if (!empty($arrayfields['c.datef']['checked']))
{
print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall ');
}
if (! empty($arrayfields['d.amount']['checked']))
if (!empty($arrayfields['d.amount']['checked']))
{
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right ');
}
@ -432,33 +432,33 @@ if (! empty($arrayfields['d.amount']['checked']))
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
$total=0;
$totalarray=array();
$total = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($result);
$total+=$obj->subscription;
$total += $obj->subscription;
$subscription->ref=$obj->crowid;
$subscription->id=$obj->crowid;
$subscription->ref = $obj->crowid;
$subscription->id = $obj->crowid;
$adherent->lastname=$obj->lastname;
$adherent->firstname=$obj->firstname;
$adherent->ref=$obj->rowid;
$adherent->id=$obj->rowid;
$adherent->statut=$obj->statut;
$adherent->login=$obj->login;
$adherent->photo=$obj->photo;
$adherent->typeid=$obj->type;
$adherent->lastname = $obj->lastname;
$adherent->firstname = $obj->firstname;
$adherent->ref = $obj->rowid;
$adherent->id = $obj->rowid;
$adherent->statut = $obj->statut;
$adherent->login = $obj->login;
$adherent->photo = $obj->photo;
$adherent->typeid = $obj->type;
$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
$adht = new AdherentType($db);
@ -467,13 +467,13 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
// Ref
if (! empty($arrayfields['d.ref']['checked']))
if (!empty($arrayfields['d.ref']['checked']))
{
print '<td>'.$subscription->getNomUrl(1).'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Type
if (! empty($arrayfields['d.fk_type']['checked']))
if (!empty($arrayfields['d.fk_type']['checked']))
{
print '<td>';
if ($typeid > 0)
@ -481,107 +481,107 @@ while ($i < min($num, $limit))
print $adht->getNomUrl(1);
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Lastname
if (! empty($arrayfields['d.lastname']['checked']))
if (!empty($arrayfields['d.lastname']['checked']))
{
$adherent->firstname = '';
print '<td>'.$adherent->getNomUrl(-1).'</td>';
$adherent->firstname = $obj->firstname;
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Firstname
if (! empty($arrayfields['d.firstname']['checked']))
if (!empty($arrayfields['d.firstname']['checked']))
{
print '<td>'.$adherent->firstname.'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Login
if (! empty($arrayfields['d.login']['checked']))
if (!empty($arrayfields['d.login']['checked']))
{
print '<td>'.$adherent->login.'</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Label
if (! empty($arrayfields['t.libelle']['checked']))
if (!empty($arrayfields['t.libelle']['checked']))
{
print '<td>';
print dol_trunc($obj->note, 128);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Banque
if (! empty($arrayfields['d.bank']['checked']))
if (!empty($arrayfields['d.bank']['checked']))
{
print "<td>";
if ($obj->fk_account > 0)
{
$accountstatic->id=$obj->fk_account;
$accountstatic->id = $obj->fk_account;
$accountstatic->fetch($obj->fk_account);
//$accountstatic->label=$obj->label;
print $accountstatic->getNomUrl(1);
}
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Date start
if (! empty($arrayfields['c.dateadh']['checked']))
if (!empty($arrayfields['c.dateadh']['checked']))
{
print '<td class="center">'.dol_print_date($db->jdate($obj->dateadh), 'day')."</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Date end
if (! empty($arrayfields['c.datef']['checked']))
if (!empty($arrayfields['c.datef']['checked']))
{
print '<td class="center">'.dol_print_date($db->jdate($obj->datef), 'day')."</td>\n";
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Price
if (! empty($arrayfields['d.amount']['checked']))
if (!empty($arrayfields['d.amount']['checked']))
{
print '<td class="right">'.price($obj->subscription).'</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.amount';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'd.amount';
$totalarray['val']['d.amount'] += $obj->subscription;
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['c.datec']['checked']))
if (!empty($arrayfields['c.datec']['checked']))
{
print '<td class="nowrap center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['c.tms']['checked']))
if (!empty($arrayfields['c.tms']['checked']))
{
print '<td class="nowrap center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
}
// Action column
print '<td class="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
@ -594,15 +594,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
$db->free($resql);
$parameters=array('sql' => $sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
$parameters = array('sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>";

View File

@ -18,7 +18,7 @@
*/
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf))
if (empty($conf) || !is_object($conf))
{
print "Error, template page can't be called as URL";
exit;
@ -32,8 +32,8 @@ $langs = $GLOBALS['langs'];
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("members");
$total=0;
foreach($linkedObjectBlock as $key => $objectlink)
$total = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
echo '<tr class="oddeven">';
echo '<td>'.$langs->trans("Subscription").'</td>';

View File

@ -41,35 +41,35 @@ $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$search_lastname = GETPOST('search_lastname', 'alpha');
$search_lastname = GETPOST('search_lastname', 'alpha');
$search_login = GETPOST('search_login', 'alpha');
$search_email = GETPOST('search_email', 'alpha');
$type = GETPOST('type', 'intcomma');
$type = GETPOST('type', 'intcomma');
$status = GETPOST('status', 'alpha');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="d.lastname"; }
if (!$sortorder) { $sortorder = "DESC"; }
if (!$sortfield) { $sortfield = "d.lastname"; }
$label=GETPOST("label", "alpha");
$morphy=GETPOST("morphy", "alpha");
$statut=GETPOST("statut", "int");
$subscription=GETPOST("subscription", "int");
$label = GETPOST("label", "alpha");
$morphy = GETPOST("morphy", "alpha");
$statut = GETPOST("statut", "int");
$subscription = GETPOST("subscription", "int");
$duration_value = GETPOST('duration_value', 'int');
$duration_unit = GETPOST('duration_unit', 'alpha');
$vote=GETPOST("vote", "int");
$comment=GETPOST("comment", 'alphanohtml');
$mail_valid=GETPOST("mail_valid", 'none');
$vote = GETPOST("vote", "int");
$comment = GETPOST("comment", 'alphanohtml');
$mail_valid = GETPOST("mail_valid", 'none');
// Security check
$result=restrictedArea($user, 'adherent', $rowid, 'adherent_type');
$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
$object = new AdherentType($db);
@ -80,16 +80,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_lastname="";
$search_login="";
$search_email="";
$type="";
$sall="";
$search_lastname = "";
$search_login = "";
$search_email = "";
$type = "";
$sall = "";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membertypecard','globalcard'));
$hookmanager->initHooks(array('membertypecard', 'globalcard'));
/*
@ -97,23 +97,23 @@ $hookmanager->initHooks(array('membertypecard','globalcard'));
*/
if ($cancel) {
$action='';
$action = '';
if (! empty($backtopage)) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
}
if ($action == 'add' && $user->rights->adherent->configurer) {
$object->label = trim($label);
$object->label = trim($label);
$object->morphy = trim($morphy);
$object->statut = (int) $statut;
$object->subscription = (int) $subscription;
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->mail_valid = trim($mail_valid);
$object->vote = (int) $vote;
// Fill array 'array_options' with data from add form
@ -137,9 +137,9 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
}
}
if (! $error)
if (!$error)
{
$id=$object->create($user);
$id = $object->create($user);
if ($id > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
@ -164,22 +164,22 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object->oldcopy = clone $object;
$object->label = trim($label);
$object->morphy = trim($morphy);
$object->morphy = trim($morphy);
$object->statut = (int) $statut;
$object->subscription = (int) $subscription;
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
$object->mail_valid = trim($mail_valid);
$object->mail_valid = trim($mail_valid);
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$ret=$object->update($user);
$ret = $object->update($user);
if ($ret >= 0 && ! count($object->errors))
if ($ret >= 0 && !count($object->errors))
{
setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
}
@ -195,7 +195,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
{
$object->fetch($rowid);
$res=$object->delete();
$res = $object->delete();
if ($res > 0)
{
@ -206,7 +206,7 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
else
{
setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
$action='';
$action = '';
}
}
@ -215,20 +215,20 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer)
* View
*/
$form=new Form($db);
$form = new Form($db);
$formproduct = new FormProduct($db);
llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
// List of members type
if (! $rowid && $action != 'create' && $action != 'edit')
if (!$rowid && $action != 'create' && $action != 'edit')
{
//dol_fiche_head('');
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql.= " WHERE d.entity IN (".getEntity('member_type').")";
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
$result = $db->query($sql);
if ($result)
@ -240,10 +240,10 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$param = '';
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->adherent->configurer)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -260,7 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Ref").'</th>';
@ -280,6 +280,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$membertype->id = $objp->rowid;
$membertype->ref = $objp->rowid;
$membertype->label = $objp->rowid;
$membertype->status = $objp->status;
print '<tr class="oddeven">';
print '<td>';
@ -294,13 +295,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
print '</td>';
print '<td class="center">'.yn($objp->subscription).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center">';
if ( !empty($objp->statut) ) {
print img_picto($langs->trans("InActivity"), 'statut4');
} else {
print img_picto($langs->trans("ActivityCeased"), 'statut5');
}
print '</td>';
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
if ($user->rights->adherent->configurer)
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
else
@ -337,13 +332,13 @@ if ($action == 'create')
dol_fiche_head('');
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tbody>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1);
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
print '</td></tr>';
// Morphy
@ -351,7 +346,7 @@ if ($action == 'create')
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy);
print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
@ -372,17 +367,17 @@ if ($action == 'create')
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print '</td></tr>';
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
print $object->showOptionals($extrafields, 'edit', $parameters);
}
print '<tbody>';
print "</table>\n";
@ -412,7 +407,7 @@ if ($rowid > 0)
$object->fetch_optionals();
/*
* Confirmation suppression
* Confirmation deletion
*/
if ($action == 'delete')
{
@ -430,17 +425,9 @@ if ($rowid > 0)
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr><td class="titlefield">'.$langs->trans("Status").'</td><td>';
if ( !empty($object->statut) ) {
print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity");
} else {
print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased");
}
print '</tr>';
// Morphy
// Morphy
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
print '</tr>';
@ -455,13 +442,13 @@ if ($rowid > 0)
print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
if ($object->duration_value > 1)
{
$dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
}
elseif ($object->duration_value > 0)
{
$dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
}
print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;";
print '</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
@ -471,7 +458,7 @@ if ($rowid > 0)
print nl2br($object->mail_valid)."</td></tr>";
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
@ -491,7 +478,7 @@ if ($rowid > 0)
}
// Add
if ( $user->rights->adherent->configurer && !empty($object->statut) )
if ($user->rights->adherent->configurer && !empty($object->statut))
{
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
} else {
@ -509,55 +496,55 @@ if ($rowid > 0)
// Show list of members (nearly same code than in page list.php)
$membertypestatic=new AdherentType($db);
$membertypestatic = new AdherentType($db);
$now=dol_now();
$now = dol_now();
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,";
$sql.= " d.datefin,";
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql.= " t.libelle as type, t.subscription";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.fk_adherent_type = t.rowid ";
$sql.= " AND d.entity IN (".getEntity('adherent').")";
$sql.= " AND t.rowid = ".$object->id;
$sql .= " d.datefin,";
$sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
$sql .= " t.libelle as type, t.subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE d.fk_adherent_type = t.rowid ";
$sql .= " AND d.entity IN (".getEntity('adherent').")";
$sql .= " AND t.rowid = ".$object->id;
if ($sall)
{
$sql.=natural_search(array("f.firstname","d.lastname","d.societe","d.email","d.login","d.address","d.town","d.note_public","d.note_private"), $sall);
$sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
}
if ($status != '')
{
$sql.= natural_search('d.statut', $status, 2);
$sql .= natural_search('d.statut', $status, 2);
}
if ($action == 'search')
{
if (GETPOST('search', 'alpha'))
{
$sql.= natural_search(array("d.firstname","d.lastname"), GETPOST('search', 'alpha'));
$sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
}
}
if (! empty($search_lastname))
if (!empty($search_lastname))
{
$sql.= natural_search(array("d.firstname","d.lastname"), $search_lastname);
$sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
}
if (! empty($search_login))
if (!empty($search_login))
{
$sql.= natural_search("d.login", $search_login);
$sql .= natural_search("d.login", $search_login);
}
if (! empty($search_email))
if (!empty($search_email))
{
$sql.= natural_search("d.email", $search_email);
$sql .= natural_search("d.email", $search_email);
}
if ($filter == 'uptodate')
{
$sql.=" AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
$sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
}
if ($filter == 'outofdate')
{
$sql.=" AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
}
$sql.= " ".$db->order($sortfield, $sortorder);
$sql .= " ".$db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -573,7 +560,7 @@ if ($rowid > 0)
}
}
$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
$resql = $db->query($sql);
if ($resql)
@ -581,35 +568,35 @@ if ($rowid > 0)
$num = $db->num_rows($resql);
$i = 0;
$titre=$langs->trans("MembersList");
$titre = $langs->trans("MembersList");
if ($status != '')
{
if ($status == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
elseif ($status == '-1') { $titre=$langs->trans("MembersListToValid"); }
elseif ($status == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); }
elseif ($status == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); }
elseif ($status == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); }
elseif ($status == '0') { $titre=$langs->trans("MembersListResiliated"); }
if ($status == '-1,1') { $titre = $langs->trans("MembersListQualified"); }
elseif ($status == '-1') { $titre = $langs->trans("MembersListToValid"); }
elseif ($status == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); }
elseif ($status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); }
elseif ($status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); }
elseif ($status == '0') { $titre = $langs->trans("MembersListResiliated"); }
}
elseif ($action == 'search')
{
$titre=$langs->trans("MembersListQualified");
$titre = $langs->trans("MembersListQualified");
}
if ($type > 0)
{
$membertype=new AdherentType($db);
$result=$membertype->fetch($type);
$titre.=" (".$membertype->label.")";
$membertype = new AdherentType($db);
$result = $membertype->fetch($type);
$titre .= " (".$membertype->label.")";
}
$param="&rowid=".$object->id;
if (! empty($status)) $param.="&status=".$status;
if (! empty($search_lastname)) $param.="&search_lastname=".$search_lastname;
if (! empty($search_firstname)) $param.="&search_firstname=".$search_firstname;
if (! empty($search_login)) $param.="&search_login=".$search_login;
if (! empty($search_email)) $param.="&search_email=".$search_email;
if (! empty($filter)) $param.="&filter=".$filter;
$param = "&rowid=".$object->id;
if (!empty($status)) $param .= "&status=".$status;
if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname;
if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname;
if (!empty($search_login)) $param .= "&search_login=".$search_login;
if (!empty($search_email)) $param .= "&search_email=".$search_email;
if (!empty($filter)) $param .= "&filter=".$filter;
if ($sall)
{
@ -617,7 +604,7 @@ if ($rowid > 0)
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">';
print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
print '<br>';
@ -626,7 +613,7 @@ if ($rowid > 0)
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search
print '<tr class="liste_titre_filter">';
@ -666,11 +653,11 @@ if ($rowid > 0)
{
$objp = $db->fetch_object($resql);
$datefin=$db->jdate($objp->datefin);
$datefin = $db->jdate($objp->datefin);
$adh=new Adherent($db);
$adh->lastname=$objp->lastname;
$adh->firstname=$objp->firstname;
$adh = new Adherent($db);
$adh->lastname = $objp->lastname;
$adh->firstname = $objp->firstname;
// Lastname
print '<tr class="oddeven">';
@ -787,14 +774,14 @@ if ($rowid > 0)
dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut);
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut);
print '</td></tr>';
// Morphy
@ -802,7 +789,7 @@ if ($rowid > 0)
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"]) ? $_POST["morphy"] : $object->morphy);
print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
@ -823,20 +810,20 @@ if ($rowid > 0)
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create();
print "</td></tr>";
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
print $object->showOptionals($extrafields, 'edit', $parameters);
}
print '</table>';

View File

@ -30,27 +30,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","members","ldap"));
$langs->loadLangs(array("admin", "members", "ldap"));
$id = GETPOST('rowid', 'int');
$action = GETPOST('action', 'alpha');
// Security check
$result=restrictedArea($user, 'adherent', $id, 'adherent_type');
$result = restrictedArea($user, 'adherent', $id, 'adherent_type');
$object = new AdherentType($db);
$object->fetch($id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membertypeldapcard','globalcard'));
$hookmanager->initHooks(array('membertypeldapcard', 'globalcard'));
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -66,7 +66,7 @@ if (empty($reshook))
$info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info);
$olddn = $dn; // We can say that old dn = dn as we force synchro
$olddn = $dn; // We can say that old dn = dn as we force synchro
$result = $ldap->update($dn, $info, $user, $olddn);
}
@ -99,7 +99,7 @@ dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
// LDAP DN
print '<tr><td>LDAP '.$langs->trans("LDAPMemberTypeDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_TYPE_DN."</td></tr>\n";
@ -121,7 +121,7 @@ print '</div>';
dol_fiche_end();
/*
* Barre d'actions
* Action bar
*/
print '<div class="tabsAction">';
@ -137,7 +137,7 @@ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) print "<br>\n";
// Affichage attributs LDAP
// Display LDAP attributes
print load_fiche_titre($langs->trans("LDAPInformationsForThisMemberType"));
print '<table width="100%" class="noborder">';
@ -147,13 +147,13 @@ print '<td>'.$langs->trans("LDAPAttributes").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
// Lecture LDAP
$ldap=new Ldap();
$result=$ldap->connect_bind();
// LDAP reading
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info, 1);
$info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")";
$records = $ldap->getAttribute($dn, $search);
@ -161,15 +161,15 @@ if ($result > 0)
//print_r($records);
// Show tree
if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0))
{
if (! is_array($records))
if (!is_array($records))
{
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$result=show_ldap_content($records, 0, $records['count'], true);
$result = show_ldap_content($records, 0, $records['count'], true);
}
}
else

View File

@ -22,7 +22,7 @@
/**
* \file htdocs/adherents/type_translation.php
* \ingroup product
* \brief Page de traduction des produits
* \brief Member translation page
*/
require '../main.inc.php';
@ -35,22 +35,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$langs->loadLangs(array('members', 'languages'));
$id = GETPOST('rowid', 'int');
$action=GETPOST('action', 'alpha');
$cancel=GETPOST('cancel', 'alpha');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid=$user->socid;
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
// Security check
$result=restrictedArea($user, 'adherent', $id, 'adherent_type');
$result = restrictedArea($user, 'adherent', $id, 'adherent_type');
/*
* Actions
*/
// retour a l'affichage des traduction si annulation
// return to translation display if cancellation
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
@ -70,7 +70,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
// update de l'objet
// update of object
if ( $_POST["forcelangprod"] == $current_lang )
{
$object->label = $_POST["libelle"];
@ -84,7 +84,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad
$object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]);
}
// sauvegarde en base
// backup into database
if ( $object->setMultiLangs($user) > 0 )
{
$action = '';
@ -103,23 +103,23 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet
foreach ($object->multilangs as $key => $value) // saving new values in the object
{
if ( $key == $current_lang )
if ($key == $current_lang)
{
$object->label = $_POST["libelle-".$key];
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->other = dol_htmlcleanlastbr($_POST["other-".$key]);
}
else
{
$object->multilangs[$key]["label"] = $_POST["libelle-".$key];
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]);
}
}
if ( $object->setMultiLangs($user) > 0 )
if ($object->setMultiLangs($user) > 0)
{
$action = '';
}
@ -135,10 +135,10 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights-
{
$object = new AdherentType($db);
$object->fetch($id);
$langtodelete=GETPOST('langdel', 'alpha');
$langtodelete = GETPOST('langdel', 'alpha');
if ( $object->delMultiLangs($langtodelete, $user) > 0 )
if ($object->delMultiLangs($langtodelete, $user) > 0)
{
$action = '';
}
@ -161,20 +161,20 @@ $title = $langs->trans('MemberTypeCard');
$helpurl = '';
$shortlabel = dol_trunc($object->label, 16);
$title = $langs->trans('MemberType')." ". $shortlabel ." - ".$langs->trans('Translation');
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
$title = $langs->trans('MemberType')." ".$shortlabel." - ".$langs->trans('Translation');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
llxHeader('', $title, $helpurl);
$form = new Form($db);
$formadmin=new FormAdmin($db);
$formadmin = new FormAdmin($db);
$head = member_type_prepare_head($object);
$titre=$langs->trans("MemberType".$object->type);
$titre = $langs->trans("MemberType".$object->type);
// Calculate $cnt_trans
$cnt_trans = 0;
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
@ -224,15 +224,15 @@ if ($action == 'edit')
print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
$s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
$s = picto_from_langcode($key);
print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>";
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.dol_escape_htmltag($object->multilangs[$key]["label"]).'"></td></tr>';
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%');
@ -255,23 +255,23 @@ if ($action == 'edit')
}
elseif ($action != 'add')
{
if (! empty($object->multilangs))
if (!empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
$s=picto_from_langcode($key);
print ($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
$s = picto_from_langcode($key);
print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr><td class="titlefieldcreate">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
print '</table>';
print '</div>';
}
}
if (! $cnt_trans && $action != 'add') print '<div class="opacitymedium">'. $langs->trans('NoTranslation').'</div>';
if (!$cnt_trans && $action != 'add') print '<div class="opacitymedium">'.$langs->trans('NoTranslation').'</div>';
}
@ -293,7 +293,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
dol_fiche_head();
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>';
print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1);
print '</td></tr>';

View File

@ -109,7 +109,7 @@ print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">'
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="oddeven liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name

View File

@ -41,9 +41,9 @@ $search_event = GETPOST('search_event', 'alpha');
// Get list of triggers available
$sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " ORDER BY a.rang ASC";
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql .= " ORDER BY a.rang ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
@ -51,11 +51,11 @@ if ($resql)
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$triggers[$i]['rowid'] = $obj->rowid;
$triggers[$i]['rowid'] = $obj->rowid;
$triggers[$i]['code'] = $obj->code;
$triggers[$i]['element'] = $obj->elementtype;
$triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
$triggers[$i]['position'] = $obj->position;
$triggers[$i]['element'] = $obj->elementtype;
$triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code) != "Notify_".$obj->code ? $langs->trans("Notify_".$obj->code) : $obj->label);
$triggers[$i]['position'] = $obj->position;
$i++;
}
@ -74,35 +74,35 @@ else
*/
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_event = '';
$action = '';
}
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') ||GETPOST('button_search', 'alpha')) // To avoid the save when we click on search
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search
{
$action = '';
}
if ($action == "save" && empty($cancel))
{
$i=0;
$i = 0;
$db->begin();
foreach ($triggers as $trigger)
{
$keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
//print "param=".$param." - ".$_POST[$param];
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam))
{
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha')?GETPOST($keyparam, 'alpha'):''), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
}
}
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
$db->commit();
@ -120,10 +120,10 @@ if ($action == "save" && empty($cancel))
* View
*/
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -131,23 +131,23 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="save">';
$param = '';
$param.= '&search_event='.urlencode($search_event);
$param .= '&search_event='.urlencode($search_event);
$head=agenda_prepare_head();
$head = agenda_prepare_head();
dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
print '<span class="opacitymedium">'.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'</span><br>';
print "<br>\n";
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder" width="100%">';
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" name="search_event" value="'.dol_escape_htmltag($search_event).'"></td>';
print '<td class="liste_titre"></td>';
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
@ -155,10 +155,10 @@ print '</tr>'."\n";
print '<tr class="liste_titre">';
print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</th>';
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param?$param:'').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param?$param:'').'">'.$langs->trans("None").'</a></th>';
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
print '</tr>'."\n";
// Show each trigger (list is in c_action_trigger)
if (! empty($triggers))
if (!empty($triggers))
{
foreach ($triggers as $trigger)
{
@ -170,7 +170,7 @@ if (! empty($triggers))
if ($module == 'proposal_supplier') $module = 'supplier_proposal';
//print 'module='.$module.'<br>';
if (! empty($conf->$module->enabled))
if (!empty($conf->$module->enabled))
{
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
@ -182,9 +182,9 @@ if (! empty($triggers))
print '<td>'.$trigger['code'].'</td>';
print '<td>'.$trigger['label'].'</td>';
print '<td class="right" width="40">';
$key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
$value=$conf->global->$key;
print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action=='selectall'||$value) && $action!="selectnone")?' checked':'').'>';
$key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
$value = $conf->global->$key;
print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action == 'selectall' || $value) && $action != "selectnone") ? ' checked' : '').'>';
print '</td></tr>'."\n";
}
}

View File

@ -53,8 +53,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code=$reg[1];
$value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
$code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@ -68,7 +68,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
{
$code=$reg[1];
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@ -88,21 +88,21 @@ if ($action == 'set')
}
elseif ($action == 'specimen') // For orders
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db);
$commande->initAsSpecimen();
$commande->thirdparty=$specimenthirdparty;
$commande->thirdparty = $specimenthirdparty;
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -171,18 +171,18 @@ elseif ($action == 'setdoc')
* View
*/
$formactions=new FormActions($db);
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$formactions = new FormActions($db);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
$head=agenda_prepare_head();
$head = agenda_prepare_head();
dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
@ -196,15 +196,15 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = 'action'";
$sql.= " AND entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = 'action'";
$sql .= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -221,7 +221,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
print '<table class="noborder" width="100%">'."\n";
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
print '<td>'.$langs->trans("Description").'</td>'."\n";
@ -239,22 +239,22 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db, new ActionComm($db));
print '<tr class="oddeven">'."\n";
print "<td>";
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td>\n";
print "<td>\n";
require_once $dir.$file;
@ -301,11 +301,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
@ -353,15 +353,15 @@ print '</td></tr>'."\n";
// AGENDA_DEFAULT_VIEW
print '<tr class="oddeven">'."\n";
$htmltext=$langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
$htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
print '<td>'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n";
$tmplist=array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
$tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n";
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
print '<tr class="oddeven">'."\n";

View File

@ -33,22 +33,22 @@ if (!$user->admin)
accessforbidden();
// Load translation files required by the page
$langs->loadLangs(array("admin","other","agenda"));
$langs->loadLangs(array("admin", "other", "agenda"));
$def = array();
$actionsave=GETPOST('save', 'alpha');
$actionsave = GETPOST('save', 'alpha');
// Sauvegardes parametres
if ($actionsave)
{
$i=0;
$i = 0;
$db->begin();
$i+=dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i+=dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i+=dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
$i+=dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
if ($i >= 4)
{
@ -68,26 +68,26 @@ if ($actionsave)
* View
*/
if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$head=agenda_prepare_head();
$head = agenda_prepare_head();
dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print "<td>".$langs->trans("Parameter")."</td>";
@ -98,8 +98,8 @@ print "</tr>";
print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="' . (GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha'):$conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) . '" size="40">';
if (! empty($conf->use_javascript_ajax))
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
if (!empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td>';
print "<td>&nbsp;</td>";
@ -107,13 +107,13 @@ print "</tr>";
print '<tr class="oddeven">';
print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"". (GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')?GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha'):$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY) . "\" size=\"10\"> ".$langs->trans("days")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)."\" size=\"10\"> ".$langs->trans("days")."</td>";
print "<td>&nbsp;</td>";
print "</tr>";
print '<tr class="oddeven">';
print "<td>".$langs->trans("UseACacheDelay")."</td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"". (GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')?GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha'):$conf->global->MAIN_AGENDA_EXPORT_CACHE) . "\" size=\"10\"></td>";
print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_CACHE)."\" size=\"10\"></td>";
print "<td>&nbsp;</td>";
print "</tr>";
@ -121,7 +121,7 @@ print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("Parameter")."</td>";
@ -153,35 +153,35 @@ print "<br>";
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Show message
$message='';
$urlvcal='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal);
$message.='<br>';
$urlical='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical);
$message.='<br>';
$urlrss='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'rss', $urlrss);
$message.='<br>';
$message.='<br>';
$message = '';
$urlvcal = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal);
$message .= '<br>';
$urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical);
$message .= '<br>';
$urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'rss', $urlrss);
$message .= '<br>';
$message .= '<br>';
print $message;
$message =$langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions3", $user->login, $user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
$message = $langs->trans("AgendaUrlOptions1", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptions3", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptionsNotAdmin", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptions4", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptionsProject", $user->login, $user->login).'<br>';
$message .= $langs->trans("AgendaUrlOptionsNotAutoEvent", 'systemauto', 'systemauto').'<br>';
print info_admin($message);
if (! empty($conf->use_javascript_ajax))
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {

View File

@ -25,20 +25,20 @@
* \brief Page to setup the bank module
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","companies","bills","other","banks"));
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
$actionsave=GETPOST('save', 'alpha');
$actionsave = GETPOST('save', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
@ -53,7 +53,7 @@ $type = 'bankaccount';
if ($action == 'setbankorder') {
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: " . $_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
@ -65,7 +65,7 @@ if ($action == 'setbankorder') {
if ($action == 'setreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: " . $_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
@ -75,7 +75,7 @@ if ($action == 'setreportlastnumreleve') {
elseif ($action == 'unsetreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: " . $_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
@ -87,7 +87,7 @@ elseif ($action == 'unsetreportlastnumreleve') {
if ($action == 'setbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: " . $_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
@ -97,7 +97,7 @@ if ($action == 'setbankcolorizemovement') {
elseif ($action == 'unsetbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: " . $_SERVER["PHP_SELF"]);
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else {
@ -109,21 +109,21 @@ if ($actionsave)
{
$db->begin();
$i=1; $errorsaved=0;
$error=0;
$i = 1; $errorsaved = 0;
$error = 0;
// Save colors
while ($i <= 2)
{
$color=trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'));
if ($color=='-1') $color='';
$color = trim(GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'));
if ($color == '-1') $color = '';
$res=dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
$i++;
}
if (! $error)
if (!$error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -153,10 +153,10 @@ if ($action == 'specimen') {
$filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) {
$filefound = 1;
$classname = "pdf_" . $modele;
$classname = "pdf_".$modele;
break;
}
}
@ -167,7 +167,7 @@ if ($action == 'specimen') {
$module = new $classname($db);
if ($module->write_file($object, $langs) > 0) {
header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf");
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf");
return;
}
else {
@ -214,13 +214,13 @@ elseif ($action == 'setdoc') {
*/
$form = new Form($db);
$formother=new FormOther($db);
$formother = new FormOther($db);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("BankSetupModule"));
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup');
print '<form name="bankmovementcolorconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -233,12 +233,12 @@ dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'
//Show bank account order
print load_fiche_titre($langs->trans("BankOrderShow"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="140">' . $langs->trans("Name") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td>' . $langs->trans("Example") . '</td>';
print '<td class="center">' . $langs->trans("Status") . '</td>';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print '<td class="center">'.$langs->trans("Status").'</td>';
print '<td class="center" width="60">&nbsp;</td>';
print "</tr>\n";
@ -254,7 +254,7 @@ $i = 0;
$nbofbank = count($bankorder);
while ($i < $nbofbank) {
print '<tr class="oddeven">';
print '<td>' . $bankorder[$i][0] . "</td><td>\n";
print '<td>'.$bankorder[$i][0]."</td><td>\n";
print $bankorder[$i][1];
print '</td>';
print '<td class="nowrap">';
@ -272,16 +272,16 @@ while ($i < $nbofbank) {
print '</td>';
}
else {
print '<td class="center"><a href="' . $_SERVER['PHP_SELF'] . '?action=setbankorder&amp;value=' . $i . '">';
print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
print img_picto($langs->trans("Disabled"), 'off');
print '</a></td>';
}
print '<td>&nbsp;</td>';
print '</tr>' . "\n";
print '</tr>'."\n";
$i++;
}
print '</table>' . "\n";
print '</table>'."\n";
print '<br><br>';
@ -296,9 +296,9 @@ print load_fiche_titre($langs->trans("BankAccountModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
$sql .= " WHERE type = '" . $type . "'";
$sql .= " AND entity = " . $conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$i = 0;
@ -315,19 +315,19 @@ else {
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<td>' . $langs->trans("Name") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td class="center" width="60">' . $langs->trans("Status") . "</td>\n";
print '<td class="center" width="60">' . $langs->trans("Default") . "</td>\n";
print '<td class="center" width="38">' . $langs->trans("ShortInfo") . '</td>';
print '<td class="center" width="38">' . $langs->trans("Preview") . '</td>';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) {
$dir = dol_buildpath($reldir . "core/modules/bank" . $valdir);
$dir = dol_buildpath($reldir."core/modules/bank".$valdir);
if (is_dir($dir)) {
$handle = opendir($dir);
@ -340,11 +340,11 @@ foreach ($dirmodels as $reldir) {
foreach ($filelist as $file) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir . '/' . $file)) {
if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir . '/' . $file;
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified = 1;
@ -365,15 +365,15 @@ foreach ($dirmodels as $reldir) {
// Active
if (in_array($name, $def)) {
print '<td class="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=del&value=' . $name . '">';
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
}
else {
print '<td class="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=set&value=' . $name . '&amp;scan_dir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
@ -383,21 +383,21 @@ foreach ($dirmodels as $reldir) {
print img_picto($langs->trans("Default"), 'on');
}
else {
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setdoc&value=' . $name . '&amp;scan_dir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name;
$htmltooltip .= '<br>' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') {
$htmltooltip .= '<br>' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>' . $langs->trans("FeaturesSupported") . ':</u>';
$htmltooltip .= '<br>' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1);
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
//$htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
//$htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
$htmltooltip .= '<br>' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
// $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
// $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
//$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) {
// Preview
print '<td class="center">';
if ($module->type == 'pdf') {
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=specimen&module=' . $name . '">' . img_object($langs->trans("Preview"), 'bill') . '</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
}
else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -431,9 +431,9 @@ print '</table>';
print '<br><br>';
print load_fiche_titre($langs->trans("BankColorizeMovement"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print "<tr class=\"liste_titre\">\n";
print '<td colspan="4">' . $langs->trans("Name") . '</td>';
print '<td colspan="4">'.$langs->trans("Name").'</td>';
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print "</tr>\n";
@ -442,28 +442,28 @@ print $langs->trans('BankColorizeMovementDesc');
print "</td>";
// Active
if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print '<td align="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=unsetbankcolorizemovement">';
print '<td align="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
}
else
{
print '<td align="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setbankcolorizemovement">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
print '<td align="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
print "</tr>\n";
if(! empty($conf->global->BANK_COLORIZE_MOVEMENT))
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
{
$i=1;
$i = 1;
while ($i <= 2)
{
$key=$i;
$color='BANK_COLORIZE_MOVEMENT_COLOR'.$key;
$key = $i;
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
print '<tr class="oddeven">';
@ -471,7 +471,7 @@ if(! empty($conf->global->BANK_COLORIZE_MOVEMENT))
print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
// Color
print '<td class="nowrap right">';
print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key)?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key):$conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
print '</td>';
print "</tr>";
$i++;
@ -491,9 +491,9 @@ print load_fiche_titre($langs->trans("Other"), '', '');
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<td>' . $langs->trans("Name") . '</td>';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td class="center" width="60">' . $langs->trans("Status") . "</td>\n";
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
print "</tr>\n";
print '<tr class="oddeven"><td width="100">';
@ -503,16 +503,16 @@ print $langs->trans('AutoReportLastAccountStatement');
print '</td>';
// Active
if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
print '<td class="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=unsetreportlastnumreleve">';
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
}
else
{
print '<td class="center">' . "\n";
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setreportlastnumreleve">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}

View File

@ -45,15 +45,15 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton')
{
$barcodenumberingmodule = GETPOST('value', 'alpha');
$res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK))
{
$res=dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
}
}
elseif ($action == 'setbarcodeproductoff')
{
$res=dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
}
if ($action == 'setcoder')
@ -61,12 +61,12 @@ if ($action == 'setcoder')
$coder = GETPOST('coder', 'alpha');
$code_id = GETPOST('code_id', 'alpha');
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
$sqlp.= " SET coder = '" . $coder."'";
$sqlp.= " WHERE rowid = ". $code_id;
$sqlp.= " AND entity = ".$conf->entity;
$sqlp .= " SET coder = '".$coder."'";
$sqlp .= " WHERE rowid = ".$code_id;
$sqlp .= " AND entity = ".$conf->entity;
$resql=$db->query($sqlp);
if (! $resql) dol_print_error($db);
$resql = $db->query($sqlp);
if (!$resql) dol_print_error($db);
}
elseif ($action == 'update')
{
@ -130,33 +130,33 @@ elseif ($action == 'updateengine')
$form = new Form($db);
$formbarcode = new FormBarCode($db);
$help_url='EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra';
$help_url = 'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra';
llxHeader('', $langs->trans("BarcodeSetup"), $help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BarcodeSetup"), $linkback, 'title_setup');
// Detect bar codes modules
$barcodelist=array();
$barcodelist = array();
clearstatcache();
// Scan list of all barcode included provided by external modules
$dirbarcode=array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
foreach($dirbarcode as $reldir)
foreach ($dirbarcode as $reldir)
{
$dir=dol_buildpath($reldir);
$newdir=dol_osencode($dir);
$dir = dol_buildpath($reldir);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (! is_dir($newdir)) continue;
if (!is_dir($newdir)) continue;
$handle=@opendir($newdir);
$handle = @opendir($newdir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
@ -164,7 +164,7 @@ foreach($dirbarcode as $reldir)
{
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg))
{
$filebis=$reg[1];
$filebis = $reg[1];
// Loading encoding class
require_once $newdir.$file;
@ -172,12 +172,12 @@ foreach($dirbarcode as $reldir)
$module = new $classname($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
{
$barcodelist[$filebis]=$module->info();
$barcodelist[$filebis] = $module->info();
}
}
}
@ -200,7 +200,7 @@ if (empty($conf->use_javascript_ajax))
print '<input type="hidden" name="action" value="updateengine">';
}
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -237,17 +237,17 @@ if ($resql)
print '<td class="center">';
if ($obj->coder && $obj->coder != -1)
{
$result=0;
$result = 0;
foreach($dirbarcode as $reldir)
foreach ($dirbarcode as $reldir)
{
$dir=dol_buildpath($reldir, 0);
$newdir=dol_osencode($dir);
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (! is_dir($newdir)) continue;
if (!is_dir($newdir)) continue;
$result=@include_once $newdir.$obj->coder.'.modules.php';
$result = @include_once $newdir.$obj->coder.'.modules.php';
if ($result) break;
}
if ($result)
@ -259,9 +259,9 @@ if ($resql)
if ($module->encodingIsSupported($obj->encoding))
{
// Build barcode on disk (not used, this is done to make debug easier)
$result=$module->writeBarCode($obj->example, $obj->encoding, 'Y');
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
// Generate on the fly and output barcode with generator
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&amp;generator='.urlencode($obj->coder).'&amp;code='.urlencode($obj->example).'&amp;encoding='.urlencode($obj->encoding);
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&amp;generator='.urlencode($obj->coder).'&amp;code='.urlencode($obj->example).'&amp;encoding='.urlencode($obj->encoding);
//print $url;
print '<img src="'.$url.'" title="'.$obj->example.'" border="0">';
}
@ -309,7 +309,7 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td width="60" class="center">'.$langs->trans("Value").'</td>';
@ -317,13 +317,13 @@ print '<td>&nbsp;</td>';
print '</tr>';
// Chemin du binaire genbarcode sous linux
if (! isset($_SERVER['WINDIR']))
if (!isset($_SERVER['WINDIR']))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
print '<td width="60" class="center">';
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
if (! empty($conf->global->GENBARCODE_LOCATION) && ! @file_exists($conf->global->GENBARCODE_LOCATION))
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION))
{
$langs->load("errors");
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
@ -332,7 +332,7 @@ if (! isset($_SERVER['WINDIR']))
}
// Module products
if (! empty($conf->product->enabled))
if (!empty($conf->product->enabled))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
@ -342,7 +342,7 @@ if (! empty($conf->product->enabled))
}
// Module thirdparty
if (! empty($conf->societe->enabled))
if (!empty($conf->societe->enabled))
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
@ -366,7 +366,7 @@ if ($conf->product->enabled)
{
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -375,7 +375,7 @@ if ($conf->product->enabled)
print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
print "</tr>\n";
$dirbarcodenum=array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
foreach ($dirbarcodenum as $dirroot)
{
@ -384,16 +384,16 @@ if ($conf->product->enabled)
$handle = @opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (preg_match('/^mod_barcode_product_.*php$/', $file))
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
try {
dol_include_once($dirroot.$file.'.php');
}
catch(Exception $e)
catch (Exception $e)
{
dol_syslog($e->getMessage(), LOG_ERR);
}
@ -401,7 +401,7 @@ if ($conf->product->enabled)
$modBarCode = new $file();
print '<tr class="oddeven">';
print '<td>'.(isset($modBarCode->name)?$modBarCode->name:$modBarCode->nom)."</td><td>\n";
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
print $modBarCode->info($langs);
print '</td>';
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
@ -419,7 +419,7 @@ if ($conf->product->enabled)
print '</a></td>';
}
print '<td class="center">';
$s=$modBarCode->getToolTip($langs, null, -1);
$s = $modBarCode->getToolTip($langs, null, -1);
print $form->textwithpicto('', $s, 1);
print '</td>';
print "</tr>\n";

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
@ -47,14 +47,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstbom=GETPOST('maskconstBom', 'alpha');
$maskbom=GETPOST('maskBom', 'alpha');
$maskconstbom = GETPOST('maskconstBom', 'alpha');
$maskbom = GETPOST('maskBom', 'alpha');
if ($maskconstbom) $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -66,20 +66,20 @@ if ($action == 'updateMask')
elseif ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$bom = new BOM($db);
$bom->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -155,9 +155,9 @@ elseif ($action == 'set_BOM_DRAFT_WATERMARK')
$draft = GETPOST("BOM_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -169,13 +169,13 @@ elseif ($action == 'set_BOM_DRAFT_WATERMARK')
elseif ($action == 'set_BOM_FREE_TEXT')
{
$freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string
$freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -190,13 +190,13 @@ elseif ($action == 'set_BOM_FREE_TEXT')
* View
*/
$form=new Form($db);
$form = new Form($db);
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("BOMsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup');
$head = bomAdminPrepareHead();
@ -209,7 +209,7 @@ dol_fiche_head($head, 'settings', $langs->trans("BOMs"), -1, 'bom');
print load_fiche_titre($langs->trans("BOMsNumberingModules"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -229,18 +229,18 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file)-3, 3) == 'php')
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
@ -251,9 +251,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
@ -270,22 +270,22 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$bom=new BOM($db);
$bom = new BOM($db);
$bom->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$bom->type=0;
$nextval=$module->getNextValue($mysoc, $bom);
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$bom->type = 0;
$nextval = $module->getNextValue($mysoc, $bom);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
@ -313,14 +313,14 @@ print load_fiche_titre($langs->trans("BOMsModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -348,43 +348,43 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/bom".$valdir);
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
$filelist[]=$file;
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
$var = !$var;
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -419,15 +419,15 @@ foreach ($dirmodels as $reldir)
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf')
{
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
print '<td class="center">';
@ -464,25 +464,25 @@ print "<br>";
*/
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
$htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename='BOM_FREE_TEXT';
$variablename = 'BOM_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@ -490,7 +490,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';

View File

@ -31,7 +31,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'boxes', 'accountancy'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$rowid = GETPOST('rowid', 'int');
$action = GETPOST('action', 'alpha');
@ -53,34 +53,34 @@ if ($action == 'addconst')
}
if ($action == 'add') {
$error=0;
$error = 0;
$db->begin();
if (isset($_POST['boxid']) && is_array($_POST['boxid']))
{
foreach($_POST['boxid'] as $boxid)
foreach ($_POST['boxid'] as $boxid)
{
if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=...
{
$pos = $boxid['pos'];
// Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
$distinctfkuser=array();
if (! $error)
$distinctfkuser = array();
if (!$error)
{
$sql = "SELECT fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
$sql.= " AND entity = ".$conf->entity;
$sql .= " FROM ".MAIN_DB_PREFIX."user_param";
$sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
$sql .= " AND entity = ".$conf->entity;
dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i=0;
$i = 0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
$distinctfkuser[$obj->fk_user]=$obj->fk_user;
$obj = $db->fetch_object($resql);
$distinctfkuser[$obj->fk_user] = $obj->fk_user;
$i++;
}
}
@ -91,21 +91,21 @@ if ($action == 'add') {
}
}
$distinctfkuser['0']='0'; // Add entry for fk_user = 0. We must use string as key and val
$distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
foreach($distinctfkuser as $fk_user)
foreach ($distinctfkuser as $fk_user)
{
if (! $error && $fk_user != '')
if (!$error && $fk_user != '')
{
$nbboxonleft=$nbboxonright=0;
$nbboxonleft = $nbboxonright = 0;
$sql = "SELECT box_order FROM ".MAIN_DB_PREFIX."boxes WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
dol_syslog("boxes.php activate box", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
while ($obj = $db->fetch_object($resql))
{
$boxorder=$obj->box_order;
$boxorder = $obj->box_order;
if (preg_match('/A/', $boxorder)) $nbboxonleft++;
if (preg_match('/B/', $boxorder)) $nbboxonright++;
}
@ -113,14 +113,14 @@ if ($action == 'add') {
else dol_print_error($db);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
$sql.= "box_id, position, box_order, fk_user, entity";
$sql.= ") values (";
$sql.= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql.= ")";
$sql .= "box_id, position, box_order, fk_user, entity";
$sql .= ") values (";
$sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
$sql .= ")";
dol_syslog("boxes.php activate box", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql)
if (!$resql)
{
setEventMessages($db->lasterror(), null, 'errors');
$error++;
@ -130,10 +130,10 @@ if ($action == 'add') {
}
}
}
if (! $error)
if (!$error)
{
$db->commit();
$action='';
$action = '';
}
else
{
@ -144,11 +144,11 @@ if ($action == 'add') {
if ($action == 'delete')
{
$sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE rowid=".$rowid;
$sql .= " WHERE rowid=".$rowid;
$resql = $db->query($sql);
$obj=$db->fetch_object($resql);
if (! empty($obj->box_id))
$obj = $db->fetch_object($resql);
if (!empty($obj->box_id))
{
$db->begin();
@ -158,8 +158,8 @@ if ($action == 'delete')
// $resql = $db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " AND box_id=".$obj->box_id;
$sql .= " WHERE entity = ".$conf->entity;
$sql .= " AND box_id=".$obj->box_id;
$resql = $db->query($sql);
@ -172,33 +172,33 @@ if ($action == 'switch')
// We switch values of field box_order for the 2 lines of table boxes
$db->begin();
$objfrom=new ModeleBoxes($db);
$objfrom = new ModeleBoxes($db);
$objfrom->fetch($_GET["switchfrom"]);
$objto=new ModeleBoxes($db);
$objto = new ModeleBoxes($db);
$objto->fetch($_GET["switchto"]);
$resultupdatefrom=0;
$resultupdateto=0;
$resultupdatefrom = 0;
$resultupdateto = 0;
if (is_object($objfrom) && is_object($objto))
{
$newfirst=$objto->box_order;
$newsecond=$objfrom->box_order;
$newfirst = $objto->box_order;
$newsecond = $objfrom->box_order;
if ($newfirst == $newsecond)
{
$newsecondchar=preg_replace('/[0-9]+/', '', $newsecond);
$newsecondnum=preg_replace('/[a-zA-Z]+/', '', $newsecond);
$newsecond=sprintf("%s%02d", $newsecondchar?$newsecondchar:'A', $newsecondnum+1);
$newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
$newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
$newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
}
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
dol_syslog($sql);
$resultupdatefrom = $db->query($sql);
if (! $resultupdatefrom) { dol_print_error($db); }
if (!$resultupdatefrom) { dol_print_error($db); }
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newsecond."' WHERE rowid=".$objto->rowid;
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newsecond."' WHERE rowid=".$objto->rowid;
dol_syslog($sql);
$resultupdateto = $db->query($sql);
if (! $resultupdateto) { dol_print_error($db); }
if (!$resultupdateto) { dol_print_error($db); }
}
if ($resultupdatefrom && $resultupdateto)
@ -216,7 +216,7 @@ if ($action == 'switch')
* View
*/
$form=new Form($db);
$form = new Form($db);
llxHeader('', $langs->trans("Boxes"));
@ -232,12 +232,12 @@ print '<span class="opacitymedium">'.$langs->trans("BoxesDesc")." ".$langs->tran
$actives = array();
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
$sql.= " bd.rowid as boxid";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql.= " WHERE b.box_id = bd.rowid";
$sql.= " AND b.entity IN (0,".$conf->entity.")";
$sql.= " AND b.fk_user=0";
$sql.= " ORDER by b.position, b.box_order";
$sql .= " bd.rowid as boxid";
$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
$sql .= " WHERE b.box_id = bd.rowid";
$sql .= " AND b.entity IN (0,".$conf->entity.")";
$sql .= " AND b.fk_user=0";
$sql .= " ORDER by b.position, b.box_order";
dol_syslog("Search available boxes", LOG_DEBUG);
$resql = $db->query($sql);
@ -247,11 +247,11 @@ if ($resql)
// Check record to know if we must recalculate sort order
$i = 0;
$decalage=0;
$decalage = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$boxes[$obj->position][$obj->box_id]=1;
$boxes[$obj->position][$obj->box_id] = 1;
$i++;
array_push($actives, $obj->box_id);
@ -261,7 +261,7 @@ if ($resql)
// This occurs just after an insert.
if ($decalage)
{
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$decalage."' WHERE rowid=".$obj->rowid;
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$decalage."' WHERE rowid=".$obj->rowid;
$db->query($sql);
}
}
@ -271,9 +271,9 @@ if ($resql)
// If we have renumbered, we correct the field box_order
// This occurs just after an insert.
$sql = "SELECT box_order";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " AND LENGTH(box_order) <= 2";
$sql .= " FROM ".MAIN_DB_PREFIX."boxes";
$sql .= " WHERE entity = ".$conf->entity;
$sql .= " AND LENGTH(box_order) <= 2";
dol_syslog("Execute requests to renumber box order", LOG_DEBUG);
$result = $db->query($sql);
@ -286,13 +286,13 @@ if ($resql)
if (preg_match("/[13579]{1}/", substr($record['box_order'], -1)))
{
$box_order = "A0".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1)))
{
$box_order = "B0".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
}
@ -301,13 +301,13 @@ if ($resql)
if (preg_match("/[13579]{1}/", substr($record['box_order'], -1)))
{
$box_order = "A".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
elseif (preg_match("/[02468]{1}/", substr($record['box_order'], -1)))
{
$box_order = "B".$record['box_order'];
$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE entity = ".$conf->entity." AND box_order = '".$record['box_order']."'";
$resql = $db->query($sql);
}
}
@ -318,9 +318,9 @@ if ($resql)
}
// Available boxes to activate
$boxtoadd=InfoBox::listBoxes($db, 'available', -1, null, $actives);
$boxtoadd = InfoBox::listBoxes($db, 'available', -1, null, $actives);
// Activated boxes
$boxactivated=InfoBox::listBoxes($db, 'activated', -1, null);
$boxactivated = InfoBox::listBoxes($db, 'activated', -1, null);
print "<br>\n";
print "\n\n".'<!-- Boxes Available -->'."\n";
@ -340,7 +340,7 @@ print '<td>'.$langs->trans("SourceFile").'</td>';
print '<td width="160" class="center">'.$langs->trans("ActivateOn").'</td>';
print "</tr>\n";
foreach($boxtoadd as $box)
foreach ($boxtoadd as $box)
{
if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
{
@ -348,13 +348,13 @@ foreach($boxtoadd as $box)
}
else
{
$logo=preg_replace("/^object_/i", "", $box->boximg);
$logo = preg_replace("/^object_/i", "", $box->boximg);
}
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr class="oddeven">'."\n";
print '<td>'.img_object("", $logo).' '.$langs->transnoentitiesnoconv($box->boxlabel);
if (! empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
print '</td>'."\n";
print '<td>';
if ($box->note == '(WarningUsingThisBoxSlowDown)')
@ -362,9 +362,9 @@ foreach($boxtoadd as $box)
$langs->load("errors");
print $langs->trans("WarningUsingThisBoxSlowDown");
}
else print ($box->note?$box->note:'&nbsp;');
else print ($box->note ? $box->note : '&nbsp;');
print '</td>'."\n";
print '<td>' . $box->sourcefile . '</td>'."\n";
print '<td>'.$box->sourcefile.'</td>'."\n";
// For each possible position, an activation link is displayed if the box is not already active for that position
print '<td class="center">';
@ -374,7 +374,7 @@ foreach($boxtoadd as $box)
print '</tr>'."\n";
}
if (! count($boxtoadd) && count($boxactivated))
if (!count($boxtoadd) && count($boxactivated))
{
print '<tr><td class="opacitymedium" colspan="4">'.$langs->trans("AllWidgetsWereEnabled").'</td></tr>';
}
@ -382,7 +382,7 @@ print '</table>'."\n";
print '</div>';
print '<div class="right">';
print '<input type="submit" class="button"'.(count($boxtoadd)?'':' disabled').' value="'.$langs->trans("Activate").'">';
print '<input type="submit" class="button"'.(count($boxtoadd) ? '' : ' disabled').' value="'.$langs->trans("Activate").'">';
print '</div>'."\n";
print '</form>';
print "\n".'<!-- End Boxes Available -->'."\n";
@ -403,9 +403,9 @@ print '<td class="center" width="60" colspan="2">'.$langs->trans("PositionByDefa
print '<td class="center" width="80">'.$langs->trans("Disable").'</td>';
print '</tr>'."\n";
$box_order=1;
$foundrupture=1;
foreach($boxactivated as $key => $box)
$box_order = 1;
$foundrupture = 1;
foreach ($boxactivated as $key => $box)
{
if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
{
@ -413,13 +413,13 @@ foreach($boxactivated as $key => $box)
}
else
{
$logo=preg_replace("/^object_/i", "", $box->boximg);
$logo = preg_replace("/^object_/i", "", $box->boximg);
}
print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
print '<tr class="oddeven">';
print '<td>'.img_object("", $logo).' '.$langs->transnoentitiesnoconv($box->boxlabel);
if (! empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
print '</td>';
print '<td>';
if ($box->note == '(WarningUsingThisBoxSlowDown)')
@ -427,15 +427,15 @@ foreach($boxactivated as $key => $box)
$langs->load("errors");
print img_warning('', 0).' '.$langs->trans("WarningUsingThisBoxSlowDown");
}
else print ($box->note?$box->note:'&nbsp;');
else print ($box->note ? $box->note : '&nbsp;');
print '</td>';
print '<td class="center">' . (empty($pos_name[$box->position])?'':$langs->trans($pos_name[$box->position])) . '</td>';
$hasnext=($key < (count($boxactivated)-1));
$hasprevious=($key != 0);
print '<td class="center">'.($key+1).'</td>';
print '<td class="center">'.(empty($pos_name[$box->position]) ? '' : $langs->trans($pos_name[$box->position])).'</td>';
$hasnext = ($key < (count($boxactivated) - 1));
$hasprevious = ($key != 0);
print '<td class="center">'.($key + 1).'</td>';
print '<td class="center">';
print ($hasnext?'<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key+1]->rowid.'">'.img_down().'</a>&nbsp;':'');
print ($hasprevious?'<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
print ($hasnext ? '<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key + 1]->rowid.'">'.img_down().'</a>&nbsp;' : '');
print ($hasprevious ? '<a href="boxes.php?action=switch&amp;switchfrom='.$box->rowid.'&amp;switchto='.$boxactivated[$key - 1]->rowid.'">'.img_up().'</a>' : '');
print '</td>';
print '<td class="center">';
print '<a href="boxes.php?rowid='.$box->rowid.'&amp;action=delete">'.img_delete().'</a>';
@ -456,7 +456,7 @@ print load_fiche_titre($langs->trans("Other"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addconst">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("Parameter").'</td>';

View File

@ -111,7 +111,7 @@ dol_fiche_head($head, 'checkreceipts', $langs->trans("BankSetupModule"), -1, 'ac
print load_fiche_titre($langs->trans("ChequeReceiptsNumberingModule"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -240,7 +240,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_BANK_CHEQUERECEIPT_FREE_TEXT">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>';
print '<td class="center" width="60">&nbsp;</td>';

View File

@ -73,7 +73,7 @@ print '<form method="post" action="clicktodial.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Value").'</td>';

View File

@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
@ -56,14 +56,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconstorder=GETPOST('maskconstorder', 'alpha');
$maskorder=GETPOST('maskorder', 'alpha');
$maskconstorder = GETPOST('maskconstorder', 'alpha');
$maskorder = GETPOST('maskorder', 'alpha');
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -75,20 +75,20 @@ if ($action == 'updateMask')
elseif ($action == 'specimen')
{
$modele=GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$commande = new Commande($db);
$commande->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -164,9 +164,9 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK')
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -178,13 +178,13 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK')
elseif ($action == 'set_ORDER_FREE_TEXT')
{
$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -192,12 +192,12 @@ elseif ($action == 'set_ORDER_FREE_TEXT')
{
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action=="setshippableiconinlist") {
} elseif ($action == "setshippableiconinlist") {
// Activate Set Shippable Icon In List
$setshippableiconinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (! $error) {
if (!$res > 0) $error++;
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
@ -209,9 +209,9 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
{
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -226,9 +226,9 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
{
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -243,13 +243,13 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
* View
*/
$form=new Form($db);
$form = new Form($db);
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader("", $langs->trans("OrdersSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup');
$head = order_admin_prepare_head();
@ -262,7 +262,7 @@ dol_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order');
print load_fiche_titre($langs->trans("OrdersNumberingModules"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -282,18 +282,18 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php')
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
@ -304,9 +304,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
@ -323,22 +323,22 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$commande=new Commande($db);
$commande = new Commande($db);
$commande->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$commande->type=0;
$nextval=$module->getNextValue($mysoc, $commande);
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$commande->type = 0;
$nextval = $module->getNextValue($mysoc, $commande);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
@ -366,14 +366,14 @@ print load_fiche_titre($langs->trans("OrdersModelModule"), '', '');
// Load array def with activated templates
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -401,42 +401,42 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/commande".$valdir);
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
$filelist[]=$file;
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -521,25 +521,25 @@ print "<br>";
*/
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
$htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename='ORDER_FREE_TEXT';
$variablename = 'ORDER_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@ -547,7 +547,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td><td class="right">';
@ -659,7 +659,7 @@ print '<br>';
*/
print load_fiche_titre($langs->trans("Notifications"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60"></td>';

View File

@ -37,52 +37,52 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$action=GETPOST('action', 'aZ09');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'admincompany'; // To manage different context of search
$action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
// Load translation files required by the page
$langs->loadLangs(array('admin', 'companies'));
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$error=0;
$error = 0;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admincompany','globaladmin'));
$hookmanager->initHooks(array('admincompany', 'globaladmin'));
/*
* Actions
*/
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit') )
if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit'))
{
$tmparray=getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
if (! empty($tmparray['id']))
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id']))
{
$mysoc->country_id =$tmparray['id'];
$mysoc->country_code =$tmparray['code'];
$mysoc->country_label=$tmparray['label'];
$mysoc->country_id = $tmparray['id'];
$mysoc->country_code = $tmparray['code'];
$mysoc->country_label = $tmparray['label'];
$s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
$s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
activateModulesRequiredByCountry($mysoc->country_code);
}
$tmparray=getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
if (! empty($tmparray['id']))
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id']))
{
$mysoc->state_id =$tmparray['id'];
$mysoc->state_code =$tmparray['code'];
$mysoc->state_label=$tmparray['label'];
$mysoc->state_id = $tmparray['id'];
$mysoc->state_code = $tmparray['code'];
$mysoc->state_label = $tmparray['label'];
$s=$mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
$s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity);
}
else
@ -105,28 +105,28 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alpha'), 'chaine', 0, '', $conf->entity);
$dirforimage=$conf->mycompany->dir_output.'/logos/';
$dirforimage = $conf->mycompany->dir_output.'/logos/';
$arrayofimages = array('logo', 'logo_squarred');
foreach($arrayofimages as $varforimage)
foreach ($arrayofimages as $varforimage)
{
if ($_FILES[$varforimage]["tmp_name"])
{
$reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg))
{
$original_file=$reg[1];
$original_file = $reg[1];
$isimage=image_format_supported($original_file);
$isimage = image_format_supported($original_file);
if ($isimage >= 0)
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (! is_dir($dirforimage))
if (!is_dir($dirforimage))
{
dol_mkdir($dirforimage);
}
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0)
{
$constant = "MAIN_INFO_SOCIETE_LOGO";
@ -144,7 +144,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
{
$imgThumbSmall = $reg[1]; // Save only basename
$imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
}
else dol_syslog($imgThumbSmall);
@ -153,7 +153,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
{
$imgThumbMini = $reg[1]; // Save only basename
$imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
}
else dol_syslog($imgThumbMini);
@ -162,7 +162,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
$error++;
$langs->load("errors");
$tmparray=explode(':', $result);
$tmparray = explode(':', $result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
}
else
@ -201,12 +201,12 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
$usevat = GETPOST("optiontva", 'aZ09');
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
if ($uselocaltax1 == 'localtax1on' && ! $usevat)
if ($uselocaltax1 == 'localtax1on' && !$usevat)
{
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++;
}
if ($uselocaltax2 == 'localtax2on' && ! $usevat)
if ($uselocaltax2 == 'localtax2on' && !$usevat)
{
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++;
@ -216,9 +216,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
if($_POST["optionlocaltax1"]=="localtax1on")
if ($_POST["optionlocaltax1"] == "localtax1on")
{
if(!isset($_REQUEST['lt1']))
if (!isset($_REQUEST['lt1']))
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
}
@ -228,9 +228,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
}
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
}
if($_POST["optionlocaltax2"]=="localtax2on")
if ($_POST["optionlocaltax2"] == "localtax2on")
{
if(!isset($_REQUEST['lt2']))
if (!isset($_REQUEST['lt2']))
{
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
}
@ -241,7 +241,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
}
if (! $error)
if (!$error)
{
$db->commit();
}
@ -250,7 +250,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha'))
$db->rollback();
}
if ($action != 'updateedit' && ! $error)
if ($action != 'updateedit' && !$error)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@ -261,7 +261,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
{
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
{
$isimage=image_format_supported($_GET["file"]);
$isimage = image_format_supported($_GET["file"]);
// Create thumbs of logo
if ($isimage > 0)
@ -278,7 +278,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg))
{
$imgThumbSmall = $reg[1]; // Save only basename
$imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
}
else dol_syslog($imgThumbSmall);
@ -287,7 +287,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg))
{
$imgThumbMini = $reg[1]; // Save only basename
$imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
}
else dol_syslog($imgThumbMini);
@ -328,11 +328,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
$logofilenamebis = $mysoc->logo;
}
$logofile=$conf->mycompany->dir_output.'/logos/'.$logofilename;
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile);
dolibarr_del_const($db, $constant, $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred='';
else $mysoc->logo='';
if ($action == 'removelogosquarred') $mysoc->logo_squarred = '';
else $mysoc->logo = '';
$logofilename = $mysoc->logo_small;
$logofilenamebis = $mysoc->logo_squarred_small;
@ -342,11 +342,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
$logofilenamebis = $mysoc->logo_small;
}
$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile);
dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small='';
else $mysoc->logo_small='';
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = '';
else $mysoc->logo_small = '';
$logofilename = $mysoc->logo_mini;
$logofilenamebis = $mysoc->logo_squarred_mini;
@ -356,11 +356,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
$logofilenamebis = $mysoc->logo_mini;
}
$logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile);
dolibarr_del_const($db, $constant."_MINI", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini='';
else $mysoc->logo_mini='';
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = '';
else $mysoc->logo_mini = '';
}
@ -368,14 +368,14 @@ if ($action == 'removelogo' || $action == 'removelogosquarred')
* View
*/
$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
llxHeader('', $langs->trans("Setup"), $wikihelp);
$form=new Form($db);
$formother=new FormOther($db);
$formcompany=new FormCompany($db);
$form = new Form($db);
$formother = new FormOther($db);
$formcompany = new FormCompany($db);
$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
$countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
@ -403,7 +403,7 @@ print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name
@ -434,11 +434,11 @@ print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$state_id=0;
if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE))
$state_id = 0;
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE))
{
$tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
$state_id=$tmp[0];
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
$state_id = $tmp[0];
}
$formcompany->select_departement($state_id, $mysoc->country_code, 'state_id');
print '</td></tr>'."\n";
@ -450,28 +450,28 @@ print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
print '<input name="tel" id="phone" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL) . '"></td></tr>';
print '<input name="tel" id="phone" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TEL).'"></td></tr>';
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
print '<input name="fax" id="fax" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FAX) . '"></td></tr>';
print '<input name="fax" id="fax" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_FAX).'"></td></tr>';
print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
print '<input name="mail" id="email" class="minwidth200" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL) . '"></td></tr>';
print '<input name="mail" id="email" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MAIL).'"></td></tr>';
print '</td></tr>'."\n";
// Web
print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
print '<input name="web" id="web" class="minwidth300" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB) . '"></td></tr>';
print '<input name="web" id="web" class="minwidth300" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_WEB).'"></td></tr>';
print '</td></tr>'."\n";
// Barcode
if (! empty($conf->barcode->enabled)) {
if (!empty($conf->barcode->enabled)) {
print '<tr class="oddeven"><td><label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
print '<input name="barcode" id="barcode" class="minwidth150" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_GENCOD) . '"></td></tr>';
print '<input name="barcode" id="barcode" class="minwidth150" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_GENCOD).'"></td></tr>';
print '</td></tr>';
}
@ -480,7 +480,7 @@ print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
print '<input type="file" class="flat minwidth200" name="logo" id="logo" accept="image/*">';
print '</td><td class="nocellnopadd right" valign="middle">';
if (! empty($mysoc->logo_mini)) {
if (!empty($mysoc->logo_mini)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
print ' &nbsp; ';
@ -497,7 +497,7 @@ print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto
print '<table width="100%" class="nobordernopadding"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
print '<input type="file" class="flat minwidth200" name="logo_squarred" id="logo_squarred" accept="image/*">';
print '</td><td class="nocellnopadd right" valign="middle">';
if (! empty($mysoc->logo_squarred_mini)) {
if (!empty($mysoc->logo_squarred_mini)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
print ' &nbsp; ';
@ -519,7 +519,7 @@ print '</table>';
print '<br>';
// IDs of the company (country-specific)
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
$langs->load("companies");
@ -527,19 +527,19 @@ $langs->load("companies");
// Managing Director(s)
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS) . '"></td></tr>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS).'"></td></tr>';
// GDPR contact
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
print '</td><td>';
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_GDPR) . '"></td></tr>';
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_GDPR).'"></td></tr>';
// Capital
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
print '<input name="capital" id="capital" class="minwidth100" value="' . dol_escape_htmltag($conf->global->MAIN_INFO_CAPITAL) . '"></td></tr>';
print '<input name="capital" id="capital" class="minwidth100" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_CAPITAL).'"></td></tr>';
// Juridical Status
@ -555,9 +555,9 @@ print '</td></tr>';
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="siren" id="profid1" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">';
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
}
else
{
@ -570,9 +570,9 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="siret" id="profid2" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '') . '">';
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
}
else
{
@ -585,9 +585,9 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="ape" id="profid3" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">';
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
}
else
{
@ -600,9 +600,9 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="rcs" id="profid4" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">';
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
}
else
{
@ -615,9 +615,9 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">';
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
}
else
{
@ -630,9 +630,9 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
{
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code))
if (!empty($mysoc->country_code))
{
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">';
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
}
else
{
@ -644,13 +644,13 @@ if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-')
// TVA Intra
print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" id="intra_vat" class="minwidth200" value="' . dol_escape_htmltag(! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
print '</td></tr>';
// Object of the company
print '<tr class="oddeven"><td><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(!empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
print '</td></tr>';
print '</table>';
@ -658,27 +658,27 @@ print '</table>';
// Fiscal year start
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100') . '</td></tr>';
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
print "</table>";
// Fiscal options
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="140">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print '<td colspan="2">';
print "<table>";
print "<tr><td><label for=\"use_vat\">".$langs->trans("VATIsUsedDesc")."</label></td></tr>";
@ -687,7 +687,7 @@ print "</table>";
print "</td></tr>\n";
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"no_vat\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
print "<tr class=\"oddeven\"><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"no_vat\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
print '<td colspan="2">';
print "<table>";
print "<tr><td><label for=\"no_vat\">".$langs->trans("VATIsNotUsedDesc")."</label></td></tr>";
@ -704,27 +704,27 @@ if ($mysoc->useLocalTax(1))
{
// Local Tax 1
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="140">'.$langs->transcountry("LocalTax1Management", $mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
print "</tr>\n";
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
print '<table class="nobordernopadding">';
print "<tr><td><label for=\"lt1\">".$langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
if(! isOnlyOneLocalTax(1))
$example = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
print ($example != "LocalTax1IsUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
if (!isOnlyOneLocalTax(1))
{
print '<tr><td class="left"><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
print '</td></tr>';
}
$opcions=array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"),$langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"),$langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
$opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
print '<tr><td class="left"></label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
@ -733,12 +733,12 @@ if ($mysoc->useLocalTax(1))
print "</td></tr>\n";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" value=\"localtax1off\"".((empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."</td>";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" value=\"localtax1off\"".((empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
print "<table>";
print "<tr><td><label for=\"nolt1\">".$langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
$example = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
print ($example != "LocalTax1IsNotUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
print "</table>";
print "</td></tr>\n";
print "</table>";
@ -747,7 +747,7 @@ if ($mysoc->useLocalTax(2))
{
// Local Tax 2
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->transcountry("LocalTax2Management", $mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>';
@ -755,13 +755,13 @@ if ($mysoc->useLocalTax(2))
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
print '<table class="nobordernopadding">';
print "<tr><td><label for=\"lt2\">".$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
if(! isOnlyOneLocalTax(2))
$example = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
print ($example != "LocalTax2IsUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
if (!isOnlyOneLocalTax(2))
{
print '<tr><td class="left"><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
@ -774,12 +774,12 @@ if ($mysoc->useLocalTax(2))
print "</td></tr>\n";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"".((empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."</td>";
print "<tr class=\"oddeven\"><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"".((empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">';
print "<table>";
print "<tr><td><label for=\"nolt2\">".$langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n":"");
$example = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
print ($example != "LocalTax2IsNotUsedExample" ? "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i></td></tr>\n" : "");
print "</table>";
print "</td></tr>\n";
print "</table>";

View File

@ -110,7 +110,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
// case of the parameter ACCOUNTING_MODE
@ -138,7 +138,7 @@ print "</table>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";

View File

@ -97,7 +97,7 @@ dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'sending');
// Miscellaneous parameters
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Feature").'</td>';
print '<td width="20">&nbsp;</td>';

View File

@ -198,7 +198,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '')."\n";
print '<td>'.$langs->trans("Value").'</td>';

View File

@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","errors","contracts"));
$langs->loadLangs(array("admin", "errors", "contracts"));
if (!$user->admin) accessforbidden();
@ -37,11 +37,11 @@ $action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type='contract';
$type = 'contract';
if (empty($conf->global->CONTRACT_ADDON))
{
$conf->global->CONTRACT_ADDON='mod_contract_serpis';
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
}
@ -54,12 +54,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
$maskconst = GETPOST('maskconstcontract', 'alpha');
$maskvalue = GETPOST('maskcontract', 'alpha');
$maskvalue = GETPOST('maskcontract', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
if (! $res > 0) $error++;
if (!$res > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -71,20 +71,20 @@ if ($action == 'updateMask')
elseif ($action == 'specimen') // For contract
{
$modele= GETPOST('module', 'alpha');
$modele = GETPOST('module', 'alpha');
$contract = new Contrat($db);
$contract->initAsSpecimen();
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
@ -157,15 +157,15 @@ elseif ($action == 'setmod')
elseif ($action == 'set_other')
{
$freetext= GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
$draft= GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
$draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (! $res1 > 0 || ! $res2 > 0) $error++;
if (!$res1 > 0 || !$res2 > 0) $error++;
if (! $error)
if (!$error)
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
@ -180,16 +180,16 @@ elseif ($action == 'set_other')
* View
*/
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader();
$form=new Form($db);
$form = new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ContractsSetup"), $linkback, 'title_setup');
$head=contract_admin_prepare_head();
$head = contract_admin_prepare_head();
dol_fiche_head($head, 'contract', $langs->trans("Contracts"), -1, 'contract');
@ -199,7 +199,7 @@ dol_fiche_head($head, 'contract', $langs->trans("Contracts"), -1, 'contract');
print load_fiche_titre($langs->trans("ContractsNumberingModules"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -219,18 +219,18 @@ foreach ($dirmodels as $reldir)
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php')
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file)-4);
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
if ($module->isEnabled())
@ -241,9 +241,9 @@ foreach ($dirmodels as $reldir)
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
@ -260,21 +260,21 @@ foreach ($dirmodels as $reldir)
}
print '</td>';
$contract=new Contrat($db);
$contract = new Contrat($db);
$contract->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc, $contract);
$htmltooltip = '';
$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval = $module->getNextValue($mysoc, $contract);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
$htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}
@ -302,14 +302,14 @@ print load_fiche_titre($langs->trans("TemplatePDFContracts"), '', '');
// Defini tableau def des modeles
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$type."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
@ -323,7 +323,7 @@ else
}
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -337,42 +337,42 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
foreach (array('', '/doc') as $valdir)
{
$dir = dol_buildpath($reldir."core/modules/contract".$valdir);
if (is_dir($dir))
{
$handle=opendir($dir);
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
while (($file = readdir($handle)) !== false)
{
$filelist[]=$file;
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
if ($modulequalified)
{
print '<tr class="oddeven"><td width="100">';
print (empty($module->name)?$name:$module->name);
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
@ -460,22 +460,22 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_other">';
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
print "</tr>\n";
$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>';
$htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '<br>';
$variablename='CONTRACT_FREE_TEXT';
$variablename = 'CONTRACT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
@ -483,7 +483,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
else
{
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
print $doleditor->Create();
}
print '</td></tr>'."\n";

View File

@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","other","agenda"));
$langs->loadLangs(array("admin", "other", "agenda"));
if (!$user->admin)
accessforbidden();
@ -37,7 +37,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters=array(
$arrayofparameters = array(
'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
@ -60,14 +60,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
llxHeader('', $langs->trans("DAVSetup"), $wikihelp);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("DAVSetup"), $linkback, 'title_setup');
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$head=dav_admin_prepare_head();
$head = dav_admin_prepare_head();
dol_fiche_head($head, 'webdav', '', -1, 'action');
@ -77,10 +77,10 @@ if ($action == 'edit')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
foreach ($arrayofparameters as $key => $val)
{
if (isset($val['enabled']) && empty($val['enabled'])) continue;
@ -100,7 +100,7 @@ if ($action == 'edit')
}
else
{
print '<input name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'" value="' . $conf->global->$key . '">';
print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
}
print '</td></tr>';
}
@ -116,10 +116,10 @@ if ($action == 'edit')
}
else
{
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $key => $val)
foreach ($arrayofparameters as $key => $val)
{
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
@ -166,22 +166,22 @@ print "<br>";
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Show message
$message='';
$url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url);
$message.='<br>';
if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
$message = '';
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url);
$message .= '<br>';
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
{
$urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:'');
$url='<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url);
$message.='<br>';
$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url);
$message .= '<br>';
}
print $message;

View File

@ -93,7 +93,7 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
print '<td class="right"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>';

View File

@ -36,12 +36,12 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'error
if (!$user->admin) accessforbidden();
$id=GETPOST('rowid', 'int');
$action=GETPOST('action', 'alpha');
$id = GETPOST('rowid', 'int');
$action = GETPOST('action', 'alpha');
$mode = GETPOST('mode', 'aZ09')?GETPOST('mode', 'aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -49,32 +49,32 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield='page,param';
if (! $sortorder) $sortorder='ASC';
if (!$sortfield) $sortfield = 'page,param';
if (!$sortorder) $sortorder = 'ASC';
$defaulturl = GETPOST('defaulturl');
$defaultkey = GETPOST('defaultkey', 'alpha');
$defaultvalue = GETPOST('defaultvalue');
$defaulturl=preg_replace('/^\//', '', $defaulturl);
$defaulturl = preg_replace('/^\//', '', $defaulturl);
$urlpage = GETPOST('urlpage');
$key = GETPOST('key');
$value = GETPOST('value');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('admindefaultvalues','globaladmin'));
$hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
/*
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
@ -82,11 +82,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$defaulturl='';
$defaultkey='';
$defaultvalue='';
$toselect='';
$search_array_options=array();
$defaulturl = '';
$defaultkey = '';
$defaultvalue = '';
$toselect = '';
$search_array_options = array();
}
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
@ -97,7 +97,7 @@ if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
{
$error=0;
$error = 0;
if (($action == 'add' || (GETPOST('add') && $action != 'update')))
{
@ -126,7 +126,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
}
}
if (! $error)
if (!$error)
{
$db->begin();
@ -137,7 +137,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
if (GETPOST('actionmodify'))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql.= " WHERE rowid = ".$id;
$sql .= " WHERE rowid = ".$id;
}
$result = $db->query($sql);
@ -145,16 +145,16 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
{
$db->commit();
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action="";
$defaulturl='';
$defaultkey='';
$defaultvalue='';
$action = "";
$defaulturl = '';
$defaultkey = '';
$defaultvalue = '';
}
else
{
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
$action='';
$action = '';
}
}
}
@ -181,28 +181,28 @@ if ($action == 'delete')
* View
*/
$form=new Form($db);
$form = new Form($db);
$formadmin = new FormAdmin($db);
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
$wikihelp = 'EN:Setup|FR:Paramétrage|ES:Configuración';
llxHeader('', $langs->trans("Setup"), $wikihelp);
$param='&mode='.$mode;
$param = '&mode='.$mode;
$enabledisablehtml.= $langs->trans("EnableDefaultValues").' ';
$enabledisablehtml .= $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{
// Button off, click to enable
$enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
$enabledisablehtml.= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml.= '</a>';
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
$enabledisablehtml .= '</a>';
}
else
{
// Button on, click to disable
$enabledisablehtml.= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
$enabledisablehtml.= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml.= '</a>';
$enabledisablehtml .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&value=0'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
$enabledisablehtml .= '</a>';
}
print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'title_setup');
@ -210,15 +210,15 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
print "<br>\n";
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($defaulturl) $param.='&defaulturl='.urlencode($defaulturl);
if ($defaultkey) $param.='&defaultkey='.urlencode($defaultkey);
if ($defaultvalue) $param.='&defaultvalue='.urlencode($defaultvalue);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($optioncss != '') $param .= '&optioncss='.$optioncss;
if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl);
if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey);
if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue);
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug) ? '?debug=1' : '').'" method="POST">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -227,7 +227,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$head=defaultvalues_prepare_head();
$head = defaultvalues_prepare_head();
dol_fiche_head($head, $mode, '', -1, '');
@ -245,25 +245,25 @@ print '<input type="hidden" id="action" name="action" value="">';
print '<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
// Page
$texthelp=$langs->trans("PageUrlForDefaultValues");
if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
$texthelp.='<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
$texthelp = $langs->trans("PageUrlForDefaultValues");
if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl = $form->textwithpicto($langs->trans("Url"), $texthelp);
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
// Field
$texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField");
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder')
{
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
}
else
{
$texthelp='field or alias.field';
$textkey=$form->textwithpicto($langs->trans("Field"), $texthelp);
$texthelp = 'field or alias.field';
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
}
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
// Value
@ -271,24 +271,24 @@ if ($mode != 'focus' && $mode != 'mandatory')
{
if ($mode != 'sortorder')
{
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val)
{
$texthelp.=$key.' -> '.$val.'<br>';
$texthelp .= $key.' -> '.$val.'<br>';
}
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
}
else
{
$texthelp='ASC or DESC';
$textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp);
$texthelp = 'ASC or DESC';
$textvalue = $form->textwithpicto($langs->trans("SortOrder"), $texthelp);
}
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
}
// Entity
if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
// Actions
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
@ -315,10 +315,10 @@ if ($mode != 'focus' && $mode != 'mandatory')
print '</td>';
}
// Limit to superadmin
if (! empty($conf->multicompany->enabled) && !$user->entity)
if (!empty($conf->multicompany->enabled) && !$user->entity)
{
print '<td>';
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
print '</td>';
}
else
@ -328,8 +328,8 @@ else
print '</td>';
}
print '<td class="center">';
$disabled='';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"';
$disabled = '';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"';
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
print "</td>\n";
print '</tr>';
@ -337,10 +337,10 @@ print '</tr>';
// Show constants
$sql = "SELECT rowid, entity, type, page, param, value";
$sql.= " FROM ".MAIN_DB_PREFIX."default_values";
$sql.= " WHERE type = '".$db->escape($mode)."'";
$sql.= " AND entity IN (".$user->entity.",".$conf->entity.")";
$sql.= $db->order($sortfield, $sortorder);
$sql .= " FROM ".MAIN_DB_PREFIX."default_values";
$sql .= " WHERE type = '".$db->escape($mode)."'";
$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")";
$sql .= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql);
@ -389,15 +389,15 @@ if ($result)
print '<td class="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
{
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_edit().'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print ' &nbsp; ';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete'.((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
}
else
{
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$id.'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:'none').'"></div>';
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : 'none').'"></div>';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
}

View File

@ -30,11 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->load("admin");
if (! $user->admin) accessforbidden();
if (!$user->admin) accessforbidden();
$action=GETPOST('action', 'alpha');
$action = GETPOST('action', 'alpha');
$modules=array(
$modules = array(
'agenda' => array(
array(
'code' => 'MAIN_DELAY_ACTIONS_TODO',
@ -137,11 +137,11 @@ $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->
if ($action == 'update')
{
foreach($modules as $module => $delays)
foreach ($modules as $module => $delays)
{
if (! empty($conf->$module->enabled))
if (!empty($conf->$module->enabled))
{
foreach($delays as $delay)
foreach ($delays as $delay)
{
if (GETPOST($delay['code']) != '')
{
@ -155,11 +155,11 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
// For update value with percentage
$plus='';
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
$plus = '';
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
// Update values
for($i=0; $i<4; $i++) {
if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
for ($i = 0; $i < 4; $i++) {
if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
}
}
@ -178,7 +178,7 @@ print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceD
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
print "<br>\n";
$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
$countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
if ($action == 'edit')
{
@ -186,16 +186,16 @@ if ($action == 'edit')
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach($modules as $module => $delays)
foreach ($modules as $module => $delays)
{
if (! empty($conf->$module->enabled))
if (!empty($conf->$module->enabled))
{
foreach($delays as $delay)
foreach ($delays as $delay)
{
$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td>';
@ -209,12 +209,12 @@ if ($action == 'edit')
print '<br>';
// Show if meteo is enabled
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
print '</td></tr>';
print '</table>';
@ -225,16 +225,16 @@ else
* Show parameters
*/
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach($modules as $module => $delays)
foreach ($modules as $module => $delays)
{
if (! empty($conf->$module->enabled))
if (!empty($conf->$module->enabled))
{
foreach($delays as $delay)
foreach ($delays as $delay)
{
$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
@ -248,7 +248,7 @@ else
print '<br>';
// Show if meteo is enabled
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">';
@ -264,30 +264,30 @@ print '<br>';
// Show logo for weather
print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
if($action == 'edit') {
if ($action == 'edit') {
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
else $str_mode_enabled = $str_mode_percentage;
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
print '<br><br>';
} else {
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
else print $langs->trans('MeteoPercentageModEnabled');
print '<br><br>';
}
$offset=0;
$cursor=10; // By default
$offset = 0;
$cursor = 10; // By default
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
$level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
$text=''; $options='class="valignmiddle" height="60px"';
$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0;
$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1;
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2;
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3;
$text = ''; $options = 'class="valignmiddle" height="60px"';
if ($action == 'edit') {
@ -361,7 +361,7 @@ if ($action == 'edit') {
<?php
} else {
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 0, $options);
@ -404,7 +404,7 @@ if ($action == 'edit') {
print '</div>';
if($action == 'edit') {
if ($action == 'edit') {
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
print '<br></form>';
} else {

File diff suppressed because it is too large Load Diff

View File

@ -88,7 +88,7 @@ class PrestaShopWebservice
protected function checkStatusCode($status_code)
{
$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
switch($status_code)
switch ($status_code)
{
case 200:
case 201:
@ -106,7 +106,7 @@ class PrestaShopWebservice
case 500:
throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error'));
default:
throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code);
throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:'.$status_code);
}
}
@ -125,7 +125,7 @@ class PrestaShopWebservice
CURLINFO_HEADER_OUT => true,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $this->key.':',
CURLOPT_HTTPHEADER => array( 'Expect:' )
CURLOPT_HTTPHEADER => array('Expect:')
);
dol_syslog("curl_init url=".$url);
@ -328,7 +328,7 @@ class PrestaShopWebservice
throw new PrestaShopWebserviceException('Bad parameters given ');
$request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
self::checkStatusCode($request['status_code']);// check the response validity
self::checkStatusCode($request['status_code']); // check the response validity
return self::parseXML($request['response']);
}
@ -360,7 +360,7 @@ class PrestaShopWebservice
else
throw new PrestaShopWebserviceException('Bad parameters given');
$request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => true));
self::checkStatusCode($request['status_code']);// check the response validity
self::checkStatusCode($request['status_code']); // check the response validity
return $request['header'];
}
/**
@ -392,7 +392,7 @@ class PrestaShopWebservice
throw new PrestaShopWebserviceException('Bad parameters given');
$request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml));
self::checkStatusCode($request['status_code']);// check the response validity
self::checkStatusCode($request['status_code']); // check the response validity
return self::parseXML($request['response']);
}
}

View File

@ -40,15 +40,15 @@ class Dolistore
*/
public $end;
public $per_page; // pagination: display per page
public $categorie; // the current categorie
public $search; // the search keywords
public $per_page; // pagination: display per page
public $categorie; // the current categorie
public $search; // the search keywords
// setups
public $url; // the url of this page
public $shop_url; // the url of the shop
public $lang; // the integer representing the lang in the store
public $debug_api; // usefull if no dialog
public $url; // the url of this page
public $shop_url; // the url of the shop
public $lang; // the integer representing the lang in the store
public $debug_api; // usefull if no dialog
/**
@ -66,8 +66,8 @@ class Dolistore
$langtmp = explode('_', $langs->defaultlang);
$lang = $langtmp[0];
$lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
$lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
if (!in_array($lang, array_keys($lang_array))) $lang = 'en';
$this->lang = $lang_array[$lang];
}
@ -142,7 +142,7 @@ class Dolistore
// make a search to limit the id returned.
if ($this->search != '') {
$opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; // It seems for search, key start with
$opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; // It seems for search, key start with
// Call
dol_syslog("Call API with opt2 = ".var_export($opt2, true));
@ -277,12 +277,12 @@ class Dolistore
// free or pay ?
if ($product->price > 0) {
$price = '<h3>'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'</h3>';
$price = '<h3>'.price(price2num($product->price, 'MT'), 0, $langs, 1, -1, -1, 'EUR').' '.$langs->trans("HT").'</h3>';
$download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
} else {
$price = '<h3>'.$langs->trans('Free').'</h3>';
$download_link = '<a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/Download-128.png" /></a>';
$download_link.= '<br><br><a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
$download_link .= '<br><br><a target="_blank" href="'.$this->shop_url.$product->id.'"><img width="32" src="'.DOL_URL_ROOT.'/admin/dolistore/img/follow.png" /></a>';
}
//checking versions

View File

@ -74,7 +74,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values
print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup');
print '<br>';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td class="center" width="20">&nbsp;</td>';

View File

@ -40,12 +40,12 @@ if (empty($conf->emailcollector->enabled)) accessforbidden();
$langs->loadLangs(array("admin", "mails", "other"));
// Get parameters
$id = GETPOST('id', 'int');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$operationid = GETPOST('operationid', 'int');
@ -53,7 +53,7 @@ $operationid = GETPOST('operationid', 'int');
// Initialize technical objects
$object = new EmailCollector($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id;
$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
@ -65,14 +65,14 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
$search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha');
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
}
if (GETPOST('saveoperation2')) $action = 'updateoperation';
if (empty($action) && empty($id) && empty($ref)) $action='view';
if (empty($action) && empty($id) && empty($ref)) $action = 'view';
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user
//if ($user->socid > 0) access_forbidden();
@ -80,11 +80,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd=$user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissionnote = $user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$debuginfo='';
$debuginfo = '';
/*
@ -99,8 +99,8 @@ if (empty($reshook))
{
$error = 0;
$permissiontoadd=1;
$permissiontodelete=1;
$permissiontoadd = 1;
$permissiontodelete = 1;
if (empty($backtopage)) $backtopage = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.($id > 0 ? $id : '__ID__');
$backurlforlist = DOL_URL_ROOT.'/admin/emailcollector_list.php';
@ -252,10 +252,10 @@ jQuery(document).ready(function() {
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector")));
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
dol_fiche_head(array(), '');
@ -264,19 +264,19 @@ if ($action == 'create') {
//unset($fields[]);
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
print '</table>'."\n";
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">';
print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
print '&nbsp; ';
print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="javascript:history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage
print '<input type="'.($backtopage ? "submit" : "button").'" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
print '</div>';
print '</form>';
@ -287,28 +287,28 @@ if (($id || $ref) && $action == 'edit')
{
print load_fiche_titre($langs->trans("EmailCollector"));
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
dol_fiche_head();
print '<table class="border centpercent tableforfield">' . "\n";
print '<table class="border centpercent tableforfield">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -330,14 +330,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete
if ($action == 'delete')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteEmailCollector'), $langs->trans('ConfirmDeleteEmailCollector'), 'confirm_delete', '', 0, 1);
}
// Clone confirmation
if ($action == 'clone') {
// Create an array for form
$formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEmailCollector', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEmailCollector', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
// Confirmation of action process
@ -345,21 +345,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formquestion = array(
'text' => $langs->trans("EmailCollectorConfirmCollect"),
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $text, 'confirm_collect', $formquestion, 0, 1, 220);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $text, 'confirm_collect', $formquestion, 0, 1, 220);
}
// Call Hook formConfirm
$parameters = array('lineid' => $lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
// Print form confirm
print $formconfirm;
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' . dol_buildpath('/admin/emailcollector_list.php', 1) . '?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="'.dol_buildpath('/admin/emailcollector_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
/*
@ -408,7 +408,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml = $langs->trans("NbOfEmailsInInbox").' : ';
$sourcedir = $object->source_directory;
$targetdir = ($object->target_directory ? $object->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag'
$targetdir = ($object->target_directory ? $object->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag'
$connection = null;
$connectstringserver = '';
@ -428,7 +428,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml .= 'IMAP functions not available on your PHP';
}
if (! $connection)
if (!$connection)
{
$morehtml .= 'Failed to open IMAP connection '.$connectstringsource;
}
@ -451,19 +451,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Common attributes
//$keyforbreak='fieldkeytoswithonsecondcolumn';
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updatefiltersactions">';
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
// Filters
print '<table class="border centpercent">';
@ -473,7 +473,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Add filter
print '<tr class="oddeven">';
print '<td>';
$arrayoftypes=array(
$arrayoftypes = array(
'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
@ -509,10 +509,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
else { jQuery("#rulevalue").prop("disabled", false); }
jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
';
$noparam=array();
foreach($arrayoftypes as $key => $value)
$noparam = array();
foreach ($arrayoftypes as $key => $value)
{
if ($value['noparam']) $noparam[]=$key;
if ($value['noparam']) $noparam[] = $key;
}
print '})';
print '</script>'."\n";
@ -523,9 +523,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
// List filters
foreach($object->filters as $rulefilter)
foreach ($object->filters as $rulefilter)
{
$rulefilterobj=new EmailCollectorFilter($db);
$rulefilterobj = new EmailCollectorFilter($db);
$rulefilterobj->fetch($rulefilter['id']);
print '<tr class="oddeven">';
@ -552,16 +552,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Add operation
print '<tr class="oddeven">';
print '<td>';
$arrayoftypes=array(
$arrayoftypes = array(
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
if ($conf->ticket->enabled) $arrayoftypes['ticket']='CreateTicketAndThirdParty';
if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
print '</td><td>';
print '<input type="text" name="operationparam">';
$htmltext=$langs->transnoentitiesnoconv("OperationParamDesc");
$htmltext = $langs->transnoentitiesnoconv("OperationParamDesc");
//var_dump($htmltext);
print $form->textwithpicto('', $htmltext);
print '</td>';
@ -571,11 +571,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// List operations
$nboflines = count($object->actions);
$table_element_line = 'emailcollector_emailcollectoraction';
$fk_element='position';
$i=0;
foreach($object->actions as $ruleaction)
$fk_element = 'position';
$i = 0;
foreach ($object->actions as $ruleaction)
{
$ruleactionobj=new EmailcollectorAction($db);
$ruleactionobj = new EmailcollectorAction($db);
$ruleactionobj->fetch($ruleaction['id']);
print '<tr class="drag drop oddeven" id="row-'.$ruleaction['id'].'">';
@ -604,7 +604,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=up&amp;rowid='.$ruleaction['id'].'">'.img_up('default', 0, 'imgupforline').'</a>';
}
if ($i < count($object->actions)-1) {
if ($i < count($object->actions) - 1) {
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&amp;rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>';
}
print '</td>';
@ -620,15 +620,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</tr>';
print '</table>';
if (! empty($conf->use_javascript_ajax)) {
if (!empty($conf->use_javascript_ajax)) {
$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '</form>';
print '</div>';
print '</div>'; // End <div class="fichecenter">
print '</div>'; // End <div class="fichecenter">
print '<div class="clearboth"></div><br>';
@ -637,26 +637,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Buttons for actions
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">' . "\n";
print '<div class="tabsAction">'."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Edit") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>';
// Clone
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=collect">' . $langs->trans("CollectNow") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=collect">'.$langs->trans("CollectNow").'</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>';
}
print '</div>' . "\n";
print '</div>'."\n";
}
if (! empty($debuginfo))
if (!empty($debuginfo))
{
print info_admin($debuginfo);
}

View File

@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
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';
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';
dol_include_once('/emailcollector/class/emailcollector.class.php');
if (!$user->admin) accessforbidden();
@ -37,20 +37,20 @@ if (empty($conf->emailcollector->enabled)) accessforbidden();
// Load traductions files required by page
$langs->loadLangs(array("admin", "other"));
$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'emailcollectorlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$id = GETPOST('id', 'int');
$id = GETPOST('id', 'int');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -64,7 +64,7 @@ $pagenext = $page + 1;
// Initialize technical objects
$object = new EmailCollector($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id;
$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
@ -73,11 +73,11 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (! $sortorder) $sortorder="ASC";
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortorder) $sortorder = "ASC";
// Security check
$socid=0;
$socid = 0;
if ($user->socid > 0) // Protection if external user
{
//$socid = $user->socid;
@ -86,34 +86,34 @@ if ($user->socid > 0) // Protection if external user
//$result = restrictedArea($user, 'emailcollector', $id, '');
// Initialize array of search criterias
$search_all=trim(GETPOST("search_all", 'alpha'));
$search=array();
foreach($object->fields as $key => $val)
$search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha');
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label'];
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
}
// Definition of fields for list
$arrayfields=array();
foreach($object->fields as $key => $val)
$arrayfields = array();
foreach ($object->fields as $key => $val)
{
// If $val['visible']==0, then we never show the field
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (! empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position');
@ -125,11 +125,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
$parameters=array();
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
@ -138,24 +138,24 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$search[$key]='';
$search[$key] = '';
}
$toselect='';
$search_array_options=array();
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass='EmailCollector';
$objectlabel='EmailCollector';
$objectclass = 'EmailCollector';
$objectlabel = 'EmailCollector';
$permissiontoread = $user->rights->emailcollector->read;
$permissiontodelete = $user->rights->emailcollector->delete;
$uploaddir = $conf->emailcollector->dir_output;
@ -168,47 +168,47 @@ if (empty($reshook))
* View
*/
$form=new Form($db);
$form = new Form($db);
$now=dol_now();
$now = dol_now();
//$help_url="EN:Module_EmailCollector|FR:Module_EmailCollector_FR|ES:Módulo_EmailCollector";
$help_url='';
$help_url = '';
$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector"));
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$sql.='t.'.$key.', ';
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label']))
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
if (!empty($extrafields->attributes[$object->table_element]['label']))
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/', '', $sql);
$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")";
else $sql.=" WHERE 1 = 1";
foreach($search as $key => $val)
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/, $/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
else $sql .= " WHERE 1 = 1";
foreach ($search as $key => $val)
{
if ($key == 'status' && $search[$key] == -1) continue;
$mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0);
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search));
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
}
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY "
@ -226,7 +226,7 @@ $sql.=$hookmanager->resPrint;
$sql=preg_replace('/, $/','', $sql);
*/
$sql.=$db->order($sortfield, $sortorder);
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
@ -247,10 +247,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
}
else
{
$sql.= $db->plimit($limit+1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
$resql=$db->query($sql);
if (! $resql)
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
@ -260,7 +260,7 @@ else
}
// Direct jump if only one record found
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
@ -289,27 +289,27 @@ jQuery(document).ready(function() {
});
</script>';
$arrayofselected=is_array($toselect)?$toselect:array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
foreach($search as $key => $val)
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val)
{
$param.= '&search_'.$key.'='.urlencode($search[$key]);
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available
$arrayofmassactions = array(
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -321,10 +321,10 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton='';
$newcardbutton = '';
//if ($user->rights->emailcollector->creer)
//{
$newcardbutton.= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']));
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']));
//}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
@ -338,8 +338,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'</div>';
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
$moreforfilter = '';
@ -347,47 +347,47 @@ $moreforfilter = '';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter))
if (!empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
$cssforfield = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
@ -396,66 +396,66 @@ print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
$cssforfield = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked']))
{
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n";
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
print '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}
}
// Loop on record
// --------------------------------------------------------------------
$i=0;
$totalarray=array();
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) break; // Should not happen
// Store properties in $object
$object->id = $obj->rowid;
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
if (property_exists($obj, $key)) $object->$key = $obj->$key;
}
// Show here line of result
print '<tr class="oddeven">';
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
$cssforfield = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if (! empty($arrayfields['t.'.$key]['checked']))
if (!empty($arrayfields['t.'.$key]['checked']))
{
print '<td';
if ($cssforfield || $val['css']) print ' class="';
@ -466,10 +466,10 @@ while ($i < min($num, $limit))
print '>';
print $object->showOutputField($val, $key, $obj->$key, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
$totalarray['val']['t.'.$key] += $obj->$key;
}
}
@ -477,19 +477,19 @@ while ($i < min($num, $limit))
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (!$i) $totalarray['nbfield']++;
print '</tr>';
@ -503,16 +503,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
$db->free($resql);
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
@ -522,19 +522,19 @@ print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
$hidegeneratedfilelistifempty=1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0;
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
// Show list of available documents
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;', '&', $param);
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->emailcollector->read;
$delallowed=$user->rights->emailcollector->create;
$filedir = $diroutputmassaction;
$genallowed = $user->rights->emailcollector->read;
$delallowed = $user->rights->emailcollector->create;
print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}

View File

@ -203,7 +203,7 @@ dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'sending');
print load_fiche_titre($langs->trans("SendingsNumberingModules"));
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -332,7 +332,7 @@ else
dol_print_error($db);
}
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="140">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';

View File

@ -211,7 +211,7 @@ dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), -1, 'tri
print load_fiche_titre($langs->trans("ExpenseReportNumberingModules"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -334,7 +334,7 @@ else
dol_print_error($db);
}
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -466,7 +466,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setoptions">';
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60"></td>';

View File

@ -110,7 +110,7 @@ if ($action == 'edit')
echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
echo '<table class="noborder" width="100%">';
echo '<table class="noborder centpercent">';
foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab)
{

View File

@ -161,7 +161,7 @@ if ($action != 'edit')
echo '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
echo '<input type="hidden" name="action" value="save" />';
echo '<table class="noborder" width="100%">';
echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';
@ -204,7 +204,7 @@ if ($action == 'edit')
echo '<input type="hidden" name="action" value="save" />';
}
echo '<table class="noborder" width="100%">';
echo '<table class="noborder centpercent">';
echo '<tr class="liste_titre">';
echo '<th>'.$langs->trans('ExpenseReportApplyTo').'</th>';

View File

@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'exports', 'other'));
if (! $user->admin)
if (!$user->admin)
accessforbidden();
$action=GETPOST('action', 'alpha');
$value=GETPOST('value', 'alpha');
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
/*
* Actions
@ -51,18 +51,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
* View
*/
$form=new Form($db);
$form = new Form($db);
$page_name = "ExportSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback);
//$head = export_admin_prepare_head();
$h=0;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/export.php';
$head[$h][1] = $langs->trans("Setup");
@ -72,7 +72,7 @@ $h++;
dol_fiche_head($head, 'setup', $langs->trans("ExportsArea"), -1, "exports");
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print '<td class="center" width="20">&nbsp;</td>';

View File

@ -200,7 +200,7 @@ print '<br>';
print '<form name="externalrssconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("NewRSS").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
@ -254,7 +254,7 @@ if ($resql)
print "<br>";
print "<form name=\"externalrssconfig\" action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<tr class=\"liste_titre\">";

View File

@ -279,7 +279,7 @@ dol_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'invoice');
print load_fiche_titre($langs->trans("BillsNumberingModule"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -468,7 +468,7 @@ else
dol_print_error($db);
}
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
@ -607,7 +607,7 @@ if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
print '<table id="default-pdf-modules-by-type-table" class="noborder" width="100%">';
print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Name").'</td>';
@ -648,7 +648,7 @@ print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>';
@ -738,7 +738,7 @@ print "</form>";
print "<br>";
print load_fiche_titre($langs->trans("OtherOptions"), '', '');
print '<table class="noborder" width="100%">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td class="center" width="60">'.$langs->trans("Value").'</td>';

Some files were not shown because too many files have changed in this diff Show More