Merge branch 'develop' of github.com:aspangaro/dolibarr into

aspangaro-develop

Conflicts:
	ChangeLog
This commit is contained in:
Laurent Destailleur 2014-05-01 11:16:42 +02:00
commit 6a200105b9
12 changed files with 358 additions and 152 deletions

View File

@ -49,10 +49,11 @@ For users:
- New: Extrafields can be used as substitution key %EXTRA_XXX% into emails texts for members.
- Fix: Project Task numbering customs rule works.
- Fix: Add actions events not implemented.
- Fix: Price min of composition is not supplier price min by quantity
- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers
- New: Add categories translation
- New: Enable option "clone target emailing"
- Fix: Price min of composition is not supplier price min by quantity.
- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers.
- New: Add categories translation.
- New: Enable option "clone target emailing".
- New: Improved tax module: Add specific page for salaries payment
TODO
- New: Predefined product and free product use same form.

View File

@ -43,6 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
$langs->load("companies");
$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
$ref = GETPOST('ref','alpha');
@ -464,10 +465,11 @@ if ($id > 0 || ! empty($ref))
if ($mode_search && ! empty($conf->tax->enabled))
{
// VAT
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid";
// Salary payment
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'";
// Salary payment
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as sal ON bu3.url_id = sal.rowid";
}
if ($mode_search && ! empty($conf->adherent->enabled))
@ -586,7 +588,7 @@ if ($id > 0 || ! empty($ref))
$paymentvatstatic->ref=$links[$key]['url_id'];
print ' '.$paymentvatstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='payment_salary')
elseif ($links[$key]['type']=='payment_salary')
{
$paymentsalstatic->id=$links[$key]['url_id'];
$paymentsalstatic->ref=$links[$key]['url_id'];
@ -627,7 +629,7 @@ if ($id > 0 || ! empty($ref))
{
}
elseif ($links[$key]['type']=='user')
elseif ($links[$key]['type']=='user')
{
}
@ -669,7 +671,7 @@ if ($id > 0 || ! empty($ref))
$societestatic->nom=$links[$key]['label'];
print $societestatic->getNomUrl(1,'',16);
}
else if ($links[$key]['type']=='user')
else if ($links[$key]['type']=='user')
{
$userstatic->id=$links[$key]['url_id'];
$userstatic->lastname=$links[$key]['label'];

View File

@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("companies");
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@ -251,7 +252,7 @@ if ($resql)
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->dv),"day")."</td>\n";
// Payment type
print "<td align=\"center\">";
print '<td class="nowrap">';
$labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle');
if ($labeltype == 'SOLD') print '&nbsp;'; //$langs->trans("InitialBankBalance");
else print $labeltype;

View File

@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
$langs->load("companies");
// Security check
if (isset($_GET["account"]) || isset($_GET["ref"]))

View File

