Merge branch 'develop' into style

Conflicts:
	htdocs/core/lib/functions.lib.php
This commit is contained in:
Marcos García 2012-08-03 23:20:35 +02:00
commit ba41a94bca
14 changed files with 2782 additions and 2701 deletions

View File

@ -27,6 +27,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
$langs->load("companies");
$langs->load('other');
if ($conf->facture->enabled) $langs->load("bills");
// Security check

View File

@ -1930,16 +1930,6 @@ class Facture extends CommonInvoice
$rangtouse = $rangmax + 1;
}
// TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
//$price = $pu;
//$remise = 0;
//if ($remise_percent > 0)
//{
// $remise = round(($pu * $remise_percent / 100),2);
// $price = ($pu - $remise);
//}
$product_type=$type;
if ($fk_product)
{
@ -1980,10 +1970,6 @@ class Facture extends CommonInvoice
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
// TODO Ne plus utiliser
//$this->line->price=($this->type==2?-1:1)*abs($price);
//$this->line->remise=($this->type==2?-1:1)*abs($remise);
$result=$this->line->insert();
if ($result > 0)
{

View File

@ -33,6 +33,13 @@ $langs->load("companies");
$langs->load("other");
$langs->load("compta");
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
// Protection if external user
if ($user->societe_id > 0)
accessforbidden();
@ -64,8 +71,8 @@ if ($pastmonth == 0)
$pastmonthyear--;
}
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
@ -73,7 +80,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
}
$nom=$langs->trans("PurchasesJournal");
//$nomlink=;
$nomlink='';
$periodlink='';
$exportlink='';
$builddate=time();
$description=$langs->trans("DescPurchasesJournal");
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);

View File

