Merge remote-tracking branch 'upstream/develop' into 14a5

This commit is contained in:
Alexandre SPANGARO 2021-01-03 11:46:20 +01:00
commit 99949c4817
109 changed files with 1929 additions and 1634 deletions

102
build.xml
View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Script build for hudson CI -->
<project name="dolibarr" default="hudson" basedir=".">
<!-- Exclude/ignore paths -->
<property name="ignorepaths" value="${basedir}/htdocs/conf,${basedir}/htdocs/core/filemanagerdol,${basedir}/htdocs/includes" />
<property name="ignoreregexp" value="**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*" />
<target name="clean">
<!-- Clean up -->
<delete dir="${basedir}/hudson"/>
<delete dir="${basedir}/generatedJUnitFiles"/>
<!-- Create build directories -->
<mkdir dir="${basedir}/hudson/doxygen"/>
<mkdir dir="${basedir}/hudson/logs"/>
<mkdir dir="${basedir}/hudson/coverage"/>
</target>
<!-- Run phpmd, phpcpd, phpcs, doxygen and phploc in parallel -->
<target name="parallelTasks">
<parallel>
<!-- <antcall target="phpmd"/> -->
<antcall target="phpcpd"/>
<!-- <antcall target="phpcs"/> -->
<antcall target="doxygen"/>
<antcall target="phploc"/>
</parallel>
</target>
<!-- Generate pmd.xml -->
<!--
<target name="phpmd">
<exec executable="phpmd">
<arg line="htdocs xml codesize,unusedcode
-\-reportfile '${basedir}/hudson/logs/pmd.xml'
-\-ignore=${ignorepaths}
" />
</exec>
</target>
-->
<!-- Generate pmd-cpd.xml -->
<target name="phpcpd">
<exec executable="phpcpd">
<arg line=" --log-pmd '${basedir}/hudson/logs/pmd-cpd.xml'
--exclude '${basedir}/htdocs/conf'
--exclude '${basedir}/htdocs/core/filemanagerdol'
--exclude '${basedir}/htdocs/includes'
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*'
--min-tokens 70
--min-lines 20
htdocs
" />
</exec>
</target>
<!-- Generate phploc.csv -->
<target name="phploc">
<exec executable="phploc">
<arg line=" --log-csv '${basedir}/hudson/logs/phploc.csv'
--exclude '${basedir}/htdocs/conf'
--exclude '${basedir}/htdocs/core/filemanagerdol'
--exclude '${basedir}/htdocs/includes'
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*'
htdocs
" />
</exec>
</target>
<!-- Generate checkstyle.xml -->
<target name="phpcs">
<exec executable="phpcs" dir="${basedir}">
<arg line=" --standard=${basedir}/dev/codesniffer/jenkins_ruleset.xml
--report=checkstyle
--report-file=${basedir}/hudson/logs/checkstyle.xml
--ignore=${ignorepaths},${ignoreregexp}
htdocs
"/>
</exec>
</target>
<!-- Run unit tests and generate junit.xml and clover.xml -->
<target name="phpunit">
<exec executable="phpunit" dir="${basedir}" failonerror="true">
<arg line=" --configuration ${basedir}/test/phpunit/phpunittest.xml
--log-junit ${basedir}/hudson/logs/junit.xml
--coverage-clover ${basedir}/hudson/coverage/clover.xml
--coverage-html ${basedir}/hudson/coverage/
test/phpunit/AllTests.php
"/>
</exec>
</target>
<!-- Generate Doxygen documentation -->
<target name="doxygen" description="Dolibarr documentation" >
<exec executable="doxygen" dir="${basedir}" failonerror="false">
<arg value="${basedir}/build/doxygen/jenkins_doxygen.doxyfile"/>
</exec>
</target>
<target name="hudson" depends="clean,phpunit,phpcs,parallelTasks"/>
</project>

View File

