222 changes: 0 additions & 222 deletions htdocs/admin/carrier.php

This file was deleted.

2 changes: 1 addition & 1 deletion htdocs/admin/compta.php
Expand Up @@ -107,7 +107,7 @@
$h = 0;

$head[$h][0] = DOL_URL_ROOT."/admin/compta.php";
$head[$h][1] = $langs->trans("Compta");
$head[$h][1] = $langs->trans("Accountancy");
$head[$h][2] = 'Compta';
$hselected=$h;
$h++;
Expand Down
4 changes: 0 additions & 4 deletions htdocs/admin/confexped.php
Expand Up @@ -84,10 +84,6 @@
$hselected=$h;
$h++;

$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
$head[$h][1] = $langs->trans("Carriers");
$h++;

if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
Expand Down
66 changes: 43 additions & 23 deletions htdocs/admin/dict.php
Expand Up @@ -6,9 +6,9 @@
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012 Marcos GarcĂ­a <marcosgdf@gmail.com>
* Copyright (C) 2012-2013 Marcos GarcĂ­a <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -147,7 +147,7 @@
$tabsql[15]= "SELECT rowid as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
$tabsql[16]= "SELECT code, label as libelle, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
$tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
$tabsql[18]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$tabsql[18]= "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
Expand Down Expand Up @@ -203,7 +203,7 @@
$tabfield[15]= "code,libelle,width,height,unit";
$tabfield[16]= "code,libelle";
$tabfield[17]= "code,libelle";
$tabfield[18]= "code,libelle";
$tabfield[18]= "code,libelle,tracking";
$tabfield[19]= "code,libelle";
$tabfield[20]= "code,libelle";
$tabfield[21]= "code,label";
Expand Down Expand Up @@ -231,7 +231,7 @@
$tabfieldvalue[15]= "code,libelle,width,height,unit";
$tabfieldvalue[16]= "code,libelle";
$tabfieldvalue[17]= "code,libelle";
$tabfieldvalue[18]= "code,libelle";
$tabfieldvalue[18]= "code,libelle,tracking";
$tabfieldvalue[19]= "code,libelle";
$tabfieldvalue[20]= "code,libelle";
$tabfieldvalue[21]= "code,label";
Expand Down Expand Up @@ -259,7 +259,7 @@
$tabfieldinsert[15]= "code,label,width,height,unit";
$tabfieldinsert[16]= "code,label";
$tabfieldinsert[17]= "code,libelle";
$tabfieldinsert[18]= "code,libelle";
$tabfieldinsert[18]= "code,libelle,tracking";
$tabfieldinsert[19]= "code,libelle";
$tabfieldinsert[20]= "code,libelle";
$tabfieldinsert[21]= "code,label";
Expand Down Expand Up @@ -391,7 +391,7 @@

// Define localtax_typeList (used for dictionnary "c_tva")
$localtax_typeList = array();
if (GETPOST("id") == 10)
if ($id == 10)
{
$localtax_typeList = array(
"0" => $langs->trans("No"),
Expand Down Expand Up @@ -441,22 +441,32 @@
if ($fieldnamekey == 'position') $fieldnamekey = 'Position';
if ($fieldnamekey == 'unicode') $fieldnamekey = 'Unicode';

$msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).'<br>';
$msg.=$langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)).'<br>';
}
}
// Other checks
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"],array('system','systemauto'))) {
$ok=0;
$msg.="Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record.<br>";
$msg.= $langs->transnoentities('ErrorReservedTypeSystemSystemAuto').'<br>';
}
if (isset($_POST["code"]) && $_POST["code"]=='0') {
$ok=0;
$msg.="Code can't contains value 0<br>";
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
{
$ok=0;
$msg.= $langs->transnoentities('ErrorCodeCantContainZero').'<br>';
}
if (!is_numeric($_POST['code']))
{
$ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br />';
}
}
if (isset($_POST["country"]) && $_POST["country"]=='0') {
$ok=0;
$msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'<br>';
$msg.=$langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")).'<br>';
}

// Clean some parameters
if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0
if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0
Expand Down Expand Up @@ -518,7 +528,7 @@
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$msg=$langs->trans("ErrorRecordAlreadyExists").'<br>';
$msg=$langs->transnoentities("ErrorRecordAlreadyExists").'<br>';
}
else {
dol_print_error($db);
Expand Down Expand Up @@ -588,7 +598,7 @@
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
$msg='<div class="error">'.$langs->trans("ErrorRecordIsUsedByChild").'</div>';
$msg='<div class="error">'.$langs->transnoentities("ErrorRecordIsUsedByChild").'</div>';
}
else
{
Expand Down Expand Up @@ -994,6 +1004,7 @@
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') {
$langs->load('agenda');
$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
Expand Down Expand Up @@ -1084,15 +1095,23 @@
}

// Est-ce une entree du dictionnaire qui peut etre desactivee ?
$iserasable=1; // Oui par defaut
if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable=0;
if (isset($obj->code) && $obj->code == 'RECEP') $iserasable=0;
if (isset($obj->code) && $obj->code == 'EF0') $iserasable=0;
// True by default
$iserasable=1;

if (isset($obj->code))
{
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable = 0;
else if ($obj->code == 'RECEP') $iserasable = 0;
else if ($obj->code == 'EF0') $iserasable = 0;
}

if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) $iserasable=0;

$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;';

// Active
print '<td align="center" nowrap="nowrap">';
if ($iserasable) print '<a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
if ($iserasable) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else
{
if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
Expand All @@ -1101,11 +1120,11 @@
print "</td>";

// Modify link
if ($iserasable) print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;action=edit#'.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'">'.img_edit().'</a></td>';
if ($iserasable) print '<td align="center"><a href="'.$url.'action=edit#'.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>';

// Delete link
if ($iserasable) print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&amp;code='.(! empty($obj->code)?$obj->code:'').'&amp;id='.$id.'&amp;action=delete">'.img_delete().'</a></td>';
if ($iserasable) print '<td align="center"><a href="'.$url.'action=delete">'.img_delete().'</a></td>';
else print '<td>&nbsp;</td>';

print "</tr>\n";
Expand Down Expand Up @@ -1153,7 +1172,7 @@

$var=!$var;
$value=$tabname[$i];
print '<tr '.$bc[$var].'><td width="30%">';
print '<tr '.$bc[$var].'><td width="50%">';
if (! empty($tabcond[$i]))
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">'.$langs->trans($tablib[$i]).'</a>';
Expand Down Expand Up @@ -1299,6 +1318,7 @@ function fieldList($fieldlist,$obj='',$tabname='')
print '<td>';
$size='';
if ($fieldlist[$field]=='libelle') $size='size="32" ';
if ($fieldlist[$field]=='tracking') $size='size="92" ';
if ($fieldlist[$field]=='accountancy_code') $size='size="15" ';
if ($fieldlist[$field]=='accountancy_code_sell') $size='size="15" ';
if ($fieldlist[$field]=='accountancy_code_buy') $size='size="15" ';
Expand Down
4 changes: 0 additions & 4 deletions htdocs/admin/expedition.php
Expand Up @@ -201,10 +201,6 @@
$head[$h][1] = $langs->trans("Setup");
$h++;

$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
$head[$h][1] = $langs->trans("Carriers");
$h++;

$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
$head[$h][1] = $langs->trans("Sending");
$hselected=$h;
Expand Down
4 changes: 0 additions & 4 deletions htdocs/admin/livraison.php
Expand Up @@ -189,10 +189,6 @@
$head[$h][1] = $langs->trans("Setup");
$h++;

$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
$head[$h][1] = $langs->trans("Carriers");
$h++;

if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/menus/edit.php
Expand Up @@ -29,6 +29,7 @@


$langs->load("admin");
$langs->load('other');

if (! $user->admin) accessforbidden();

Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/modules.php
Expand Up @@ -194,7 +194,7 @@

$nbofactivatedmodules=count($conf->modules);
$moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1));

if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'setup');

// Start to show page
Expand All @@ -206,7 +206,7 @@
if ($mode==='marketplace') print $langs->trans("ModulesMarketPlaceDesc")."<br>\n";
if ($mode==='expdev') print $langs->trans("ModuleFamilyExperimental")."<br>\n";

if ($nbofactivatedmodules <= 1) print ' '.img_warning($langs->trans("YouMustEnableOneModule"));

//print '<br>'."\n";


Expand Down
15 changes: 15 additions & 0 deletions htdocs/admin/stock.php
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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
Expand Down Expand Up @@ -67,6 +68,7 @@
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_DELETE_INVOICE", '','chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
Expand Down Expand Up @@ -239,6 +241,19 @@
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}
if (! empty($conf->facture->enabled))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td width="60%">'.$langs->trans("ReStockOnDeleteInvoice").'</td>';
print '<td width="160" align="right">';
print "<form method=\"post\" action=\"stock.php\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_DELETE_INVOICE\">";
print $form->selectyesno("STOCK_CALCULATE_ON_DELETE_INVOICE",$conf->global->STOCK_CALCULATE_ON_DELETE_INVOICE,1);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</form>\n</td>\n</tr>\n";
}

print '</table>';

Expand Down
7 changes: 5 additions & 2 deletions htdocs/categories/categorie.php
Expand Up @@ -99,7 +99,7 @@

