forked from Wavyzz/dolibarr
NEW: Add category to bank transaction in various payment
This commit is contained in:
@@ -63,6 +63,7 @@ class PaymentVarious extends CommonObject
|
||||
public $amount;
|
||||
public $type_payment;
|
||||
public $num_payment;
|
||||
public $category_transaction;
|
||||
|
||||
/**
|
||||
* @var string various payments label
|
||||
@@ -414,13 +415,13 @@ class PaymentVarious extends CommonObject
|
||||
$sign=1;
|
||||
if ($this->sens == '0') $sign=-1;
|
||||
|
||||
$bank_line_id = $acc->addline(
|
||||
$bank_line_id = $acc->addline(
|
||||
$this->datep,
|
||||
$this->type_payment,
|
||||
$this->label,
|
||||
$sign * abs($this->amount),
|
||||
$this->num_payment,
|
||||
'',
|
||||
($category_transaction > 0 ? $category_transaction : 0),
|
||||
$user
|
||||
);
|
||||
|
||||
|
||||
@@ -45,14 +45,15 @@ $action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$accountid=GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
|
||||
$label=GETPOST("label", "alpha");
|
||||
$sens=GETPOST("sens", "int");
|
||||
$amount=GETPOST("amount", "alpha");
|
||||
$paymenttype=GETPOST("paymenttype", "int");
|
||||
$accountancy_code=GETPOST("accountancy_code", "alpha");
|
||||
$subledger_account=GETPOST("subledger_account", "alpha");
|
||||
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
|
||||
$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0;
|
||||
$label = GETPOST("label", "alpha");
|
||||
$sens = GETPOST("sens", "int");
|
||||
$amount = GETPOST("amount", "alpha");
|
||||
$paymenttype = GETPOST("paymenttype", "int");
|
||||
$accountancy_code = GETPOST("accountancy_code", "alpha");
|
||||
$subledger_account = GETPOST("subledger_account", "alpha");
|
||||
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
|
||||
$cat1 = GETPOST("cat1", 'alpha');
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid", "int");
|
||||
@@ -64,8 +65,6 @@ $object = new PaymentVarious($db);
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('variouscard','globalcard'));
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
@@ -113,6 +112,7 @@ if (empty($reshook))
|
||||
$object->type_payment=GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0;
|
||||
$object->num_payment=GETPOST("num_payment", 'alpha');
|
||||
$object->fk_user_author=$user->id;
|
||||
$object->category_transaction=GETPOST("cat1", 'alpha');
|
||||
|
||||
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : "";
|
||||
$object->subledger_account=GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : "";
|
||||
@@ -240,6 +240,16 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
// Load bank groups
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
|
||||
$bankcateg = new BankCateg($db);
|
||||
|
||||
foreach ($bankcateg->fetchAll() as $bankcategory) {
|
||||
$options[$bankcategory->id] = $bankcategory->label;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Create mode */
|
||||
@@ -259,7 +269,7 @@ if ($action == 'create')
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Date payment
|
||||
print '<tr><td>';
|
||||
print '<tr><td class="titlefieldcreate">';
|
||||
print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
print $form->selectDate((empty($datep)?-1:$datep), "datep", '', '', '', 'add', 1, 1);
|
||||
print '</td></tr>';
|
||||
@@ -314,17 +324,50 @@ if ($action == 'create')
|
||||
print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
|
||||
}
|
||||
|
||||
// Category
|
||||
if (is_array($options) && count($options))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Rubrique").'</td><td>';
|
||||
print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
// Associated project
|
||||
$langs->load("projects");
|
||||
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$numproject=$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
// Accountancy account
|
||||
if (! empty($conf->accounting->enabled))
|
||||
{
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
|
||||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
|
||||
print '</td></tr>';
|
||||
}
|
||||
else // For external software
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
|
||||
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code" value="'.$accountancy_code.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
@@ -351,26 +394,6 @@ if ($action == 'create')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
// Associated project
|
||||
$langs->load("projects");
|
||||
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$numproject=$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
Reference in New Issue
Block a user