@ -238,18 +238,18 @@ if ($action == 'create') {
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 '<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 '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
print '</td></tr>';
print '</table>';
print dol_get_fiche_end();
@ -300,18 +300,18 @@ if ($action == 'create') {
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
// Chart of accounts type
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
print '<td>';
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
print '</td></tr>';
// Category
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
print '<td>';
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
print '</td></tr>';
print '</table>';
print dol_get_fiche_end();

View File

@ -37,8 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
// Security access
if (empty($user->rights->accounting->chartofaccount))
{
if (empty($user->rights->accounting->chartofaccount)) {
accessforbidden();
}
@ -48,8 +47,9 @@ $action = GETPOST('action', 'aZ09');
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
'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
// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated.
// '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
);
$list_binding = array(
@ -64,10 +64,8 @@ $list_binding = array(
if ($action == 'update') {
$error = 0;
if (!$error)
{
foreach ($list as $constname)
{
if (!$error) {
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@ -78,8 +76,7 @@ if ($action == 'update') {
setEventMessages($langs->trans("Error"), null, 'errors');
}
foreach ($list_binding as $constname)
{
foreach ($list_binding as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
@ -103,8 +100,9 @@ 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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -116,8 +114,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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -128,8 +127,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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -140,8 +140,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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -152,8 +153,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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -164,8 +166,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)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -176,8 +179,9 @@ if ($action == 'setenablesubsidiarylist') {
if ($action == 'setdisablebindingonsales') {
$setdisablebindingonsales = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -188,8 +192,9 @@ if ($action == 'setdisablebindingonsales') {
if ($action == 'setdisablebindingonpurchases') {
$setdisablebindingonpurchases = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -200,8 +205,9 @@ if ($action == 'setdisablebindingonpurchases') {
if ($action == 'setdisablebindingonexpensereports') {
$setdisablebindingonexpensereports = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
if (!$res > 0)
if (!$res > 0) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -288,11 +294,12 @@ if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
print '</tr>';
// Param a user $user->rights->accounting->chartofaccount can access
foreach ($list as $key)
{
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);
@ -341,8 +348,7 @@ if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
print '</tr>';
// Param a user $user->rights->accounting->chartofaccount can access
foreach ($list_binding as $key)
{
foreach ($list_binding as $key) {
print '<tr class="oddeven value">';
// Param

View File

@ -78,7 +78,7 @@ $form = new Form($db);
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 .= " 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) {
@ -242,10 +242,12 @@ if ($action != 'export_csv')
print '</div>';
}
$colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4);
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" colspan="5">';
print '<td class="liste_titre" colspan="'.$colspan.'">';
print $langs->trans('From');
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
print ' ';
@ -261,7 +263,7 @@ if ($action != 'export_csv')
print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
@ -278,22 +280,30 @@ if ($action != 'export_csv')
$accountingaccountstatic = new AccountingAccount($db);
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
$sql .= " GROUP BY t.numero_compte";
// TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts
// without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal.
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features
$sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'";
$sql .= " GROUP BY t.numero_compte";
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = array();
for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array();
$opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
$resql = $db->query($sql);
$nrows = $resql->num_rows;
$opening_balances = array();
for ($i = 0; $i < $nrows; $i++) {
$arr = $resql->fetch_array();
$opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance'];
}
}
foreach ($object->lines as $line)
{
// reset before the fetch (in case of the fetch fails)
$accountingaccountstatic->id = 0;
$accountingaccountstatic->account_number = '';
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) {
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
@ -311,8 +321,8 @@ if ($action != 'export_csv')
$root_account_description = $tmparrayforrootaccount['label'];
$root_account_number = $tmparrayforrootaccount['account_number'];
if (empty($accountingaccountstatic->account_number)) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=update&token='.newToken().'&id='.$accountingaccountstatic->id.'">'.img_edit().'</a>';
}
if (!empty($show_subgroup))
@ -322,17 +332,22 @@ if ($action != 'export_csv')
// Show subtotal per accounting account
if ($displayed_account != "") {
print '<tr class="liste_total">';
print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
print '<td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_credit - $sous_total_debit)).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).'</td>';
} else {
print '<td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
}
print "<td></td>\n";
print '</tr>';
}
// Show first line of a break
print '<tr class="trforbreak">';
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '<td colspan="'.($colspan+1).'" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
print '</tr>';
$displayed_account = $root_account_number;
@ -344,10 +359,14 @@ if ($action != 'export_csv')
print '<tr class="oddeven">';
print '<td>'.$accounting_account.'</td>';
print '<td class="nowraponall right">'.price($opening_balance).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowraponall right">'.price($opening_balance).'</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(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
} else {
print '<td class="nowraponall right">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
}
print '<td class="center">'.$link;
print '</td>';
print "</tr>\n";
@ -360,12 +379,28 @@ if ($action != 'export_csv')
if (!empty($show_subgroup))
{
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_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).'</td>';
print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
} else {
print '<td class="nowrap right">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
}
print "<td></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_opening_balance + $total_debit - $total_credit, 'MT')).'</td>';
print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($total_opening_balance).'</td>';
print '<td class="nowrap right">'.price($total_debit).'</td>';
print '<td class="nowrap right">'.price($total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>';
} else {
print '<td class="nowrap right">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>';
}
print "<td></td>\n";
print '</tr>';

View File

@ -85,7 +85,7 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
@ -192,7 +192,7 @@ if (empty($reshook))
$search_accountancy_aux_code_end = '';
$search_mvt_label = '';
$search_direction = '';
$search_ledger_code = '';
$search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_creation_start = '';
@ -267,7 +267,9 @@ if (empty($reshook))
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
foreach ($search_ledger_code as $code) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
@ -447,6 +449,8 @@ if (count($filter) > 0) {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL';
} elseif ($key == 't.code_journal' && !empty($value)) {
$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
} else {
$sqlwhere[] = natural_search($key, $value, 0, 1);
}
@ -780,7 +784,9 @@ if (!empty($arrayfields['t.lettering_code']['checked']))
// Code journal
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">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Fields from hook

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
@ -22,7 +22,7 @@
/**
* \file htdocs/accountancy/bookkeeping/listbyaccount.php
* \ingroup Accountancy (Double entries)
* \brief List operation of book keeping ordered by account number
* \brief List operation of ledger ordered by account number
*/
require '../../main.inc.php';
@ -62,7 +62,7 @@ $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
@ -172,7 +172,7 @@ if (empty($reshook))
$search_label_operation = '';
$search_mvt_num = '';
$search_direction = '';
$search_ledger_code = '';
$search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_startyear = '';
@ -233,7 +233,9 @@ if (empty($reshook))
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
foreach ($search_ledger_code as $code) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
@ -448,7 +450,9 @@ print '<tr class="liste_titre_filter">';
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
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">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Date document
if (!empty($arrayfields['t.doc_date']['checked'])) {
@ -758,40 +762,42 @@ while ($i < min($num, $limit))
$i++;
}
// Show sub-total of last shown account
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
if ($num > 0) {
// Show sub-total of last shown account
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
@ -62,7 +62,7 @@ $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
@ -171,7 +171,7 @@ if (empty($reshook))
$search_label_operation = '';
$search_mvt_num = '';
$search_direction = '';
$search_ledger_code = '';
$search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_startyear = '';
@ -232,7 +232,9 @@ if (empty($reshook))
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
foreach ($search_ledger_code as $code) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
@ -452,7 +454,9 @@ print '<tr class="liste_titre_filter">';
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
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">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Date document
if (!empty($arrayfields['t.doc_date']['checked'])) {
@ -770,40 +774,42 @@ while ($i < min($num, $limit))
$i++;
}
// Show sub-total of last shown account
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
if ($num > 0) {
// Show sub-total of last shown account
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
$colnumber = 3;
$colnumberend = 7;
} else {
$colnumber = 4;
$colnumberend = 7;
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
$colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -25,11 +25,16 @@
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.formaccounting.class.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"));
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
@ -39,6 +44,7 @@ if ($user->socid > 0)
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$object = new BookKeeping($db);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
@ -60,14 +66,91 @@ $year_current = $year_start;
/*
* Actions
*/
if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) {
$result = $object->fetchAll();
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Specify as export : update field date_validated on selected month/year
$error = 0;
$db->begin();
$date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
if (is_array($object->lines))
{
foreach ($object->lines as $movement)
{
$now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_validated = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
$sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'";
$sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'";
dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if (!$result)
{
$error++;
break;
}
}
}
if (!$error)
{
$db->commit();
setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs');
} else {
$error++;
$db->rollback();
setEventMessages($langs->trans("NotAllMovementsCouldBeRecordedAsValidated"), null, 'errors');
}
header("Location: ".$_SERVER['PHP_SELF']."?year=".$year_start);
exit;
}
}
/*
* View
*/
$form = new Form($db);
$formaccounting = new FormAccounting($db);
llxHeader('', $langs->trans("Closure"));
if ($action == 'validate_movements') {
$form_question = array();
$month = isset($conf->global->SOCIETE_FISCAL_MONTH_START) ? intval($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$date_start = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1));
$date_end = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1));
$date_end->add(new DateInterval('P1Y'));
$date_end->sub(new DateInterval('P1D'));
$form_question['date_start'] = array(
'name' => 'date_start',
'type' => 'date',
'label' => $langs->trans('DateStart'),
'value' => $date_start->format('Y-m-d')
);
$form_question['date_end'] = array(
'name' => 'date_end',
'type' => 'date',
'label' => $langs->trans('DateEnd'),
'value' => $date_end->format('Y-m-d')
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?year='.$year_start, $langs->trans('ValidateMovements'), $langs->trans('DescValidateMovements', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'validate_movements_confirm', $form_question, '', 1, 300);
print $formconfirm;
}
$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>';
@ -80,9 +163,9 @@ print '<br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="./validate.php">'.$langs->trans("ValidateMovements").'</a>';
$buttonvalidate = '<a class="butAction" name="button_validate_movements" href="'.$_SERVER["PHP_SELF"].'?action=validate_movements&year='.$year_start.'">'.$langs->trans("ValidateMovements").'</a>';
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
@ -104,6 +187,7 @@ $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 .= " AND date_validated IS NULL";
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);

View File

@ -1,156 +0,0 @@
<?php
/* Copyright (C) 2019 Open-DSI <support@open-dsi.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/closure/validate.php
* \ingroup Accountancy
* \brief Validate entries page
*/
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';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->socid > 0)
accessforbidden();
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$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
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
$year_current = $year_start;
/*
* Actions
*/
if ($action == 'validate')
{
$now = dol_now();
// Update database
$db->begin();
$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++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
$db->commit();
}
// End clean database
}
/*
* View
*/
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>';
print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print $langs->trans("DescValidateMovements").'<br>';
print '<br>';
$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 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>';
}
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).",";
}
$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
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>';
}
print '<td class="valigntop"><b>'.$row[13].'</b></td>';
}
$db->free($resql);
} else {
print $db->lasterror(); // Show last sql error
}
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 '</div>';
// End of page
llxFooter();
$db->close();

View File

@ -1761,7 +1761,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
*/
// Shon online payment link
// Show online payment link
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
if ($useonlinepayment) {

View File

@ -2597,38 +2597,8 @@ class Adherent extends CommonObject
*/
public function setCategories($categories)
{
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, Categorie::TYPE_MEMBER);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, Categorie::TYPE_MEMBER);
}
}
return;
return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
}
/**

View File

@ -87,7 +87,7 @@ class Subscriptions extends DolibarrApi
*/
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{
global $db, $conf;
global $conf;
$obj_ret = array();
@ -183,7 +183,9 @@ class Subscriptions extends DolibarrApi
}
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
if ($field == 'id') {
continue;
}
$subscription->$field = $value;
}
@ -236,8 +238,9 @@ class Subscriptions extends DolibarrApi
{
$subscription = array();
foreach (Subscriptions::$FIELDS as $field) {
if (!isset($data[$field]))
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
$subscription[$field] = $data[$field];
}
return $subscription;

View File

@ -84,8 +84,15 @@ class Subscription extends CommonObject
* @var int ID
*/
public $fk_type;
/**
* @var int Member ID
*/
public $fk_adherent;
/**
* @var double amount subscription
*/
public $amount;
/**
@ -140,7 +147,9 @@ class Subscription extends CommonObject
$this->error = $langs->trans("ErrorBadValueForDate");
return -1;
}
if (empty($this->datec)) $this->datec = $now;
if (empty($this->datec)) {
$this->datec = $now;
}
$this->db->begin();
@ -177,7 +186,9 @@ class Subscription extends CommonObject
$this->context = array('member' => $member);
// Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
@ -278,7 +289,9 @@ class Subscription extends CommonObject
$this->context = array('member'=>$member);
// Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
if ($result < 0) {
$error++;
} //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
} else {
@ -320,7 +333,9 @@ class Subscription extends CommonObject
if (!$notrigger) {
// Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
if ($result < 0) {
$error++;
} // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
@ -407,16 +422,24 @@ class Subscription extends CommonObject
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
$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 .= $this->ref;
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 .= $this->ref;
}
$result .= $linkend;
return $result;

View File

@ -230,6 +230,7 @@ if (empty($reshook)) {
$objectlabel = 'Members';
$permissiontoread = $user->rights->adherent->lire;
$permissiontodelete = $user->rights->adherent->supprimer;
$permissiontoadd = $user->rights->adherent->creer;
$uploaddir = $conf->adherent->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -406,7 +407,8 @@ $arrayofmassactions = array(
);
if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate");
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();
if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';

View File

@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2011-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
@ -205,7 +205,7 @@ $tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FR
$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
$tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[21] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
@ -250,7 +250,7 @@ $tabsqlsort[17] = "code ASC";
$tabsqlsort[18] = "code ASC, libelle ASC";
$tabsqlsort[19] = "id ASC";
$tabsqlsort[20] = "code ASC, libelle ASC";
$tabsqlsort[21] = "code ASC, label ASC";
$tabsqlsort[21] = "code ASC, label ASC, position ASC";
$tabsqlsort[22] = "code ASC, label ASC";
$tabsqlsort[23] = "country ASC, taux ASC";
$tabsqlsort[24] = "code ASC, label ASC";
@ -295,7 +295,7 @@ $tabfield[17] = "code,label,accountancy_code";
$tabfield[18] = "code,libelle,tracking";
$tabfield[19] = "code,libelle";
$tabfield[20] = "code,libelle";
$tabfield[21] = "code,label";
$tabfield[21] = "code,label,position";
$tabfield[22] = "code,label";
$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24] = "code,label";
@ -340,7 +340,7 @@ $tabfieldvalue[17] = "code,label,accountancy_code";
$tabfieldvalue[18] = "code,libelle,tracking";
$tabfieldvalue[19] = "code,libelle";
$tabfieldvalue[20] = "code,libelle";
$tabfieldvalue[21] = "code,label";
$tabfieldvalue[21] = "code,label,position";
$tabfieldvalue[22] = "code,label";
$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24] = "code,label";
@ -385,7 +385,7 @@ $tabfieldinsert[17] = "code,label,accountancy_code";
$tabfieldinsert[18] = "code,libelle,tracking";
$tabfieldinsert[19] = "code,libelle";
$tabfieldinsert[20] = "code,libelle";
$tabfieldinsert[21] = "code,label";
$tabfieldinsert[21] = "code,label,position";
$tabfieldinsert[22] = "code,label";
$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24] = "code,label";
@ -523,7 +523,7 @@ $tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc"));
$tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'trips', 'other'));
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
@ -52,51 +54,47 @@ $type = 'expensereport';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask')
{
if ($action == 'updateMask') {
$maskconst = GETPOST('maskconst', 'alpha');
$maskvalue = GETPOST('maskvalue', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
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');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'specimen') // For fiche inter
{
} elseif ($action == 'specimen') { // For fiche expensereport
$modele = GETPOST('module', 'alpha');
$inter = new ExpenseReport($db);
$inter->initAsSpecimen();
$inter->status = 0; // Force statut draft to show watermark
$inter->fk_statut = 0; // Force statut draft to show watermark
$expensespecimen = new ExpenseReport($db);
$expensespecimen->initAsSpecimen();
$expensespecimen->status = 0; // Force statut draft to show watermark
// Search template files
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file))
{
if (file_exists($file)) {
$filefound = 1;
$classname = "pdf_".$modele;
break;
}
}
if ($filefound)
{
if ($filefound) {
require_once $file;
$module = new $classname($db);
if ($module->write_file($inter, $langs) > 0)
{
if ($module->write_file($expensespecimen, $langs) > 0) {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
return;
} else {
@ -107,30 +105,22 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Activate a model
elseif ($action == 'set')
{
} elseif ($action == 'set') {
// Activate a model
$ret = addDocumentModel($value, $type, $label, $scandir);
if ($ret > 0 && empty($conf->global->EXPENSEREPORT_ADDON_PDF))
{
if ($ret > 0 && empty($conf->global->EXPENSEREPORT_ADDON_PDF)) {
dolibarr_set_const($db, 'EXPENSEREPORT_ADDON_PDF', $value, 'chaine', 0, '', $conf->entity);
}
} elseif ($action == 'del')
{
} elseif ($action == 'del') {
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPENSEREPORT_ADDON_PDF', $conf->entity);
if ($ret > 0) {
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$value") {
dolibarr_del_const($db, 'EXPENSEREPORT_ADDON_PDF', $conf->entity);
}
}
}
// Set default model
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "EXPENSEREPORT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
} elseif ($action == 'setdoc') {
// Set default model
if (dolibarr_set_const($db, "EXPENSEREPORT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
// La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent
$conf->global->EXPENSEREPORT_ADDON_PDF = $value;
@ -138,18 +128,15 @@ elseif ($action == 'setdoc')
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($ret > 0) {
$ret = addDocumentModel($value, $type, $label, $scandir);
}
} elseif ($action == 'setmod')
{
} elseif ($action == 'setmod') {
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
dolibarr_set_const($db, "EXPENSEREPORT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setoptions')
{
} elseif ($action == 'setoptions') {
$db->begin();
$freetext = GETPOST('EXPENSEREPORT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
@ -158,10 +145,11 @@ elseif ($action == 'setdoc')
$draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!$res1 > 0 || !$res2 > 0) $error++;
if (!$res1 > 0 || !$res2 > 0) {
$error++;
}
if (!$error)
{
if (!$error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
@ -206,19 +194,14 @@ print '</tr>'."\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/expensereport/");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
$file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php';
@ -226,11 +209,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db);
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) 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())
{
if ($module->isEnabled()) {
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
@ -241,13 +227,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n";
print '<td class="center">';
if ($conf->global->EXPENSEREPORT_ADDON == $file)
{
if ($conf->global->EXPENSEREPORT_ADDON == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -266,8 +254,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$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>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
@ -289,7 +278,7 @@ foreach ($dirmodels as $reldir)
print "</table><br>\n";
/*
* Documents models for Interventions
* Documents models for ExpenseReport
*/
print load_fiche_titre($langs->trans("TemplatePDFExpenseReports"), '', '');
@ -302,12 +291,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows)
{
while ($i < $num_rows) {
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
@ -328,28 +315,21 @@ print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/expensereport/doc");
if (is_dir($dir))
{
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file)
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
if (file_exists($dir.'/'.$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);
@ -357,21 +337,26 @@ foreach ($dirmodels as $reldir)
$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;
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)
{
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs);
else print $module->description;
if (method_exists($module, 'info')) {
print $module->info($langs);
} else {
print $module->description;
}
print '</td>';
// Active
if (in_array($name, $def))
{
if (in_array($name, $def)) {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
@ -385,8 +370,7 @@ foreach ($dirmodels as $reldir)
// Default
print '<td class="center">';
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$name")
{
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$name") {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -409,8 +393,7 @@ foreach ($dirmodels as $reldir)
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
if ($module->type == 'pdf') {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -451,14 +434,15 @@ print "</tr>\n";
$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>';
foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'EXPENSEREPORT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
{
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -20,7 +20,7 @@
/**
* \file htdocs/admin/expensereport_ik.php
* \file htdocs/admin/expensereport_rules.php
* \ingroup expensereport
* \brief Page to display expense tax ik
*/
@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.ph
// Load translation files required by the page
$langs->loadLangs(array("admin", "other", "trips", "errors", "dict"));
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
//Init error
$error = false;
@ -55,15 +57,15 @@ $amount = GETPOST('amount');
$restrictive = GETPOST('restrictive');
$object = new ExpenseReportRule($db);
if (!empty($id))
{
if (!empty($id)) {
$result = $object->fetch($id);
if ($result < 0) dol_print_error('', $object->error, $object->errors);
if ($result < 0) {
dol_print_error('', $object->error, $object->errors);
}
}
// TODO do action
if ($action == 'save')
{
if ($action == 'save') {
$error = 0;
// check parameters
@ -92,8 +94,7 @@ if ($action == 'save')
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitAmount")), null, 'errors');
}
if (empty($error))
{
if (empty($error)) {
$object->setValues($_POST);
if ($apply_to == 'U') {
@ -116,18 +117,22 @@ if ($action == 'save')
$object->entity = $conf->entity;
$res = $object->create($user);
if ($res > 0) setEventMessages($langs->trans('ExpenseReportRuleSave'), null);
else dol_print_error($object->db);
if ($res > 0) {
setEventMessages($langs->trans('ExpenseReportRuleSave'), null);
} else {
dol_print_error($object->db);
}
header('Location: '.$_SERVER['PHP_SELF']);
exit;
}
} elseif ($action == 'delete')
{
} elseif ($action == 'delete') {
// TODO add confirm
$res = $object->delete($user);
if ($res < 0) dol_print_error($object->db);
if ($res < 0) {
dol_print_error($object->db);
}
header('Location: '.$_SERVER['PHP_SELF']);
exit;
@ -135,8 +140,17 @@ if ($action == 'save')
$rules = ExpenseReportRule::getAllRule();
$tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User'));
$tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense'));
$tab_apply = array(
'A' => $langs->trans('All'),
'G' => $langs->trans('Group'),
'U' => $langs->trans('User')
);
$tab_rules_type = array(
'EX_DAY' => $langs->trans('Day'),
'EX_MON' => $langs->trans('Month'),
'EX_YEA' => $langs->trans('Year'),
'EX_EXP' => $langs->trans('OnExpense')
);
/*
@ -156,8 +170,7 @@ print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRul
echo '<span class="opacitymedium">'.$langs->trans('ExpenseReportRulesDesc').'</span>';
print '<br><br>';
if ($action != 'edit')
{
if ($action != 'edit') {
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<input type="hidden" name="token" value="'.newToken().'" />';
echo '<input type="hidden" name="action" value="save" />';
@ -199,8 +212,7 @@ if ($action != 'edit')
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<input type="hidden" name="token" value="'.newToken().'" />';
if ($action == 'edit')
{
if ($action == 'edit') {
echo '<input type="hidden" name="id" value="'.$object->id.'" />';
echo '<input type="hidden" name="action" value="save" />';
}
@ -218,43 +230,47 @@ echo '<th>'.$langs->trans('ExpenseReportRestrictive').'</th>';
echo '<th>&nbsp;</th>';
echo '</tr>';
foreach ($rules as $rule)
{
foreach ($rules as $rule) {
echo '<tr class="oddeven">';
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
$selected = ($object->is_for_all > 0) ? 'A' : ($object->fk_usergroup > 0 ? 'G' : 'U');
echo '<div class="float">'.$form->selectarray('apply_to', $tab_apply, $selected, 0).'</div>';
echo '<div id="user" class="float">'.$form->select_dolusers($object->fk_user, 'fk_user').'</div>';
echo '<div id="group" class="float">'.$form->select_dolgroups($object->fk_usergroup, 'fk_usergroup').'</div>';
} else {
if ($rule->is_for_all > 0) echo $tab_apply['A'];
elseif ($rule->fk_usergroup > 0) echo $tab_apply['G'].' ('.$rule->getGroupLabel().')';
elseif ($rule->fk_user > 0) echo $tab_apply['U'].' ('.$rule->getUserName().')';
}
echo '</td>';
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1);
} else {
if ($rule->fk_c_type_fees == -1) echo $langs->trans('AllExpenseReport');
else {
$key = getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
if ($key != $langs->trans($key)) echo $langs->trans($key);
else echo $langs->trans(getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id')); // TODO check to return trans of 'code'
if ($rule->is_for_all > 0) {
echo $tab_apply['A'];
} elseif ($rule->fk_usergroup > 0) {
echo $tab_apply['G'].' ('.$rule->getGroupLabel().')';
} elseif ($rule->fk_user > 0) {
echo $tab_apply['U'].' ('.$rule->getUserName().')';
}
}
echo '</td>';
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1);
} else {
if ($rule->fk_c_type_fees == -1) {
echo $langs->trans('AllExpenseReport');
} else {
$key = getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id');
if ($key != $langs->trans($key)) {
echo $langs->trans($key);
} else {
echo $langs->trans(getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id')); // TODO check to return trans of 'code'
}
}
}
echo '</td>';
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectarray('code_expense_rules_type', $tab_rules_type, $object->code_expense_rules_type, 0);
} else {
echo $tab_rules_type[$rule->code_expense_rules_type];
@ -263,8 +279,7 @@ foreach ($rules as $rule)
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0);
} else {
echo dol_print_date($rule->dates, 'day');
@ -273,8 +288,7 @@ foreach ($rules as $rule)
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0);
} else {
echo dol_print_date($rule->datee, 'day');
@ -283,8 +297,7 @@ foreach ($rules as $rule)
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
echo '<input type="text" value="'.price2num($object->amount).'" name="amount" class="amount" />'.$conf->currency;
} else {
echo price($rule->amount, 0, $langs, 1, -1, -1, $conf->currency);
@ -293,8 +306,7 @@ foreach ($rules as $rule)
echo '<td>';
if ($action == 'edit' && $object->id == $rule->id)
{
if ($action == 'edit' && $object->id == $rule->id) {
echo $form->selectyesno('restrictive', $object->restrictive, 1);
} else {
echo yn($rule->restrictive, 1, 1);
@ -303,8 +315,7 @@ foreach ($rules as $rule)
echo '<td class="center">';
if ($object->id != $rule->id)
{
if ($object->id != $rule->id) {
echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$rule->id.'">'.img_edit().'</a>&nbsp;';
echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$rule->id.'">'.img_delete().'</a>';
} else {

View File

@ -299,7 +299,7 @@ if (empty($mysoc->country_code))
print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
$s = 10 / 3; $qty = 2; $vat = 10;
$tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);

View File

@ -1137,7 +1137,7 @@ if ($mode == 'deploy') {
print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall"> ';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Upload")).'" class="button">';
if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($user->admin) {

View File

@ -71,10 +71,10 @@ if ($action == "set")
if (! $res > 0) $error++;
*/
} else $error++;
/* Moved to account
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ICS", GETPOST("PAYMENTBYBANKTRANSFER_ICS"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
*/
if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0)
{
$res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity);
@ -156,11 +156,13 @@ print '<td class="left">';
$form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1);
print '</td></tr>';
/* Moved to bank account data
// ICS
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ICS").'</td>';
print '<td class="left">';
print '<input type="text" name="PAYMENTBYBANKTRANSFER_ICS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.'" size="15" ></td>';
print '</td></tr>';
*/
//User
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';

View File

@ -74,21 +74,23 @@ if ($action == "set")
*/
} else $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++;
/* Moved to account
if (GETPOST("PRELEVEMENT_USER") > 0) {
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++;
}
if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++;
}
if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++;
}
$res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
*/
if (GETPOST("PRELEVEMENT_USER") > 0) {
$res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
}
if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
}
if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD") == "") {
$res = dolibarr_set_const($db, "PRELEVEMENT_USTRD", GETPOST("PRELEVEMENT_USTRD"), 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++;
}
$res = dolibarr_set_const($db, "PRELEVEMENT_ADDDAYS", GETPOST("PRELEVEMENT_ADDDAYS"), 'chaine', 0, '', $conf->entity);
if (! ($res > 0)) $error++;
@ -146,13 +148,16 @@ print '<td class="titlefieldcreate">'.$langs->trans("Parameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>";
// Bank account (from Banks module)
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("BankToReceiveWithdraw").'</td>';
print '<td class="left">';
$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1);
print '</td></tr>';
/* Moved to bank account data
// ICS
print '<tr class="oddeven"><td class="fieldrequired">';
$htmltext = $langs->trans("AskThisIDToYourBank");
print $form->textwithpicto($langs->trans("ICS"), $htmltext);
@ -161,6 +166,7 @@ print '<td class="left">';
print '<input type="text" name="PRELEVEMENT_ICS" value="'.$conf->global->PRELEVEMENT_ICS.'" size="15" >';
print '</td>';
print '</td></tr>';
*/
//User
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';

View File

@ -224,7 +224,7 @@ if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
print '<tr class="oddeven"><td>&nbsp; => price(1234.56)</td><td>'.price(1234.56).'</td></tr>'."\n";
// Timezone
$txt = $langs->trans("OSTZ").' (variable system TZ): '.(!empty($_ENV["TZ"]) ? $_ENV["TZ"] : $langs->trans("NotDefined")).'<br>'."\n";
$txt .= $langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone") ?ini_get("date.timezone") : $langs->trans("NotDefined")).''."<br>\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
$txt .= $langs->trans("PHPTZ").' (date_default_timezone_get() / php.ini date.timezone): '.(getServerTimeZoneString()." / ".(ini_get("date.timezone") ? ini_get("date.timezone") : $langs->trans("NotDefined")))."<br>\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
$txt .= $langs->trans("Dolibarr constant MAIN_SERVER_TZ").': '.(empty($conf->global->MAIN_SERVER_TZ) ? $langs->trans("NotDefined") : $conf->global->MAIN_SERVER_TZ);
print '<tr class="oddeven"><td>'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
$a = getServerTimeZoneInt('now');

View File

@ -92,7 +92,15 @@ $date_endday = $tmp['mday'];
$date_endmonth = $tmp['mon'];
$date_endyear = $tmp['year'];
$arrayfields = array();
// Add prefix session
$arrayfields = array(
'e.prefix_session' => array(
'label'=>'UserAgent',
'checked'=>(empty($conf->global->AUDIT_ENABLE_PREFIX_SESSION) ? 0 : 1),
'enabled'=>(empty($conf->global->AUDIT_ENABLE_PREFIX_SESSION) ? 0 : 1),
'position'=>110
)
);
/*
@ -211,7 +219,7 @@ if ($result)
if ($search_user) $param .= '&search_user='.urlencode($search_user);
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc);
if ($search_ua) $param .= '&search_ua='.urlencode($search_ua);
if ($search_prefix_sessiona) $param .= '&search_prefix_session='.urlencode($search_prefix_session);
if ($search_prefix_session) $param .= '&search_prefix_session='.urlencode($search_prefix_session);
if ($date_startmonth) $param .= "&date_startmonth=".urlencode($date_startmonth);
if ($date_startday) $param .= "&date_startday=".urlencode($date_startday);
if ($date_startyear) $param .= "&date_startyear=".urlencode($date_startyear);

View File

@ -233,6 +233,7 @@ if (empty($reshook))
$uploaddir = true;
// Only users that can delete any event can remove records.
$permissiontodelete = $user->rights->agenda->allactions->delete;
$permissiontoadd = $user->rights->agenda->myactions->create;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -296,7 +297,8 @@ if ($user->rights->agenda->allactions->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();
if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$sql = "SELECT";
@ -532,6 +534,7 @@ if ($resql)
print $s;
$objecttmp = new ActionComm($db);
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$moreforfilter = '';

View File

@ -600,6 +600,7 @@ class Propal extends CommonObject
// Clean vat code
$reg = array();
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
@ -771,7 +772,9 @@ class Propal extends CommonObject
$qty = price2num($qty);
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);

View File

@ -631,9 +631,9 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{

View File

@ -3060,7 +3060,9 @@ class Commande extends CommonOrder
$pu = price2num($pu);
$pa_ht = price2num($pa_ht);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -95,6 +95,9 @@ if ($action == 'add')
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
$object->ics = trim(GETPOST("ics", 'alpha'));
$object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
$account_number = GETPOST('account_number', 'alphanohtml');
if (empty($account_number) || $account_number == '-1')
{
@ -196,6 +199,9 @@ if ($action == 'update')
$object->proprio = trim(GETPOST("proprio", 'alphanohtml'));
$object->owner_address = trim(GETPOST("owner_address", 'nohtml'));
$object->ics = trim(GETPOST("ics", 'alpha'));
$object->ics_transfer = trim(GETPOST("ics_transfer", 'alpha'));
$account_number = GETPOST('account_number', 'alpha');
if (empty($account_number) || $account_number == '-1')
{
@ -730,6 +736,18 @@ if ($action == 'create')
}
print '</td></tr>';
if ($conf->prelevement->enabled){
print '<tr><td>'.$langs->trans("ICS").'</td>';
print '<td>'.$object->ics.'</td>';
print '</tr>';
}
if ($conf->paymentbybanktransfer->enabled){
print '<tr><td>'.$langs->trans("ICSTransfer").'</td>';
print '<td>'.$object->ics_transfer.'</td>';
print '</tr>';
}
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
print nl2br($object->domiciliation);
print "</td></tr>\n";
@ -1010,6 +1028,16 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans($bickey).'</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="11" type="text" class="flat" name="bic" value="'.$object->bic.'"></td></tr>';
if ($conf->prelevement->enabled){
print '<tr><td>'.$langs->trans("ICS").'</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.$object->ics.'"></td></tr>';
}
if ($conf->paymentbybanktransfer->enabled){
print '<tr><td>'.$langs->trans("ICSTransfer").'</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics_transfer" value="'.$object->ics_transfer.'"></td></tr>';
}
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
print '<textarea class="flat quatrevingtpercent" name="domiciliation" rows="'.ROWS_2.'">';
print $object->domiciliation;

View File

@ -8,6 +8,7 @@
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -214,6 +215,19 @@ class Account extends CommonObject
*/
public $date_solde;
/**
* Creditor Identifier CI. Some banks use different ICS for direct debit and bank tranfer
* @var string
*/
public $ics;
/**
* Creditor Identifier for Bank Transfer.
* @var string
*/
public $ics_transfer;
/**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@ -598,8 +612,6 @@ class Account extends CommonObject
// Clean parameters
if (!$this->min_allowed) $this->min_allowed = 0;
if (!$this->min_desired) $this->min_desired = 0;
$this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
$this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
// Check parameters
if (empty($this->country_id))
@ -652,6 +664,8 @@ class Account extends CommonObject
$sql .= ", comment";
$sql .= ", state_id";
$sql .= ", fk_pays";
$sql .= ", ics";
$sql .= ", ics_transfer";
$sql .= ") VALUES (";
$sql .= "'".$this->db->idate($now)."'";
$sql .= ", '".$this->db->escape($this->ref)."'";
@ -670,12 +684,14 @@ class Account extends CommonObject
$sql .= ", '".$this->db->escape($this->proprio)."'";
$sql .= ", '".$this->db->escape($this->owner_address)."'";
$sql .= ", '".$this->db->escape($this->currency_code)."'";
$sql .= ", ".$this->rappro;
$sql .= ", ".((int) $this->rappro);
$sql .= ", ".price2num($this->min_allowed);
$sql .= ", ".price2num($this->min_desired);
$sql .= ", '".$this->db->escape($this->comment)."'";
$sql .= ", ".($this->state_id > 0 ? $this->state_id : "null");
$sql .= ", ".$this->country_id;
$sql .= ", ".($this->country_id > 0 ? $this->country_id : "null");
$sql .= ", '".$this->db->escape($this->ics)."'";
$sql .= ", '".$this->db->escape($this->ics_transfer)."'";
$sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -755,10 +771,6 @@ class Account extends CommonObject
$this->db->begin();
// Clean parameters
$this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
$this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
// Check parameters
if (empty($this->country_id))
{
@ -803,7 +815,9 @@ class Account extends CommonObject
$sql .= ",comment = '".$this->db->escape($this->comment)."'";
$sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null");
$sql .= ",fk_pays = ".$this->country_id;
$sql .= ",fk_pays = ".($this->country_id > 0 ? $this->country_id : "null");
$sql .= ",ics = '".$this->db->escape($this->ics)."'";
$sql .= ",ics_transfer = '".$this->db->escape($this->ics_transfer)."'";
$sql .= " WHERE rowid = ".$this->id;
@ -854,11 +868,7 @@ class Account extends CommonObject
// phpcs:enable
global $conf, $langs;
// Clean parameters
$this->state_id = ($this->state_id ? $this->state_id : $this->state_id);
$this->country_id = ($this->country_id ? $this->country_id : $this->country_id);
// Chargement librairie pour acces fonction controle RIB
// Load library to get BAN control function
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
@ -882,7 +892,7 @@ class Account extends CommonObject
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null");
$sql .= ",fk_pays = ".$this->country_id;
$sql .= ",fk_pays = ".($this->country_id > 0 ? $this->country_id : "null");
$sql .= " WHERE rowid = ".$this->id;
$sql .= " AND entity = ".$conf->entity;
@ -922,7 +932,7 @@ class Account extends CommonObject
$sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
$sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,";
$sql .= " ba.min_allowed, ba.min_desired, ba.comment,";
$sql .= " ba.datec as date_creation, ba.tms as date_update,";
$sql .= " ba.datec as date_creation, ba.tms as date_update, ba.ics, ba.ics_transfer,";
$sql .= ' c.code as country_code, c.label as country,';
$sql .= ' d.code_departement as state_code, d.nom as state';
$sql .= ' , aj.code as accountancy_journal';
@ -984,6 +994,9 @@ class Account extends CommonObject
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_update = $this->db->jdate($obj->date_update);
$this->ics = $obj->ics;
$this->ics_transfer = $obj->ics_transfer;
// Retrieve all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
@ -1011,38 +1024,8 @@ class Account extends CommonObject
*/
public function setCategories($categories)
{
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, Categorie::TYPE_ACCOUNT);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, Categorie::TYPE_ACCOUNT);
}
}
return;
return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT);
}
/**

View File

@ -200,7 +200,7 @@ class PaymentVarious extends CommonObject
$sql .= " datev='".$this->db->idate($this->datev)."',";
$sql .= " sens=".(int) $this->sens.",";
$sql .= " amount=".price2num($this->amount).",";
$sql .= " fk_typepayment=".(int) $this->fk_typepayment.",";
$sql .= " fk_typepayment=".(int) $this->type_payment.",";
$sql .= " num_payment='".$this->db->escape($this->num_payment)."',";
$sql .= " label='".$this->db->escape($this->label)."',";
$sql .= " note='".$this->db->escape($this->note)."',";

View File

@ -123,18 +123,26 @@ $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';
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
{
$search_ref = '';
$search_label = '';
$search_number = '';
$search_status = '';
// 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_ref = '';
$search_label = '';
$search_number = '';
$search_status = '';
}
// Mass actions
$objectclass = 'Account';
$objectlabel = 'FinancialAccount';
$permissiontoadd = $user->rights->banque->modifier;
$uploaddir = $conf->banque->dir_output;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
}
/*
* View
*/
@ -235,7 +243,8 @@ $arrayofmassactions = array(
// 'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->banque->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->banque->modifier) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer);
@ -251,7 +260,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="search_status" value="'.$search_status.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1);
$topicmail = "Information";
//$modelmail="subscription";

View File

@ -408,7 +408,7 @@ if ($action == 'create')
// Subledger account
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("SubledgerAccount").'aaaa</td>';
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
print '<td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');

View File

@ -437,9 +437,9 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -450,7 +450,7 @@ if (empty($reshook))
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
// Extrafields

View File

@ -4738,7 +4738,15 @@ if ($action == 'create')
print '<tr class="oddeven"><td>';
print $paymentstatic->getNomUrl(1);
print '</td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'dayhour').'</td>';
print '<td>';
$dateofpayment = $db->jdate($objp->dp);
$tmparray = dol_getdate($dateofpayment);
if ($tmparray['seconds'] == 0 && $tmparray['minutes'] == 0 && ($tmparray['hours'] == 0 || $tmparray['hours'] == 12)) { // We set hours to 0:00 or 12:00 because we don't know it
print dol_print_date($dateofpayment, 'day');
} else { // Hours was set to real date of payment (special case for POS for example)
print dol_print_date($dateofpayment, 'dayhour', 'tzuser');
}
print '</td>';
$label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label;
print '<td>'.$label.' '.$objp->num_payment.'</td>';
if (!empty($conf->banque->enabled))

View File

@ -853,7 +853,9 @@ class FactureRec extends CommonInvoice
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txtva)) $txtva = 0;
@ -1031,7 +1033,9 @@ class FactureRec extends CommonInvoice
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txlocaltax1)) $txlocaltax1 = 0;
@ -1057,6 +1061,7 @@ class FactureRec extends CommonInvoice
// Clean vat code
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];