@ -125,14 +125,14 @@ class PaymentSalary extends CommonObject
if (! $notrigger)
{
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SALARY_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
// End triggers
}
return 1;
@ -239,14 +239,14 @@ class PaymentSalary extends CommonObject
return -1;
}
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SALARY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
// End triggers
return 1;
}
@ -277,18 +277,23 @@ class PaymentSalary extends CommonObject
$this->fk_user_modif='';
}
/**
* Ajoute un paiement de salaire
*
* @param User $user Object user that insert
* @return int <0 if KO, rowid in tva table if OK
*/
/**
* Create in database
*
* @param User $user User that create
* @return int <0 if KO, >0 if OK
*/
function create($user)
{
global $conf,$langs;
// Clean parameters
$this->amount=price2num(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
if (! $this->label)
@ -314,20 +319,20 @@ class PaymentSalary extends CommonObject
if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
return -6;
return -7;
}
$this->db->begin();
// Insertion dans table des paiement salaires
// Insert into llx_payment_salary
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user";
$sql.= ", datep";
$sql.= ", datev";
$sql.= ", amount";
$sql.= ", fk_typepayment";
$sql.= ", num_payment";
$sql.=", note";
$sql.=", label";
if ($this->note) $sql.= ", note";
$sql.= ", label";
$sql.= ", datesp";
$sql.= ", dateep";
$sql.= ", fk_user_creat";
@ -338,10 +343,10 @@ class PaymentSalary extends CommonObject
$sql.= "'".$this->fk_user."'";
$sql.= ", '".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount;
$sql.= ", ".$this->type_payment;
$sql.= ", ".$this->num_payment;
$sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->amount."'";
$sql.= ", '".$this->type_payment."'";
$sql.= ", '".$this->num_payment."'";
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", '".$this->db->idate($this->datesp)."'";
$sql.= ", '".$this->db->idate($this->dateep)."'";
@ -354,23 +359,23 @@ class PaymentSalary extends CommonObject
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO devrait s'appeler payment_salary
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); // TODO should be called payment_salary
// Appel des triggers
// 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;
}
// Fin appel triggers
// End triggers
if ($this->id > 0)
{
$ok=1;
if (! empty($conf->banque->enabled) && ! empty($this->amount))
{
// Insertion dans llx_bank
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
@ -389,8 +394,8 @@ class PaymentSalary extends CommonObject
$user
);
// Mise a jour fk_bank dans llx_paiement.
// On connait ainsi le paiement qui a genere l'ecriture bancaire
// Update fk_bank into llx_paiement.
// So we know the payment which has generate the banking ecriture
if ($bank_line_id > 0)
{
$this->update_fk_bank($bank_line_id);
@ -464,9 +469,9 @@ class PaymentSalary extends CommonObject
}
/**
* Mise a jour du lien entre le paiement salaire et la ligne générée dans llx_bank
* Update link between payment salary and line generate into llx_bank
*
* @param int $id_bank Id compte bancaire
* @param int $id_bank Id bank account
* @return int <0 if KO, >0 if OK
*/
function update_fk_bank($id_bank)
@ -487,11 +492,11 @@ class PaymentSalary extends CommonObject
/**
* Renvoie nom clicable (avec eventuellement le picto)
* Send name clicable (with possibly the picto)
*
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param string $option Sur quoi pointe le lien
* @return string Chaine avec URL
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option link option
* @return string Chaine with URL
*/
function getNomUrl($withpicto=0,$option='')
{

View File

@ -75,8 +75,9 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$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->num_payment=GETPOST("num_payment");
if (empty($sal->fk_user) || $sal->fk_user < 0)
{
@ -243,20 +244,19 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print '</td></tr>';
// Type payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
print "</td>\n";
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";
}
// TYpe payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
print "</td>\n";
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
$parameters=array('colspan' => ' colspan="1"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -33,7 +33,33 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$limit = $conf->liste_limit;
if (! $sortfield) $sortfield="s.datev";
if (! $sortorder) $sortorder="DESC";
$filtre=$_GET["filtre"];
if (empty($_REQUEST['typeid']))
{
$newfiltre=str_replace('filtre=','',$filtre);
$filterarray=explode('-',$newfiltre);
foreach($filterarray as $val)
{
$part=explode(':',$val);
if ($part[0] == 's.fk_typepayment') $typeid=$part[1];
}
}
else
{
$typeid=$_REQUEST['typeid'];
}
/*
* View
@ -41,20 +67,29 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
llxHeader();
$form = new Form($db);
$salstatic = new PaymentSalary($db);
$userstatic = new User($db);
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, s.num_payment,";
$sql.= " pst.code as payment_code";
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type,";
$sql.= " s.num_payment, 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.= " AND s.entity = ".$conf->entity;
$sql.= " ORDER BY dm DESC";
if (GETPOST("search_label")) $sql.=" AND s.label LIKE '%".$db->escape(GETPOST("search_label"))."%'";
if (GETPOST("search_amount")) $sql.=" AND s.amount = ".price2num(GETPOST("search_amount"));
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND s.fk_typepayment=".$typeid;
}
$sql.= " GROUP BY s.rowid, s.fk_typepayment, s.amount, s.datev, s.label";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1,$offset);
$result = $db->query($sql);
if ($result)
@ -62,18 +97,44 @@ if ($result)
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$var=true;
$param='';
if ($typeid) $param.='&amp;typeid='.$typeid;
print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
dol_htmloutput_mesg($mesg);
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
print "<td>".$langs->trans("Person")."</td>";
print "<td>".$langs->trans("Label")."</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_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"u.rowid","",$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("Type"),$_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("");
print "</tr>\n";
$var=1;
while ($i < $num)
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="'.GETPOST("search_label").'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
// Type
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
print '</td>';
print '<td class="liste_titre" align="right"><input name="search_amount" class="flat" type="text" size="8" value="'.GETPOST("search_amount").'"></td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$var=!$var;
@ -92,6 +153,7 @@ if ($result)
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
// Amount
print "<td align=\"right\">".price($obj->amount,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "<td>&nbsp;</td>";
print "</tr>\n";
$total = $total + $obj->amount;
@ -99,9 +161,13 @@ if ($result)
$i++;
}
print '<tr class="liste_total"><td colspan="5" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total,0,$outputlangs,1,-1,-1,$conf->currency)."</td></tr>";
print '<td class="liste_total" align="right">'.price($total,0,$outputlangs,1,-1,-1,$conf->currency)."</td>";
print "<td>&nbsp;</td></tr>";
print "</table>";
print '</form>';
$db->free($result);
}
else

View File

@ -147,13 +147,13 @@ if ($resql)
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"index.php","id","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),"index.php","cs.libelle","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),"index.php","type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PeriodEndDate"),"index.php","periode","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),"index.php","cs.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),"index.php","cs.date_ech","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"index.php","cs.paye","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"id","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"cs.libelle","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"periode","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDue"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cs.paye","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
@ -41,6 +42,8 @@ class Tva extends CommonObject
var $datep;
var $datev;
var $amount;
var $type_payment;
var $num_payment;
var $label;
var $note;
var $fk_bank;
@ -118,12 +121,12 @@ class Tva extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TVA_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// End triggers
return $this->id;
}
@ -186,12 +189,12 @@ class Tva extends CommonObject
if (! $notrigger)
{
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TVA_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// End triggers
}
return 1;
@ -215,6 +218,8 @@ class Tva extends CommonObject
$sql.= " t.datep,";
$sql.= " t.datev,";
$sql.= " t.amount,";
$sql.= " t.fk_typepayment,";
$sql.= " t.num_payment,";
$sql.= " t.label,";
$sql.= " t.note,";
$sql.= " t.fk_bank,";
@ -242,6 +247,8 @@ class Tva extends CommonObject
$this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->type_payment = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
@ -288,12 +295,12 @@ class Tva extends CommonObject
return -1;
}
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TVA_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// End triggers
return 1;
}
@ -323,7 +330,7 @@ class Tva extends CommonObject
/**
* Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de TVA, non ?
* Balance of VAT
*
* @param int $year Year
* @return double Amount
@ -342,7 +349,7 @@ class Tva extends CommonObject
}
/**
* Total de la TVA des factures emises par la societe.
* Total of the VAT from invoices emitted by the society.
*
* @param int $year Year
* @return double Amount
@ -424,7 +431,7 @@ class Tva extends CommonObject
/**
* Total de la TVA reglee aupres de qui de droit
* Total of the VAT payed
*
* @param int $year Year
* @return double Amount
@ -466,7 +473,7 @@ class Tva extends CommonObject
/**
* Ajoute un paiement de TVA
* Create in database
*
* @param User $user Object user that insert
* @return int <0 if KO, rowid in tva table if OK
@ -479,7 +486,12 @@ class Tva extends CommonObject
// Clean parameters
$this->amount=price2num(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
if (! $this->label)
{
@ -496,51 +508,63 @@ class Tva extends CommonObject
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
return -5;
}
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"));
return -5;
}
// Insertion dans table des paiement tva
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
if ($this->note) $sql.=", note";
if ($this->label) $sql.=", label";
$sql.= ", fk_user_creat, fk_bank, entity";
// Insert into llx_tva
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep";
$sql.= ", datev";
$sql.= ", amount";
$sql.= ", fk_typepayment";
$sql.= ", num_payment";
if ($this->note) $sql.= ", note";
if ($this->label) $sql.= ", label";
$sql.= ", fk_user_creat";
$sql.= ", fk_bank";
$sql.= ", entity";
$sql.= ") ";
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
$sql.= " VALUES (";
$sql.= "'".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount;
$sql.= ", '".$this->type_payment."'";
$sql.= ", '".$this->num_payment."'";
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
if ($this->label) $sql.=", '".$this->db->escape($this->label)."'";
$sql.=", '".$user->id."', NULL, ".$conf->entity;
$sql.= ", '".$user->id."'";
$sql.= ", NULL";
$sql.= ", ".$conf->entity;
$sql.= ")";
dol_syslog(get_class($this)."::addPayment sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO devrait s'appeler paiementtva
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called paiementtva
// Appel des triggers
// Start triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TVA_ADDPAYMENT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
// End triggers
if ($this->id > 0)
{
$ok=1;
if (! empty($conf->banque->enabled) && ! empty($this->amount))
{
// Insertion dans llx_bank
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result=$acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($this->db);
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), '', '', $user);
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
if ($bank_line_id > 0)
@ -589,9 +613,9 @@ class Tva extends CommonObject
}
/**
* Mise a jour du lien entre le paiement tva et la ligne g<EFBFBD>n<EFBFBD>r<EFBFBD>e dans llx_bank
* Update link between payment tva and line generate into llx_bank
*
* @param int $id_bank Id compte bancaire
* @param int $id_bank Id bank account
* @return int <0 if KO, >0 if OK
*/
function update_fk_bank($id_bank)
@ -610,13 +634,12 @@ class Tva extends CommonObject
}
}
/**
* Renvoie nom clicable (avec eventuellement le picto)
* Send name clicable (with possibly the picto)
*
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param string $option Sur quoi pointe le lien
* @return string Chaine avec URL
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option link option
* @return string Chaine with URL
*/
function getNomUrl($withpicto=0,$option='')
{

View File

@ -58,31 +58,51 @@ if ($_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"]);
$tva->accountid=$_POST["accountid"];
$tva->paymenttype=$_POST["paiementtype"];
$tva->accountid=GETPOST("accountid");
$tva->type_payment=GETPOST("type_payment");
$tva->num_payment=GETPOST("num_payment");
$tva->datev=$datev;
$tva->datep=$datep;
$tva->amount=$_POST["amount"];
$tva->label=$_POST["label"];
$tva->amount=GETPOST("amount");
$tva->label=GETPOST("label");
$tva->note=GETPOST("note");
if (empty($tva->type_payment) || $tva->type_payment < 0)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentMode")),'errors');
$error++;
}
if (empty($tva->amount))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")),'errors');
$error++;
}
$ret=$tva->addPayment($user);
if ($ret > 0)
{
$db->commit();
header("Location: reglement.php");
exit;
}
else
{
$db->rollback();
setEventMessage($tva->error, 'errors');
$action="create";
}
if (! $error)
{
$db->begin();
$ret=$tva->addPayment($user);
if ($ret > 0)
{
$db->commit();
header("Location: reglement.php");
exit;
}
else
{
$db->rollback();
setEventMessage($tva->error, 'errors');
$action="create";
}
}
$action='create';
}
if ($action == 'delete')
@ -180,10 +200,16 @@ if ($action == 'create')
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements($_POST["paiementtype"], "paiementtype");
print "</td>\n";
print "</tr>";
// Type payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOST("type_payment"), "type_payment");
print "</td>\n";
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

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
@ -27,14 +28,40 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
$langs->load("compta");
$langs->load("compta");
$langs->load("bills");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$limit = $conf->liste_limit;
if (! $sortfield) $sortfield="t.datev";
if (! $sortorder) $sortorder="DESC";
$filtre=$_GET["filtre"];
if (empty($_REQUEST['typeid']))
{
$newfiltre=str_replace('filtre=','',$filtre);
$filterarray=explode('-',$newfiltre);
foreach($filterarray as $val)
{
$part=explode(':',$val);
if ($part[0] == 't.fk_typepayment') $typeid=$part[1];
}
}
else
{
$typeid=$_REQUEST['typeid'];
}
/*
* View
@ -42,14 +69,25 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
llxHeader();
$form = new Form($db);
$tva_static = new Tva($db);
print_fiche_titre($langs->trans("VATPayments"));
$sql = "SELECT rowid, amount, label, f.datev as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f ";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " ORDER BY dm DESC";
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.fk_typepayment as type, t.num_payment, pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
$sql.= " WHERE t.entity = ".$conf->entity;
if (GETPOST("search_label")) $sql.=" AND t.label LIKE '%".$db->escape(GETPOST("search_label"))."%'";
if (GETPOST("search_amount")) $sql.=" AND t.amount = ".price2num(GETPOST("search_amount"));
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND t.fk_typepayment=".$typeid;
}
$sql.= " GROUP BY t.rowid, t.fk_typepayment, t.amount, t.datev, t.label";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1,$offset);
$result = $db->query($sql);
if ($result)
@ -57,19 +95,55 @@ if ($result)
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$var=true;
$param='';
if ($typeid) $param.='&amp;typeid='.$typeid;
print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
dol_htmloutput_mesg($mesg);
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
print "<td>".$langs->trans("Label")."</td>";
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
print "</tr>\n";
$var=1;
while ($i < $num)
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"dm","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"t.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre("");
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="'.GETPOST("search_label").'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
// Type
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
print '</td>';
print '<td class="liste_titre" align="right"><input name="search_amount" class="flat" type="text" size="8" value="'.GETPOST("search_amount").'"></td>';
print '<td class="liste_titre" align="right">';
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$var=!$var;
if ($obj->payment_code <> '')
{
$type = '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
}
else
{
$type = '<td>&nbsp;</td>';
}
print "<tr ".$bc[$var].">";
$tva_static->id=$obj->rowid;
@ -77,17 +151,24 @@ if ($result)
print "<td>".$tva_static->getNomUrl(1)."</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";
// Type
print $type;
// Amount
$total = $total + $obj->amount;
print "<td align=\"right\">".price($obj->amount)."</td>";
print "<td align=\"right\">".price($obj->amount)."</td>";
print "<td>&nbsp;</td>";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total").'</td>';
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
print "<td align=\"right\"><b>".price($total)."</b></td>";
print "<td>&nbsp;</td></tr>";
print "</table>";
print '</form>';
$db->free($result);
}
else

View File

@ -44,7 +44,7 @@ class modDeplacement extends DolibarrModules
$this->db = $db;
$this->numero = 75 ;
$this->family = "financial";
$this->family = "hr";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee