Fix and uniformize code for payment of salaries.

This commit is contained in:
Laurent Destailleur 2014-03-25 21:35:52 +01:00
parent 4828d1e89a
commit 59042a30e1
7 changed files with 540 additions and 568 deletions

View File

@ -185,7 +185,7 @@ if ($_GET["action"] == 'create')
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$charge->lib."</td></tr>\n"; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$charge->lib."</td></tr>\n";
print '<tr><td>'.$langs->trans("DateDue")."</td><td colspan=\"2\">".dol_print_date($charge->date_ech,'day')."</td></tr>\n"; print '<tr><td>'.$langs->trans("DateDue")."</td><td colspan=\"2\">".dol_print_date($charge->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td colspan=\"2\"><b>".price($charge->amount).'</b> '.$langs->trans("Currency".$conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
$sql = "SELECT sum(p.amount) as total"; $sql = "SELECT sum(p.amount) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
@ -197,8 +197,8 @@ if ($_GET["action"] == 'create')
$sumpaid = $obj->total; $sumpaid = $obj->total;
$db->free(); $db->free();
} }
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td colspan="2"><b>'.price($sumpaid).'</b> '.$langs->trans("Currency".$conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td colspan="2">'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans("RemainderToPay")."</td><td colspan=\"3\"><b>".price($total - $sumpaid).'</b> '.$langs->trans("Currency".$conf->currency).'</td></tr>'; print "<tr><td valign=\"top\">".$langs->trans("RemainderToPay")."</td><td colspan=\"3\">".price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("Payment").'</td>'; print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("Payment").'</td>';
@ -223,9 +223,10 @@ if ($_GET["action"] == 'create')
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '',1); // Show opend bank account list
print '</td></tr>'; print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero'); print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print "<td><input name=\"num_paiement\" type=\"text\"></td></tr>\n"; print '<td><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
/* /*
* Autres charges impayees * Autres charges impayees
@ -238,7 +239,7 @@ if ($_GET["action"] == 'create')
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
//print '<td>'.$langs->trans("SocialContribution").'</td>'; //print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td align="left">'.$langs->trans("DateDue").'</td>'; print '<td align="left">'.$langs->trans("DateDue").'</td>';
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; print '<td align="right">'.$langs->trans("Amount").'</td>';
print '<td align="right">'.$langs->trans("AlreadyPaid").'</td>'; print '<td align="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td align="right">'.$langs->trans("RemainderToPay").'</td>'; print '<td align="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>'; print '<td align="right">'.$langs->trans("Amount").'</td>';
@ -296,7 +297,7 @@ if ($_GET["action"] == 'create')
{ {
// Print total // Print total
print "<tr ".$bc[!$var].">"; print "<tr ".$bc[!$var].">";
print '<td colspan="2" align="left">'.$langs->trans("TotalTTC").':</td>'; print '<td colspan="2" align="left">'.$langs->trans("Total").':</td>';
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>"; print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
print "<td align=\"right\"><b>".price($totalrecu)."</b></td>"; print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
print "<td align=\"right\"><b>".price($total_ttc - $totalrecu)."</b></td>"; print "<td align=\"right\"><b>".price($total_ttc - $totalrecu)."</b></td>";
@ -304,29 +305,18 @@ if ($_GET["action"] == 'create')
print "</tr>\n"; print "</tr>\n";
} }
print "</table></td></tr>\n"; print "</table></td></tr>\n";
// }
// $db->free();
// }
// else
// {
// print $sql ."<br>".$db->error();
// }
/*
*
*/
print "</table>"; print "</table>";
print '<br><center>'; print '<br><center>';
//print '<tr><td colspan="3" align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp; &nbsp;'; print '&nbsp; &nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>'; print '</center>';
//print '</td></tr>';
print "</form>\n"; print "</form>\n";
// }
} }

View File

@ -1,19 +1,19 @@
<?php <?php
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> /* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/compta/salaries/class/paymentsalary.class.php * \file htdocs/compta/salaries/class/paymentsalary.class.php
@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/** /**
* Put here description of your class * Class to manage salary payments
*/ */
class PaymentSalary extends CommonObject class PaymentSalary extends CommonObject
{ {
@ -41,6 +41,8 @@ class PaymentSalary extends CommonObject
var $datep; var $datep;
var $datev; var $datev;
var $amount; var $amount;
var $type_payment;
var $num_payment;
var $label; var $label;
var $datesp; var $datesp;
var $dateep; var $dateep;
@ -50,7 +52,6 @@ class PaymentSalary extends CommonObject
var $fk_user_modif; var $fk_user_modif;
/** /**
* Constructor * Constructor
* *
@ -64,86 +65,6 @@ class PaymentSalary extends CommonObject
return 1; return 1;
} }
/**
* Create in database
*
* @param User $user User that create
* @return int <0 if KO, >0 if OK
*/
function create($user)
{
global $conf, $langs;
$error=0;
// Clean parameters
$this->fk_user=trim($this->fk_user);
$this->amount=trim($this->amount);
$this->label=trim($this->label);
$this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary(";
$sql.= "tms,";
$sql.= "fk_user,";
$sql.= "datep,";
$sql.= "datev,";
$sql.= "amount,";
$sql.= "label,";
$sql.= "datesp,";
$sql.= "dateep,";
$sql.= "note,";
$sql.= "fk_bank,";
$sql.= "fk_user_creat,";
$sql.= "fk_user_modif";
$sql.= ") VALUES (";
$sql.= " '".$this->db->idate($this->tms).",";
$sql.= " '".$this->fk_user."',";
$sql.= " '".$this->db->idate($this->datep)."',";
$sql.= " '".$this->db->idate($this->datev)."',";
$sql.= " '".$this->amount."',";
$sql.= " '".$this->label."',";
$sql.= " '".$this->db->idate($this->datesp)."',";
$sql.= " '".$this->db->idate($this->dateep)."',";
$sql.= " '".$this->note."',";
$sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->fk_bank."'").",";
$sql.= " '".$this->fk_user_creat."',";
$sql.= " '".$this->fk_user_modif."'";
$sql.= ")";
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
// Appel des 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; }
// Fin appel triggers
return $this->id;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
}
/** /**
* Update database * Update database
* *
@ -181,11 +102,13 @@ class PaymentSalary extends CommonObject
$sql.= " datep=".$this->db->idate($this->datep).","; $sql.= " datep=".$this->db->idate($this->datep).",";
$sql.= " datev=".$this->db->idate($this->datev).","; $sql.= " datev=".$this->db->idate($this->datev).",";
$sql.= " amount='".$this->amount."',"; $sql.= " amount='".$this->amount."',";
$sql.= " fk_typepayment=".$this->fk_typepayment."',";
$sql.= " num_payment='".$this->num_payment."',";
$sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " label='".$this->db->escape($this->label)."',";
$sql.= " datesp=".$this->db->idate($this->datesp).","; $sql.= " datesp=".$this->db->idate($this->datesp).",";
$sql.= " dateep=".$this->db->idate($this->dateep).","; $sql.= " dateep=".$this->db->idate($this->dateep).",";
$sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " note='".$this->db->escape($this->note)."',";
$sql.= " fk_bank='".$this->fk_bank."',"; $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->fk_bank."'":"null").",";
$sql.= " fk_user_creat='".$this->fk_user_creat."',"; $sql.= " fk_user_creat='".$this->fk_user_creat."',";
$sql.= " fk_user_modif='".$this->fk_user_modif."'"; $sql.= " fk_user_modif='".$this->fk_user_modif."'";
@ -206,7 +129,9 @@ class PaymentSalary extends CommonObject
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf); $result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers // Fin appel triggers
} }
@ -232,6 +157,8 @@ class PaymentSalary extends CommonObject
$sql.= " s.datep,"; $sql.= " s.datep,";
$sql.= " s.datev,"; $sql.= " s.datev,";
$sql.= " s.amount,"; $sql.= " s.amount,";
$sql.= " s.fk_typepayment,";
$sql.= " s.num_payment,";
$sql.= " s.label,"; $sql.= " s.label,";
$sql.= " s.datesp,"; $sql.= " s.datesp,";
$sql.= " s.dateep,"; $sql.= " s.dateep,";
@ -262,6 +189,8 @@ class PaymentSalary extends CommonObject
$this->datep = $this->db->jdate($obj->datep); $this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev); $this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->type_payement = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label; $this->label = $obj->label;
$this->datesp = $this->db->jdate($obj->datesp); $this->datesp = $this->db->jdate($obj->datesp);
$this->dateep = $this->db->jdate($obj->dateep); $this->dateep = $this->db->jdate($obj->dateep);
@ -314,7 +243,9 @@ class PaymentSalary extends CommonObject
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers // Fin appel triggers
return 1; return 1;
@ -352,12 +283,10 @@ class PaymentSalary extends CommonObject
* @param User $user Object user that insert * @param User $user Object user that insert
* @return int <0 if KO, rowid in tva table if OK * @return int <0 if KO, rowid in tva table if OK
*/ */
function addPayment($user) function create($user)
{ {
global $conf,$langs; global $conf,$langs;
$this->db->begin();
// Clean parameters // Clean parameters
$this->amount=price2num(trim($this->amount)); $this->amount=price2num(trim($this->amount));
@ -382,19 +311,23 @@ class PaymentSalary extends CommonObject
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account")); $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
return -6; return -6;
} }
if (! empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
return -6; return -6;
} }
$this->db->begin();
// Insertion dans table des paiement salaires // Insertion dans table des paiement salaires
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user";
$sql.= ", datep"; $sql.= ", datep";
$sql.= ", datev"; $sql.= ", datev";
$sql.= ", amount"; $sql.= ", amount";
if ($this->note) $sql.=", note"; $sql.= ", fk_typepayment";
if ($this->label) $sql.=", label"; $sql.= ", num_payment";
$sql.=", note";
$sql.=", label";
$sql.= ", datesp"; $sql.= ", datesp";
$sql.= ", dateep"; $sql.= ", dateep";
$sql.= ", fk_user_creat"; $sql.= ", fk_user_creat";
@ -406,8 +339,10 @@ class PaymentSalary extends CommonObject
$sql.= ", '".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount; $sql.= ", ".$this->amount;
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", ".$this->type_payment;
if ($this->label) $sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", ".$this->num_payment;
$sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", '".$this->db->idate($this->datesp)."'"; $sql.= ", '".$this->db->idate($this->datesp)."'";
$sql.= ", '".$this->db->idate($this->dateep)."'"; $sql.= ", '".$this->db->idate($this->dateep)."'";
$sql.= ", '".$user->id."'"; $sql.= ", '".$user->id."'";
@ -415,7 +350,7 @@ class PaymentSalary extends CommonObject
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::addPayment sql=".$sql); dol_syslog(get_class($this)."::create sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -424,8 +359,10 @@ class PaymentSalary extends CommonObject
// Appel des triggers // Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SALARY_ADDPAYMENT',$this,$user,$langs,$conf); $result=$interface->run_triggers('PAYMENT_SALARY_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers // Fin appel triggers
if ($this->id > 0) if ($this->id > 0)
@ -444,10 +381,10 @@ class PaymentSalary extends CommonObject
// Add link 'payment_salary' in bank_url between payment and bank transaction // Add link 'payment_salary' in bank_url between payment and bank transaction
$bank_line_id = $acc->addline( $bank_line_id = $acc->addline(
$this->datep, $this->datep,
$this->paymenttype, $this->type_payment,
$this->label, $this->label,
-abs($this->amount), -abs($this->amount),
'', $this->num_payment,
'', '',
$user $user
); );

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> /* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +18,7 @@
/** /**
* \file htdocs/compta/salaries/fiche.php * \file htdocs/compta/salaries/fiche.php
* \ingroup tax * \ingroup salaries
* \brief Page of salaries payments * \brief Page of salaries payments
*/ */
@ -59,25 +60,45 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
{ {
$db->begin(); $error=0;
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
$datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
$sal->accountid=GETPOST("accountid");
$sal->accountid=$_POST["accountid"]; $sal->fk_user=GETPOST("fk_user");
$sal->paymenttype=$_POST["paiementtype"];
$sal->fk_user=$_POST["fk_user"];
$sal->datev=$datev; $sal->datev=$datev;
$sal->datep=$datep; $sal->datep=$datep;
$sal->amount=$_POST["amount"]; $sal->amount=price2num(GETPOST("amount"));
$sal->label=$_POST["label"]; $sal->label=GETPOST("label");
$sal->datesp=$datesp; $sal->datesp=$datesp;
$sal->dateep=$dateep; $sal->dateep=$dateep;
$sal->type_payment=GETPOST("paymenttype");
$sal->num_payment=GETPOST('num_payment');
$ret=$sal->addPayment($user); if (empty($sal->fk_user) || $sal->fk_user < 0)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Employee")),'errors');
$error++;
}
if (empty($sal->type_payment) || $sal->type_payment < 0)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentMode")),'errors');
$error++;
}
if (empty($sal->amount))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")),'errors');
$error++;
}
if (! $error)
{
$db->begin();
$ret=$sal->create($user);
if ($ret > 0) if ($ret > 0)
{ {
$db->commit(); $db->commit();
@ -90,6 +111,9 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
setEventMessage($sal->error, 'errors'); setEventMessage($sal->error, 'errors');
$action="create"; $action="create";
} }
}
$action='create';
} }
if ($action == 'delete') if ($action == 'delete')
@ -137,8 +161,8 @@ if ($action == 'delete')
/* /*
* View * View
*/ */
llxHeader(); llxHeader();
@ -211,7 +235,7 @@ if ($action == 'create')
print '</td></tr>'; print '</td></tr>';
// Amount // Amount
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.$_POST["amount"].'"></td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.GETPOST("amount").'"></td></tr>';
// Bank // Bank
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
@ -220,11 +244,18 @@ if ($action == 'create')
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant $form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print '</td></tr>'; print '</td></tr>';
}
// TYpe payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>'; print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements($_POST["paiementtype"], "paiementtype"); $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
print "</td>\n"; print "</td>\n";
print "</tr>"; print "</tr>";
}
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
// Other attributes // Other attributes
$parameters=array('colspan' => ' colspan="1"'); $parameters=array('colspan' => ' colspan="1"');
@ -293,7 +324,7 @@ if ($id)
print dol_print_date($salpayment->datev,'day'); print dol_print_date($salpayment->datev,'day');
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($salpayment->amount).'</td></tr>'; print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($salpayment->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
{ {
@ -342,7 +373,8 @@ if ($id)
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -17,7 +17,7 @@
/** /**
* \file htdocs/compta/salaries/index.php * \file htdocs/compta/salaries/index.php
* \ingroup tax * \ingroup salaries
* \brief List of salaries payments * \brief List of salaries payments
*/ */
@ -26,6 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
$langs->load("compta"); $langs->load("compta");
$langs->load("salaries"); $langs->load("salaries");
$langs->load("bills");
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -46,8 +47,11 @@ $userstatic = new User($db);
print_fiche_titre($langs->trans("SalariesPayments")); print_fiche_titre($langs->trans("SalariesPayments"));
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm"; $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.num_payment,";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; $sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,";
$sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.rowid = s.fk_user"; $sql.= " WHERE u.rowid = s.fk_user";
$sql.= " AND s.entity = ".$conf->entity; $sql.= " AND s.entity = ".$conf->entity;
$sql.= " ORDER BY dm DESC"; $sql.= " ORDER BY dm DESC";
@ -65,6 +69,7 @@ if ($result)
print "<td>".$langs->trans("Person")."</td>"; print "<td>".$langs->trans("Person")."</td>";
print "<td>".$langs->trans("Label")."</td>"; print "<td>".$langs->trans("Label")."</td>";
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>'; print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle","",$paramlist,"",$sortfield,$sortorder);
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>"; print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
print "</tr>\n"; print "</tr>\n";
$var=1; $var=1;
@ -83,15 +88,18 @@ if ($result)
print "<td>".$userstatic->getNomUrl(1)."</td>\n"; print "<td>".$userstatic->getNomUrl(1)."</td>\n";
print "<td>".dol_trunc($obj->label,40)."</td>\n"; print "<td>".dol_trunc($obj->label,40)."</td>\n";
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n"; print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
$total = $total + $obj->amount; // Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
print "<td align=\"right\">".price($obj->amount)."</td>"; // Amount
print "<td align=\"right\">".price($obj->amount,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "</tr>\n"; print "</tr>\n";
$total = $total + $obj->amount;
$i++; $i++;
} }
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>'; print '<tr class="liste_total"><td colspan="5" class="liste_total">'.$langs->trans("Total").'</td>';
print "<td align=\"right\"><b>".price($total)."</b></td></tr>"; print '<td class="liste_total" align="right">'.price($total,0,$outputlangs,1,-1,-1,$conf->currency)."</td></tr>";
print "</table>"; print "</table>";
$db->free($result); $db->free($result);

View File

@ -226,7 +226,7 @@ if ($action == 'create')
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1); print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
print '</td>'; print '</td>';
print '<td align="right"><input type="text" size="6" name="amount" class="flat"></td>'; print '<td align="right"><input type="text" size="6" name="amount" class="flat" value="'.GETPOST('amount').'"></td>';
print '<td align="center">'; print '<td align="center">';
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);

View File

@ -1044,6 +1044,7 @@ CREATE TABLE llx_expeditiondet_batch (
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--Salary payment in tax module --Salary payment in tax module
--DROP TABLE llx_payment_salary
CREATE TABLE llx_payment_salary ( CREATE TABLE llx_payment_salary (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,
@ -1051,6 +1052,8 @@ CREATE TABLE llx_payment_salary (
datep date, datep date,
datev date, datev date,
amount real NOT NULL DEFAULT 0, amount real NOT NULL DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
label varchar(255), label varchar(255),
datesp date, -- date de début de la période datesp date, -- date de début de la période
dateep date, -- date de fin de la période dateep date, -- date de fin de la période

View File

@ -24,6 +24,8 @@ create table llx_payment_salary
datep date, -- date de paiement datep date, -- date de paiement
datev date, -- date de valeur datev date, -- date de valeur
amount real NOT NULL DEFAULT 0, amount real NOT NULL DEFAULT 0,
fk_typepayment integer NOT NULL,
num_payment varchar(50),
label varchar(255), label varchar(255),
datesp date, -- date de début de la période datesp date, -- date de début de la période
dateep date, -- date de fin de la période dateep date, -- date de fin de la période