NEW Can modify bank account of sepa payment (if file not sent yet)
This commit is contained in:
parent
f0986a0fc0
commit
4bf7c6f84c
@ -71,11 +71,22 @@ $type = $object->type;
|
||||
|
||||
if ($type == 'bank-transfer') {
|
||||
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
|
||||
|
||||
$permissiontoadd = $user->hasRight('paymentbybanktransfer', 'read');
|
||||
$permissiontosend = $user->hasRight('paymentbybanktransfer', 'send');
|
||||
$permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
|
||||
$permissiontodelete = $user->hasRight('paymentbybanktransfer', 'read');
|
||||
} else {
|
||||
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
||||
|
||||
$permissiontoadd = $user->hasRight('prelevement', 'bons', 'read');
|
||||
$permissiontosend = $user->hasRight('prelevement', 'bons', 'send');
|
||||
$permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
|
||||
$permissiontodelete = $user->hasRight('prelevement', 'bons', 'read');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -87,20 +98,13 @@ if ($reshook < 0) {
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'confirm_delete') {
|
||||
$savtype = $object->type;
|
||||
$res = $object->delete($user);
|
||||
if ($res > 0) {
|
||||
if ($savtype == 'bank-transfer') {
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
|
||||
} else {
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
if ($action == 'setbankaccount' && $permissiontoadd) {
|
||||
$object->oldcopy = dol_clone($object);
|
||||
$object->fk_bank_account = GETPOST('fk_bank_account', 'int');
|
||||
$object->update($user);
|
||||
}
|
||||
|
||||
if ($action == 'infotrans' && (($user->rights->prelevement->bons->send && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type == 'bank-transfer'))) {
|
||||
if ($action == 'infotrans' && $permissiontosend) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
@ -133,7 +137,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// Set direct debit order to credited, create payment and close invoices
|
||||
if ($action == 'infocredit' && (($user->rights->prelevement->bons->credit && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type == 'bank-transfer'))) {
|
||||
if ($action == 'infocredit' && $permissiontocreditdebit) {
|
||||
$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
|
||||
|
||||
if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
|
||||
@ -147,6 +151,19 @@ if (empty($reshook)) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $permissiontodelete) {
|
||||
$savtype = $object->type;
|
||||
$res = $object->delete($user);
|
||||
if ($res > 0) {
|
||||
if ($savtype == 'bank-transfer') {
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
|
||||
} else {
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -179,13 +196,6 @@ if ($id > 0 || $ref) {
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
|
||||
|
||||
// Status
|
||||
/*
|
||||
print '<tr><td>'.$langs->trans('Status').'</td>';
|
||||
print '<td>'.$object->getLibStatut(1).'</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
if (!empty($object->date_trans)) {
|
||||
$muser = new User($db);
|
||||
$muser->fetch($object->user_trans);
|
||||
@ -220,20 +230,43 @@ if ($id > 0 || $ref) {
|
||||
$result = $acc->fetch($fk_bank_account);
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
// Bank account
|
||||
$labelofbankfield = "BankToReceiveWithdraw";
|
||||
if ($object->type == 'bank-transfer') {
|
||||
$labelofbankfield = 'BankToPayCreditTransfer';
|
||||
}
|
||||
print $langs->trans($labelofbankfield);
|
||||
//print $langs->trans($labelofbankfield);
|
||||
$caneditbank = $permissiontoadd;
|
||||
if ($object->status != $object::STATUS_DRAFT) {
|
||||
$caneditbank = 0;
|
||||
}
|
||||
/*
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($acc->id > 0) {
|
||||
print $acc->getNomUrl(1);
|
||||
}
|
||||
print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
|
||||
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
|
||||
print '<td>';
|
||||
if (($action != 'editbankaccount') && $caneditbank) {
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editfkbankaccount&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editfkbankaccount') {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'fk_bank_account', 0);
|
||||
} else {
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'none');
|
||||
}
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
// Donwload file
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
$labelfororderfield = 'WithdrawalFile';
|
||||
if ($object->type == 'bank-transfer') {
|
||||
|
||||
@ -70,13 +70,11 @@ class BonPrelevement extends CommonObject
|
||||
public $emetteur_bic;
|
||||
public $emetteur_ics;
|
||||
|
||||
public $date_trans;
|
||||
public $user_trans;
|
||||
public $method_trans;
|
||||
public $user_credit;
|
||||
|
||||
public $total;
|
||||
public $fetched;
|
||||
public $statut; // 0-Wait, 1-Trans, 2-Done
|
||||
public $labelStatus = array();
|
||||
|
||||
public $factures = array();
|
||||
@ -84,15 +82,6 @@ class BonPrelevement extends CommonObject
|
||||
public $invoice_in_error = array();
|
||||
public $thirdparty_in_error = array();
|
||||
|
||||
public $amount;
|
||||
public $note;
|
||||
public $datec;
|
||||
|
||||
public $date_credit;
|
||||
public $user_credit;
|
||||
|
||||
public $type;
|
||||
public $fk_bank_account; // The bank the receipt is generated for
|
||||
|
||||
const STATUS_DRAFT = 0;
|
||||
const STATUS_TRANSFERED = 1;
|
||||
@ -100,6 +89,83 @@ class BonPrelevement extends CommonObject
|
||||
const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
|
||||
|
||||
|
||||
/**
|
||||
* 'type' field format:
|
||||
* 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
|
||||
* 'select' (list of values are in 'options'),
|
||||
* 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]',
|
||||
* 'chkbxlst:...',
|
||||
* 'varchar(x)',
|
||||
* 'text', 'text:none', 'html',
|
||||
* 'double(24,8)', 'real', 'price',
|
||||
* 'date', 'datetime', 'timestamp', 'duration',
|
||||
* 'boolean', 'checkbox', 'radio', 'array',
|
||||
* 'mail', 'phone', 'url', 'password', 'ip'
|
||||
* Note: Filter must be a Dolibarr filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
|
||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
* 'validate' is 1 if need to validate with $this->validateField()
|
||||
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
|
||||
*
|
||||
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
|
||||
*/
|
||||
|
||||
// BEGIN MODULEBUILDER PROPERTIES
|
||||
/**
|
||||
* @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(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,),
|
||||
'ref' => array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150', 'showoncombobox'=>'1',),
|
||||
'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,),
|
||||
'amount' => array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>-1,),
|
||||
'statut' => array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>'1', 'position'=>500, 'notnull'=>0, 'visible'=>-1, 'arrayofkeyval'=>array(0=>'Wait', 1=>'Transfered', 2=>'Credited')),
|
||||
'credite' => array('type'=>'smallint(6)', 'label'=>'Credite', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>-1,),
|
||||
'note' => array('type'=>'text', 'label'=>'Note', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>-1,),
|
||||
'date_trans' => array('type'=>'datetime', 'label'=>'Datetrans', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,),
|
||||
'method_trans' => array('type'=>'smallint(6)', 'label'=>'Methodtrans', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1,),
|
||||
'fk_user_trans' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkusertrans', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
|
||||
'date_credit' => array('type'=>'datetime', 'label'=>'Datecredit', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-1,),
|
||||
'fk_user_credit' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkusercredit', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
|
||||
'type' => array('type'=>'varchar(16)', 'label'=>'Type', 'enabled'=>'1', 'position'=>75, 'notnull'=>0, 'visible'=>-1,),
|
||||
'fk_bank_account' => array('type'=>'integer', 'label'=>'Fkbankaccount', 'enabled'=>'1', 'position'=>80, 'notnull'=>0, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx',),
|
||||
);
|
||||
public $rowid;
|
||||
public $ref;
|
||||
public $datec;
|
||||
public $amount;
|
||||
public $statut;
|
||||
public $credite;
|
||||
public $note;
|
||||
public $date_trans;
|
||||
public $method_trans;
|
||||
public $fk_user_trans;
|
||||
public $date_credit;
|
||||
public $fk_user_credit;
|
||||
public $type;
|
||||
public $fk_bank_account;
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -291,8 +357,6 @@ class BonPrelevement extends CommonObject
|
||||
*/
|
||||
public function fetch($rowid, $ref = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.note";
|
||||
$sql .= ", p.datec as dc";
|
||||
$sql .= ", p.date_trans as date_trans";
|
||||
@ -347,6 +411,18 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
* @param User $user User that modifies
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
return $this->updateCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set direct debit or credit transfer order to "paid" status.
|
||||
|
||||
@ -139,12 +139,13 @@ if ($id > 0 || $ref) {
|
||||
$result = $acc->fetch($fk_bank_account);
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
$labelofbankfield = "BankToReceiveWithdraw";
|
||||
if ($object->type == 'bank-transfer') {
|
||||
$labelofbankfield = 'BankToPayCreditTransfer';
|
||||
}
|
||||
print $langs->trans($labelofbankfield);
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($acc->id > 0) {
|
||||
|
||||
@ -134,12 +134,13 @@ if ($id > 0 || $ref) {
|
||||
$result = $acc->fetch($fk_bank_account);
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
$labelofbankfield = "BankToReceiveWithdraw";
|
||||
if ($object->type == 'bank-transfer') {
|
||||
$labelofbankfield = 'BankToPayCreditTransfer';
|
||||
}
|
||||
print $langs->trans($labelofbankfield);
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($acc->id > 0) {
|
||||
|
||||
@ -128,12 +128,13 @@ if ($id > 0 || $ref) {
|
||||
$result = $acc->fetch($fk_bank_account);
|
||||
}
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
$labelofbankfield = "BankToReceiveWithdraw";
|
||||
if ($object->type == 'bank-transfer') {
|
||||
$labelofbankfield = 'BankToPayCreditTransfer';
|
||||
}
|
||||
print $langs->trans($labelofbankfield);
|
||||
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($acc->id > 0) {
|
||||
|
||||
@ -94,7 +94,7 @@ class Form
|
||||
* @param string $text Text of label or key to translate
|
||||
* @param string $htmlname Name of select field ('edit' prefix will be added)
|
||||
* @param string $preselected Value to show/edit (not used in this function)
|
||||
* @param object $object Object
|
||||
* @param object $object Object (on the page we show)
|
||||
* @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
|
||||
* @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' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
|
||||
* @param string $moreparam More param to add on a href URL.
|
||||
@ -194,7 +194,7 @@ class Form
|
||||
* @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
|
||||
* @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
|
||||
@ -303,6 +303,8 @@ class Form
|
||||
$arraylist[$tmpkey] = $tmp[1];
|
||||
}
|
||||
$ret .= $this->selectarray($htmlname, $arraylist, $value);
|
||||
} elseif (preg_match('/^link/', $typeofdata)) {
|
||||
// TODO Not yet implemented. See code for extrafields
|
||||
} elseif (preg_match('/^ckeditor/', $typeofdata)) {
|
||||
$tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user