View File

@ -3283,7 +3283,9 @@ class Facture extends CommonInvoice
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$pa_ht = price2num($pa_ht);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -294,7 +294,7 @@ class Paiement extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")";
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((float) $this->pos_change).")";
$resql = $this->db->query($sql);
if ($resql)
@ -1171,9 +1171,19 @@ class Paiement extends CommonObject
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Payment").'</u><br>';
$label .= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref;
if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
$dateofpayment = ($this->datepaye ? $this->datepaye : $this->date);
if ($dateofpayment) {
$label .= '<br><strong>'.$langs->trans("Date").':</strong> ';
$tmparray = dol_getdate($dateofpayment);
if ($tmparray['seconds'] == 0 && $tmparray['minutes'] == 0 && ($tmparray['hours'] == 0 || $tmparray['hours'] == 12)) { // We set hours to 0:00 or 12:00 because we don't know it
$label .= dol_print_date($dateofpayment, 'day');
} else { // Hours was set to real date of payment (special case for POS for example)
$label .= dol_print_date($dateofpayment, 'dayhour', 'tzuser');
}
}
if ($mode == 'withlistofinvoices')
{
$arraybill = $this->getBillsArray();

View File

@ -55,7 +55,7 @@ $result = restrictedArea($user, 'paymentbybanktransfer', '', '');
llxHeader('', $langs->trans("SuppliersStandingOrdersArea"));
if (prelevement_check_config() < 0)
if (prelevement_check_config('bank-transfer') < 0)
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');

View File

@ -5,6 +5,7 @@
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019 JC Prieto <jcprieto@virtual20.com><prietojc@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1158,7 +1159,7 @@ class BonPrelevement extends CommonObject
$this->emetteur_iban = $account->iban;
$this->emetteur_bic = $account->bic;
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
$this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics);
$this->raison_sociale = $account->proprio;
}
@ -1589,7 +1590,7 @@ class BonPrelevement extends CommonObject
fputs($this->file, ' <Id>'.$CrLf);
fputs($this->file, ' <PrvtId>'.$CrLf);
fputs($this->file, ' <Othr>'.$CrLf);
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
fputs($this->file, ' <Id>'.$this->emetteur_ics.'</Id>'.$CrLf);
fputs($this->file, ' </Othr>'.$CrLf);
fputs($this->file, ' </PrvtId>'.$CrLf);
fputs($this->file, ' </Id>'.$CrLf);
@ -2130,7 +2131,7 @@ class BonPrelevement extends CommonObject
$this->emetteur_iban = $account->iban;
$this->emetteur_bic = $account->bic;
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
$this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
$this->raison_sociale = $account->proprio;
}

