diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 2c79a0bb3444aa3d3da5fd2b35e9ef6c207916a2..fee53c412b8e830df62d3aab5b63835a313c53fb 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -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').' '; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 0e4f12104199bb8395d5336cbab2c87ab954d28e..ecf4b16212b15b754975c3b27d21a27e92ea3e2d 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -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(); diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php index b4816b10c6130cd473decb735dff76275377f6b3..ae74344ccf8289968059a8cb0a440775f1949ad4 100644 --- a/htdocs/compta/salaries/fiche.php +++ b/htdocs/compta/salaries/fiche.php @@ -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