if (empty($reshook))
{
//Suppression d'un objet d'une categorie
// Remove element from category
if ($removecat > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
Expand All @@ -113,17 +113,20 @@
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'societe';
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
$cat = new Categorie($db);
$result=$cat->fetch($removecat);
Expand Down Expand Up @@ -507,7 +510,7 @@ function formCategory($db,$object,$typeid,$socid=0)
//print $c->getNomUrl(1);
print img_object('','category').' '.$way."</td>";

// Lien supprimer
// Link to delete from category
print '<td align="right">';
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
Expand Down
1 change: 1 addition & 0 deletions htdocs/categories/class/categorie.class.php
Expand Up @@ -420,6 +420,7 @@ function del_type($obj,$type)
$sql .= " WHERE fk_categorie = ".$this->id;
$sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id;

dol_syslog(get_class($this).'::del_type sql='.$sql);
if ($this->db->query($sql))
{
return 1;
Expand Down
121 changes: 107 additions & 14 deletions htdocs/categories/viewcat.php
Expand Up @@ -36,6 +36,7 @@
$type=GETPOST('type');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
$removeelem = GETPOST('removeelem','int');

if ($id == "")
{
Expand All @@ -61,6 +62,40 @@
* Actions
*/

// Remove element from category
if ($id > 0 && $removeelem > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$tmpobject = new Product($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'societe';
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$tmpobject = new Adherent($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'member';
}

$result=$object->del_type($tmpobject,$elementtype);
if ($result < 0) dol_print_error('',$object->error);
}

if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{
if ($object->delete($user) >= 0)
Expand Down Expand Up @@ -214,7 +249,7 @@
{
print "<br>";
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ProductsAndServices")."</td></tr>\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ProductsAndServices")."</td></tr>\n";

if (count($prods) > 0)
{
Expand All @@ -224,10 +259,24 @@
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print '<td nowrap="nowrap" valign="top">';
if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service");
else print img_object($langs->trans("ShowProduct"),"product");
print " <a href='".DOL_URL_ROOT."/product/fiche.php?id=".$prod->id."'>".$prod->ref."</a></td>\n";
print $prod->getNomUrl(1,'category');
print "</td>\n";
print '<td valign="top">'.$prod->libelle."</td>\n";
// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print '</td>';
print "</tr>\n";
}
}
Expand All @@ -249,8 +298,8 @@
else
{
print "<br>";
print "<table class='noborder' width='100%'>\n";
print "<tr class='liste_titre'><td>".$langs->trans("Suppliers")."</td></tr>\n";
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Suppliers")."</td></tr>\n";

if (count($socs) > 0)
{
Expand All @@ -261,9 +310,24 @@
print "\t<tr ".$bc[$var].">\n";

print '<td nowrap="nowrap" valign="top">';
print $soc->getNomUrl(1);
print $soc->getNomUrl(1,'category_supplier');
print "</td>\n";

// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print '</td>';

print "</tr>\n";
}
}
Expand All @@ -285,8 +349,8 @@
else
{
print "<br>";
print "<table class='noborder' width='100%'>\n";
print "<tr class='liste_titre'><td>".$langs->trans("Customers")."</td></tr>\n";
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Customers")."</td></tr>\n";

if (count($socs) > 0)
{
Expand All @@ -298,9 +362,23 @@
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print '<td nowrap="nowrap" valign="top">';
print $soc->getNomUrl(1);
print $soc->getNomUrl(1,'category');
print "</td>\n";

// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print '</td>';
print "</tr>\n";
}
}
Expand All @@ -326,7 +404,7 @@
{
print "<br>";
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Member")."</td></tr>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Member")."</td></tr>\n";

if (count($prods) > 0)
{
Expand All @@ -336,10 +414,25 @@
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print '<td nowrap="nowrap" valign="top">';
print $member->getNomUrl(1);
$member->ref=$member->login;
print $member->getNomUrl(1,0,'category');
print "</td>\n";
print '<td valign="top">'.$member->lastname."</td>\n";
print '<td valign="top">'.$member->firstname."</td>\n";
// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print "</tr>\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/class/cactioncomm.class.php
Expand Up @@ -132,7 +132,7 @@ function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0)
$qualified=1;

// $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto
if ($qualified && $onlyautoornot && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTHER)
if ($qualified && $onlyautoornot && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO)

if ($qualified && $obj->module)
{
Expand Down
18 changes: 11 additions & 7 deletions htdocs/comm/action/fiche.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -592,7 +592,7 @@ function setdatefields()
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$actioncomm->note),'',280,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_7,90);
$doleditor=new DolEditor('note',(GETPOST('note')?GETPOST('note'):$actioncomm->note),'',240,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_7,90);
$doleditor->Create();
print '</td></tr>';

Expand Down Expand Up @@ -663,7 +663,6 @@ function setdatefields()
*/

$head=actions_prepare_head($act);
dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');

$now=dol_now();
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
Expand Down Expand Up @@ -711,6 +710,8 @@ function setdatefields()
print '<input type="hidden" name="ref_ext" value="'.$act->ref_ext.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1'? $backtopage : $_SERVER["HTTP_REFERER"]).'">';

dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');

print '<table class="border" width="100%">';

// Ref
Expand Down Expand Up @@ -836,14 +837,18 @@ function setdatefields()

print '</table>';

print '<center><br><input type="submit" class="button" name="edit" value="'.$langs->trans("Save").'">';
dol_fiche_end();

print '<center><input type="submit" class="button" name="edit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>';

print '</form>';
}
else
{
dol_fiche_head($head, 'card', $langs->trans("Action"),0,'action');

// Affichage fiche action en mode visu
print '<table class="border" width="100%">';

Expand Down Expand Up @@ -1021,14 +1026,13 @@ function setdatefields()
}
print '</table><br><br>';
}
}

print "</div>\n";
dol_fiche_end();
}


/*
* Barre d'actions
*
*/

print '<div class="tabsAction">';
Expand Down
6 changes: 3 additions & 3 deletions htdocs/comm/action/index.php
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
Expand Down Expand Up @@ -72,11 +72,11 @@
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$day=GETPOST("day","int")?GETPOST("day","int"):0;
$actioncode=GETPOST("actioncode","alpha",3);
$pid=GETPOST("projectid","int",3);
$status=GETPOST("status");
$type=GETPOST("type");
$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=="0"?'':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':''));

if (GETPOST('viewcal')) {
$action='show_month'; $day='';
Expand Down Expand Up @@ -271,7 +271,7 @@
$head = calendars_prepare_head('');

dol_fiche_head($head, 'card', $langs->trans('Events'), 0, $picto);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals);
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals,$actioncode);
dol_fiche_end();

$link='';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/listactions.php
Expand Up @@ -238,7 +238,7 @@
$i = 0;
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"acode",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
//print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/rapport/index.php
Expand Up @@ -132,7 +132,7 @@

if (file_exists($file))
{
print '<td align="center"><a href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a></td>';
print '<td align="center"><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a></td>';
print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>';
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/propal.php
Expand Up @@ -1534,7 +1534,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify=new Notify($db);
$text.='<br>';
$text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid);
$text.=$notify->confirmMessage('PROPAL_VALIDATE',$object->socid);
}

if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1);
Expand Down Expand Up @@ -2171,7 +2171,7 @@


//print '</td></tr></table>';
print '</div></div></div>';
print '</div></div></div>';
}


Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/apercu.php
Expand Up @@ -142,7 +142,7 @@

print "<tr $bc[$var]><td>".$langs->trans("Propal")." PDF</td>";

print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';

print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/propal/list.php
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
Expand Down Expand Up @@ -165,7 +165,7 @@
}
if ($search_montant_ht)
{
$sql.= " AND p.total_ht='".$db->escape(trim($search_montant_ht))."'";
$sql.= " AND p.total_ht='".$db->escape(price2num(trim($search_montant_ht)))."'";
}
if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%' OR pd.description LIKE '%".$db->escape($sall)."%')";
if ($socid) $sql.= ' AND s.rowid = '.$socid;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/apercu.php
Expand Up @@ -128,7 +128,7 @@

print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</td>";

print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>';
Expand All @@ -139,7 +139,7 @@
{
print "<tr $bc[$var]><td>Commande detaillee</td>";

print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>';
Expand Down
137 changes: 56 additions & 81 deletions htdocs/commande/fiche.php
@@ -1,34 +1,34 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos GarcĂ­a <marcosgdf@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos GarcĂ­a <marcosgdf@gmail.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/commande/fiche.php
* \ingroup commande
* \brief Page to show customer order
*/
* \ingroup commande
* \brief Page to show customer order
*/

require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
Expand Down Expand Up @@ -541,7 +541,7 @@

else if ($action == 'setnote_private' && $user->rights->commande->creer)
{
$result=$object->update_note_rivate(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES));
$result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES), '_private');
if ($result < 0) dol_print_error($db,$object->error);
}

Expand Down Expand Up @@ -1121,7 +1121,7 @@
{
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
$printer->print_file(GETPOST('file','alpha'),GETPOST('printer','alpha'));
$printer->print_file(GETPOST('file','alpha'),GETPOST('printer','alpha'));
}

else if ($action == 'update_extras')
Expand Down Expand Up @@ -1784,7 +1784,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify=new Notify($db);
$text.='<br>';
$text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid);
$text.=$notify->confirmMessage('ORDER_VALIDATE',$object->socid);
}
$formquestion=array();
if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1))
Expand Down Expand Up @@ -1935,15 +1935,15 @@
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print '</tr>';

if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
{
$filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
}
else
{
$filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
$filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
{
$filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
}
else
{
$filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
$filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
}

// Relative and absolute discounts
Expand Down Expand Up @@ -2135,48 +2135,23 @@
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
if(count($extrafields->attribute_label) > 0) {

if ($action == 'edit_extras')
{
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
}

// TODO : use showOptionals($extrafields) function
foreach($extrafields->attribute_label as $key=>$label)
{
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
if ($extrafields->attribute_type[$key] == 'separate')
if ($action == 'edit_extras')
{
print $extrafields->showSeparator($key);
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
}
else
{
print '<tr><td';
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.'</td><td colspan="3">';

// Convert date into timestamp format
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
{
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key];
}

if ($action == 'edit_extras' && $user->rights->propal->creer)
{
print $extrafields->showInputField($key,$value);
}
else
{
print $extrafields->showOutputField($key,$value);
}
print '</td></tr>'."\n";
if ($action == 'edit_extras' && $user->rights->propal->creer) {
print $object->showOptionals($extrafields,'edit');
}
else {
print $object->showOptionals($extrafields);
}
}

if(count($extrafields->attribute_label) > 0) {

if ($action == 'edit_extras' && $user->rights->propal->creer)
{
Expand All @@ -2195,9 +2170,9 @@
}
}

$rowspan=4;
if ($mysoc->localtax1_assuj=="1") $rowspan++;
if ($mysoc->localtax2_assuj=="1") $rowspan++;
$rowspan=4;
if ($mysoc->localtax1_assuj=="1") $rowspan++;
if ($mysoc->localtax2_assuj=="1") $rowspan++;

// Total HT
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
Expand Down Expand Up @@ -2307,7 +2282,7 @@

/*
* Boutons actions
*/
*/
if ($action != 'presend')
{
if ($user->societe_id == 0 && $action <> 'editline')
Expand Down Expand Up @@ -2436,7 +2411,7 @@
print '</div>';
}
}
print '<br>';
print '<br>';


if ($action != 'presend')
Expand All @@ -2447,7 +2422,7 @@

/*
* Documents generes
*/
*/
$comref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
$relativepath = $comref.'/'.$comref.'.pdf';
Expand All @@ -2461,7 +2436,7 @@

/*
* Linked object block
*/
*/
$somethingshown=$object->showLinkedObjectBlock();

print '</div><div class="fichehalfright"><div class="ficheaddleft">';
Expand All @@ -2473,7 +2448,7 @@
$somethingshown=$formactions->showactions($object,'order',$socid);

//print '</td></tr></table>';
print '</div></div></div>';
print '</div></div></div>';
}


Expand Down
6,454 changes: 3,316 additions & 3,138 deletions htdocs/compta/facture.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions htdocs/compta/facture/apercu.php
Expand Up @@ -318,7 +318,7 @@

print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";

print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($file)). '</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>';
Expand All @@ -328,7 +328,7 @@
{
print "<tr $bc[$var]><td>Facture detaillee</td>";

print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>';
Expand Down
6,737 changes: 3,391 additions & 3,346 deletions htdocs/compta/facture/class/facture.class.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions htdocs/compta/facture/list.php
Expand Up @@ -3,7 +3,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
Expand Down Expand Up @@ -183,11 +183,11 @@
}
if ($search_montant_ht)
{
$sql.= ' AND f.total = \''.$db->escape(trim($search_montant_ht)).'\'';
$sql.= ' AND f.total = \''.$db->escape(price2num(trim($search_montant_ht))).'\'';
}
if ($search_montant_ttc)
{
$sql.= ' AND f.total_ttc = \''.$db->escape(trim($search_montant_ttc)).'\'';
$sql.= ' AND f.total_ttc = \''.$db->escape(price2num(trim($search_montant_ttc))).'\'';
}
if ($month > 0)
{
Expand Down
149 changes: 63 additions & 86 deletions htdocs/compta/journal/purchasesjournal.php
Expand Up @@ -3,7 +3,8 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2011-2012 Alexandre spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013 Marcos GarcĂ­a <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -99,12 +100,9 @@
$sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,";
$sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,";
$sql.= " ct.accountancy_code_buy as account_tva, ct.recuperableonly,";
$sql.= " ctl1.accountancy_code_buy as account_localtax1, ctl2.accountancy_code_buy as account_localtax2";
$sql.= " ct.accountancy_code_buy as account_tva, ct.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl1 ON fd.localtax1_tx = ctl1.localtax1 AND ctl1.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl2 ON fd.localtax2_tx = ctl2.localtax2 AND ctl2.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn";
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ;
Expand Down Expand Up @@ -145,6 +143,11 @@
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));

$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
$compta_localtax1= (! empty($account_localtax1[2])?$account_localtax1[2]:$langs->trans("CodeNotDef"));
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
$compta_localtax2= (! empty($account_localtax2[2])?$account_localtax2[2]:$langs->trans("CodeNotDef"));

$tabfac[$obj->rowid]["date"] = $obj->datef;
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier;
$tabfac[$obj->rowid]["type"] = $obj->type;
Expand All @@ -166,7 +169,6 @@
/*
* Show result array
*/
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
///print "<td>".$langs->trans("JournalNum")."</td>";
Expand All @@ -177,96 +179,71 @@
print "</tr>\n";

$var=true;
$r='';

$invoicestatic=new FactureFournisseur($db);
$companystatic=new Fournisseur($db);

foreach ($tabfac as $key => $val)
{
$invoicestatic->id=$key;
$invoicestatic->ref=$val["ref"];
$invoicestatic->type=$val["type"];

// product
foreach ($tabht[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var]." >";
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$langs->trans("Products")."</td>";
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
print "</tr>";
}
}
// vat
foreach ($tabtva[$key] as $k => $mt)
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];

$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];

$lines = array(
array(
'var' => $tabht[$key],
'label' => $langs->trans('Products'),
),
array(
'var' => $tabtva[$key],
'label' => $langs->trans('VAT')
),
array(
'var' => $tablocaltax1[$key],
'label' => $langs->transcountry('LT1', $mysoc->country_code)
),
array(
'var' => $tablocaltax2[$key],
'label' => $langs->transcountry('LT2', $mysoc->country_code)
),
array(
'var' => $tabttc[$key],
'label' => $langs->trans('ThirdParty').' ('.$companystatic->getNomUrl(0, 'supplier', 16).')',
'nomtcheck' => true,
'inv' => true
)
);

foreach ($lines as $line)
{
if ($mt)
foreach ($line['var'] as $k => $mt)
{
print "<tr ".$bc[$var]." >";
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$langs->trans("VAT")."</td>";
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
print "</tr>";
if (isset($line['nomtcheck']) || $mt)
{
print "<tr ".$bc[$var]." >";
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$line['label']."</td>";

if (isset($line['inv']))
{
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
}
else
{
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
}

print "</tr>";
}
}
}
// localtax1
foreach ($tablocaltax1[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$langs->transcountrynoentities("LT1",$mysoc->country_code)."</td>";
print "<td align='right'>".($mt>=0?price($mt):'')."</td>";
print "<td align='right'>".($mt<0?price(-$mt):'')."</td>";
print "</tr>";
}
}
// localtax2
foreach ($tablocaltax2[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$langs->transcountrynoentities("LT2",$mysoc->country_code)."</td>";
print "<td align='right'>".($mt>=0?price($mt):'')."</td>";
print "<td align='right'>".($mt<0?price(-$mt):'')."</td>";
print "</tr>";
}
}
print "<tr ".$bc[$var].">";
// third party
//print "<td>".$conf->global->COMPTA_JOURNAL_BUY."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";

foreach ($tabttc[$key] as $k => $mt)
{
$companystatic->id=$tabcompany[$key]['id'];
$companystatic->name=$tabcompany[$key]['name'];

print "<td>".$k;
print "</td><td>".$langs->trans("ThirdParty");
print ' ('.$companystatic->getNomUrl(0,'supplier',16).')';
print "</td>";
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
}
print "</tr>";

$var = !$var;
}
Expand Down
146 changes: 67 additions & 79 deletions htdocs/compta/journal/sellsjournal.php
Expand Up @@ -3,8 +3,8 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013 Marcos GarcĂ­a <marcosgdf@gmail.com>
* Copyright (C) 2011-2012 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013 Marcos GarcĂ­a <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -102,15 +102,12 @@
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
$sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly,";
$sql.= " ctl1.accountancy_code_sell as account_localtax1, ctl2.accountancy_code_sell as account_localtax2";
$sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture";
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl1 ON fd.localtax1_tx = ctl1.localtax1 AND ctl1.fk_pays = '".$idpays."'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ctl2 ON fd.localtax2_tx = ctl2.localtax2 AND ctl2.fk_pays = '".$idpays."'";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
Expand All @@ -129,6 +126,8 @@
$tablocaltax2 = array();
$tabttc = array();
$tabcompany = array();
$account_localtax1=0;
$account_localtax2=0;

$num = $db->num_rows($result);
$i=0;
Expand All @@ -147,9 +146,12 @@
}
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)?$conf->global->COMPTA_VAT_ACCOUNT:$langs->trans("CodeNotDef"));
$compta_tva = (! empty($obj->account_tva)?$obj->account_tva:$cpttva);
$compta_localtax1 = (! empty($obj->account_localtax1)?$obj->account_localtax1:$langs->trans("CodeNotDef"));
$compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef"));

$account_localtax1=getLocalTaxesFromRate($obj->tva_tx, 1, $mysoc);
$compta_localtax1= (! empty($account_localtax1[3])?$account_localtax1[3]:$langs->trans("CodeNotDef"));
$account_localtax2=getLocalTaxesFromRate($obj->tva_tx, 2, $mysoc);
$compta_localtax2= (! empty($account_localtax2[3])?$account_localtax2[3]:$langs->trans("CodeNotDef"));

//la ligne facture
$tabfac[$obj->rowid]["date"] = $obj->datef;
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
Expand Down Expand Up @@ -178,17 +180,15 @@
*/


$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
//print "<td>".$langs->trans("JournalNum")."</td>";
print "<td>".$langs->trans("Date")."</td><td>".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")</td>";
print "<td>".$langs->trans("Account")."</td>";
print "<td>".$langs->trans("Type")."</td><td align='right'>".$langs->trans("Debit")."</td><td align='right'>".$langs->trans("Credit")."</td>";
print '<td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Piece').' ('.$langs->trans('InvoiceRef').')</td>';
print '<td>'.$langs->trans('Account').'</td>';
print '<td>'.$langs->trans('Type').'</td><td align="right">'.$langs->trans('Debit').'</td><td align="right">'.$langs->trans('Credit').'</td>';
print "</tr>\n";

$var=true;
$r='';

$invoicestatic=new Facture($db);
$companystatic=new Client($db);
Expand All @@ -199,74 +199,62 @@
$invoicestatic->ref=$val["ref"];
$invoicestatic->type=$val["type"];

print "<tr ".$bc[$var].">";
// third party
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
foreach ($tabttc[$key] as $k => $mt)
$companystatic->id=$tabcompany[$key]['id'];
$companystatic->name=$tabcompany[$key]['name'];
$companystatic->client=$tabcompany[$key]['client'];

$lines = array(
array(
'var' => $tabttc[$key],
'label' => $langs->trans('ThirdParty').' ('.$companystatic->getNomUrl(0, 'customer', 16).')',
'nomtcheck' => true,
'inv' => true
),
array(
'var' => $tabht[$key],
'label' => $langs->trans('Products'),
),
array(
'var' => $tabtva[$key],
'label' => $langs->trans('VAT')
),
array(
'var' => $tablocaltax1[$key],
'label' => $langs->transcountry('LT1', $mysoc->country_code)
),
array(
'var' => $tablocaltax2[$key],
'label' => $langs->transcountry('LT2', $mysoc->country_code)
)
);

foreach ($lines as $line)
{
$companystatic->id=$tabcompany[$key]['id'];
$companystatic->name=$tabcompany[$key]['name'];
$companystatic->client=$tabcompany[$key]['client'];
print "<td>".$k;
print "</td><td>".$langs->trans("ThirdParty");
print ' ('.$companystatic->getNomUrl(0,'customer',16).')';
print "</td><td align='right'>".($mt>=0?price($mt):'')."</td><td align='right'>".($mt<0?price(-$mt):'')."</td>";
}
print "</tr>";
// product
foreach ($tabht[$key] as $k => $mt)
{
if ($mt)
foreach ($line['var'] as $k => $mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k;
print "</td><td>".$langs->trans("Products")."</td><td align='right'>".($mt<0?price(-$mt):'')."</td><td align='right'>".($mt>=0?price($mt):'')."</td></tr>";
if (isset($line['nomtcheck']) || $mt)
{
print "<tr ".$bc[$var]." >";
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k."</td><td>".$line['label']."</td>";

if (isset($line['inv']))
{
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
}
else
{
print '<td align="right">'.($mt<0?price(-$mt):'')."</td>";
print '<td align="right">'.($mt>=0?price($mt):'')."</td>";
}

print "</tr>";
}
}
}
// vat
foreach ($tabtva[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k;
print "</td><td>".$langs->trans("VAT")."</td><td align='right'>".($mt<0?price(-$mt):'')."</td><td align='right'>".($mt>=0?price($mt):'')."</td></tr>";
}
}
// localtax1
foreach ($tablocaltax1[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k;
print "</td><td>".$langs->transcountrynoentities("LT1",$mysoc->country_code)."</td><td align='right'>".($mt<0?price(-$mt):'')."</td><td align='right'>".($mt>=0?price($mt):'')."</td></tr>";
}
}
// localtax2
foreach ($tablocaltax2[$key] as $k => $mt)
{
if ($mt)
{
print "<tr ".$bc[$var].">";
//print "<td>".$conf->global->COMPTA_JOURNAL_SELL."</td>";
print "<td>".$val["date"]."</td>";
print "<td>".$invoicestatic->getNomUrl(1)."</td>";
print "<td>".$k;
print "</td><td>".$langs->transcountrynoentities("LT2",$mysoc->country_code)."</td><td align='right'>".($mt<0?price(-$mt):'')."</td><td align='right'>".($mt>=0?price($mt):'')."</td></tr>";
}
}

$var = !$var;
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/paiement.php
Expand Up @@ -286,7 +286,8 @@ function setPaiementCode()
$(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
if ($(\'#fieldchqemetteur\').val() == \'\')
{
$(\'#fieldchqemetteur\').val(jQuery(\'#thirdpartylabel\').val());
var emetteur = ('.$facture->type.' == 2) ? \''.dol_escape_htmltag(MAIN_INFO_SOCIETE_NOM).'\' : jQuery(\'#thirdpartylabel\').val();
$(\'#fieldchqemetteur\').val(emetteur);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/paiement/rapport.php
Expand Up @@ -154,7 +154,7 @@
$var=!$var;
$tfile = $dir . '/'.$year.'/'.$file;
$relativepath = $year.'/'.$file;
print "<tr $bc[$var]>".'<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a></td>';
print "<tr ".$bc[$var].">".'<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=facture_paiement&amp;file='.urlencode($relativepath).'">'.img_pdf().' '.$file.'</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($tfile)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($tfile),"dayhour").'</td></tr>';
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/bon.php
Expand Up @@ -63,7 +63,7 @@

$relativepath = 'bon/'.$object->ref;

print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';

print '</td></tr>';
print '</table><br>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/factures.php
Expand Up @@ -94,7 +94,7 @@
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';

dol_fiche_end();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/fiche-rejet.php
Expand Up @@ -93,7 +93,7 @@
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';

dol_fiche_end();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/fiche-stat.php
Expand Up @@ -92,7 +92,7 @@
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';

dol_fiche_end();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/fiche.php
Expand Up @@ -191,7 +191,7 @@
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';

dol_fiche_end();
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/lignes.php
Expand Up @@ -101,7 +101,7 @@
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';

dol_fiche_end();
Expand Down
390 changes: 390 additions & 0 deletions htdocs/compta/stats/cabyprodserv.php
@@ -0,0 +1,390 @@
<?php
/* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/compta/stats/cabyprodserv.php
* \brief Page reporting TO by Products & Services
*/

require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';

$langs->load("products");
$langs->load("categories");
$langs->load("errors");

// Security pack (data & check)
$socid = GETPOST('socid','int');

if ($user->societe_id > 0) $socid = $user->societe_id;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');

// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->COMPTA_MODE;
if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");

$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
if (! $sortorder) $sortorder="asc";
if (! $sortfield) $sortfield="name";

// Category
$selected_cat = (int)GETPOST('search_categ', 'int');
$subcat = false;
if (GETPOST('subcat', 'alpha') === 'yes') {
$subcat = true;
}

// Date range
$year=GETPOST("year");
$month=GETPOST("month");
$date_startyear = GETPOST("date_startyear");
$date_startmonth = GETPOST("date_startmonth");
$date_startday = GETPOST("date_startday");
$date_endyear = GETPOST("date_endyear");
$date_endmonth = GETPOST("date_endmonth");
$date_endday = GETPOST("date_endday");
if (empty($year))
{
$year_current = strftime("%Y",dol_now());
$month_current = strftime("%m",dol_now());
$year_start = $year_current;
} else {
$year_current = $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_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q")?GETPOST("q"):0;
if ($q==0)
{
// We define date_start and date_end
$month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$year_end=$year_start;
$month_end=$month_start;
if (! GETPOST("month")) // If month not forced
{
if (! GETPOST('year') && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end=$month_start-1;
if ($month_end < 1) $month_end=12;
else $year_end++;
}
$date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false);
}
if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); }
if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); }
if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); }
if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
} else {
// TODO We define q
}

$commonparams=array();
$commonparams['modecompta']=$modecompta;
$commonparams['sortorder'] = $sortorder;
$commonparams['sortfield'] = $sortfield;

$headerparams = array();
$headerparams['date_startyear'] = $date_startyear;
$headerparams['date_startmonth'] = $date_startmonth;
$headerparams['date_startday'] = $date_startday;
$headerparams['date_endyear'] = $date_endyear;
$headerparams['date_endmonth'] = $date_endmonth;
$headerparams['date_endday'] = $date_endday;
$headerparams['q'] = $q;

$tableparams = array();
$tableparams['search_categ'] = $selected_cat;
$tableparams['subcat'] = ($subcat === true)?'yes':'';

// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);

foreach($allparams as $key => $value) {
$paramslink .= '&' . $key . '=' . $value;
}
/*
* View
*/
llxHeader();
$form=new Form($db);
$formother = new FormOther($db);

