2004-10-19 22:35:36 +02:00
|
|
|
|
<?php
|
2014-05-06 22:54:33 +02:00
|
|
|
|
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
2013-04-15 21:27:01 +02:00
|
|
|
|
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
|
2004-05-02 18:01:35 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-05-02 18:01:35 +02:00
|
|
|
|
* (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
|
2011-08-01 00:21:57 +02:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-02 18:01:35 +02:00
|
|
|
|
*/
|
2004-10-03 20:31:14 +02:00
|
|
|
|
|
2006-08-20 23:09:23 +02:00
|
|
|
|
/**
|
2009-10-25 21:48:44 +01:00
|
|
|
|
* \file htdocs/compta/sociales/charges.php
|
|
|
|
|
|
* \ingroup tax
|
|
|
|
|
|
* \brief Social contribution car page
|
|
|
|
|
|
*/
|
2004-10-03 20:31:14 +02:00
|
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
|
require '../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
2004-05-02 18:01:35 +02:00
|
|
|
|
|
2004-10-03 20:31:14 +02:00
|
|
|
|
$langs->load("compta");
|
|
|
|
|
|
$langs->load("bills");
|
|
|
|
|
|
|
2012-02-27 22:26:22 +01:00
|
|
|
|
$id=GETPOST('id','int');
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action=GETPOST("action");
|
2004-05-02 18:01:35 +02:00
|
|
|
|
|
2008-10-13 16:22:10 +02:00
|
|
|
|
// Security check
|
2012-02-27 22:26:22 +01:00
|
|
|
|
$socid = GETPOST('socid','int');
|
2008-10-13 16:22:10 +02:00
|
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2012-11-06 14:54:17 +01:00
|
|
|
|
$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
|
2008-10-13 16:22:10 +02:00
|
|
|
|
|
2004-05-02 18:01:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
2004-06-08 17:09:49 +02:00
|
|
|
|
|
|
|
|
|
|
/* *************************************************************************** */
|
|
|
|
|
|
/* */
|
2007-01-30 20:58:19 +01:00
|
|
|
|
/* Actions */
|
2004-06-08 17:09:49 +02:00
|
|
|
|
/* */
|
|
|
|
|
|
/* *************************************************************************** */
|
2007-01-30 20:58:19 +01:00
|
|
|
|
|
|
|
|
|
|
/*
|
2011-12-21 21:14:10 +01:00
|
|
|
|
* Classify paid
|
2007-01-30 20:58:19 +01:00
|
|
|
|
*/
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'confirm_paid' && $_REQUEST["confirm"] == 'yes')
|
2004-06-08 17:09:49 +02:00
|
|
|
|
{
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$chargesociales = new ChargeSociales($db);
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$chargesociales->fetch($id);
|
2010-10-11 21:22:55 +02:00
|
|
|
|
$result = $chargesociales->set_paid($user);
|
2004-06-08 17:09:49 +02:00
|
|
|
|
}
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2007-01-30 01:30:48 +01:00
|
|
|
|
/*
|
2011-12-21 21:14:10 +01:00
|
|
|
|
* Delete social contribution
|
2007-01-30 01:30:48 +01:00
|
|
|
|
*/
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
|
2007-01-30 01:30:48 +01:00
|
|
|
|
{
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$chargesociales=new ChargeSociales($db);
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$chargesociales->fetch($id);
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$result=$chargesociales->delete($user);
|
|
|
|
|
|
if ($result > 0)
|
2007-01-30 01:30:48 +01:00
|
|
|
|
{
|
2012-08-31 05:58:38 +02:00
|
|
|
|
header("Location: index.php");
|
2009-05-09 21:45:18 +02:00
|
|
|
|
exit;
|
2007-01-30 01:30:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$mesg='<div class="error">'.$chargesociales->error.'</div>';
|
2007-01-30 01:30:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-06-08 17:09:49 +02:00
|
|
|
|
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
/*
|
2011-12-21 21:14:10 +01:00
|
|
|
|
* Add social contribution
|
2007-06-25 02:02:37 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'add' && $user->rights->tax->charges->creer)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
|
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
2007-07-31 02:23:30 +02:00
|
|
|
|
if (! $dateech)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'create';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
2009-05-09 21:45:18 +02:00
|
|
|
|
elseif (! $dateperiod)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'create';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
2009-10-25 21:48:44 +01:00
|
|
|
|
elseif (! $_POST["actioncode"] > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'create';
|
2009-10-25 21:48:44 +01:00
|
|
|
|
}
|
2007-06-25 02:02:37 +02:00
|
|
|
|
elseif (! $_POST["amount"])
|
|
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'create';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$chargesociales=new ChargeSociales($db);
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2008-06-09 22:14:47 +02:00
|
|
|
|
$chargesociales->type=$_POST["actioncode"];
|
2007-06-25 02:02:37 +02:00
|
|
|
|
$chargesociales->lib=$_POST["label"];
|
2007-07-31 02:23:30 +02:00
|
|
|
|
$chargesociales->date_ech=$dateech;
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$chargesociales->periode=$dateperiod;
|
2007-06-25 02:02:37 +02:00
|
|
|
|
$chargesociales->amount=$_POST["amount"];
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$id=$chargesociales->create($user);
|
|
|
|
|
|
if ($id > 0)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
//$mesg='<div class="ok">'.$langs->trans("SocialContributionAdded").'</div>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$chargesociales->error.'</div>';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-06-08 17:09:49 +02:00
|
|
|
|
|
2007-01-30 01:30:48 +01:00
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
2011-08-05 23:05:19 +02:00
|
|
|
|
$dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
|
|
|
|
|
$dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
2007-07-31 02:23:30 +02:00
|
|
|
|
if (! $dateech)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'edit';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
2009-05-09 21:45:18 +02:00
|
|
|
|
elseif (! $dateperiod)
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Period")).'</div>';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$action = 'edit';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$chargesociales=new ChargeSociales($db);
|
|
|
|
|
|
$result=$chargesociales->fetch($_GET["id"]);
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
$chargesociales->lib=$_POST["label"];
|
2007-07-31 02:23:30 +02:00
|
|
|
|
$chargesociales->date_ech=$dateech;
|
2009-05-09 21:45:18 +02:00
|
|
|
|
$chargesociales->periode=$dateperiod;
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
$result=$chargesociales->update($user);
|
|
|
|
|
|
if ($result > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//$mesg='<div class="ok">'.$langs->trans("SocialContributionAdded").'</div>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$mesg='<div class="error">'.$chargesociales->error.'</div>';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* View
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2012-02-20 10:09:28 +01:00
|
|
|
|
$form = new Form($db);
|
|
|
|
|
|
$formsocialcontrib = new FormSocialContrib($db);
|
|
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
|
|
|
|
|
|
llxHeader("",$langs->trans("SocialContribution"),$help_url);
|
2007-01-30 01:30:48 +01:00
|
|
|
|
|
2007-07-31 02:23:30 +02:00
|
|
|
|
|
2011-08-05 23:05:19 +02:00
|
|
|
|
// Mode creation
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'create')
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
|
|
|
|
|
print_fiche_titre($langs->trans("NewSocialContribution"));
|
|
|
|
|
|
print "<br>\n";
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2012-01-11 20:31:40 +01:00
|
|
|
|
dol_htmloutput_mesg($mesg);
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
$var=false;
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
2009-05-17 10:01:54 +02:00
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
|
|
|
|
|
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
|
|
|
|
|
print "<tr class=\"liste_titre\">";
|
|
|
|
|
|
print '<td>';
|
|
|
|
|
|
print ' ';
|
|
|
|
|
|
print '</td><td align="left">';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print $langs->trans("Label");
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '</td><td align="left">';
|
|
|
|
|
|
print $langs->trans("Type");
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '</td><td align="center">';
|
|
|
|
|
|
print $langs->trans("PeriodEndDate");
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '</td><td align="right">';
|
|
|
|
|
|
print $langs->trans("Amount");
|
|
|
|
|
|
print '</td><td align="center">';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print $langs->trans("DateDue");
|
|
|
|
|
|
print '</td><td align="left">';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print ' ';
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr '.$bc[$var].' valign="top">';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '<td> </td>';
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Label
|
2012-11-18 16:41:10 +01:00
|
|
|
|
print '<td align="left"><input type="text" size="34" name="label" class="flat" value="'.GETPOST('label').'"></td>';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
|
|
|
|
|
|
// Type
|
2008-06-09 22:06:50 +02:00
|
|
|
|
print '<td align="left">';
|
2012-11-18 16:41:10 +01:00
|
|
|
|
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode")?GETPOST("actioncode"):'','actioncode',1);
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Date end period
|
|
|
|
|
|
print '<td align="center">';
|
2011-11-08 10:18:45 +01:00
|
|
|
|
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '</td>';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
|
|
|
|
|
|
print '<td align="right"><input type="text" size="6" name="amount" class="flat"></td>';
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '<td align="center">';
|
2011-11-08 10:18:45 +01:00
|
|
|
|
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-05-02 18:01:35 +02:00
|
|
|
|
/* *************************************************************************** */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Mode fiche */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* *************************************************************************** */
|
2012-02-11 20:30:16 +01:00
|
|
|
|
if ($id > 0)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$object = new ChargeSociales($db);
|
|
|
|
|
|
$result=$object->fetch($id);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2010-09-12 13:49:02 +02:00
|
|
|
|
if ($result > 0)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2011-08-05 23:05:19 +02:00
|
|
|
|
dol_htmloutput_mesg($mesg);
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$head=tax_prepare_head($object);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2014-05-06 23:19:48 +02:00
|
|
|
|
dol_fiche_head($head, 'card', $langs->trans("SocialContribution"),0,'bill');
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2012-01-11 20:31:40 +01:00
|
|
|
|
// Confirmation de la suppression de la charge
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'paid')
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2007-01-30 20:58:19 +01:00
|
|
|
|
$text=$langs->trans('ConfirmPaySocialContribution');
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans('PaySocialContribution'),$text,"confirm_paid",'','',2);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'delete')
|
2007-01-30 20:58:19 +01:00
|
|
|
|
{
|
|
|
|
|
|
$text=$langs->trans('ConfirmDeleteSocialContribution');
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('DeleteSocialContribution'),$text,'confirm_delete','','',2);
|
2007-01-30 20:58:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'edit')
|
2009-05-16 14:52:53 +02:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<form name=\"charge\" action=\"charges.php?id=$object->id&action=update\" method=\"post\">";
|
2009-05-17 10:01:54 +02:00
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2009-05-16 14:52:53 +02:00
|
|
|
|
}
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Ref
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
|
|
|
|
|
print $form->showrefnav($object,'id');
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print "</td></tr>";
|
|
|
|
|
|
|
|
|
|
|
|
// Label
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'edit')
|
2009-05-09 21:45:18 +02:00
|
|
|
|
{
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">';
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print '<input type="text" name="label" size="40" value="'.$object->lib.'">';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->lib.'</td></tr>';
|
2009-05-09 21:45:18 +02:00
|
|
|
|
}
|
2007-01-30 20:58:19 +01:00
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Type
|
2013-11-03 15:07:26 +01:00
|
|
|
|
print "<tr><td>".$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2010-02-14 14:12:05 +01:00
|
|
|
|
$rowspan=5;
|
|
|
|
|
|
print '<td rowspan="'.$rowspan.'" valign="top">';
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
/*
|
2014-05-06 22:54:33 +02:00
|
|
|
|
* Payments
|
|
|
|
|
|
*/
|
2010-02-08 17:33:11 +01:00
|
|
|
|
$sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,";
|
|
|
|
|
|
$sql.= "c.libelle as paiement_type";
|
2009-04-27 22:37:50 +02:00
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
|
|
|
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
2012-02-01 11:32:55 +01:00
|
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$sql.= " WHERE p.fk_charge = ".$id;
|
2012-02-01 11:32:55 +01:00
|
|
|
|
$sql.= " AND p.fk_charge = cs.rowid";
|
|
|
|
|
|
$sql.= " AND cs.entity = ".$conf->entity;
|
2009-04-27 22:37:50 +02:00
|
|
|
|
$sql.= " AND p.fk_typepaiement = c.id";
|
|
|
|
|
|
$sql.= " ORDER BY dp DESC";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2010-02-08 17:33:11 +01:00
|
|
|
|
//print $sql;
|
2009-06-04 21:42:34 +02:00
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
|
if ($resql)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2009-06-04 21:42:34 +02:00
|
|
|
|
$num = $db->num_rows($resql);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
$i = 0; $total = 0;
|
2009-10-25 21:48:44 +01:00
|
|
|
|
echo '<table class="nobordernopadding" width="100%">';
|
2006-08-20 23:09:23 +02:00
|
|
|
|
print '<tr class="liste_titre">';
|
2014-05-06 22:54:33 +02:00
|
|
|
|
print '<td>'.$langs->trans("RefPayment").'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Date").'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Type").'</td>';
|
|
|
|
|
|
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
|
|
|
|
|
print '<td> </td>';
|
|
|
|
|
|
print '</tr>';
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
$var=True;
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
2009-06-04 21:42:34 +02:00
|
|
|
|
$objp = $db->fetch_object($resql);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
$var=!$var;
|
2011-08-05 23:05:19 +02:00
|
|
|
|
print "<tr ".$bc[$var]."><td>";
|
2014-05-06 22:54:33 +02:00
|
|
|
|
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
|
|
|
|
|
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
2010-02-08 17:33:11 +01:00
|
|
|
|
print "<td>".$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
2014-05-06 22:54:33 +02:00
|
|
|
|
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
print "</tr>";
|
|
|
|
|
|
$totalpaye += $objp->amount;
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
2014-05-06 22:54:33 +02:00
|
|
|
|
|
2012-02-11 20:30:16 +01:00
|
|
|
|
if ($object->paye == 0)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2011-11-23 14:55:36 +01:00
|
|
|
|
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2012-02-11 20:30:16 +01:00
|
|
|
|
$resteapayer = $object->amount - $totalpaye;
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
2011-11-23 14:55:36 +01:00
|
|
|
|
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
print "</table>";
|
2009-06-04 21:42:34 +02:00
|
|
|
|
$db->free($resql);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
|
dol_print_error($db);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
print "</td>";
|
|
|
|
|
|
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
2014-05-06 23:19:48 +02:00
|
|
|
|
// Period end date
|
2013-11-03 15:07:26 +01:00
|
|
|
|
print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
|
|
|
|
|
|
print "<td>";
|
|
|
|
|
|
if ($action == 'edit')
|
|
|
|
|
|
{
|
|
|
|
|
|
print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print dol_print_date($object->periode,"day");
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</td></tr>";
|
2014-05-06 22:54:33 +02:00
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Due date
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'edit')
|
2007-01-30 01:30:48 +01:00
|
|
|
|
{
|
2007-01-30 22:20:05 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("DateDue")."</td><td>";
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
|
2007-01-30 22:20:05 +01:00
|
|
|
|
print "</td></tr>";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
else {
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($object->date_ech,'day')."</td></tr>";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
2010-07-27 01:00:39 +02:00
|
|
|
|
|
|
|
|
|
|
// Amount
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount).'</td></tr>';
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2010-12-27 19:46:45 +01:00
|
|
|
|
// Status
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
if ($action == 'edit')
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
2012-01-14 01:13:24 +01:00
|
|
|
|
print '<br><div align="center">';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
|
|
|
|
|
print ' ';
|
|
|
|
|
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
2011-12-21 21:14:10 +01:00
|
|
|
|
print '</div';
|
2007-06-25 02:02:37 +02:00
|
|
|
|
}
|
2009-03-03 00:43:17 +01:00
|
|
|
|
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action == 'edit') print "</form>\n";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
2014-05-06 23:19:48 +02:00
|
|
|
|
dol_fiche_end();
|
2006-08-20 23:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
2007-06-25 02:02:37 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Boutons actions
|
|
|
|
|
|
*/
|
2011-12-21 21:14:10 +01:00
|
|
|
|
if ($action != 'edit')
|
2007-06-25 02:02:37 +02:00
|
|
|
|
{
|
2006-08-20 23:09:23 +02:00
|
|
|
|
print "<div class=\"tabsAction\">\n";
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Edit
|
|
|
|
|
|
if ($user->rights->tax->charges->creer)
|
2007-01-30 22:20:05 +01:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&action=edit\">".$langs->trans("Modify")."</a>";
|
2007-01-30 22:20:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-08-20 23:09:23 +02:00
|
|
|
|
// Emettre paiement
|
2012-02-11 20:30:16 +01:00
|
|
|
|
if ($object->paye == 0 && ((price2num($object->amount) < 0 && round($resteapayer) < 0) || (price2num($object->amount) > 0 && round($resteapayer) > 0)) && $user->rights->tax->charges->creer)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_charge.php?id=$object->id&action=create\">".$langs->trans("DoPayment")."</a>";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2009-08-19 19:16:47 +02:00
|
|
|
|
// Classify 'paid'
|
2012-02-11 20:30:16 +01:00
|
|
|
|
if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer)
|
2006-08-20 23:09:23 +02:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&action=paid\">".$langs->trans("ClassifyPaid")."</a>";
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2009-05-09 21:45:18 +02:00
|
|
|
|
// Delete
|
2011-08-05 23:05:19 +02:00
|
|
|
|
if ($user->rights->tax->charges->supprimer)
|
2007-01-30 20:58:19 +01:00
|
|
|
|
{
|
2012-02-11 20:30:16 +01:00
|
|
|
|
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$object->id&action=delete\">".$langs->trans("Delete")."</a>";
|
2007-01-30 20:58:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-08-20 23:09:23 +02:00
|
|
|
|
print "</div>";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-05-09 21:45:18 +02:00
|
|
|
|
/* Charge non trouv<75> */
|
2012-02-11 20:30:16 +01:00
|
|
|
|
dol_print_error('',$object->error);
|
2006-08-20 23:09:23 +02:00
|
|
|
|
}
|
2004-05-02 18:01:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
|
llxFooter();
|
2012-02-11 20:30:16 +01:00
|
|
|
|
|
|
|
|
|
|
$db->close();
|
2004-05-02 18:01:35 +02:00
|
|
|
|
?>
|