Fix: [ bug #1383 ] When add a salary payment - In bank, link "user"
doesn't work
This commit is contained in:
parent
d4534f4a0b
commit
76330ad04a
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
@ -267,7 +267,7 @@ if ($result)
|
||||
if ($action == 'delete_categ')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
|
||||
@ -341,6 +341,12 @@ if ($result)
|
||||
print $langs->trans("VATPayment");
|
||||
print '</a>';
|
||||
}
|
||||
else if ($links[$key]['type']=='payment_salary') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/salaries/fiche.php?id='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowPaymentSalary'),'payment').' ';
|
||||
print $langs->trans("SalaryPayment");
|
||||
print '</a>';
|
||||
}
|
||||
else if ($links[$key]['type']=='member') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowMember'),'user').' ';
|
||||
@ -353,6 +359,12 @@ if ($result)
|
||||
print $langs->trans("TransactionOnTheOtherAccount");
|
||||
print '</a>';
|
||||
}
|
||||
else if ($links[$key]['type']=='user') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche?id='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowUser'),'user').' ';
|
||||
print $langs->trans("User");
|
||||
print '</a>';
|
||||
}
|
||||
else {
|
||||
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
||||
print img_object('','generic').' ';
|
||||
|
||||
@ -359,20 +359,12 @@ class PaymentSalary extends CommonObject
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO should be called payment_salary
|
||||
$ok=1;
|
||||
|
||||
// Start triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
// End triggers
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
|
||||
|
||||
if ($this->id > 0)
|
||||
{
|
||||
$ok=1;
|
||||
if (! empty($conf->banque->enabled) && ! empty($this->amount))
|
||||
{
|
||||
// Insert into llx_bank
|
||||
@ -406,42 +398,53 @@ class PaymentSalary extends CommonObject
|
||||
$ok=0;
|
||||
}
|
||||
|
||||
// Add link 'payment_salary' in bank_url between payment and bank transaction
|
||||
$url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id=';
|
||||
if ($ok)
|
||||
{
|
||||
// Add link 'payment_salary' in bank_url between payment and bank transaction
|
||||
$url=DOL_URL_ROOT.'/compta/salaries/fiche.php?id=';
|
||||
|
||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error=$acc->error;
|
||||
$ok=0;
|
||||
}
|
||||
}
|
||||
|
||||
$fuser=new User($this->db);
|
||||
$fuser->fetch($this->fk_user);
|
||||
|
||||
// Add link 'user' in bank_url between operation and bank transaction
|
||||
$result=$acc->add_url_line(
|
||||
$bank_line_id,
|
||||
$this->fk_user,
|
||||
DOL_URL_ROOT.'/user/fiche.php?id=',
|
||||
$langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'),
|
||||
'(User)',
|
||||
'user'
|
||||
);
|
||||
|
||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
|
||||
if ($result <= 0)
|
||||
{
|
||||
$this->error=$acc->error;
|
||||
$ok=0;
|
||||
}
|
||||
|
||||
// Add link 'user' in bank_url between operation and bank transaction
|
||||
$linkaddedforthirdparty=array();
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
$sal = new PaymentSalary($this->db);
|
||||
|
||||
$sal->fetch($key);
|
||||
$sal->fetch_user($this->fk_user);
|
||||
|
||||
if (! in_array($sal->user->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
|
||||
{
|
||||
$result=$acc->add_url_line(
|
||||
$bank_line_id,
|
||||
$sal->user->id,
|
||||
DOL_URL_ROOT.'/user/fiche.php?id=',
|
||||
$sal->user->lastname,
|
||||
'user'
|
||||
);
|
||||
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
$linkaddedforthirdparty[$sal->user->id]=$sal->user->id; // Mark as done for this thirdparty
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Start triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
// End triggers
|
||||
|
||||
}
|
||||
else $ok=0;
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($ok)
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
@ -78,6 +78,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
$sal->note=GETPOST("note");
|
||||
$sal->type_payment=GETPOST("paymenttype");
|
||||
$sal->num_payment=GETPOST("num_payment");
|
||||
$sal->fk_user_creat=$user->id;
|
||||
|
||||
if (empty($datep) || empty($datesp) || empty($dateep))
|
||||
{
|
||||
@ -215,11 +216,11 @@ if ($action == 'create')
|
||||
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
|
||||
print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add');
|
||||
print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||
print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add');
|
||||
print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
|
||||
Loading…
Reference in New Issue
Block a user