@ -34,6 +34,13 @@ $langs->load("companies");
$langs->load("other");
$langs->load("compta");
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
// Protection if external user
if ($user->societe_id > 0)
accessforbidden();
@ -66,8 +73,8 @@ if ($pastmonth == 0)
$pastmonthyear--;
}
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
@ -75,7 +82,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
}
$nom=$langs->trans("SellsJournal");
//$nomlink=;
$nomlink='';
$periodlink='';
$exportlink='';
$builddate=time();
$description=$langs->trans("DescSellsJournal");
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
@ -113,25 +122,28 @@ if ($result)
{
$obj = $db->fetch_object($result);
// les variables
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER))?$conf->global->COMPTA_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef");
$compta_soc = (! empty($obj->code_compta))?$obj->code_compta:$cptcli;
$cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER)?$conf->global->COMPTA_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"));
$compta_soc = (! empty($obj->code_compta)?$obj->code_compta:$cptcli);
$compta_prod = $obj->accountancy_code_sell;
if (empty($compta_prod))
{
if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT))?$conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT:$langs->trans("CodeNotDef");
else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT))?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef");
if($obj->product_type == 0) $compta_prod = (! empty($conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT)?$conf->global->COMPTA_PRODUCT_SOLD_ACCOUNT:$langs->trans("CodeNotDef"));
else $compta_prod = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT)?$conf->global->COMPTA_SERVICE_SOLD_ACCOUNT:$langs->trans("CodeNotDef"));
}
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT))?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->accountancy_code))?$obj->accountancy_code:$cpttva;
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"));
$compta_tva = (! empty($obj->accountancy_code)?$obj->accountancy_code:$cpttva);
//la ligne facture
$tabfac[$obj->rowid]["date"] = $obj->datef;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
$tabfac[$obj->rowid]["type"] = $obj->type;
if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc]=0;
if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod]=0;
if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva]=0;
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabcompany[$obj->rowid]=array('id'=>$obj->socid,'name'=>$obj->name,'client'=>$obj->client);
$tabcompany[$obj->rowid]=array('id'=>$obj->socid, 'name'=>$obj->name, 'client'=>$obj->client);
$i++;
}
}
@ -217,6 +229,6 @@ print "</table>";
// End of page
$db->close();
llxFooter();
$db->close();
?>

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -32,10 +32,18 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$langs->load("bills");
$date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday');
$date_startyear=GETPOST('date_startyear');
$date_endmonth=GETPOST('date_endmonth');
$date_endday=GETPOST('date_endday');
$date_endyear=GETPOST('date_endyear');
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id > 0) $socid = $user->societe_id;
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire) accessforbidden();
if (! $user->rights->compta->resultat->lire && ! $user->rights->accounting->comptarapport->lire)
accessforbidden();
// Date range
$year=GETPOST("year");
@ -49,8 +57,8 @@ if (empty($year))
$month_current = strftime("%m",dol_now());
$year_start = $year;
}
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); // Date for local PHP server
$date_start=dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
@ -86,9 +94,7 @@ else
}
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->COMPTA_MODE;
if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");
$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->COMPTA_MODE);
/*
@ -99,6 +105,13 @@ llxHeader();
$form=new Form($db);
$nomlink='';
$periodlink='';
$exportlink='';
$total_ht=0;
$total_ttc=0;
// Affiche en-tete de rapport
if ($modecompta=="CREANCES-DETTES")
{
@ -128,7 +141,8 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="10%">&nbsp;</td><td>&nbsp;</td>';
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
print "</tr>\n";
@ -144,9 +158,12 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
else
{
@ -162,7 +179,8 @@ else
$sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
@ -183,11 +201,12 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("Bills").' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$objp->socid.'">'.$objp->nom."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
$total_ht = $total_ht + $objp->amount_ht;
$total_ttc = $total_ttc + $objp->amount_ttc;
$total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ttc += $objp->amount_ttc;
print "</tr>\n";
$i++;
}
@ -208,7 +227,8 @@ if ($modecompta != 'CREANCES-DETTES')
$sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity = ".$conf->entity;
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY nom, idp";
$sql.= " ORDER BY nom";
@ -226,11 +246,13 @@ if ($modecompta != 'CREANCES-DETTES')
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".price($objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price($objp->amount_ttc)."</td>\n";
$total_ht = $total_ht + $objp->amount_ht;
$total_ttc = $total_ttc + $objp->amount_ttc;
$total_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ttc += $objp->amount_ttc;
print "</tr>\n";
$i++;
}
@ -250,7 +272,8 @@ if ($total_ttc == 0)
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price($total_ht).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price($total_ht).'</td>';
print '<td colspan="3" align="right">'.price($total_ttc).'</td>';
print '</tr>';
@ -265,9 +288,12 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
else
{
@ -279,7 +305,8 @@ else
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
$sql.= " ON f.fk_soc = s.rowid";
$sql.= " WHERE p.rowid = pf.fk_paiementfourn ";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
@ -306,13 +333,15 @@ if ($result) {
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("Bills")." <a href=\"".DOL_URL_ROOT."/fourn/facture/index.php?socid=".$objp->socid."\">".$objp->nom."</a></td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price(-$objp->amount_ht)."</td>\n";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".price(-$objp->amount_ht)."</td>\n";
print "<td align=\"right\">".price(-$objp->amount_ttc)."</td>\n";
$total_ht = $total_ht - $objp->amount_ht;
$total_ttc = $total_ttc - $objp->amount_ttc;
$subtotal_ht = $subtotal_ht + $objp->amount_ht;
$subtotal_ttc = $subtotal_ttc + $objp->amount_ttc;
$total_ht -= (isset($objp->amount_ht)?$objp->amount_ht:0);
$total_ttc -= $objp->amount_ttc;
$subtotal_ht += (isset($objp->amount_ht)?$objp->amount_ht:0);
$subtotal_ttc += $objp->amount_ttc;
print "</tr>\n";
$i++;
}
@ -330,7 +359,8 @@ if ($result) {
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>';
@ -349,7 +379,8 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 0";
if ($date_start && $date_end) $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
}
else
{
@ -360,7 +391,8 @@ else
$sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 0";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle";
@ -378,10 +410,10 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
$total_ht = $total_ht - $obj->amount;
$total_ttc = $total_ttc - $obj->amount;
$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$var = !$var;
print "<tr $bc[$var]><td>&nbsp;</td>";
@ -402,7 +434,8 @@ if ($result) {
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>';
@ -420,7 +453,8 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 1";
if ($date_start && $date_end) $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle";
$sql.= " ORDER BY c.libelle";
@ -434,7 +468,8 @@ else
$sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 1";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle";
$sql.= " ORDER BY c.libelle";
@ -452,15 +487,16 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
$total_ht = $total_ht - $obj->amount;
$total_ttc = $total_ttc - $obj->amount;
$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$var = !$var;
print "<tr $bc[$var]><td>&nbsp;</td>";
print '<td>'.$obj->nom.'</td>';
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price(-$obj->amount).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td align="right">'.price(-$obj->amount).'</td>';
print '<td align="right">'.price(-$obj->amount).'</td>';
print '</tr>';
$i++;
@ -476,7 +512,8 @@ if ($result) {
dol_print_error($db);
}
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>';
@ -488,7 +525,8 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujeti
print '</tr>';
print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("Profit").'</td>';
if ($modecompta == 'CREANCES-DETTES') print '<td class="border" align="right">'.price($total_ht).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td class="border" align="right">'.price($total_ht).'</td>';
print '<td align="right">'.price($total_ttc).'</td>';
print '</tr>';
@ -512,9 +550,12 @@ if ($modecompta == 'CREANCES-DETTES')
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
@ -529,11 +570,11 @@ if ($modecompta == 'CREANCES-DETTES')
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount = $amount - $obj->amount;
//$total_ht = $total_ht - $obj->amount;
$total_ttc = $total_ttc - $obj->amount;
//$subtotal_ht = $subtotal_ht - $obj->amount;
$subtotal_ttc = $subtotal_ttc - $obj->amount;
$amount -= $obj->amount;
//$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
//$subtotal_ht -= $obj->amount;
$subtotal_ttc -= $obj->amount;
$i++;
}
}
@ -551,9 +592,12 @@ if ($modecompta == 'CREANCES-DETTES')
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
$sql.= " AND f.type IN (0,1,2)";
else
$sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
@ -568,11 +612,11 @@ if ($modecompta == 'CREANCES-DETTES')
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount = $amount + $obj->amount;
//$total_ht = $total_ht + $obj->amount;
$total_ttc = $total_ttc + $obj->amount;
//$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$amount += $obj->amount;
//$total_ht += $obj->amount;
$total_ttc += $obj->amount;
//$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$i++;
}
@ -593,7 +637,8 @@ else
$sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount > 0";
if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
@ -608,11 +653,11 @@ else
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount = $amount - $obj->amount;
$total_ht = $total_ht - $obj->amount;
$total_ttc = $total_ttc - $obj->amount;
$subtotal_ht = $subtotal_ht - $obj->amount;
$subtotal_ttc = $subtotal_ttc - $obj->amount;
$amount -= $obj->amount;
$total_ht -= $obj->amount;
$total_ttc -= $obj->amount;
$subtotal_ht -= $obj->amount;
$subtotal_ttc -= $obj->amount;
$i++;
}
@ -623,7 +668,8 @@ else
}
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("VATPaid")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($amount)."</td>\n";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".price($amount)."</td>\n";
print "<td align=\"right\">".price($amount)."</td>\n";
print "</tr>\n";
@ -632,7 +678,8 @@ else
$sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount < 0";
if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " AND t.entity = ".$conf->entity;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
@ -647,11 +694,11 @@ else
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount = $amount + $obj->amount;
$total_ht = $total_ht + $obj->amount;
$total_ttc = $total_ttc + $obj->amount;
$subtotal_ht = $subtotal_ht + $obj->amount;
$subtotal_ttc = $subtotal_ttc + $obj->amount;
$amount += $obj->amount;
$total_ht += $obj->amount;
$total_ttc += $obj->amount;
$subtotal_ht += $obj->amount;
$subtotal_ttc += $obj->amount;
$i++;
}
@ -664,7 +711,8 @@ else
}
print "<tr $bc[$var]><td>&nbsp;</td>";
print "<td>".$langs->trans("VATCollected")."</td>\n";
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".price($amount)."</td>\n";
if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">".price($amount)."</td>\n";
print "<td align=\"right\">".price($amount)."</td>\n";
print "</tr>\n";
}
@ -673,7 +721,8 @@ else
if ($mysoc->tva_assuj != 'franchise') // Assujeti
{
print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">&nbsp;</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">&nbsp;</td>';
print '<td colspan="3" align="right">'.price(price2num($subtotal_ttc,'MT')).'</td>';
print '</tr>';
}
@ -687,7 +736,8 @@ if ($mysoc->tva_assuj != 'franchise') // Assujeti
print '</tr>';
print '<tr class="liste_total"><td align="left" colspan="2">'.$langs->trans("Profit").'</td>';
if ($modecompta == 'CREANCES-DETTES') print '<td class="liste_total" align="right">'.price(price2num($total_ht,'MT')).'</td>';
if ($modecompta == 'CREANCES-DETTES')
print '<td class="liste_total" align="right">'.price(price2num($total_ht,'MT')).'</td>';
print '<td class="liste_total" align="right">'.price(price2num($total_ttc,'MT')).'</td>';
print '</tr>';
}

View File

@ -40,13 +40,11 @@ else {
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id > 0) $socid = $user->societe_id;
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
accessforbidden();
if (! $user->rights->compta->resultat->lire && ! $user->rights->accounting->comptarapport->lire)
accessforbidden();
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->COMPTA_MODE;
if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");
$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->COMPTA_MODE);
/*
@ -57,6 +55,9 @@ llxHeader();
$form=new Form($db);
$nomlink='';
$exportlink='';
// Affiche en-tete du rapport
if ($modecompta == 'CREANCES-DETTES')
{
@ -125,7 +126,7 @@ if ($result)
while ($i < $num)
{
$row = $db->fetch_object($result);
$encaiss[$row->dm] = $row->amount_ht;
$encaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
$encaiss_ttc[$row->dm] = $row->amount_ttc;
$i++;
}
@ -159,7 +160,10 @@ if ($modecompta != 'CREANCES-DETTES')
{
$row = $db->fetch_object($result);
$encaiss[$row->dm] += $row->amount_ht;
if (! isset($encaiss[$row->dm])) $encaiss[$row->dm]=0;
$encaiss[$row->dm] += (isset($row->amount_ht)?$row->amount_ht:0);
if (! isset($encaiss_ttc[$row->dm])) $encaiss_ttc[$row->dm]=0;
$encaiss_ttc[$row->dm] += $row->amount_ttc;
$i++;
@ -208,7 +212,10 @@ if ($result)
{
$row = $db->fetch_object($result);
$decaiss[$row->dm] = $row->amount_ht;
if (! isset($decaiss[$row->dm])) $decaiss[$row->dm]=0;
$decaiss[$row->dm] = (isset($row->amount_ht)?$row->amount_ht:0);
if (! isset($decaiss_ttc[$row->dm])) $decaiss_ttc[$row->dm]=0;
$decaiss_ttc[$row->dm] = $row->amount_ttc;
$i++;
@ -246,7 +253,10 @@ if ($modecompta == 'CREANCES-DETTES')
while ($i < $num) {
$obj = $db->fetch_object($result);
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
$decaiss[$obj->dm] += $obj->amount;
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
@ -274,7 +284,10 @@ if ($modecompta == 'CREANCES-DETTES')
while ($i < $num) {
$obj = $db->fetch_object($result);
if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
$encaiss[$obj->dm] += $obj->amount;
if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
$encaiss_ttc[$obj->dm] += $obj->amount;
$i++;
@ -302,7 +315,10 @@ else {
while ($i < $num) {
$obj = $db->fetch_object($result);
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
$decaiss[$obj->dm] += $obj->amount;
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
@ -328,7 +344,10 @@ else {
while ($i < $num) {
$obj = $db->fetch_object($result);
if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
$encaiss[$obj->dm] += $obj->amount;
if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
$encaiss_ttc[$obj->dm] += $obj->amount;
$i++;
@ -346,7 +365,7 @@ $subtotal_ht = 0;
$subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount_ht, sum(cs.amount) as amount_ttc";
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
@ -354,7 +373,7 @@ if ($modecompta == 'CREANCES-DETTES')
}
else
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc";
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
@ -375,8 +394,11 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
$decaiss[$obj->dm] += $obj->amount_ht;
$decaiss_ttc[$obj->dm] += $obj->amount_ttc;
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
$decaiss[$obj->dm] += $obj->amount;
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
@ -393,7 +415,7 @@ $subtotal_ht = 0;
$subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount_ht, sum(cs.amount) as amount_ttc";
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id";
@ -401,7 +423,7 @@ if ($modecompta == 'CREANCES-DETTES')
}
else
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc";
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
@ -422,8 +444,11 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
$decaiss[$obj->dm] += $obj->amount_ht;
$decaiss_ttc[$obj->dm] += $obj->amount_ttc;
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
$decaiss[$obj->dm] += $obj->amount;
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
@ -479,17 +504,19 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage));
print '<td align="right">&nbsp;';
if ($decaiss_ttc[$case] != 0)
if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0)
{
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price(price2num($decaiss_ttc[$case],'MT')).'</a>';
if (! isset($totsorties[$annee])) $totsorties[$annee]=0;
$totsorties[$annee]+=$decaiss_ttc[$case];
}
print "</td>";
print '<td align="right">&nbsp;';
if ($encaiss_ttc[$case] != 0)
if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0)
{
print '<a href="clientfourn.php?year='.$annee_decalage.'&month='.$mois_modulo.'">'.price(price2num($encaiss_ttc[$case],'MT')).'</a>';
if (! isset($totentrees[$annee])) $totentrees[$annee]=0;
$totentrees[$annee]+=$encaiss_ttc[$case];
}
print "</td>";
@ -523,7 +550,9 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
print '<td align="right" colspan="2"> ';
if (isset($totentrees[$annee]) || isset($totsorties[$annee]))
{
print price(price2num($totentrees[$annee]-$totsorties[$annee],'MT')).'</td>';
$in=(isset($totentrees[$annee])?price2num($totentrees[$annee], 'MT'):0);
$out=(isset($totsorties[$annee])?price2num($totsorties[$annee],' MT'):0);
print price($in-$out).'</td>';
// print '<td>&nbsp;</td>';
}
}
@ -533,6 +562,5 @@ print "</table>";
llxFooter();
$db->close();
?>
?>

View File

@ -2189,11 +2189,6 @@ abstract class CommonObject
{
$nb=0;
//if (empty($this->table_element_line)) dol_print_error('Call hasPredefinedProducts on a class with no table_element_line property');
//$sql ='SELECT COUNT(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
//$sql.='WHERE ...';
//var_dump($this->lines);
foreach($this->lines as $key => $val)
{
$qualified=0;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -44,7 +45,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
$h=0;
$head[$h][0] = $_SERVER["PHP_SELF"];
$head[$h][1] = $langs->trans("Report");
dol_fiche_head($head, $hselected, $societe->nom);
$head[$h][2] = 'report';
dol_fiche_head($head, $hselected);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
foreach($moreparam as $key => $value)

View File

@ -361,7 +361,7 @@ $moreheadjs=empty($conf->use_javascript_ajax)?"":"
});
</script>";
llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECM"),'','','','',$morejs,'',0,0);
llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0);
// Add sections to manage

View File

@ -364,6 +364,7 @@ if (! $error && $db->connected && $action == "set")
}
}
}
if ($error)
{
print "<tr><td>".$langs->trans("ErrorDirDoesNotExists",$main_data_dir);
@ -377,14 +378,14 @@ if (! $error && $db->connected && $action == "set")
{
//ODT templates
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$srcroot='./doctemplates';
$srcroot=$main_dir.'/install/doctemplates';
$destroot=$main_data_dir.'/doctemplates';
$docs=array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice');
foreach($docs as $dir => $file)
foreach($docs as $cursordir => $cursorfile)
{
$src=$srcroot.'/thirdparties/template_'.$file.'.odt';
$dirodt=$destroot.'/'.$dir;
$dest=$dirodt.'/template_'.$file.'.odt';
$src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
$dirodt=$destroot.'/'.$cursordir;
$dest=$dirodt.'/template_'.$cursorfile.'.odt';
dol_mkdir($dirodt);
$result=dol_copy($src,$dest,0,0);

File diff suppressed because it is too large Load Diff

View File

@ -541,7 +541,8 @@ class Project extends CommonObject
if (!$error)
{
$this->db->commit();
$this->statut=1;
$this->db->commit();
return 1;
}
else

View File

@ -314,7 +314,7 @@ if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confi
}
else
{
$object->id=$result;
$object->fetch($result); // Load new object
$action='edit';
$comefromclone=true;
}
@ -494,7 +494,9 @@ else
// Customer
print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $form->select_company($object->societe->id,'socid','',1,1);
$text=$form->select_company($object->societe->id,'socid','',1,1);
$texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty");
print $form->textwithtooltip($text.' '.img_help(),$texthelp,1);
print '</td></tr>';
// Visibility