// Show report header
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices");

if ($modecompta=="CREANCES-DETTES") {
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">','</a>').')';

$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);

$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.= $langs->trans("DepositsAreNotIncluded");
} else {
$description.= $langs->trans("DepositsAreIncluded");
}

$builddate=time();
} else {
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">','</a>').')';

$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);

$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");

$builddate=time();
}

report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams);


// SQL request
$catotal=0;

if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,";
$sql.= " sum(DISTINCT l.total_ht) as amount, sum(DISTINCT l.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " JOIN ".MAIN_DB_PREFIX."facturedet as l";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON l.fk_facture = f.rowid";
if ($selected_cat === -2) {
$sql.=" LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
}
if ($selected_cat && $selected_cat !== -2) {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = " . $selected_cat;
if ($subcat) {
$sql.=" OR c.fk_parent = " . $selected_cat;
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE l.fk_product = p.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 ($selected_cat === -2) {
$sql.=" AND cp.fk_product is null";
}
if ($selected_cat && $selected_cat !== -2) {
$sql.= " AND cp.fk_product = p.rowid";
}
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " GROUP BY p.rowid ";
$sql.= "ORDER BY p.ref ";

$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i=0;
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount_ht[$obj->rowid] = $obj->amount;
$amount[$obj->rowid] = $obj->amount_ttc;
$name[$obj->rowid] = $obj->ref . '&nbsp;-&nbsp;' . $obj->label;
$catotal_ht+=$obj->amount;
$catotal+=$obj->amount_ttc;
$i++;
}
} else {
dol_print_error($db);
}

// Show Array
$i=0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
// Extra parameters management
foreach($headerparams as $key => $value)
{
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}

print '<table class="noborder" width="100%">';
// Category filter
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans("Category") . ': ' . $formother->select_categories(0, $selected_cat, 'search_categ', true);
print ' ';
print $langs->trans("SubCats") . '? ';
print '<input type="checkbox" name="subcat" value="yes"';
if ($subcat) {
print ' checked';
}
print '></td>';
print '<td colspan="3" align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td></tr>';
// Array header
print "<tr class=\"liste_titre\">";
print_liste_field_titre(
$langs->trans("Product"),
$_SERVER["PHP_SELF"],
"name",
"",
$paramslink,
"",
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('AmountHT'),
$_SERVER["PHP_SELF"],
"amount_ht",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("AmountTTC"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Percentage"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
// TODO: statistics?
print "</tr>\n";

// Array Data
$var=true;

if (count($amount)) {
$arrayforsort=$name;
// defining arrayforsort
if ($sortfield == 'nom' && $sortorder == 'asc') {
asort($name);
$arrayforsort=$name;
}
if ($sortfield == 'nom' && $sortorder == 'desc') {
arsort($name);
$arrayforsort=$name;
}
if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
asort($amount_ht);
$arrayforsort=$amount_ht;
}
if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
arsort($amount_ht);
$arrayforsort=$amount_ht;
}
if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
asort($amount);
$arrayforsort=$amount;
}
if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
arsort($amount);
$arrayforsort=$amount;
}
foreach($arrayforsort as $key=>$value) {
$var=!$var;
print "<tr ".$bc[$var].">";

// Third party
$fullname=$name[$key];
if ($key >= 0) {
$linkname='<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$fullname.'</a>';
} else {
$linkname=$langs->trans("PaymentsNotLinkedToProduct");
}

print "<td>".$linkname."</td>\n";

// Amount w/o VAT
print '<td align="right">';
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
} else {
print '<a href="#">';
}
print price($amount_ht[$key]);
print '</td>';

// Amount with VAT
print '<td align="right">';
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?productid='.$key.'">';
} else {
print '<a href="#">';
}
print price($amount[$key]);
print '</a>';
print '</td>';

// Percent;
print '<td align="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';

// TODO: statistics?
print "</tr>\n";
$i++;
}

// Total
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td align="right">'.price($catotal_ht).'</td>';
print '<td align="right">'.price($catotal).'</td>';
print '<td>&nbsp;</td>';
print '</tr>';

$db->free($result);
}
print "</table>";
print '</form>';
} else {
// $modecompta != 'CREANCES-DETTES'
// TODO: better message
print '<div class="warning">' . $langs->trans("WarningNotRelevant") . '</div>';
}