View File

@ -49,6 +49,7 @@ $type = GETPOST('type', 'aZ09');
$action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
$format = GETPOST('format', 'aZ09');
$id_bankaccount = GETPOST('id_bankaccount', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
@ -77,11 +78,27 @@ if (empty($reshook))
}
if ($action == 'create')
{
$default_account=($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
if ($id_bankaccount != $conf->global->{$default_account}){
$res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$bank = new Account($db);
$bank->fetch($conf->global->{$default_account});
if (empty($bank->ics) || empty($bank->ics_transfer)){
setEventMessages($langs->trans("ErrorICSmissing", $bank->getNomUrl(1)), null, 'errors');
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php');
exit;
}
$delayindays = 0;
if ($type != 'bank-transfer') {
$conf->global->PRELEVEMENT_ADDDAYS;
$delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
} else {
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
$delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
}
$bprev = new BonPrelevement($db);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
@ -128,12 +145,13 @@ $bprev = new BonPrelevement($db);
llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config() < 0)
if (prelevement_check_config($type) < 0)
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
}
/*$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php';
$head[$h][1] = $langs->trans("NewStandingOrder");
@ -188,10 +206,15 @@ print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="type" value="'.$type.'">';
if ($nb) {
if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' ';
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print $form->selectDate($datere, 're');
if ($pricetowithdraw) {
print $langs->trans('BankToReceiveWithdraw').': ';
$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1");
print ' - ';
print $langs->trans('ExecutionDate').' ';
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print $form->selectDate($datere, 're');
if ($mysoc->isInEEC()) {
$title = $langs->trans("CreateForSepa");

View File

@ -1579,38 +1579,8 @@ class Contact extends CommonObject
*/
public function setCategories($categories)
{
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_CONTACT, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, Categorie::TYPE_CONTACT);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, Categorie::TYPE_CONTACT);
}
}
return;
return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT);
}
/**

View File

@ -267,7 +267,7 @@ if (empty($reshook))
$search_categ_thirdparty = '';
$search_categ_supplier = '';
$search_import_key = '';
$toselect = '';
$toselect = array();
$search_array_options = array();
$search_roles = array();
}
@ -277,6 +277,7 @@ if (empty($reshook))
$objectlabel = 'Contact';
$permissiontoread = $user->rights->societe->lire;
$permissiontodelete = $user->rights->societe->supprimer;
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@ -525,7 +526,8 @@ $arrayofmassactions = array(
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer);

View File

@ -89,6 +89,7 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem
$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
$error = 0;
/*
@ -383,9 +384,9 @@ if (empty($reshook))
{
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = price2num(GETPOST('price_ht'));
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'));
if (GETPOST('prod_entry_mode', 'alpha') == 'free')
{
$idprod = 0;
@ -395,7 +396,7 @@ if (empty($reshook))
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef));
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0);
if ($qty == '')

View File

@ -1465,7 +1465,6 @@ class Contrat extends CommonObject
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -1291,6 +1291,64 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread)
}
}
if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) {
$db->begin();
$affecttag_type=GETPOST('affecttag_type', 'alpha');
if (!empty($affecttag_type)) {
$affecttag_type_array=explode(',', $affecttag_type);
} else {
setEventMessage('CategTypeNotFound', 'errors');
}
if (!empty($affecttag_type_array)) {
//check if tag type submited exists into Tag Map categorie class
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categ = new Categorie($db);
$to_affecttag_type_array=array();
$categ_type_array=$categ->getMapList();
foreach ($categ_type_array as $categdef) {
if (in_array($categdef['code'], $affecttag_type_array)) {
$to_affecttag_type_array[] = $categdef['code'];
}
}
//For each valid categ type set common categ
$nbok = 0;
if (!empty($to_affecttag_type_array)) {
foreach ($to_affecttag_type_array as $categ_type) {
$contcats = GETPOST('contcats_' . $categ_type, 'array');
//var_dump($toselect);exit;
foreach ($toselect as $toselectid) {
$result = $object->fetch($toselectid);
//var_dump($contcats);exit;
if ($result > 0) {
$result = $object->setCategoriesCommon($contcats, $categ_type, false);
if ($result > 0) {
$nbok++;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
}
}
}
}
if (!$error)
{
if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null);
else setEventMessages($langs->trans("RecordsModified", $nbok), null);
$db->commit();
$toselect=array();
} else {
$db->rollback();
}
}
$parameters['toselect'] = $toselect;
$parameters['uploaddir'] = $uploaddir;
$parameters['massaction'] = $massaction;

View File

@ -33,8 +33,7 @@
/*
* Add file in email form
*/
if (GETPOST('addfile', 'alpha'))
{
if (GETPOST('addfile', 'alpha')) {
$trackid = GETPOST('trackid', 'aZ09');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -50,8 +49,7 @@ if (GETPOST('addfile', 'alpha'))
/*
* Remove file in email form
*/
if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
{
if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) {
$trackid = GETPOST('trackid', 'aZ09');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -69,24 +67,28 @@ if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
/*
* Remove all files in email form
*/
if (GETPOST('removAll', 'alpha'))
{
if (GETPOST('removAll', 'alpha')) {
$trackid = GETPOST('trackid', 'aZ09');
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid = $trackid;
foreach ($listofpaths as $key => $value)
{
foreach ($listofpaths as $key => $value) {
$pathtodelete = $value;
$filetodelete = $listofnames[$key];
$result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
@ -101,50 +103,56 @@ if (GETPOST('removAll', 'alpha'))
/*
* Send mail
*/
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
{
if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) {
if (empty($trackid)) {
$trackid = GETPOST('trackid', 'aZ09');
}
$subject = ''; $actionmsg = ''; $actionmsg2 = '';
$langs->load('mails');
if (is_object($object))
{
if (is_object($object)) {
$result = $object->fetch($id);
$sendtosocid = 0; // Id of related thirdparty
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact')))
{
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) {
$resultthirdparty = $object->fetch_thirdparty();
$thirdparty = $object->thirdparty;
if (is_object($thirdparty)) $sendtosocid = $thirdparty->id;
} elseif ($object->element == 'member' || $object->element == 'user')
{
if (is_object($thirdparty)) {
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'member' || $object->element == 'user') {
$thirdparty = $object;
if ($object->socid > 0) $sendtosocid = $object->socid;
} elseif ($object->element == 'expensereport')
{
if ($object->socid > 0) {
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'expensereport') {
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$thirdparty = $tmpuser;
if ($object->socid > 0) $sendtosocid = $object->socid;
} elseif ($object->element == 'societe')
{
if ($object->socid > 0) {
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'societe') {
$thirdparty = $object;
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
} elseif ($object->element == 'contact')
{
if (is_object($thirdparty) && $thirdparty->id > 0) {
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'contact') {
$contact = $object;
if ($contact->id > 0) {
$contact->fetch_thirdparty();
$thirdparty = $contact->thirdparty;
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
if (is_object($thirdparty) && $thirdparty->id > 0) {
$sendtosocid = $thirdparty->id;
}
}
} else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
} else {
dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
}
if (is_object($hookmanager))
{
if (is_object($hookmanager)) {
$parameters = array();
$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
}
@ -152,8 +160,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$thirdparty = $mysoc;
}
if ($result > 0)
{
if ($result > 0) {
$sendto = '';
$sendtocc = '';
$sendtobcc = '';
@ -163,48 +170,40 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
// Define $sendto
$receiver = $_POST['receiver'];
if (!is_array($receiver))
{
if ($receiver == '-1') $receiver = array();
else $receiver = array($receiver);
if (!is_array($receiver)) {
if ($receiver == '-1') {
$receiver = array();
} else {
$receiver = array($receiver);
}
}
$tmparray = array();
if (trim($_POST['sendto']))
{
if (trim($_POST['sendto'])) {
// Recipients are provided into free text
$tmparray[] = trim($_POST['sendto']);
}
if (count($receiver) > 0)
{
if (count($receiver) > 0) {
// Recipient was provided from combo list
foreach ($receiver as $key=>$val)
{
if ($val == 'thirdparty') // Key selected means current third party ('thirdparty' may be used for current member or current user too)
{
foreach ($receiver as $key => $val) {
if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too)
$tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
}
elseif ($val == 'contact') // Key selected means current contact
{
} elseif ($val == 'contact') { // Key selected means current contact
$tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
$sendtoid[] = $contact->id;
} elseif ($val) // $val is the Id of a contact
{
} elseif ($val) { // $val is the Id of a contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
$sendtoid[] = ((int) $val);
}
}
}
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiveruser = $_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser) > 0)
{
if (is_array($receiveruser) && count($receiveruser) > 0) {
$fuserdest = new User($db);
foreach ($receiveruser as $key=>$val)
{
foreach ($receiveruser as $key => $val) {
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtouserid[] = $val;
}
@ -215,32 +214,27 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
// Define $sendtocc
$receivercc = $_POST['receivercc'];
if (!is_array($receivercc))
{
if ($receivercc == '-1') $receivercc = array();
else $receivercc = array($receivercc);
if (!is_array($receivercc)) {
if ($receivercc == '-1') {
$receivercc = array();
} else {
$receivercc = array($receivercc);
}
}
$tmparray = array();
if (trim($_POST['sendtocc']))
{
if (trim($_POST['sendtocc'])) {
$tmparray[] = trim($_POST['sendtocc']);
}
if (count($receivercc) > 0)
{
foreach ($receivercc as $key=>$val)
{
// Recipient was provided from combo list
if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
{
if (count($receivercc) > 0) {
foreach ($receivercc as $key => $val) {
if ($val == 'thirdparty') { // Key selected means currentthird party (may be usd for current member or current user too)
// Recipient was provided from combo list
$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
}
// Recipient was provided from combo list
elseif ($val == 'contact') // Key selected means current contact
{
} elseif ($val == 'contact') { // Key selected means current contact
// Recipient was provided from combo list
$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
//$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
} elseif ($val) // $val is the Id of a contact
{
} elseif ($val) { // $val is the Id of a contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
//$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
}
@ -249,11 +243,9 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiverccuser = $_POST['receiverccuser'];
if (is_array($receiverccuser) && count($receiverccuser) > 0)
{
if (is_array($receiverccuser) && count($receiverccuser) > 0) {
$fuserdest = new User($db);
foreach ($receiverccuser as $key=>$val)
{
foreach ($receiverccuser as $key => $val) {
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtoccuserid[] = $val;
}
@ -261,8 +253,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
}
$sendtocc = implode(',', $tmparray);
if (dol_strlen($sendto))
{
if (dol_strlen($sendto)) {
// 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
@ -291,8 +282,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$sql .= ' WHERE rowid = '.(int) $reg[1];
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
}
} else {
@ -312,21 +302,20 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$sendtobcc = GETPOST('sendtoccc');
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (!empty($autocopy))
{
if (!empty($autocopy)) {
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
}
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($action == 'send' || $action == 'relance')
{
if ($action == 'send' || $action == 'relance') {
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
if ($message)
{
if ($message) {
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
if ($sendtocc) {
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
}
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
$actionmsg = dol_concatdesc($actionmsg, $message);
@ -343,50 +332,6 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
// Feature to push mail sent into Sent folder
/* This code must be now included into the hook mail, method sendMailAfter
if (! empty($conf->dolimail->enabled))
{
$mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
else
{
$mbid = $mailfromid[1];
// IMAP Postbox
$mailboxconfig = new IMAP($db);
$mailboxconfig->fetch($mbid);
if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
$mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
$mailboxconfig->userfolder_fetch();
if ($mailboxconfig->mailbox_save_sent_mails == 1)
{
$folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
if (!$folder) $folder = "Sent"; // Default Sent folder
$mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
if (false === $mailboxconfig->mbox)
{
$info = false;
$err = $langs->trans('Error3_Imap_Connection_Error');
setEventMessages($err,$mailboxconfig->element, null, 'errors');
}
else
{
$mailboxconfig->mailboxid=$_POST['frommail'];
$mailboxconfig->foldername=$folder;
$from = $mailfromid[0] . $mailfromid[2];
$imap=1;
}
}
}
}
*/
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
@ -398,38 +343,38 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
if (method_exists($object, 'makeSubstitution'))
{
if (method_exists($object, 'makeSubstitution')) {
$subject = $object->makeSubstitution($subject);
$message = $object->makeSubstitution($message);
}
// Send mail (substitutionarray must be done just before this)
if (empty($sendcontext)) $sendcontext = 'standard';
if (empty($sendcontext)) {
$sendcontext = 'standard';
}
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
if ($mailfile->error)
{
if ($mailfile->error) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = 'presend';
} else {
$result = $mailfile->sendfile();
if ($result)
{
if ($result) {
// Initialisation of datas of object to call trigger
if (is_object($object))
{
if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
if (is_object($object)) {
if (empty($actiontypecode)) {
$actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
}
$object->socid = $sendtosocid; // To link to a company
$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties)
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
if (is_array($attachedfiles) && count($attachedfiles) > 0) {
$object->attachedfiles = $attachedfiles;
}
@ -447,11 +392,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$object->email_msgid = $mailfile->msgid;
// Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
if (!empty($triggersendname) || !empty($trigger_name))
{
if (!empty($triggersendname) || !empty($trigger_name)) {
// Call trigger
$result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
if ($error) {
@ -466,10 +412,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
setEventMessages($mesg, null, 'mesgs');
$moreparam = '';
if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
exit;
$moreparam = '';
if (isset($paramname2) || isset($paramval2)) {
$moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
}
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
exit;
} else {
$langs->load("other");
$mesg = '<div class="error">';

View File

@ -8384,18 +8384,26 @@ abstract class CommonObject
/**
* Sets object to given categories.
*
* Deletes object from existing categories not supplied.
* Adds it to non existing supplied categories.
* Deletes object from existing categories not supplied (if remove_existing==true).
* Existing categories are left untouch.
*
* @param int[]|int $categories Category ID or array of Categories IDs
* @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...)
* @param int[]|int $categories Category ID or array of Categories IDs
* @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type
* @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them
* @return int <0 if KO, >0 if OK
*/
public function setCategoriesCommon($categories, $type_categ)
public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true)
{
dol_syslog(get_class($this)."::setCategoriesCommon Oject Id:".$this->id.' type_categ:'.$type_categ.' nb tag add:'.count($categories), LOG_DEBUG);
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (empty($type_categ)) {
dol_syslog(__METHOD__.': Type '.$type_categ.'is an unknown category type. Done nothing.', LOG_ERR);
return -1;
}
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
@ -8404,22 +8412,36 @@ abstract class CommonObject
// Get current categories
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_categ, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
if ($remove_existing) {
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
$to_add = array_diff($categories, $existing);
}
$error = 0;
$ok=0;
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, $type_categ);
$result=$c->del_type($this, $type_categ);
if ($result < 0)
{
$error++;
$this->error = $c->error;
$this->errors = $c->errors;
break;
} else {
$ok+=$result;
}
}
}
foreach ($to_add as $add) {
@ -8432,11 +8454,13 @@ abstract class CommonObject
$this->error = $c->error;
$this->errors = $c->errors;
break;
} else {
$ok+=$result;
}
}
}
return $error ? -1 : 1;
return $error ? -1 * $error : $ok;
}
/**

View File

@ -15,7 +15,7 @@
* Copyright (C) 2012-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
@ -2652,14 +2652,14 @@ class Form
if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
{
if (!empty($user->rights->stock->lire)) {
$opt .= ' - '.$langs->trans("Stock").':'.$objp->stock;
$opt .= ' - '.$langs->trans("Stock").': '.price(price2num($objp->stock, 'MS'));
if ($objp->stock > 0) {
$outval .= ' - <span class="product_line_stock_ok">';
} elseif ($objp->stock <= 0) {
$outval .= ' - <span class="product_line_stock_too_low">';
}
$outval .= $langs->transnoentities("Stock").':'.$objp->stock;
$outval .= $langs->transnoentities("Stock").': '.price(price2num($objp->stock, 'MS'));
$outval .= '</span>';
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
{
@ -2989,14 +2989,14 @@ class Form
$novirtualstock = ($showstockinlist == 2);
if (!empty($user->rights->stock->lire)) {
$outvallabel .= ' - '.$langs->trans("Stock").':'.$objp->stock;
$outvallabel .= ' - '.$langs->trans("Stock").': '.price(price2num($objp->stock, 'MS'));
if ($objp->stock > 0) {
$optlabel .= ' - <span class="product_line_stock_ok">';
} elseif ($objp->stock <= 0) {
$optlabel .= ' - <span class="product_line_stock_too_low">';
}
$optlabel .= $langs->transnoentities("Stock").':'.$objp->stock;
$optlabel .= $langs->transnoentities("Stock").':'.price(price2num($objp->stock, 'MS'));
$optlabel .= '</span>';
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
{
@ -3291,7 +3291,7 @@ class Form
$langs->load('propal');
$sql = "SELECT rowid, code, label";
$sql = "SELECT rowid, code, label, position";
$sql .= " FROM ".MAIN_DB_PREFIX.'c_availability';
$sql .= " WHERE active > 0";
@ -3308,10 +3308,11 @@ class Form
$label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_availability[$obj->rowid]['code'] = $obj->code;
$this->cache_availability[$obj->rowid]['label'] = $label;
$this->cache_availability[$obj->rowid]['position'] = $obj->position;
$i++;
}
$this->cache_availability = dol_sort_array($this->cache_availability, 'label', 'asc', 0, 0, 1);
$this->cache_availability = dol_sort_array($this->cache_availability, 'position', 'asc', 0, 0, 1);
return $num;
} else {
@ -6667,8 +6668,7 @@ class Form
});
</script>';
if ($acceptdelayedhtml)
{
if ($acceptdelayedhtml) {
$delayedhtmlcontent .= $outdelayed;
} else {
$out .= $outdelayed;
@ -6706,24 +6706,20 @@ class Form
}
// Add code for jquery to use multiselect
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
$out .= "\n".'<!-- JS CODE TO ENABLE select for id '.$htmlname.' -->
<script>'."\n";
if ($addjscombo == 1)
{
if ($addjscombo == 1) {
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out .= 'function formatResult(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
}
$out .= '};'."\n";
$out .= 'function formatSelection(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
@ -6740,8 +6736,7 @@ class Form
templateSelection: formatSelection /* For 4.0 */
});
});'."\n";
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT'))
{
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
// Add other js lib
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
// ...
@ -6762,20 +6757,18 @@ class Form
// Try also magic suggest
$out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
if (is_array($array) && !empty($array))
{
if ($value_as_key) $array = array_combine($array, $array);
if (is_array($array) && !empty($array)) {
if ($value_as_key) {
$array = array_combine($array, $array);
}
if (!empty($array))
{
foreach ($array as $key => $value)
{
if (!empty($array)) {
foreach ($array as $key => $value) {
$newval = ($translate ? $langs->trans($value) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out .= '<option value="'.$key.'"';
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
{
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) {
$out .= ' selected';
}
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
@ -6804,36 +6797,36 @@ class Form
{
global $conf, $langs, $user, $extrafields;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return '';
}
$tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties
if (!empty($user->conf->$tmpvar))
{
if (!empty($user->conf->$tmpvar)) {
$tmparray = explode(',', $user->conf->$tmpvar);
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
//var_dump($key);
//var_dump($tmparray);
if (in_array($key, $tmparray)) $array[$key]['checked'] = 1;
else $array[$key]['checked'] = 0;
if (in_array($key, $tmparray)) {
$array[$key]['checked'] = 1;
} else {
$array[$key]['checked'] = 0;
}
}
}
$lis = '';
$listcheckedstring = '';
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
/* var_dump($val);
var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled'])
{
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
unset($array[$key]); // We don't want this field
continue;
}
if ($val['label'])
{
if ($val['label']) {
if (!empty($val['langfile']) && is_object($langs)) {
$langs->load($val['langfile']);
}

View File

@ -59,7 +59,7 @@ class FormAccounting extends Form
/**
* Return list of journals with label by nature
*
* @param string $selectid Preselected pcg_type
* @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
@ -136,6 +136,86 @@ class FormAccounting extends Form
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of journals with label by nature
*
* @param array $selectedIds Preselected journal code array
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
* @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int $disabledajaxcombo Disable ajax combo box.
* @return string String with HTML select
*/
public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
{
// phpcs:enable
global $conf, $langs;
$out = '';
$options = array();
if ($usecache && !empty($this->options_cache[$usecache]))
{
$options = $this->options_cache[$usecache];
$selected = $selectedIds;
} else {
$sql = "SELECT rowid, code, label, nature, entity, active";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE active = 1";
$sql .= " AND entity = ".$conf->entity;
if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature;
$sql .= " ORDER BY code";
dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
return -1;
}
$selected = array();
$langs->load('accountancy');
while ($obj = $this->db->fetch_object($resql))
{
$label = $langs->trans($obj->label);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->code;
}
if ($select_out == 1) {
$select_value_out = $obj->code;
}
// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected[] = $select_value_out;
}
$options[$select_value_out] = $label;
}
$this->db->free($resql);
if ($usecache)
{
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '', ($disabledajaxcombo ? 0 : 1));
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounting category.

View File

@ -120,8 +120,16 @@ class FormMail extends Form
public $withtocc;
public $withtoccc;
public $withtopic;
public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
/**
* @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files
*/
public $withfile;
/**
* @var int 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
*/
public $withmaindocfile;
public $withbody;
public $withfromreadonly;
@ -195,7 +203,9 @@ class FormMail extends Form
// Set tmp user directory
$vardir = $conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
if (is_dir($upload_dir)) {
dol_delete_dir_recursive($upload_dir);
}
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
unset($_SESSION["listofpaths".$keytoavoidconflict]);
@ -219,15 +229,24 @@ class FormMail extends Form
$listofnames = array();
$listofmimes = array();
if (empty($file)) $file = basename($path);
if (empty($type)) $type = dol_mimetype($file);
if (empty($file)) {
$file = basename($path);
}
if (empty($type)) {
$type = dol_mimetype($file);
}
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!in_array($file, $listofnames))
{
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
if (!in_array($file, $listofnames)) {
$listofpaths[] = $path;
$listofnames[] = $file;
$listofmimes[] = $type;
@ -252,11 +271,16 @@ class FormMail extends Form
$listofmimes = array();
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if ($keytodelete >= 0)
{
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
if ($keytodelete >= 0) {
unset($listofpaths[$keytodelete]);
unset($listofnames[$keytodelete]);
unset($listofmimes[$keytodelete]);
@ -281,9 +305,15 @@ class FormMail extends Form
$listofmimes = array();
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
}

View File

@ -21,13 +21,27 @@
* \brief File that include javascript functions (included if option use_javascript activated)
*/
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
if (!defined('NOLOGIN')) define('NOLOGIN', 1);
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', 1);
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
session_cache_limiter('public');
@ -36,8 +50,11 @@ require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
else header('Cache-Control: no-cache');
if (empty($dolibarr_nocache)) {
header('Cache-Control: max-age=10800, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}
//var_dump($conf);
@ -46,15 +63,14 @@ else header('Cache-Control: no-cache');
print "\n/* JS CODE TO ENABLE Tooltips on all object with class classfortooltip */\n";
print "jQuery(document).ready(function () {\n";
if (empty($conf->dol_no_mouse_hover))
{
if (empty($conf->dol_no_mouse_hover)) {
print 'jQuery(".classfortooltip").tooltip({
show: { collision: "flipfit", effect:\'toggle\', delay:50 },
hide: { delay: 250 },
show: { collision: "flipfit", effect:"toggle", delay:75, duration:150 },
hide: { delay: 250, duration: 20 },
tooltipClass: "mytooltip",
content: function () {
console.log("Return title for popup");
return $(this).prop(\'title\'); /* To force to get title as is */
return $(this).prop("title"); /* To force to get title as is */
}
});'."\n";
}
@ -79,8 +95,7 @@ print "});\n";
// Wrapper to manage dropdown
if (!defined('JS_JQUERY_DISABLE_DROPDOWN'))
{
if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) {
print "\n/* JS CODE TO ENABLE dropdown (hamburger, linkto, ...) */\n";
print '
jQuery(document).ready(function () {
@ -149,8 +164,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN'))
}
// Wrapper to manage document_preview
if ($conf->browser->layout != 'phone')
{
if ($conf->browser->layout != 'phone') {
print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header
print '
jQuery(document).ready(function () {

View File

@ -64,7 +64,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
print '<input type="hidden" name="year" value="'.$year.'">';
print '<input type="hidden" name="month" value="'.$month.'">';
print '<input type="hidden" name="day" value="'.$day.'">';
if ($massaction != 'predelete') { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
if ($massaction != 'predelete' && $massaction != 'preaffecttag') { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
print '<input type="hidden" name="action" value="'.$action.'">';
}
print '<input type="hidden" name="search_showbirthday" value="'.$showbirthday.'">';

View File

@ -4810,7 +4810,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CR'=Currency rate
* 'CR'=Foreign currency accurancy
* Numeric = Nb of digits for rounding
* @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done)
* Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator).
@ -4871,10 +4871,18 @@ function price2num($amount, $rounding = '', $option = 0)
if ($rounding)
{
$nbofdectoround = '';
if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
elseif ($rounding == 'CR') $nbofdectoround = 8;
if ($rounding == 'MU') {
$nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
}
elseif ($rounding == 'MT') {
$nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
}
elseif ($rounding == 'MS') {
$nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
}
elseif ($rounding == 'CR') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
}
elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
//print "RR".$amount.' - '.$nbofdectoround.'<br>';
if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.

View File

@ -78,13 +78,21 @@ function prelevement_prepare_head(BonPrelevement $object)
/**
* Check need data to create standigns orders receipt file
*
* @param string $type 'bank-transfer' or 'direct-debit'
*
* @return int -1 if ko 0 if ok
*/
function prelevement_check_config()
function prelevement_check_config($type = 'direct-debit')
{
global $conf;
if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
if (empty($conf->global->PRELEVEMENT_USER)) return -1;
global $conf, $db;
if ($type == 'bank-transfer'){
if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1;
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1;
}else {
if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
if (empty($conf->global->PRELEVEMENT_USER)) return -1;
}
return 0;
}

View File

@ -1334,10 +1334,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Closure
if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
$newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'closure');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) {
$newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->write);
}
}
// Reports

View File

@ -37,6 +37,40 @@ if ($massaction == 'predelete')
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1);
}
if ($massaction == 'preaffecttag')
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$categ = new Categorie($db);
$categ_types=array();
$categ_type_array=$categ->getMapList();
foreach ($categ_type_array as $categdef) {
if (isset($object) && $categdef['obj_table']==$object->table_element) {
if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
}
if (isset($objecttmp) && $categdef['obj_table']==$objecttmp->table_element) {
if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
}
}
$formquestion = array();
if (!empty($categ_types)) {
foreach ($categ_types as $categ_type) {
$cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1);
$formquestion[]=array('type' => 'other',
'name' => 'affecttag_'.$categ_type['code'],
'label' => $langs->trans("Tag").' '.$categ_type['label'],
'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%'));
}
$formquestion[]=array('type' => 'other',
'name' => 'affecttag_type',
'label' => '',
'value' => '<input type="hidden" name="affecttag_type" id="affecttag_type" value="'.implode(",", array_keys($categ_types)).'"/>');
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAffectTag"), $langs->trans("ConfirmAffectTagQuestion", count($toselect)), "affecttag", $formquestion, 1, 0, 200, 500, 1);
} else {
setEventMessage('CategTypeNotFound');
}
}
if ($massaction == 'presend')
{
$langs->load("mails");
@ -47,8 +81,7 @@ if ($massaction == 'presend')
if (!GETPOST('cancel', 'alpha'))
{
foreach ($arrayofselected as $toselectid)
{
foreach ($arrayofselected as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result > 0)
{

View File

@ -386,10 +386,10 @@ if ($nolinesbefore) {
<td class="nobottom margininfos linecolmargin right">
<!-- For predef product -->
<?php if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { ?>
<select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp" style="display: none;"></select>
<select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp maxwidth150" style="display: none;"></select>
<?php } ?>
<!-- For free product -->
<input type="text" id="buying_price" name="buying_price" class="flat maxwidth75 right" value="<?php echo (GETPOSTISSET("buying_price") ? GETPOST("buying_price", 'alpha', 2) : ''); ?>">
<input type="text" id="buying_price" name="buying_price" class="flat maxwidth75 maxwidth150 right" value="<?php echo (GETPOSTISSET("buying_price") ? GETPOST("buying_price", 'alpha', 2) : ''); ?>">
</td>
<?php
if (!empty($conf->global->DISPLAY_MARGIN_RATES))

View File

@ -491,7 +491,9 @@ class FichinterRec extends Fichinter
if (!$info_bits) $info_bits = 0;
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
if ($price_base_type == 'HT') {
$pu = $pu_ht;
@ -499,7 +501,6 @@ class FichinterRec extends Fichinter
$pu = $pu_ttc;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker

View File

@ -2546,9 +2546,12 @@ class CommandeFournisseur extends CommonOrder
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (!$qty) $qty = 1;
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -356,24 +356,24 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -1175,7 +1175,7 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
@ -1183,17 +1183,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -11,7 +11,7 @@
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2017 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -60,8 +60,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sup
$socid = GETPOST('socid', 'int');
// Security check
if ($user->socid > 0)
{
if ($user->socid > 0) {
$action = '';
$_GET["action"] = '';
$socid = $user->socid;
@ -359,6 +358,93 @@ if (empty($reshook))
}
if ($massaction == 'transfer_request')
{
$langs->load("withdrawals");
if (!$user->rights->paymentbybanktransfer->create) {
$error++;
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
} else {
//Checking error
$error = 0;
$arrayofselected = is_array($toselect) ? $toselect : array();
$listofbills = array();
foreach ($arrayofselected as $toselectid)
{
$objecttmp = new FactureFournisseur($db);
$result = $objecttmp->fetch($toselectid);
if ($result > 0)
{
$totalpaye = $objecttmp->getSommePaiement();
$totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
$totaldeposits = $objecttmp->getSumDepositsUsed();
$objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
if ($objecttmp->paye || $objecttmp->resteapayer == 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
} elseif ($objecttmp->resteapayer < 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
}
if (!($objecttmp->statut > FactureFournisseur::STATUS_DRAFT)) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors');
}
$rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
$rsql .= " , pfd.date_traite as date_traite";
$rsql .= " , pfd.amount";
$rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login";
$rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$rsql .= " , ".MAIN_DB_PREFIX."user as u";
$rsql .= " WHERE fk_facture_fourn = ".$objecttmp->id;
$rsql .= " AND pfd.fk_user_demande = u.rowid";
$rsql .= " AND pfd.traite = 0";
$rsql .= " ORDER BY pfd.date_demande DESC";
$result_sql = $db->query($rsql);
if ($result_sql)
{
$numprlv = $db->num_rows($result_sql);
}
if ($numprlv > 0) {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
}
elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') {
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
} else {
$listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
}
}
}
//Massive withdraw request for request with no errors
if (!empty($listofbills)) {
$nbwithdrawrequestok = 0;
foreach ($listofbills as $aBill) {
$db->begin();
$result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice');
if ($result > 0) {
$db->commit();
$nbwithdrawrequestok++;
} else {
$db->rollback();
setEventMessages($aBill->error, $aBill->errors, 'errors');
}
}
if ($nbwithdrawrequestok > 0) {
setEventMessages($langs->trans("BankTransferRequestsDone", $nbwithdrawrequestok), null, 'mesgs');
}
}
}
}
/*
* View
*/
@ -600,6 +686,10 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($conf->paymentbybanktransfer->enabled) {
$langs->load("withdrawals");
$arrayofmassactions['transfer_request'] = $langs->trans("MakeBankTransferOrder");
}
//if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if (!empty($conf->paymentbybanktransfer->enabled) && !empty($user->rights->paymentbybanktransfer->create)) {
$langs->load('withdrawals');

View File

@ -9,7 +9,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -42,15 +42,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$facid = GETPOST('facid', 'int');
$socid = GETPOST('socid', 'int');
$facid = GETPOST('facid', 'int');
$socid = GETPOST('socid', 'int');
$accountid = GETPOST('accountid', 'int');
$day = GETPOST('day', 'int');
$month = GETPOST('month', 'int');
$month = GETPOST('month', 'int');
$year = GETPOST('year', 'int');
$search_ref = GETPOST("search_ref", "alpha");
@ -562,15 +562,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<td>'.$langs->trans('RefSupplier').'</td>';
print '<td class="center">'.$langs->trans('Date').'</td>';
print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td>'.$langs->trans('Currency').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('MulticurrencyAlreadyPaid').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td class="right">'.$langs->trans('MulticurrencyRemainderToPay').'</td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td>'.$langs->trans('Currency').'</td>';
print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
print '<td class="right">'.$langs->trans('MulticurrencyAlreadyPaid').'</td>';
print '<td class="right">'.$langs->trans('MulticurrencyRemainderToPay').'</td>';
}
print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
print '<td class="right">'.$langs->trans('AlreadyPaid').'</td>';
print '<td class="right">'.$langs->trans('RemainderToPay').'</td>';
print '<td class="center">'.$langs->trans('PaymentAmount').'</td>';
if (!empty($conf->multicurrency->enabled)) print '<td class="center">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td class="center">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
}
print '</tr>';
$total = 0;
@ -596,8 +600,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
// Multicurrency Price
if (!empty($conf->multicurrency->enabled))
{
if (!empty($conf->multicurrency->enabled)) {
$multicurrency_payment = $invoice->getSommePaiement(1);
$multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
$multicurrency_deposits = $invoice->getSumDepositsUsed(1);
@ -616,8 +619,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<td>'.$objp->ref_supplier.'</td>';
// Date
if ($objp->df > 0)
{
if ($objp->df > 0) {
print '<td class="center nowraponall">';
print dol_print_date($db->jdate($objp->df), 'day').'</td>';
} else {
@ -728,15 +730,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$totalrecudeposits += $deposits;
$i++;
}
if ($i > 1)
{
if ($i > 1) {
// Print total
print '<tr class="liste_total">';
print '<td colspan="4" class="left">'.$langs->trans('TotalTTC').':</td>';
if (!empty($conf->multicurrency->enabled)) print '<td>&nbsp;</td>';
if (!empty($conf->multicurrency->enabled)) print '<td>&nbsp;</td>';
if (!empty($conf->multicurrency->enabled)) print '<td>&nbsp;</td>';
if (!empty($conf->multicurrency->enabled)) print '<td>&nbsp;</td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
}
print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
print '<td class="right"><b>'.price($sign * $totalrecu);
if ($totalrecucreditnote) print '+'.price($totalrecucreditnote);
@ -744,7 +747,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</b></td>';
print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
print '<td class="center" id="result" style="font-weight: bold;"></td>'; // Autofilled
if (!empty($conf->multicurrency->enabled)) print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
if (!empty($conf->multicurrency->enabled)) {
print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
}
print "</tr>\n";
}
print "</table>\n";
@ -785,7 +790,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</form>';
}
} else dol_print_error($db);
} else {
dol_print_error($db);
}
}
// End of page

View File

@ -1,4 +1,5 @@
-- Copyright (C) 2011 Philippe GRAND <philippe.grand@atoo-net.com>
-- Copyright (C) 2020 Alexandre SPANGARO <aspangaro@open-dsi.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -25,7 +26,7 @@
--
delete from llx_c_availability;
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (1, 'AV_NOW', 'Immediate', 1);
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', '1 week', 1);
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1);
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1);
INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (1, 'AV_NOW', 'Immediate', 1, 10);
INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20);
INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30);
INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40);

View File

@ -35,6 +35,16 @@
delete from llx_c_tva;
-- ALGERIA (id country=13)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1);
-- ANGOLA (id country=35)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1);
-- ARGENTINA (id country=23)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '0','0','IVA Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (232, 23,'10.5','0','IVA reduced rate',1);
@ -202,6 +212,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 1
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '19','0','Algemeen BTW tarief',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 174, 17, '21','0','Algemeen BTW tarief (vanaf 1 oktober 2012)',0);
-- NEW CALEDONIA (id country=165)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1651, 165, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1652, 165, '3','0','VAT standard 3', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1653, 165, '6','0','VAT standard 6', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1654, 165, '11','0','VAT standard rate', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1655, 165, '22','0','VAT standard high', 1);
-- NEW ZEALAND (id country=166)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1661, 166, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1);
@ -361,16 +378,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1);
-- ALGERIA(id country=13)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1);
-- ANGOLA (id country=35)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1);
-- Example of code to insert a vat rate 0 for each country
--delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1')
--insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva);

View File

@ -547,7 +547,7 @@ CREATE TABLE llx_session(
fk_user integer NOT NULL,
remote_ip varchar(64) NULL,
user_agent varchar(128) NULL
)ENGINE=innodb;
) ENGINE=innodb;
INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'github', 'Github', 'https://github.com/{socialid}', 'fa-github', 1);

View File

@ -30,10 +30,10 @@
-- Missing in v13 or lower
-- For v14
ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid;
UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
@ -42,3 +42,5 @@ ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity);
ALTER TABLE llx_societe ADD COLUMN accountancy_code_sell varchar(32) AFTER webservices_key;
ALTER TABLE llx_societe ADD COLUMN accountancy_code_buy varchar(32) AFTER accountancy_code_sell;
ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;

View File

@ -475,7 +475,7 @@ UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_inventory set date_cre = null where DATE(STR_TO_DATE(date_cre, '%Y-%m-%d')) IS NULL;
-- Note that you can manually set the default value of a date to CURRENT_TIMESTAMP with:
-- Note that you can manually set the default value of a date or datetime to CURRENT_TIMESTAMP with:
--ALTER TABLE llx_table modify column columnname datetime DEFAULT CURRENT_TIMESTAMP;

View File

@ -59,5 +59,7 @@ create table llx_bank_account
note_public text,
model_pdf varchar(255),
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
extraparams varchar(255), -- for other parameters with json format
ics varchar(32), -- Creditor Identifier CI
ics_transfer varchar(32) -- Creditor Identifier CI for transfer
)ENGINE=innodb;

View File

@ -1,5 +1,6 @@
-- ========================================================================
-- Copyright (C) 2011 Philippe GRAND <philippe.grand@atoo-net.com>
-- Copyright (C) 2020 Alexandre SPANGARO <aspangaro@open-dsi.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -21,6 +22,6 @@ create table llx_c_availability
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(30) NOT NULL,
label varchar(60) NOT NULL,
active tinyint DEFAULT 1 NOT NULL
active tinyint DEFAULT 1 NOT NULL,
position integer NOT NULL DEFAULT 0
)ENGINE=innodb;

View File

@ -147,7 +147,7 @@ NotVentilatedinAccount=Not bound to the accounting account
XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account
XLineFailedToBeBinded=%s products/services were not bound to any accounting account
ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50)
ACCOUNTING_LIMIT_LIST_VENTILATION=Maximum number of lines on list and bind page (recommended: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements
@ -253,7 +253,7 @@ PaymentsNotLinkedToProduct=Payment not linked to any product / service
OpeningBalance=Opening balance
ShowOpeningBalance=Show opening balance
HideOpeningBalance=Hide opening balance
ShowSubtotalByGroup=Show subtotal by group
ShowSubtotalByGroup=Show subtotal by level
Pcgtype=Group of account
PcgtypeDesc=Group of account are used as predefined 'filter' and 'grouping' criteria for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as groups for accounting accounts of products to build the expense/income report.
@ -276,11 +276,13 @@ DescVentilExpenseReport=Consult here the list of expense report lines bound (or
DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button <strong>"%s"</strong>. If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "<strong>%s</strong>".
DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account
Closure=Annual closure
DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open
OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year)
AllMovementsWereRecordedAsValidated=All movements were recorded as validated
NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated
ValidateMovements=Validate movements
DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible
SelectMonthAndValidate=Select month and validate movements
ValidateHistory=Bind Automatically
AutomaticBindingDone=Automatic binding done

View File

@ -99,7 +99,8 @@ CashDeskRefNumberingModules=Numbering module for POS sales
CashDeskGenericMaskCodes6 = <br><b>{TN}</b> tag is used to add the terminal number
TakeposGroupSameProduct=Group same products lines
StartAParallelSale=Start a new parallel sale
ControlCashOpening=Control cash desk at opening POS
SaleStartedAt=Sale started at %s
ControlCashOpening=Control cash popup at opening POS
CloseCashFence=Close cash desk control
CashReport=Cash report
MainPrinterToUse=Main printer to use

View File

@ -92,7 +92,7 @@ MailingModuleDescEmailsFromUser=Emails input by user
MailingModuleDescDolibarrUsers=Users with Emails
MailingModuleDescThirdPartiesByCategories=Third parties (by categories)
SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed.
EmailCollectorFilterDesc=All filters must match to have an email being collected
EmailCollectorFilterDesc=All filters must match to have an email being collected
# Libelle des modules de liste de destinataires mailing
LineInFile=Line %s in file
@ -174,4 +174,4 @@ Unanswered=Unanswered
Answered=Answered
IsNotAnAnswer=Is not answer (initial email)
IsAnAnswer=Is an answer of an initial email
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s

View File

@ -1112,4 +1112,8 @@ UpToDate=Up-to-date
OutOfDate=Out-of-date
EventReminder=Event Reminder
UpdateForAllLines=Update for all lines
OnHold=On hold
OnHold=On hold
AffectTag=Affect Tag
ConfirmAffectTag=Bulk Tag Affect
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?
CategTypeNotFound=No tag type found for type of records

View File

@ -259,7 +259,8 @@ ContactCreatedByEmailCollector=Contact/address created by email collector from e
ProjectCreatedByEmailCollector=Project created by email collector from email MSGID %s
TicketCreatedByEmailCollector=Ticket created by email collector from email MSGID %s
OpeningHoursFormatDesc=Use a - to separate opening and closing hours.<br>Use a space to enter different ranges.<br>Example: 8-12 14-18
PrefixSession=Prefix for session ID
##### Export #####
ExportsArea=Exports area
AvailableFormats=Available formats

View File

@ -42,6 +42,7 @@ LastWithdrawalReceipt=Latest %s direct debit receipts
MakeWithdrawRequest=Make a direct debit payment request
MakeBankTransferOrder=Make a credit transfer request
WithdrawRequestsDone=%s direct debit payment requests recorded
BankTransferRequestsDone=%s credit transfer requests recorded
ThirdPartyBankCode=Third-party bank code
NoInvoiceCouldBeWithdrawed=No invoice debited successfully. Check that invoices are on companies with a valid IBAN and that IBAN has a UMR (Unique Mandate Reference) with mode <strong>%s</strong>.
ClassCredited=Classify credited
@ -131,7 +132,8 @@ SEPARCUR=SEPA CUR
SEPAFRST=SEPA FRST
ExecutionDate=Execution date
CreateForSepa=Create direct debit file
ICS=Creditor Identifier CI
ICS=Creditor Identifier CI for direct debit
ICSTransfer=Creditor Identifier CI for bank transfer
END_TO_END="EndToEndId" SEPA XML tag - Unique id assigned per transaction
USTRD="Unstructured" SEPA XML tag
ADDDAYS=Add days to Execution Date
@ -145,4 +147,5 @@ InfoTransData=Amount: %s<br>Method: %s<br>Date: %s
InfoRejectSubject=Direct debit payment order refused
InfoRejectMessage=Hello,<br><br>the direct debit payment order of invoice %s related to the company %s, with an amount of %s has been refused by the bank.<br><br>--<br>%s
ModeWarning=Option for real mode was not set, we stop after this simulation
ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use.
ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use.
ErrorICSmissing=Missing ICS in Bank account %s

View File

@ -144,7 +144,7 @@ NotVentilatedinAccount=Non lié au compte comptable
XLineSuccessfullyBinded=%s produits/service correctement liés à un compte comptable
XLineFailedToBeBinded=%s produits/services n'ont pu être liés à un compte comptable
ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre de ligne des listes et d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Commencez le tri de la page "Lien à réaliser" par les éléments les plus récents
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Commencez le tri de la page "Liens réalisés" par les éléments les plus récents

View File

@ -115,6 +115,10 @@ $search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
}
}
// List of fields to search into when doing a "search in all"
@ -183,6 +187,10 @@ if (empty($reshook))
{
foreach ($object->fields as $key => $val) {
$search[$key] = '';
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = '';
$search[$key.'_dtend'] = '';
}
}
$toselect = '';
$search_array_options = array();
@ -241,13 +249,27 @@ if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity
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 (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
$mode_search = 2;
if (in_array($key, $object->fields)) {
if ($key == 'status' && $search[$key] == -1) continue;
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = '';
$mode_search = 2;
}
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
} else {
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
$columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
if (preg_match('/_dtstart$/', $key)) {
$sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
}
if (preg_match('/_dtend$/', $key)) {
$sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
}
}
}
}
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);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
@ -428,7 +450,16 @@ foreach ($object->fields as $key => $val)
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
} elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
}
print '</td>';
}
}

View File

@ -5504,38 +5504,9 @@ class Product extends CommonObject
*/
public function setCategories($categories)
{
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, Categorie::TYPE_PRODUCT);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, Categorie::TYPE_PRODUCT);
}
}
return;
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
return parent::setCategoriesCommon($categories, Categorie::TYPE_PRODUCT);
}
/**

View File

@ -490,9 +490,9 @@ if ($id > 0 || $ref)
if ($rowid)
{
print '<input type="hidden" name="ref_fourn_old" value="'.$object->ref_supplier.'">';
print '<input class="flat" name="ref_fourn" size="12" value="'.$object->ref_supplier.'">';
print '<input class="flat width150" maxlength="30" name="ref_fourn" value="'.$object->ref_supplier.'">';
} else {
print '<input class="flat" name="ref_fourn" size="12" value="'.(GETPOST("ref_fourn") ?GETPOST("ref_fourn") : '').'">';
print '<input class="flat width150" maxlength="30" name="ref_fourn" value="'.(GETPOST("ref_fourn") ? GETPOST("ref_fourn") : '').'">';
}
print '</td>';
print '</tr>';

View File

@ -304,6 +304,7 @@ if (empty($reshook))
$permissiontoread = $user->rights->{$rightskey}->lire;
$permissiontodelete = $user->rights->{$rightskey}->supprimer;
$permissiontoadd = $user->rights->{$rightskey}->creer;
$uploaddir = $conf->product->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -533,8 +534,10 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "<span class='fa fa-trash paddingrightonly'></span>".$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->{$rightskey}->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';

View File

@ -890,39 +890,7 @@ class Entrepot extends CommonObject
*/
public function setCategories($categories)
{
$type_categ = Categorie::TYPE_WAREHOUSE;
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_categ, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, $type_categ);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, $type_categ);
}
}
return;
return parent::setCategoriesCommon($categories, Categorie::TYPE_WAREHOUSE);
}
}

View File

@ -46,6 +46,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // 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')
$toselect = GETPOST('toselect', 'array');
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha");
@ -160,7 +162,7 @@ if (empty($reshook))
{
$search[$key] = '';
}
$toselect = '';
$toselect = array();
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
@ -174,6 +176,7 @@ if (empty($reshook))
$objectlabel = 'Warehouse';
$permissiontoread = $user->rights->stock->lire;
$permissiontodelete = $user->rights->stock->supprimer;
$permissiontoadd = $user->rights->stock->creer;
$uploaddir = $conf->stock->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -343,7 +346,8 @@ $arrayofmassactions = array(
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
if ($user->rights->stock->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form action="'.$_SERVER["PHP_SELF"].'" id="searchFormList" method="POST" name="formulaire">';

View File

@ -2135,50 +2135,8 @@ class Project extends CommonObject
*/
public function setCategories($categories)
{
$type_categ = Categorie::TYPE_PROJECT;
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_categ, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$result = $c->del_type($this, $type_categ);
if ($result < 0) {
$this->errors = $c->errors;
$this->error = $c->error;
return -1;
}
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$result = $c->add_type($this, $type_categ);
if ($result < 0) {
$this->errors = $c->errors;
$this->error = $c->error;
return -1;
}
}
}
return 1;
return parent::setCategoriesCommon($categories, Categorie::TYPE_PROJECT);
}

View File

@ -218,6 +218,7 @@ if (empty($reshook))
$objectlabel = 'Project';
$permissiontoread = $user->rights->projet->lire;
$permissiontodelete = $user->rights->projet->supprimer;
$permissiontoadd = $user->rights->projet->creer;
$uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@ -455,7 +456,8 @@ $arrayofmassactions = array(
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close");
if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->projet->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);

View File

@ -88,6 +88,11 @@ class PaymentSalary extends CommonObject
*/
public $fk_user_modif;
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public $fields = array();
/**
* Constructor
@ -120,8 +125,7 @@ class PaymentSalary extends CommonObject
$this->note = trim($this->note);
// Check parameters
if (empty($this->fk_user) || $this->fk_user < 0)
{
if (empty($this->fk_user) || $this->fk_user < 0) {
$this->error = 'ErrorBadParameter';
return -1;
}
@ -151,35 +155,29 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
// Update extrafield
if (!$error)
{
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
if (!$notrigger)
{
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -199,6 +197,7 @@ class PaymentSalary extends CommonObject
public function fetch($id, $user = null)
{
global $langs;
$sql = "SELECT";
$sql .= " s.rowid,";
@ -227,26 +226,24 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payement = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep);
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
@ -282,18 +279,18 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user);
if ($result < 0) return -1;
if ($result < 0) {
return -1;
}
// End call triggers
// Delete donation
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields";
$sql .= " WHERE fk_object=".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->errors[] = $this->db->lasterror();
$error++;
}
@ -304,8 +301,7 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@ -326,7 +322,7 @@ class PaymentSalary extends CommonObject
$this->id = 0;
$this->tms = '';
$this->fk_user = '';
$this->fk_user = 1;
$this->datep = '';
$this->datev = '';
$this->amount = '';
@ -335,8 +331,8 @@ class PaymentSalary extends CommonObject
$this->dateep = '';
$this->note = '';
$this->fk_bank = '';
$this->fk_user_author = '';
$this->fk_user_modif = '';
$this->fk_user_author = 1;
$this->fk_user_modif = 1;
}
/**
@ -356,34 +352,29 @@ class PaymentSalary extends CommonObject
$this->amount = price2num(trim($this->amount));
$this->label = trim($this->label);
$this->note = trim($this->note);
$this->fk_bank = trim($this->fk_bank);
$this->fk_user_author = trim($this->fk_user_author);
$this->fk_user_modif = trim($this->fk_user_modif);
$this->fk_bank = (int) $this->fk_bank;
$this->fk_user_author = (int) $this->fk_user_author;
$this->fk_user_modif = (int) $this->fk_user_modif;
// Check parameters
if (!$this->label)
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if (!$this->label) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3;
}
if ($this->fk_user < 0 || $this->fk_user == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
if ($this->fk_user <= 0 || $this->fk_user == '') {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4;
}
if ($this->amount < 0 || $this->amount == '')
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
if ($this->amount < 0 || $this->amount == '') {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -6;
}
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}
@ -398,7 +389,9 @@ class PaymentSalary extends CommonObject
$sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", num_payment";
if ($this->note) $sql .= ", note";
if ($this->note) {
$sql .= ", note";
}
$sql .= ", label";
$sql .= ", datesp";
$sql .= ", dateep";
@ -416,7 +409,9 @@ class PaymentSalary extends CommonObject
$sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".$this->db->escape($this->type_payment);
$sql .= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
if ($this->note) {
$sql .= ", '".$this->db->escape($this->note)."'";
}
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
@ -428,30 +423,25 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
if ($this->id > 0)
{
if (!empty($conf->banque->enabled) && !empty($this->amount))
{
if ($this->id > 0) {
if (!empty($conf->banque->enabled) && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result = $acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($this->db);
if ($result <= 0) {
dol_print_error($this->db);
}
// Update extrafield
if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
@ -473,22 +463,19 @@ class PaymentSalary extends CommonObject
// Update fk_bank into llx_paiement.
// So we know the payment which has generate the banking ecriture
if ($bank_line_id > 0)
{
if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id);
} else {
$this->error = $acc->error;
$error++;
}
if (!$error)
{
if (!$error) {
// Add link 'payment_salary' in bank_url between payment and bank transaction
$url = DOL_URL_ROOT.'/salaries/card.php?id=';
$result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
if ($result <= 0)
{
if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@ -507,8 +494,7 @@ class PaymentSalary extends CommonObject
'user'
);
if ($result <= 0)
{
if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@ -516,12 +502,15 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
} else $error++;
} else {
$error++;
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return $this->id;
} else {
@ -548,8 +537,7 @@ class PaymentSalary extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
return 1;
} else {
dol_print_error($this->db);
@ -571,10 +559,10 @@ class PaymentSalary extends CommonObject
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
global $db, $conf, $langs, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
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 = '';
@ -583,10 +571,11 @@ class PaymentSalary extends CommonObject
if (!empty($this->label)) {
$labeltoshow = $this->label;
$reg = array();
if (preg_match('/^\((.*)\)$/i', $this->label, $reg))
{
if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1] == 'paiement') $reg[1] = 'Payment';
if ($reg[1] == 'paiement') {
$reg[1] = 'Payment';
}
$labeltoshow = $langs->trans($reg[1]);
}
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
@ -594,19 +583,20 @@ class PaymentSalary extends CommonObject
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@ -614,20 +604,26 @@ class PaymentSalary extends CommonObject
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
/*
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$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 .= $this->ref;
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 .= $this->ref;
}
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -635,8 +631,11 @@ class PaymentSalary extends CommonObject
$hookmanager->initHooks(array('salarypayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}
@ -656,14 +655,11 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
@ -703,40 +699,40 @@ class PaymentSalary extends CommonObject
$langs->load('compta');
/*if ($mode == 0)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}*/
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}*/
return '';
}
}

View File

@ -26,7 +26,9 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "s.datep,s.rowid";
if (!$sortorder) $sortorder = "DESC,DESC";
if (!$sortfield) {
$sortfield = "s.datep,s.rowid";
}
if (!$sortorder) {
$sortorder = "DESC,DESC";
}
// Initialize technical objects
$object = new PaymentSalary($db);
@ -64,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
if (!$sortfield) $sortfield = "s.datep,s.rowid";
if (!$sortorder) $sortorder = "DESC,DESC";
if (!$sortfield) {
$sortfield = "s.datep,s.rowid";
}
if (!$sortorder) {
$sortorder = "DESC,DESC";
}
$search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha');
@ -77,14 +89,14 @@ $search_account = GETPOST('search_account', 'int');
$filtre = GETPOST("filtre", 'restricthtml');
if (!GETPOST('search_type_id', 'int'))
{
if (!GETPOST('search_type_id', 'int')) {
$newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre);
foreach ($filterarray as $val)
{
foreach ($filterarray as $val) {
$part = explode(':', $val);
if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1];
if ($part[0] == 's.fk_typepayment') {
$search_type_id = $part[1];
}
}
} else {
$search_type_id = GETPOST('search_type_id', 'int');
@ -94,22 +106,26 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = GETPOST("socid", "int");
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
foreach ($object->fields as $key => $val)
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
foreach ($object->fields as $key => $val) {
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)
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
foreach ($object->fields as $key => $val) {
if ($val['searchall']) {
$fieldstosearchall['t.'.$key] = $val['label'];
}
}
$permissiontoread = $user->rights->salaries->read;
@ -121,21 +137,26 @@ $permissiontodelete = $user->rights->salaries->delete;
* 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
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
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 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_ref = "";
$search_user = "";
$search_label = "";
@ -146,8 +167,7 @@ if (empty($reshook))
$search_type_id = "";
}
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'))
{
|| 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
}
@ -158,8 +178,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Validate records
if (!$error && $massaction == 'buildsepa' && $permissiontoadd)
{
if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
$objecttmp = new $objectclass($db);
// TODO
@ -192,16 +211,32 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro
$sql .= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = s.fk_user";
$sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")";
if (empty($user->rights->salaries->readall)) {
$sql .= " AND s.fk_user IN (".join(',', $childids).")";
}
// Search criteria
if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref);
if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
if ($search_label) $sql .= natural_search(array('s.label'), $search_label);
if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1);
if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account);
if ($search_ref) {
$sql .= " AND s.rowid=".((int) $search_ref);
}
if ($search_user) {
$sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
}
if ($search_label) {
$sql .= natural_search(array('s.label'), $search_label);
}
if ($search_date_start) {
$sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
}
if ($search_date_end) {
$sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
}
if ($search_amount) {
$sql .= natural_search("s.amount", $search_amount, 1);
}
if ($search_account > 0) {
$sql .= " AND b.fk_account=".((int) $search_account);
}
if ($filtre) {
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
@ -213,26 +248,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -248,16 +281,36 @@ llxHeader('', $title, $help_url);
$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_type_id) $param .= '&search_type_id='.urlencode($search_type_id);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
if ($search_label) $param .= '&search_label='.urlencode($search_label);
if ($search_account) $param .= '&search_account='.urlencode($search_account);
if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($search_type_id) {
$param .= '&search_type_id='.urlencode($search_type_id);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode($search_user);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_account) {
$param .= '&search_account='.urlencode($search_account);
}
if ($search_date_start) {
$param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
}
if ($search_date_end) {
$param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -267,11 +320,15 @@ $arrayofmassactions = array(
//'buildsepa'=>$langs->trans("BuildSepa"), // TODO
);
//if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
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.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -280,7 +337,9 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$url = DOL_URL_ROOT.'/salaries/card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -323,8 +382,7 @@ print '<td class="liste_titre left">';
$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
print '</td>';
// Account
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>';
@ -356,7 +414,9 @@ print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'c
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "s.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->banque->enabled)) {
print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
}
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -371,11 +431,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line
$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 (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
}
}
}
@ -384,10 +444,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
$i = 0;
$total = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object
$object->setVarsFromFetchObj($obj);
@ -409,41 +470,50 @@ while ($i < ($limit ? min($num, $limit) : $num))
// Ref
print "<td>".$salstatic->getNomUrl(1)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Employee
print "<td>".$userstatic->getNomUrl(1)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Label payment
print "<td>".dol_trunc($obj->label, 40)."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Date payment
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Date value
print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
// Account
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<td>';
if ($obj->fk_bank > 0)
{
if ($obj->fk_bank > 0) {
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
$accountstatic->account_number = $obj->account_number;
$accountingjournal = new AccountingJournal($db);
@ -453,15 +523,23 @@ while ($i < ($limit ? min($num, $limit) : $num))
}
$accountstatic->label = $obj->blabel;
print $accountstatic->getNomUrl(1);
} else print '&nbsp;';
} else {
print '&nbsp;';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Amount
print '<td class="nowrap right">'.price($obj->amount).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
}
$totalarray['val']['totalttcfield'] += $obj->amount;
// Extra fields
@ -472,14 +550,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
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
{
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($object->id, $arrayofselected)) $selected = 1;
if (in_array($object->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
@ -491,10 +572,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
{
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}

View File

@ -2300,10 +2300,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company');
$formconfirm = '';
// Confirm delete third party
if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
}
if ($action == 'merge')
@ -2317,9 +2319,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
)
);
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
$formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
}
// Call Hook formConfirm
$parameters = array('formConfirm' => $formconfirm);
$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;
// Print form confirm
print $formconfirm;
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';

