NEW Can edit account on miscellaneous payment (if not transfered)
This commit is contained in:
parent
ec45cb23ac
commit
8dc1c0c7c2
@ -828,4 +828,36 @@ class PaymentVarious extends CommonObject
|
||||
$return .= '</div>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return General accounting account with defined length (used for product and miscellaneous)
|
||||
*
|
||||
* @param string $account General accounting account
|
||||
* @return string String with defined length
|
||||
*/
|
||||
public function lengthAccountg($account)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
/*
|
||||
if (isModEnabled('accounting')) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $valuetoshow, 1);
|
||||
}*/
|
||||
|
||||
return length_accountg($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Auxiliary accounting account of thirdparties with defined length
|
||||
*
|
||||
* @param string $account Auxiliary accounting account
|
||||
* @return string String with defined length
|
||||
*/
|
||||
public function lengthAccounta($account)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
return length_accounta($account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -83,14 +84,8 @@ if ($reshook < 0) {
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Link to a project
|
||||
if ($action == 'classin' && $user->rights->banque->modifier) {
|
||||
$object->fetch($id);
|
||||
$object->setProject(GETPOST('projectid'));
|
||||
}
|
||||
|
||||
if ($cancel) {
|
||||
if ($action != 'addlink') {
|
||||
if ($action != 'addlink' && $action != 'setaccountancy_code' && $action != 'setsubledger_account') {
|
||||
$urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
@ -101,6 +96,12 @@ if (empty($reshook)) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
// Link to a project
|
||||
if ($action == 'classin' && $user->rights->banque->modifier) {
|
||||
$object->fetch($id);
|
||||
$object->setProject(GETPOST('projectid'));
|
||||
}
|
||||
|
||||
if ($action == 'add') {
|
||||
$error = 0;
|
||||
|
||||
@ -214,6 +215,22 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setaccountancy_code') {
|
||||
$db->begin();
|
||||
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$object->accountancy_code = GETPOST('accountancy_code', 'alpha');
|
||||
|
||||
$res = $object->update($user);
|
||||
if ($res > 0) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setsubledger_account') {
|
||||
$db->begin();
|
||||
|
||||
@ -622,25 +639,38 @@ if ($id) {
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span></td></tr>';
|
||||
|
||||
// Accountancy code
|
||||
// Account of Chart of account
|
||||
/*
|
||||
print '<tr><td class="nowrap">';
|
||||
print $langs->trans("AccountAccounting");
|
||||
print $form->editfieldkey('AccountAccounting', 'account', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print '</td><td>';
|
||||
if (isModEnabled('accounting')) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch('', $object->accountancy_code, 1);
|
||||
|
||||
print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
|
||||
if ($action == 'editaccount') {
|
||||
if (isModEnabled('accounting')) {
|
||||
print $formaccounting->select_account($object->accountancy_code, 'accountancy_code', 1, null, 1, 1);
|
||||
} else { // For external software
|
||||
print '<input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
|
||||
}
|
||||
} else {
|
||||
print $object->accountancy_code;
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
print length_accounta($object->accountancy_code);
|
||||
}*/
|
||||
$editvalue = '';
|
||||
if (isModEnabled('accounting')) {
|
||||
$editvalue = $formaccounting->select_account($object->accountancy_code, 'accountancy_code', 1, null, 1, 1);
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
print '<tr><td class="nowrap">';
|
||||
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print '</td><td>';
|
||||
print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'asis', $editvalue, 0, null, '', 1, 'lengthAccountg');
|
||||
print '</td></tr>';
|
||||
|
||||
// Subledger account
|
||||
print '<tr><td class="nowrap">';
|
||||
print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print '</td><td>';
|
||||
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
|
||||
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0, null, '', 1, 'lengthAccounta');
|
||||
print '</td></tr>';
|
||||
|
||||
$bankaccountnotfound = 0;
|
||||
|
||||
@ -191,23 +191,23 @@ class Form
|
||||
/**
|
||||
* Output value of a field for an editable field
|
||||
*
|
||||
* @param string $text Text of label (not used in this function)
|
||||
* @param string $htmlname Name of select field
|
||||
* @param string $value Value to show/edit
|
||||
* @param object $object Object (that we want to show)
|
||||
* @param boolean $perm Permission to allow button to edit parameter
|
||||
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
|
||||
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value
|
||||
* @param object $extObject External object ???
|
||||
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
|
||||
* @param string $moreparam More param to add on the form on action href URL parameter
|
||||
* @param int $notabletag Do no output table tags
|
||||
* @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email')
|
||||
* @param string $paramid Key of parameter for id ('id', 'socid')
|
||||
* @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date)
|
||||
* @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1)
|
||||
* @param string $editaction [=''] use GETPOST default action or set action to edit mode
|
||||
* @return string HTML edit field
|
||||
* @param string $text Text of label (not used in this function)
|
||||
* @param string $htmlname Name of select field
|
||||
* @param string $value Value to show/edit
|
||||
* @param object $object Object (that we want to show)
|
||||
* @param boolean $perm Permission to allow button to edit parameter
|
||||
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
|
||||
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value, or a select combo). Use '' to use same than $value
|
||||
* @param object $extObject External object ???
|
||||
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
|
||||
* @param string $moreparam More param to add on the form on action href URL parameter
|
||||
* @param int $notabletag Do no output table tags
|
||||
* @param string $formatfunc Call a specific method of $object->$formatfunc to output field in view mode (For example: 'dol_print_email')
|
||||
* @param string $paramid Key of parameter for id ('id', 'socid')
|
||||
* @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date)
|
||||
* @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1)
|
||||
* @param string $editaction [=''] use GETPOST default action or set action to edit mode
|
||||
* @return string HTML edit field
|
||||
*/
|
||||
public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '')
|
||||
{
|
||||
@ -310,6 +310,8 @@ class Form
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ? '' : $tmp[2]), (empty($tmp[3]) ? '100' : $tmp[3]), (empty($tmp[1]) ? 'dolibarr_notes' : $tmp[1]), 'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true : false) : true), true, (empty($tmp[6]) ? '20' : $tmp[6]), (empty($tmp[7]) ? '100' : $tmp[7]));
|
||||
$ret .= $doleditor->Create(1);
|
||||
} elseif ($typeofdata == 'asis') {
|
||||
$ret .= ($editvalue ? $editvalue : $value);
|
||||
}
|
||||
if (empty($notabletag)) {
|
||||
$ret .= '</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user