llxFooter();
$db->close();
?>
246 changes: 185 additions & 61 deletions htdocs/compta/stats/cabyuser.php
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Antoine Iauch <aiauch@gpcsolutions.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
Expand Down Expand Up @@ -46,6 +47,12 @@
// Date range
$year=GETPOST("year");
$month=GETPOST("month");
$date_startyear = GETPOST("date_startyear");
$date_startmonth = GETPOST("date_startmonth");
$date_startday = GETPOST("date_startday");
$date_endyear = GETPOST("date_endyear");
$date_endmonth = GETPOST("date_endmonth");
$date_endday = GETPOST("date_endday");
if (empty($year))
{
$year_current = strftime("%Y",dol_now());
Expand Down Expand Up @@ -89,9 +96,34 @@
else
{
// TODO We define q

}

$commonparams=array();
$commonparams['modecompta']=$modecompta;
$commonparams['sortorder'] = $sortorder;
$commonparams['sortfield'] = $sortfield;

$headerparams = array();
$headerparams['date_startyear'] = $date_startyear;
$headerparams['date_startmonth'] = $date_startmonth;
$headerparams['date_startday'] = $date_startday;
$headerparams['date_endyear'] = $date_endyear;
$headerparams['date_endmonth'] = $date_endmonth;
$headerparams['date_endday'] = $date_endday;
$headerparams['q'] = $q;

$tableparams = array();
$tableparams['search_categ'] = $selected_cat;
$tableparams['subcat'] = ($subcat === true)?'yes':'';

// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);

foreach($allparams as $key => $value) {
$paramslink .= '&' . $key . '=' . $value;
}

/*
* View
Expand All @@ -102,9 +134,8 @@

$form=new Form($db);

// Affiche en-tete du rapport
if ($modecompta=="CREANCES-DETTES")
{
// Show report header
if ($modecompta=="CREANCES-DETTES") {
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$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);
Expand All @@ -114,8 +145,7 @@
else $description.= $langs->trans("DepositsAreIncluded");
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
else {
} else {
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">','</a>').')';
$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);
Expand All @@ -131,20 +161,29 @@
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam);


// Charge tableau
$catotal=0;
if ($modecompta == 'CREANCES-DETTES')
// Show array
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
// Extra parameters management
foreach($headerparams as $key => $value)
{
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}

$catotal=0;
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(f.total) as amount, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid";
$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)."'";
}
else
{
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)."'";
}
} else {
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
Expand All @@ -155,35 +194,35 @@
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.rowid = pf.fk_paiement";
$sql.= " WHERE 1=1";
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if ($date_start && $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;
$sql .= " GROUP BY u.rowid, u.lastname, u.firstname";
$sql .= " ORDER BY u.rowid";

$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i=0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount[$obj->rowid] = $obj->amount_ttc;
$name[$obj->rowid] = $obj->lastname.' '.$obj->firstname;
$catotal+=$obj->amount_ttc;
$i++;
$amount_ht[$obj->rowid] = $obj->amount;
$amount[$obj->rowid] = $obj->amount_ttc;
$name[$obj->rowid] = $obj->name.' '.$obj->firstname;
$catotal_ht+=$obj->amount;
$catotal+=$obj->amount_ttc;
$i++;
}
}
else {
} else {
dol_print_error($db);
}

// On ajoute les paiements ancienne version, non lies par paiement_facture donc sans user
if ($modecompta != 'CREANCES-DETTES')
{
$sql = "SELECT -1 as rowidx, '' as lastname, '' as firstname, sum(p.amount) as amount_ttc";
// Adding old-version payments, non-bound by "paiement_facture" then without User
if ($modecompta != 'CREANCES-DETTES') {
$sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
Expand All @@ -192,42 +231,86 @@
$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 ($date_start && $date_end) {
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql.= " GROUP BY rowidx, name, firstname";
$sql.= " ORDER BY rowidx";

$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i=0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount[$obj->rowidx] = $obj->amount_ttc;
$name[$obj->rowidx] = $obj->lastname.' '.$obj->firstname;
$name[$obj->rowidx] = $obj->name.' '.$obj->firstname;
$catotal+=$obj->amount_ttc;
$i++;
}
}
else {
} else {
dol_print_error($db);
}
}


$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("User"),$_SERVER["PHP_SELF"],"name","",'&amp;year='.($year).'&modecompta='.$modecompta,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"amount_ttc","",'&amp;year='.($year).'&modecompta='.$modecompta,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Percentage"),$_SERVER["PHP_SELF"],"amount_ttc","",'&amp;year='.($year).'&modecompta='.$modecompta,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OtherStatistics"),$_SERVER["PHP_SELF"],"","","",'align="center" width="20%"');
print_liste_field_titre(
$langs->trans("User"),
$_SERVER["PHP_SELF"],
"name",
"",
$paramslink,
"",
$sortfield,
$sortorder
);
if ($modecompta == 'CREANCES-DETTES') {
print_liste_field_titre(
$langs->trans('AmountHT'),
$_SERVER["PHP_SELF"],
"amount_ht",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
} else {
print '<td colspan="1"></td>';
}
print_liste_field_titre(
$langs->trans("AmountTTC"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Percentage"),
$_SERVER["PHP_SELF"],"amount_ttc",
"",
$paramslink,
'align="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("OtherStatistics"),
$_SERVER["PHP_SELF"],
"",
"",
"",
'align="center" width="20%"'
);
print "</tr>\n";
$var=true;

if (count($amount))
{
if (count($amount)) {
$arrayforsort=$name;

// We define arrayforsort
Expand All @@ -239,6 +322,14 @@
arsort($name);
$arrayforsort=$name;
}
if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
asort($amount_ht);
$arrayforsort=$amount_ht;
}
if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
arsort($amount_ht);
$arrayforsort=$amount_ht;
}
if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
asort($amount);
$arrayforsort=$amount;
Expand All @@ -248,32 +339,52 @@
$arrayforsort=$amount;
}

foreach($arrayforsort as $key => $value)
{
foreach($arrayforsort as $key => $value) {
$var=!$var;
print "<tr ".$bc[$var].">";

// Third party
$fullname=$name[$key];
if ($key >= 0) {
$linkname='<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$key.'">'.img_object($langs->trans("ShowUser"),'user').' '.$fullname.'</a>';
}
else {
} else {
$linkname=$langs->trans("PaymentsNotLinkedToUser");
}
print "<td>".$linkname."</td>\n";

// Amount
// Amount w/o VAT
print '<td align="right">';
if ($modecompta != 'CREANCES-DETTES')
{
if ($key > 0) print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid='.$key.'">';
else print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid=-1">';
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid='.$key.'">';
} else {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid=-1">';
}
} else {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
} else {
print '<a href="#">';
}
print price($amount_ht[$key]);
}
else
{
if ($key > 0) print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
else print '<a href="#">';
print '</td>';

// Amount with VAT
print '<td align="right">';
if ($modecompta != 'CREANCES-DETTES') {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid='.$key.'">';
} else {
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/liste.php?userid=-1">';
}
} else {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?userid='.$key.'">';
} else {
print '<a href="#">';
}
}
print price($amount[$key]);
print '</td>';
Expand All @@ -283,17 +394,30 @@

// Other stats
print '<td align="center">';
if (! empty($conf->propal->enabled) && $key>0) print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
if (! empty($conf->commande->enabled) && $key>0) print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
if (! empty($conf->facture->enabled) && $key>0) print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
if (! empty($conf->propal->enabled) && $key>0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("ProposalStats"),"stats").'</a>&nbsp;';
}
if (! empty($conf->commande->enabled) && $key>0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("OrderStats"),"stats").'</a>&nbsp;';
}
if (! empty($conf->facture->enabled) && $key>0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?userid='.$key.'">'.img_picto($langs->trans("InvoiceStats"),"stats").'</a>&nbsp;';
}
print '</td>';

print "</tr>\n";
$i++;
}

// Total
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'.price($catotal).'</td><td>&nbsp;</td>';
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
if ($modecompta != 'CREANCES-DETTES') {
print '<td colspan="1"></td>';
} else {
print '<td align="right">'.price($catotal_ht).'</td>';
}
print '<td align="right">'.price($catotal).'</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';

Expand Down