diff --git a/ChangeLog b/ChangeLog
index 030a0f68c4d..bc52dbcd2a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php
index eb11498a505..5c2d6812302 100644
--- a/htdocs/compta/bank/account.php
+++ b/htdocs/compta/bank/account.php
@@ -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'];
diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php
index 20b5247ffd7..735a78319ab 100644
--- a/htdocs/compta/bank/search.php
+++ b/htdocs/compta/bank/search.php
@@ -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 '
'.dol_print_date($db->jdate($objp->dv),"day")." | \n";
// Payment type
- print "";
+ print ' | ';
$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 ' '; //$langs->trans("InitialBankBalance");
else print $labeltype;
diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php
index ffbf6be1ce9..58876f81ab6 100644
--- a/htdocs/compta/bank/treso.php
+++ b/htdocs/compta/bank/treso.php
@@ -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"]))
diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php
index 87e23e02deb..f94861c31a6 100644
--- a/htdocs/compta/salaries/class/paymentsalary.class.php
+++ b/htdocs/compta/salaries/class/paymentsalary.class.php
@@ -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='')
{
diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php
index 5febffa2b7b..1615c297214 100644
--- a/htdocs/compta/salaries/fiche.php
+++ b/htdocs/compta/salaries/fiche.php
@@ -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 ' | | '.$langs->trans("Account").' | ';
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print ' |
';
-
+
+ // Type payment
+ print '| '.$langs->trans("PaymentMode").' | ';
+ $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
+ print " | \n";
+ print "
";
+
+ // Number
+ print '| '.$langs->trans('Numero');
+ print ' ('.$langs->trans("ChequeOrTransferNumber").')';
+ print ' | |
'."\n";
}
-
- // TYpe payment
- print '| '.$langs->trans("PaymentMode").' | ';
- $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
- print " | \n";
- print "
";
-
- // Number
- print '| '.$langs->trans('Numero');
- print ' ('.$langs->trans("ChequeOrTransferNumber").')';
- print ' | |
'."\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
diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php
index f32c1bad951..1d0358f17cd 100644
--- a/htdocs/compta/salaries/index.php
+++ b/htdocs/compta/salaries/index.php
@@ -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.='&typeid='.$typeid;
+
+ print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
+
+ dol_htmloutput_mesg($mesg);
+
+ print '';
+
$db->free($result);
}
else
diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php
index 89e2f84d7fb..48d23769cf6 100644
--- a/htdocs/compta/sociales/index.php
+++ b/htdocs/compta/sociales/index.php
@@ -147,13 +147,13 @@ if ($resql)
print "";
print "";
- 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 "
\n";
print '';
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index d9ba93188bd..94c1f3d3cee 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2011-2014 Alexandre Spangaro
*
* 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�n�r�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='')
{
diff --git a/htdocs/compta/tva/fiche.php b/htdocs/compta/tva/fiche.php
index a0d181e8f81..d4accc5134d 100644
--- a/htdocs/compta/tva/fiche.php
+++ b/htdocs/compta/tva/fiche.php
@@ -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 '
';
- print '| '.$langs->trans("PaymentMode").' | ';
- $form->select_types_paiements($_POST["paiementtype"], "paiementtype");
- print " | \n";
- print "
";
+ // Type payment
+ print '| '.$langs->trans("PaymentMode").' | ';
+ $form->select_types_paiements(GETPOST("type_payment"), "type_payment");
+ print " | \n";
+ print "
";
+
+ // Number
+ print '| '.$langs->trans('Numero');
+ print ' ('.$langs->trans("ChequeOrTransferNumber").')';
+ print ' | |
'."\n";
}
// Other attributes
diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php
index ea9f7ea445d..6183207e115 100644
--- a/htdocs/compta/tva/reglement.php
+++ b/htdocs/compta/tva/reglement.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville
* Copyright (C) 2004-2010 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2011-2014 Alexandre Spangaro
*
* 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.='&typeid='.$typeid;
+
+ print_barre_liste($langs->trans("VATPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
+
+ dol_htmloutput_mesg($mesg);
+
+ print '';
+
$db->free($result);
}
else
diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php
index a1e9a655c6e..47000d87f02 100644
--- a/htdocs/core/modules/modDeplacement.class.php
+++ b/htdocs/core/modules/modDeplacement.class.php
@@ -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