NEW Clean code into salary module, debug and add indexes
NEW Can filter on user list and salary payments on user with naural search.
This commit is contained in:
parent
8e09f54a46
commit
43b5209192
@ -94,15 +94,14 @@ if ($conf->salaries->enabled)
|
||||
|
||||
print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', '');
|
||||
|
||||
$sql = "SELECT s.rowid, s.amount, s.label, s.datev as dm, s.salary, u.salary as current_salary";
|
||||
$sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('user',1).")";
|
||||
$sql.= " AND u.rowid = s.fk_user";
|
||||
if ($year > 0)
|
||||
{
|
||||
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
|
||||
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
|
||||
$sql.= " AND s.datev between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
|
||||
$sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
|
||||
$sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."')";
|
||||
}
|
||||
if (preg_match('/^s\./',$sortfield)) $sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
@ -114,11 +113,11 @@ if ($conf->salaries->enabled)
|
||||
$total = 0 ;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="140px"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.dateep","",$param,'width="140px"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
$var=1;
|
||||
@ -130,7 +129,8 @@ if ($conf->salaries->enabled)
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day').'</td>'."\n";
|
||||
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dateep),'day').'</td>'."\n";
|
||||
|
||||
print "<td>".$obj->label."</td>\n";
|
||||
|
||||
@ -141,7 +141,7 @@ if ($conf->salaries->enabled)
|
||||
$sal_static->ref=$obj->rowid;
|
||||
print '<td align="left">'.$sal_static->getNomUrl(1)."</td>\n";
|
||||
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
|
||||
print '<td align="right">'.price($obj->amount)."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ $socid = GETPOST("socid","int");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$sal = new PaymentSalary($db);
|
||||
$object = new PaymentSalary($db);
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('salarycard','globalcard'));
|
||||
@ -66,55 +66,61 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||
$datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
|
||||
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
|
||||
|
||||
$sal->accountid=GETPOST("accountid","int");
|
||||
$sal->fk_user=GETPOST("fk_user","int");
|
||||
$sal->datev=$datev;
|
||||
$sal->datep=$datep;
|
||||
$sal->amount=price2num(GETPOST("amount"));
|
||||
$sal->label=GETPOST("label");
|
||||
$sal->datesp=$datesp;
|
||||
$sal->dateep=$dateep;
|
||||
$sal->note=GETPOST("note");
|
||||
$sal->type_payment=GETPOST("paymenttype");
|
||||
$sal->num_payment=GETPOST("num_payment");
|
||||
$sal->fk_user_creat=$user->id;
|
||||
if (empty($datev)) $datev=$datep;
|
||||
|
||||
$object->accountid=GETPOST("accountid","int");
|
||||
$object->fk_user=GETPOST("fk_user","int");
|
||||
$object->datev=$datev;
|
||||
$object->datep=$datep;
|
||||
$object->amount=price2num(GETPOST("amount"));
|
||||
$object->label=GETPOST("label");
|
||||
$object->datesp=$datesp;
|
||||
$object->dateep=$dateep;
|
||||
$object->note=GETPOST("note");
|
||||
$object->type_payment=GETPOST("paymenttype");
|
||||
$object->num_payment=GETPOST("num_payment");
|
||||
$object->fk_user_creat=$user->id;
|
||||
|
||||
// Set user current salary as ref salaray for the payment
|
||||
$fuser=new User($db);
|
||||
$fuser->fetch(GETPOST("fk_user","int"));
|
||||
$sal->salary=$fuser->salary;
|
||||
$object->salary=$fuser->salary;
|
||||
|
||||
if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($sal->fk_user) || $sal->fk_user < 0)
|
||||
if (empty($object->fk_user) || $object->fk_user < 0)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Employee")),'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($sal->type_payment) || $sal->type_payment < 0)
|
||||
if (empty($object->type_payment) || $object->type_payment < 0)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentMode")),'errors');
|
||||
$error++;
|
||||
}
|
||||
if (empty($sal->amount))
|
||||
if (empty($object->amount))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")),'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! empty($conf->banque->enabled) && ! $object->accountid > 0)
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Account")),'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$ret=$sal->create($user);
|
||||
$ret=$object->create($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$db->commit();
|
||||
@ -124,7 +130,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessage($sal->error, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action="create";
|
||||
}
|
||||
}
|
||||
@ -134,19 +140,19 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$result=$sal->fetch($id);
|
||||
$result=$object->fetch($id);
|
||||
|
||||
if ($sal->rappro == 0)
|
||||
if ($object->rappro == 0)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$ret=$sal->delete($user);
|
||||
$ret=$object->delete($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($sal->fk_bank)
|
||||
if ($object->fk_bank)
|
||||
{
|
||||
$accountline=new AccountLine($db);
|
||||
$result=$accountline->fetch($sal->fk_bank);
|
||||
$result=$accountline->fetch($object->fk_bank);
|
||||
if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
|
||||
}
|
||||
|
||||
@ -158,15 +164,15 @@ if ($action == 'delete')
|
||||
}
|
||||
else
|
||||
{
|
||||
$sal->error=$accountline->error;
|
||||
$object->error=$accountline->error;
|
||||
$db->rollback();
|
||||
setEventMessage($sal->error,'errors');
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
setEventMessage($sal->error,'errors');
|
||||
setEventMessage($object->error,'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -186,8 +192,8 @@ $form = new Form($db);
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$salpayment = new PaymentSalary($db);
|
||||
$result = $salpayment->fetch($id);
|
||||
$object = new PaymentSalary($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db);
|
||||
@ -221,6 +227,8 @@ if ($action == 'create')
|
||||
|
||||
print_fiche_titre($langs->trans("NewSalaryPayment"),'', 'title_accountancy.png');
|
||||
|
||||
dol_fiche_head('', '');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr>";
|
||||
@ -228,7 +236,7 @@ if ($action == 'create')
|
||||
print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateValue").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||
print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -281,7 +289,7 @@ if ($action == 'create')
|
||||
|
||||
print '</table>';
|
||||
|
||||
print "<br>";
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
@ -311,45 +319,45 @@ if ($id)
|
||||
|
||||
print "<tr>";
|
||||
print '<td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $salpayment->ref;
|
||||
print $object->ref;
|
||||
print '</td></tr>';
|
||||
|
||||
// Person
|
||||
print '<tr><td>'.$langs->trans("Person").'</td><td>';
|
||||
$usersal=new User($db);
|
||||
$usersal->fetch($salpayment->fk_user);
|
||||
$usersal->fetch($object->fk_user);
|
||||
print $usersal->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$salpayment->label.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DateStartPeriod").'</td><td colspan="3">';
|
||||
print dol_print_date($salpayment->datesp,'day');
|
||||
print dol_print_date($object->datesp,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateEndPeriod").'</td><td colspan="3">';
|
||||
print dol_print_date($salpayment->dateep,'day');
|
||||
print dol_print_date($object->dateep,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
|
||||
print dol_print_date($salpayment->datep,'day');
|
||||
print dol_print_date($object->datep,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateValue").'</td><td colspan="3">';
|
||||
print dol_print_date($salpayment->datev,'day');
|
||||
print dol_print_date($object->datev,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($salpayment->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
if ($salpayment->fk_account > 0)
|
||||
if ($object->fk_account > 0)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($salpayment->fk_bank);
|
||||
$bankline->fetch($object->fk_bank);
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
@ -362,21 +370,22 @@ if ($id)
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$salpayment,$action); // Note that $action and $object may have been modified by hook
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
* Boutons d'actions
|
||||
*/
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
if ($salpayment->rappro == 0)
|
||||
* Action buttons
|
||||
*/
|
||||
print '<div class="tabsAction">'."\n";
|
||||
if ($object->rappro == 0)
|
||||
{
|
||||
if (! empty($user->rights->salaries->delete))
|
||||
{
|
||||
print '<a class="butActionDelete" href="card.php?id='.$salpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -36,6 +36,7 @@ if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$search_ref = GETPOST('search_ref','int');
|
||||
$search_user = GETPOST('search_user','alpha');
|
||||
$search_label = GETPOST('search_label','alpha');
|
||||
$search_amount = GETPOST('search_amount','alpha');
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
@ -46,7 +47,7 @@ $offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
$limit = $conf->liste_limit;
|
||||
if (! $sortfield) $sortfield="s.datev";
|
||||
if (! $sortfield) $sortfield="s.datep";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
|
||||
$filtre=$_GET["filtre"];
|
||||
@ -85,7 +86,7 @@ $salstatic = new PaymentSalary($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc,";
|
||||
$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,";
|
||||
$sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment,";
|
||||
$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,";
|
||||
@ -95,7 +96,8 @@ $sql.= " AND s.entity = ".$conf->entity;
|
||||
|
||||
// Search criteria
|
||||
if ($search_ref) $sql.=" AND s.rowid=".$search_ref;
|
||||
if ($search_label) $sql.=" AND s.label LIKE '%".$db->escape($search_label)."%'";
|
||||
if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $search_user);
|
||||
if ($search_label) $sql.=natural_search(array('s.label'), $search_label);
|
||||
if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1);
|
||||
if ($filtre) {
|
||||
$filtre=str_replace(":","=",$filtre);
|
||||
@ -129,7 +131,7 @@ if ($result)
|
||||
print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.salary","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datev","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("");
|
||||
@ -141,11 +143,14 @@ if ($result)
|
||||
print '<input class="flat" type="text" size="3" name="search_ref" value="'.$search_ref.'">';
|
||||
print '</td>';
|
||||
// People
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" type="text" size="6" name="search_user" value="'.$search_user.'">';
|
||||
print '</td>';
|
||||
// Current salary
|
||||
print '<td class="liste_titre"> </td>';
|
||||
// Label
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="'.$search_label.'"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.$search_label.'"></td>';
|
||||
// Date
|
||||
print '<td class="liste_titre"> </td>';
|
||||
// Type
|
||||
print '<td class="liste_titre" align="left">';
|
||||
@ -170,6 +175,7 @@ if ($result)
|
||||
$userstatic->login=$obj->login;
|
||||
$userstatic->email=$obj->email;
|
||||
$userstatic->societe_id=$obj->fk_soc;
|
||||
|
||||
$salstatic->id=$obj->rowid;
|
||||
$salstatic->ref=$obj->rowid;
|
||||
// Ref
|
||||
@ -180,7 +186,8 @@ if ($result)
|
||||
print "<td>".($obj->salary?price($obj->salary):'')."</td>\n";
|
||||
// Label payment
|
||||
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||
// Date payment
|
||||
print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
|
||||
// Type
|
||||
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
||||
// Amount
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
|
||||
/** \class PaymentSocialContribution
|
||||
* \brief Class to manage payments of social contributions
|
||||
/**
|
||||
* Class to manage payments of social contributions
|
||||
*/
|
||||
class PaymentSocialContribution extends CommonObject
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ function salaries_prepare_head($object) {
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'salaries';
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
@ -42,11 +42,13 @@ function salaries_prepare_head($object) {
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
|
||||
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
*/
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
|
||||
|
||||
return $head;
|
||||
|
||||
@ -133,6 +133,19 @@ class modSalaries extends DolibarrModules
|
||||
//--------
|
||||
$r=0;
|
||||
|
||||
$r++;
|
||||
$this->export_code[$r]=$this->rights_class.'_'.$r;
|
||||
$this->export_label[$r]='Salaries and payments';
|
||||
$this->export_permission[$r]=array(array("salary","export"));
|
||||
$this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero','p.label'=>'Label','p.note'=>'Note');
|
||||
$this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Number",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Number','p.num_paiement'=>'Number','p.label'=>'Text');
|
||||
$this->export_entities_array[$r]=array('u.firstname'=>'user','u.lastname'=>'user','u.login'=>'user','u.salary'=>'user','p.datep'=>'payment','p.datesp'=>'payment','p.dateep'=>'payment','p.amount'=>'payment','p.label'=>'payment','p.note'=>'payment','p.num_paiement'=>'payment');
|
||||
|
||||
$this->export_sql_start[$r]='SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementsalary as p ON p.fk_user = u.rowid';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepaiement = cp.rowid';
|
||||
$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user',1).')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -78,6 +78,15 @@ ALTER TABLE llx_extrafields ADD COLUMN list integer DEFAULT 0 after perms;
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD COLUMN salary real after datev;
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datesp (datesp);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_dateep (dateep);
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD CONSTRAINT fk_payment_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
|
||||
UPDATE llx_projet_task_time SET task_datehour = task_date where task_datehour IS NULL;
|
||||
ALTER TABLE llx_projet_task_time ADD COLUMN task_date_withhour integer DEFAULT 0 after task_datehour;
|
||||
|
||||
|
||||
27
htdocs/install/mysql/tables/llx_payment_salary.key.sql
Normal file
27
htdocs/install/mysql/tables/llx_payment_salary.key.sql
Normal file
@ -0,0 +1,27 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- 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
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ============================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datesp (datesp);
|
||||
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_dateep (dateep);
|
||||
|
||||
ALTER TABLE llx_payment_salary ADD CONSTRAINT fk_payment_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
@ -22,14 +22,14 @@ create table llx_payment_salary
|
||||
tms timestamp,
|
||||
fk_user integer NOT NULL,
|
||||
datep date, -- date de paiement
|
||||
datev date, -- date de valeur
|
||||
datev date, -- date de valeur (this field should not be here, only into bank tables)
|
||||
salary real, -- salary of user when payment was done
|
||||
amount real NOT NULL DEFAULT 0,
|
||||
fk_typepayment integer NOT NULL,
|
||||
num_payment varchar(50),
|
||||
num_payment varchar(50), -- ref
|
||||
label varchar(255),
|
||||
datesp date, -- date de début de la période
|
||||
dateep date, -- date de fin de la période
|
||||
datesp date, -- date start period
|
||||
dateep date, -- date end period
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
note text,
|
||||
fk_bank integer,
|
||||
|
||||
@ -492,8 +492,8 @@ Module400Name=Projects/Opportunities/Leads
|
||||
Module400Desc=Management of projects, opportunities or leads. You can then assign any element (invoice, order, proposal, intervention, ...) to a project and get a transversal view from the project view.
|
||||
Module410Name=Webcalendar
|
||||
Module410Desc=Webcalendar integration
|
||||
Module500Name=Special expenses (tax, social contributions, dividends)
|
||||
Module500Desc=Management of special expenses like taxes, social contribution, dividends and salaries
|
||||
Module500Name=Special expenses
|
||||
Module500Desc=Management of special expenses (taxes, social contribution, dividends)
|
||||
Module510Name=Salaries
|
||||
Module510Desc=Management of employees salaries and payments
|
||||
Module520Name=Loan
|
||||
|
||||
Loading…
Reference in New Issue
Block a user