View File

@ -4393,45 +4393,7 @@ class Societe extends CommonObject
return -1;
}
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_categ, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
$error = 0;
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, $type_categ);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$result = $c->add_type($this, $type_categ);
if ($result < 0) {
$error++;
$this->error = $c->error;
$this->errors = $c->errors;
break;
}
}
}
return $error ? -1 : 1;
return parent::setCategoriesCommon($categories, $type_categ);
}
/**

View File

@ -324,6 +324,7 @@ if (empty($reshook))
$objectlabel = 'ThirdParty';
$permissiontoread = $user->rights->societe->lire;
$permissiontodelete = $user->rights->societe->supprimer;
$permissiontoadd = $user->rights->societe->creer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
@ -595,7 +596,8 @@ $arrayofmassactions = array(
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$typefilter = '';

View File

@ -540,24 +540,24 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$ref_supplier = GETPOST('fourn_ref', 'alpha');
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') {
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -416,10 +416,12 @@ class SupplierProposal extends CommonObject
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);
$pa_ht = price2num($pa_ht);
if ($price_base_type == 'HT')
{
$pu = $pu_ht;
@ -673,7 +675,9 @@ class SupplierProposal extends CommonObject
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);

View File

@ -167,6 +167,7 @@ var pageactions=0;
var place="<?php echo $place; ?>";
var editaction="qty";
var editnumber="";
var invoiceid=0;
/*
var app = this;
@ -483,17 +484,18 @@ function TakeposOrderNotes() {
}
function Refresh() {
console.log("Refresh");
$("#poslines").load("invoice.php?place="+place, function() {
console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
$("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}
function New() {
// If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined
console.log("New with place = <?php echo $place; ?>, js place="+place);
invoiceid = $("#invoiceid").val();
console.log("New with place = <?php echo $place; ?>, js place="+place+", invoiceid="+invoiceid);
$.getJSON('<?php echo DOL_URL_ROOT ?>/takepos/ajax/ajax.php?action=getInvoice&id='+invoiceid, function(data) {
var r;
@ -831,7 +833,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
</div>
<div class="topnav-right">
<div class="login_block_other">
<input type="text" id="search" name="search" onkeyup="Search2(<?php echo $keyCodeForEnter; ?>);" placeholder="<?php echo $langs->trans("Search"); ?>" autofocus>
<input type="text" id="search" name="search" onkeyup="Search2(<?php echo $keyCodeForEnter; ?>);" placeholder="<?php echo $langs->trans("Search"); ?>" autofocus>
<a onclick="ClearSearch();"><span class="fa fa-backspace"></span></a>
<a onclick="window.location.href='<?php echo DOL_URL_ROOT.'/'; ?>';"><span class="fas fa-home"></span></a>
<?php if (empty($conf->dol_use_jmobile)) { ?>

View File

@ -173,11 +173,13 @@ if ($action == 'valid' && $user->rights->facture->creer)
if ($invoice->total_ttc < 0) {
$invoice->type = $invoice::TYPE_CREDIT_NOTE;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE";
$sql .= " fk_soc = ".((int) $invoice->socid);
$sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE;
$sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED;
$sql .= " ORDER BY rowid DESC";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
@ -572,16 +574,9 @@ if ($action == "deleteline") {
}
}
// Action to delete or discard an invoice
if ($action == "delete") {
// $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works.
/*$reg = array();
if (preg_match('/^(\d+)-(\d+)$/', $place, $reg)) {
$place = $reg[1];
var_dump($place);
}*/
if ($placeid > 0) {
$result = $invoice->fetch($placeid);
@ -599,7 +594,9 @@ if ($action == "delete") {
}
}
$sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]};
$sql = "UPDATE ".MAIN_DB_PREFIX."facture";
$sql .= " SET fk_soc=".$conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}.", ";
$sql .= " datec = '".$db->idate(dol_now())."'";
$sql .= " WHERE ref='(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
$resql1 = $db->query($sql);
@ -1003,7 +1000,7 @@ function CreditNote() {
$( document ).ready(function() {
console.log("Set customer info and sales in header");
console.log("Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
<?php
$s = $langs->trans("Customer");
@ -1018,25 +1015,36 @@ $( document ).ready(function() {
<?php
$sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%' AND entity IN (".getEntity('invoice').")";
if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
// By default, only invoices with a ref not already defined can in list of open invoice we can edit.
$sql .= " WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION["takeposterminal"])."-0%' AND entity IN (".getEntity('invoice').")";
} else {
// If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
$sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
$sql .= " AND module_source = 'takepos'";
$sql .= " AND entity IN (".getEntity('invoice').")";
}
$sql .= $db->order('datec', 'ASC');
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
echo '$("#customerandsales").append(\'';
echo '<a class="valignmiddle" onclick="place=\\\'';
echo '<a class="valignmiddle" title="'.dol_escape_js($langs->trans("SaleStartedAt", dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'))).'" onclick="place=\\\'';
$num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
echo $num_sale;
if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale);
echo '\\\';Refresh();">';
echo '\\\'; invoiceid=\\\'';
echo $obj->rowid;
echo '\\\'; Refresh();">';
if ($placeid == $obj->rowid) echo "<b>";
echo date('H:i', strtotime($obj->datec));
echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
if ($placeid == $obj->rowid) echo "</b>";
echo '</a>\');';
}
echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-';
echo $max_sale + 1;
echo '\\\';Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
echo '\\\'; invoiceid=0; Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
} else {
dol_print_error($db);
}

View File

@ -1159,40 +1159,7 @@ class User extends CommonObject
public function setCategories($categories)
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$type_categ = Categorie::TYPE_USER;
// Handle single category
if (!is_array($categories)) {
$categories = array($categories);
}
// Get current categories
$c = new Categorie($this->db);
$existing = $c->containing($this->id, $type_categ, 'id');
// Diff
if (is_array($existing)) {
$to_del = array_diff($existing, $categories);
$to_add = array_diff($categories, $existing);
} else {
$to_del = array(); // Nothing to delete
$to_add = $categories;
}
// Process
foreach ($to_del as $del) {
if ($c->fetch($del) > 0) {
$c->del_type($this, $type_categ);
}
}
foreach ($to_add as $add) {
if ($c->fetch($add) > 0) {
$c->add_type($this, $type_categ);
}
}
return;
return parent::setCategoriesCommon($categories, Categorie::TYPE_USER);
}
/**
@ -1806,7 +1773,7 @@ class User extends CommonObject
$adh->pass = $this->pass;
$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
//$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
$adh->address = $this->address;
$adh->town = $this->town;

View File

@ -422,9 +422,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$arrayofmassactions = array();
if ($permissiontoadd) $arrayofmassactions['disable'] = $langs->trans("DisableUser");
if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactivate");
if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
//if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
@ -647,7 +648,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
$arrayofselected = array();
$arrayofselected = is_array($toselect) ? $toselect : array();
while ($i < ($limit ? min($num, $limit) : $num))
{
$obj = $db->fetch_object($resql);

View File

@ -270,10 +270,10 @@ function getContact($authentication, $id, $ref_ext)
if ($result > 0)
{
// Only internal user who have contact read permission
// Or for external user who have contact read permission, with restrict on societe_id
// Or for external user who have contact read permission, with restrict on socid
if (
$fuser->rights->societe->contact->lire && !$fuser->societe_id
|| ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid))
$fuser->rights->societe->contact->lire && !$fuser->socid
|| ($fuser->rights->societe->contact->lire && ($fuser->socid == $contact->socid))
) {
$contact_result_fields = array(
'id' => $contact->id,

View File

@ -364,10 +364,11 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
$objectresp = array();
$errorcode = ''; $errorlabel = '';
$error = 0;
$socid = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
@ -387,10 +388,10 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '')
if ($result > 0)
{
// Security for external user
if ($socid && ($socid != $order->socid))
if ($socid && $socid != $order->socid)
{
$error++;
$errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.'User does not have permission for this request';
$errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request';
}
if (!$error)
@ -516,7 +517,7 @@ function getOrdersForThirdParty($authentication, $idthirdparty)
$error = 0;
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && empty($idthirdparty))

View File

@ -208,7 +208,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
$fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
if ($fuser->societe_id) $socid = $fuser->societe_id;
if ($fuser->socid) $socid = $fuser->socid;
// Check parameters
if (!$error && (!$file || !$modulepart))
@ -234,7 +234,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
$original_file = $check_access['original_file'];
// Basic protection (against external users only)
if ($fuser->societe_id > 0)
if ($fuser->socid > 0)
{
if ($sqlprotectagainstexternals)
{
@ -246,7 +246,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '')
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($fuser->societe_id != $obj->fk_soc)
if ($fuser->socid != $obj->fk_soc)
{
$accessallowed = 0;
break;

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