Move permission "see hidden categories" into "see hidden products/services".

This commit is contained in:
Laurent Destailleur 2010-03-12 23:40:39 +00:00
parent 7906b63597
commit 8980d9acc2
44 changed files with 378 additions and 316 deletions

View File

@ -3,17 +3,21 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.9 compared to 2.8 *****
For users:
- New: Support products property length and area.
- New: Add "payment due before" field in invoice exports
- New: Add feature to resize or crop image files (for products photos)
- New: task #10113 : Show list of emailing on clicking on "number of mass emailing received"
- New: Add default language for third parties and use it when multilang is enabled
to define default language for document generation.
- New: Can reopen a closed supplier invoice.
- New: Move permission "see hidden categories" into "see hidden products/services".
- Fix: Format number was wrong for ar_AR language.
- Fix: Can change password if has only permission change password.
For developers:
- More comments in code
- More comments in code.
- Uniformize some code.
- First delete of useless pre.inc.php files.
***** ChangeLog for 2.8 compared to 2.7 *****

View File

@ -77,7 +77,8 @@ $sql.= " u.login, u.name, u.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid";
$sql.= " WHERE 1=1";
if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit( $limit, $offset);
$resql=$db->query($sql);
if ($resql)

View File

@ -92,7 +92,8 @@ $sql = "SELECT s.rowid, s.nom, ".$db->pdate("b.dateb")." as dateb, b.rowid as bi
$sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE b.fk_soc = s.rowid AND b.fk_user=u.rowid";
if (! $user->admin) $sql.= " AND b.fk_user = ".$user->id;
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit( $limit, $offset);
$resql=$db->query($sql);
if ($resql)

View File

@ -84,7 +84,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$nbtotalofrecords = $db->num_rows($result);
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit +1, $offset);
$result = $db->query($sql);
if ($result)

View File

@ -119,7 +119,8 @@ if ($_GET["contactname"]) // acces a partir du module de recherche
$sortorder = "ASC";
}
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit($limit+1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1, $offset);
$resql = $db->query($sql);
if ($resql)

View File

@ -357,7 +357,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
if ($search_nom) $sql.= " AND mc.nom like '%".addslashes($search_nom)."%'";
if ($search_prenom) $sql.= " AND mc.prenom like '%".addslashes($search_prenom)."%'";
if ($search_email) $sql.= " AND mc.email like '%".addslashes($search_email)."%'";
if ($sortfield) { $sql .= " ORDER BY $sortfield $sortorder"; }
$sql .= $db->order($sortfield,$sortorder);
$sql .= $db->plimit($conf->liste_limit+1, $offset);
$resql=$db->query($sql);

View File

@ -72,7 +72,8 @@ if ($filteremail)
if ($sall) $sql.= " AND (m.titre like '%".$sall."%' OR m.sujet like '%".$sall."%' OR m.body like '%".$sall."%')";
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="m.rowid";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit +1, $offset);
}
else
{
@ -83,7 +84,8 @@ else
if ($sall) $sql.= " AND (m.titre like '%".$sall."%' OR m.sujet like '%".$sall."%' OR m.body like '%".$sall."%')";
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="m.rowid";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit +1, $offset);
}
dol_syslog("sql=".$sql);

View File

@ -800,7 +800,7 @@ class Form
if ($conf->global->MAIN_USE_JQUERY)
{
print ajax_autocompleter2('','keysearch',DOL_URL_ROOT.'/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,'');
print '<div class="ui-widget">';
print '<label for="birds">'.$langs->trans("RefOrLabel").':</label>';
print '<input id="birds" />';
@ -821,7 +821,7 @@ class Form
print ajax_updater($htmlname,'keysearch',DOL_URL_ROOT.'/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); // Indicator is '' to disable it as it is alreay output
print '</td></tr>';
print '</table>';
}
}
}
else
{
@ -844,18 +844,11 @@ class Form
global $langs,$conf,$user;
$sql = "SELECT ";
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
{
$sql.="DISTINCT";
}
$sql.= " p.rowid, p.label, p.ref, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.duration, p.stock";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p ";
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if($finished == 0)
{
@ -870,11 +863,6 @@ class Form
{
$sql.= " AND p.envente = ".$status;
}
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
$sql.= " ORDER BY p.ref";

View File

@ -138,13 +138,6 @@ class FormProduct
$measuring_units[-3] = $langs->trans("WeightUnitg");
$measuring_units[-6] = $langs->trans("WeightUnitmg");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
else if ($measuring_style == 'size')
{
$measuring_units[0] = $langs->trans("SizeUnitm");
@ -152,6 +145,20 @@ class FormProduct
$measuring_units[-2] = $langs->trans("SizeUnitcm");
$measuring_units[-3] = $langs->trans("SizeUnitmm");
}
else if ($measuring_style == 'surface')
{
$measuring_units[0] = $langs->trans("SurfaceUnitm2");
$measuring_units[-2] = $langs->trans("SurfaceUnitdm2");
$measuring_units[-4] = $langs->trans("SurfaceUnitcm2");
$measuring_units[-6] = $langs->trans("SurfaceUnitmm2");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
print '<select class="flat" name="'.$name.'">';
if ($adddefault) print '<option value="0">'.$langs->trans("Default").'</option>';

View File

@ -71,21 +71,14 @@ class box_produits extends ModeleBoxes {
if ($user->rights->produit->lire || $user->rights->service->lire)
{
$clause = " WHERE";
$sql = "SELECT p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.envente";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
$sql.= $clause." COALESCE(c.visible,1)=1";
$clause = " AND";
}
$sql.= $clause." p.entity = ".$conf->entity;
$sql.= " WHERE p.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0';
if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1';
$sql.= " ORDER BY p.datec DESC";
$sql.= $db->order('p.datec', 'DESC');
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);

View File

@ -53,8 +53,8 @@ class box_services_vendus extends ModeleBoxes {
}
/**
* \brief Charge les donn<EFBFBD>es en m<EFBFBD>moire pour affichage ult<EFBFBD>rieur
* \param $max Nombre maximum d'enregistrements <EFBFBD> charger
* \brief Charge les donnees en memoire pour affichage ulterieur
* \param $max Nombre maximum d'enregistrements a charger
*/
function loadBox($max=5)
{
@ -79,22 +79,15 @@ class box_services_vendus extends ModeleBoxes {
$sql.= ", ".MAIN_DB_PREFIX."product as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ")";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as ca ON cp.fk_categorie = ca.rowid";
}
$sql.= " WHERE s.rowid = c.fk_soc";
$sql.= " AND s.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND c.rowid = cd.fk_contrat";
$sql.= " AND cd.fk_product = p.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(ca.visible,1)=1';
}
$sql.= " ORDER BY c.tms DESC ";
$sql.= $db->order("c.tms","DESC");
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -19,7 +19,7 @@
/**
* \defgroup category Module categories
* \brief Module pour g<EFBFBD>rer les cat<EFBFBD>gories
* \brief Module to manage categories
* \version $Id$
*/
@ -82,32 +82,25 @@ class modCategorie extends DolibarrModules
$this->rights[$r][0] = 241; // id de la permission
$this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour)
$this->rights[$r][3] = 1; // La permission est-elle une permission par d<EFBFBD>faut
$this->rights[$r][2] = 'r'; // type de la permission (deprecated)
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'lire';
$r++;
$this->rights[$r][0] = 242; // id de la permission
$this->rights[$r][1] = 'Creer/modifier les categories'; // libelle de la permission
$this->rights[$r][2] = 'w'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut
$this->rights[$r][2] = 'w'; // type de la permission (deprecated)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = 243; // id de la permission
$this->rights[$r][1] = 'Supprimer les categories'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut
$this->rights[$r][2] = 'd'; // type de la permission (deprecated)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer';
$r++;
$this->rights[$r][0] = 244; // id de la permission
$this->rights[$r][1] = 'Voir le contenu des categories cachees'; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (d<>pr<70>ci<63> <20> ce jour)
$this->rights[$r][3] = 1; // La permission est-elle une permission par d<>faut
$this->rights[$r][4] = 'voir';
$r++;
// Exports
//--------
$r=0;

View File

@ -41,7 +41,6 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
*/
class modProduit extends DolibarrModules
{
/**
* \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acces base
@ -50,8 +49,8 @@ class modProduit extends DolibarrModules
{
global $conf;
$this->db = $DB ;
$this->numero = 50 ;
$this->db = $DB;
$this->numero = 50;
$this->family = "products";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
@ -118,6 +117,13 @@ class modProduit extends DolibarrModules
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer';
$this->rights[$r][0] = 36; // id de la permission
$this->rights[$r][1] = 'Voir/gérer les produits cachés'; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (deprecated)
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'hidden';
$r++;
$r++;
$this->rights[$r][0] = 38; // Must be same permission than in service module
$this->rights[$r][1] = 'Exporter les produits';

View File

@ -109,6 +109,13 @@ class modService extends DolibarrModules
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer';
$this->rights[$r][0] = 536; // id de la permission
$this->rights[$r][1] = 'Voir/gérer les services cachés'; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (deprecated)
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'hidden';
$r++;
$r++;
$this->rights[$r][0] = 538; // Must be same permission than in product module
$this->rights[$r][1] = 'Exporter les services';

View File

@ -75,3 +75,8 @@ alter table llx_facture_fourn_det add column total_localtax1 double(24,8) DEFAUL
alter table llx_facture_fourn_det add column total_localtax2 double(24,8) DEFAULT 0 after total_localtax1;
alter table llx_product add column hidden tinyint DEFAULT 0;
alter table llx_product add column length float DEFAULT NULL after weight_units;
alter table llx_product add column length_units tinyint DEFAULT NULL after length;
alter table llx_product add column surface float DEFAULT NULL after length_units;
alter table llx_product add column surface_units tinyint DEFAULT NULL after surface;

View File

@ -49,6 +49,10 @@ create table llx_product
partnumber varchar(32),
weight float DEFAULT NULL,
weight_units tinyint DEFAULT NULL,
length float DEFAULT NULL,
length_units tinyint DEFAULT NULL,
surface float DEFAULT NULL,
surface_units tinyint DEFAULT NULL,
volume float DEFAULT NULL,
volume_units tinyint DEFAULT NULL,
stock integer, -- physical stock

View File

@ -173,72 +173,72 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
$versiontoarray=explode('.',$versionto);
$afterversionarray=explode('.','2.0.0');
$beforeversionarray=explode('.','2.7.9');
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
{
// Script pour V2 -> V2.1
migrate_paiements($db,$langs,$conf);
migrate_contracts_det($db,$langs,$conf);
migrate_contracts_date1($db,$langs,$conf);
migrate_contracts_date2($db,$langs,$conf);
migrate_contracts_date3($db,$langs,$conf);
migrate_contracts_open($db,$langs,$conf);
migrate_modeles($db,$langs,$conf);
migrate_price_propal($db,$langs,$conf);
migrate_price_commande($db,$langs,$conf);
migrate_price_commande_fournisseur($db,$langs,$conf);
migrate_price_facture($db,$langs,$conf);
migrate_price_contrat($db,$langs,$conf);
migrate_paiementfourn_facturefourn($db,$langs,$conf);
// Script pour V2.1 -> V2.2
migrate_paiements_orphelins_1($db,$langs,$conf);
migrate_paiements_orphelins_2($db,$langs,$conf);
migrate_links_transfert($db,$langs,$conf);
migrate_delete_old_files($db,$langs,$conf);
// Script pour V2.2 -> V2.4
migrate_commande_expedition($db,$langs,$conf);
migrate_commande_livraison($db,$langs,$conf);
migrate_detail_livraison($db,$langs,$conf);
migrate_module_menus($db,$langs,$conf);
// Script pour V2.5 -> V2.6
migrate_stocks($db,$langs,$conf);
// Script pour V2.6 -> V2.7
migrate_menus($db,$langs,$conf);
migrate_commande_deliveryaddress($db,$langs,$conf);
migrate_restore_missing_links($db,$langs,$conf);
migrate_directories($db,$langs,$conf,'/compta','/banque');
migrate_directories($db,$langs,$conf,'/societe','/mycompany');
}
@ -266,7 +266,7 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
migrate_project_task_actors($db,$langs,$conf);
}
// Script for -> V2.9
$afterversionarray=explode('.','2.8.9');
$beforeversionarray=explode('.','2.9.9');
@ -2728,7 +2728,7 @@ function migrate_project_task_time($db,$langs,$conf)
print '<br>';
print '<b>'.$langs->trans('MigrationProjectTaskTime')."</b><br>\n";
$error = 0;
$db->begin();
@ -2745,19 +2745,19 @@ function migrate_project_task_time($db,$langs,$conf)
{
$totaltime = array();
$oldtime = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if ($obj->task_duration > 0 && strlen($obj->task_duration) < 3)
{
$newtime = $obj->task_duration*60*60;
$sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
$sql2.= " task_duration = ".$newtime;
$sql2.= " WHERE rowid = ".$obj->rowid;
$resql2=$db->query($sql2);
if (!$resql2)
{
@ -2766,16 +2766,18 @@ function migrate_project_task_time($db,$langs,$conf)
}
print ". ";
$oldtime++;
$totaltime[$obj->fk_task] += $newtime;
if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime;
else $totaltime[$obj->fk_task] = $newtime;
}
else
{
$totaltime[$obj->fk_task] += $obj->task_duration;
if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration;
else $totaltime[$obj->fk_task] = $obj->task_duration;
}
$i++;
}
if ($error == 0)
{
if ($oldtime > 0)
@ -2785,7 +2787,7 @@ function migrate_project_task_time($db,$langs,$conf)
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
$sql.= " duration_effective = ".$total_duration;
$sql.= " WHERE rowid = ".$taskid;
$resql=$db->query($sql);
if (!$resql)
{
@ -2793,7 +2795,7 @@ function migrate_project_task_time($db,$langs,$conf)
dol_print_error($db);
}
}
if ($error == 0)
{
$db->commit();
@ -2823,7 +2825,7 @@ function migrate_project_task_time($db,$langs,$conf)
{
dol_print_error($db);
}
print '</td></tr>';
}

View File

@ -557,6 +557,7 @@ ToTest=Test
ValidateBefore=Card must be validated before using this feature
Visibility=Visibility
Private=Private
Hidden=Hidden
# Week day
Day1=Monday
Day2=Tuesday

View File

@ -69,13 +69,23 @@ FeatureDevelopment=Development feature. Not stable in this version
FeaturesSupported=Features supported
Width=Width
Height=Height
Weight=Weight
Depth=Depth
Weight=Weight
TotalWeight=Total weight
WeightUnitton=tonnes
WeightUnitkg=kg
WeightUnitg=g
WeightUnitmg=mg
Length=Length
LengthUnitm=m
LengthUnitdm=dm
LengthUnitcm=cm
LengthUnitmm=mm
Surface=Surface
SurfaceUnitm2=m2
SurfaceUnitdm2=dm2
SurfaceUnitcm2=cm2
SurfaceUnitmm2=mm2
Volume=Volume
TotalVolume=Total volume
VolumeUnitm3=m3

View File

@ -556,6 +556,7 @@ ToTest=Tester
ValidateBefore=La fiche doit être validée pour pouvoir utiliser cette fonction
Visibility=Visibilité
Private=Privé
Hidden=Caché
# Week day
Day1=Lundi
Day2=Mardi

View File

@ -69,13 +69,23 @@ FeatureDevelopment=Fonctionnalité en développement. Non stable dans cette vers
FeaturesSupported=Fonctionnalités supportées
Width=Largeur
Height=Hauteur
Weight=Poids
Depth=Profondeur
Weight=Poids
TotalWeight=Poids total
WeightUnitton=tonnes
WeightUnitkg=kg
WeightUnitg=g
WeightUnitmg=mg
Length=Longueur
LengthUnitm=m
LengthUnitdm=dm
LengthUnitcm=cm
LengthUnitmm=mm
Surface=Surface
SurfaceUnitm2=m2
SurfaceUnitdm2=dm2
SurfaceUnitcm2=cm2
SurfaceUnitmm2=mm2
Volume=Volume
TotalVolume=Volume total
VolumeUnitm3=m3

View File

@ -278,8 +278,8 @@ function show_stats_for_company($product,$socid)
function measuring_units_string($unit,$measuring_style='')
{
/* Note Rodo aux dev :)
* Ne pas ins<EFBFBD>rer dans la base de donn<EFBFBD>es ces valeurs
* cela surchagerait inutilement d'une requete suppl<EFBFBD>mentaire
* Ne pas inserer dans la base de donnees ces valeurs
* cela surchagerait inutilement d'une requete supplementaire
* pour quelque chose qui est somme toute peu variable
*/
@ -292,13 +292,6 @@ function measuring_units_string($unit,$measuring_style='')
$measuring_units[-3] = $langs->trans("WeightUnitg");
$measuring_units[-6] = $langs->trans("WeightUnitmg");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
else if ($measuring_style == 'size')
{
$measuring_units[0] = $langs->trans("SizeUnitm");
@ -306,6 +299,20 @@ function measuring_units_string($unit,$measuring_style='')
$measuring_units[-2] = $langs->trans("SizeUnitcm");
$measuring_units[-3] = $langs->trans("SizeUnitmm");
}
else if ($measuring_style == 'surface')
{
$measuring_units[0] = $langs->trans("SurfaceUnitm2");
$measuring_units[-2] = $langs->trans("SurfaceUnitdm2");
$measuring_units[-4] = $langs->trans("SurfaceUnitcm2");
$measuring_units[-6] = $langs->trans("SurfaceUnitmm2");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
return $measuring_units[$unit];
}

View File

@ -80,12 +80,18 @@ class Product extends CommonObject
var $duration_unit;
// Statut indique si le produit est en vente '1' ou non '0'
var $status;
// Statut indique si le produit est un produit finis '1' ou une matiere premiere '0'
// Statut indique si le produit est un produit fini '1' ou une matiere premiere '0'
var $finished;
var $hidden;
//! Unites de mesure
var $weight;
var $weight_units;
var $length;
var $length_units;
var $surface;
var $surface_units;
var $volume;
var $volume_units;
@ -160,9 +166,9 @@ class Product extends CommonObject
}
/**
* \brief Insert product in database
* \param user Utilisateur qui effectue l'insertion
* \return int id du produit ou numero d'erreur < 0
* \brief Insert product into database
* \param user User making insert
* \return int id of product/service if OK or number of error < 0
*/
function create($user)
{
@ -182,6 +188,7 @@ class Product extends CommonObject
if (empty($this->price_min)) $this->price_min = 0;
if (empty($this->status)) $this->status = 0;
if (empty($this->finished)) $this->finished = 0;
if (empty($this->hidden)) $this->hidden = 0;
$price_ht=0;
$price_ttc=0;
@ -247,6 +254,7 @@ class Product extends CommonObject
$sql.= ", price_base_type";
$sql.= ", canvas";
$sql.= ", finished";
$sql.= ", hidden";
$sql.= ") VALUES (";
$sql.= $this->db->idate(mktime());
$sql.= ", ".$conf->entity;
@ -261,6 +269,7 @@ class Product extends CommonObject
$sql.= ", '".$this->price_base_type."'";
$sql.= ", '".$this->canvas."'";
$sql.= ", ".$this->finished;
$sql.= ", ".$this->hidden;
$sql.= ")";
dol_syslog("Product::Create sql=".$sql);
@ -392,10 +401,15 @@ class Product extends CommonObject
$this->stock_loc = trim($this->stock_loc);
$this->weight = price2num($this->weight);
$this->weight_units = trim($this->weight_units);
$this->length = price2num($this->length);
$this->length_units = trim($this->length_units);
$this->surface = price2num($this->surface);
$this->surface_units = trim($this->surface_units);
$this->volume = price2num($this->volume);
$this->volume_units = trim($this->volume_units);
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->finished)) $this->finished = 0;
if (empty($this->hidden)) $this->hidden = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
$sql .= " SET label = '" . addslashes($this->libelle) ."'";
@ -403,8 +417,13 @@ class Product extends CommonObject
$sql .= ",tva_tx = " . $this->tva_tx;
$sql .= ",envente = " . $this->status;
$sql .= ",finished = " . ($this->finished<0 ? "null" : $this->finished);
$sql .= ",hidden = " . ($this->hidden<0 ? "null" : $this->hidden);
$sql .= ",weight = " . ($this->weight!='' ? "'".$this->weight."'" : 'null');
$sql .= ",weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null');
$sql .= ",length = " . ($this->length!='' ? "'".$this->length."'" : 'null');
$sql .= ",length_units = " . ($this->length_units!='' ? "'".$this->length_units."'" : 'null');
$sql .= ",surface = " . ($this->surface!='' ? "'".$this->surface."'" : 'null');
$sql .= ",surface_units = " . ($this->surface_units!='' ? "'".$this->surface_units."'" : 'null');
$sql .= ",volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null');
$sql .= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
$sql .= ",seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->seuil_stock_alerte."'" : "null");
@ -891,7 +910,7 @@ class Product extends CommonObject
dol_syslog("Product::fetch id=$id ref=$ref");
// Verification parametres
// Check parameters
if (! $id && ! $ref)
{
$this->error=$langs->trans('ErrorWrongParameters');
@ -901,8 +920,8 @@ class Product extends CommonObject
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc,";
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, envente,";
$sql.= " fk_product_type, duration, seuil_stock_alerte,canvas,";
$sql.= " stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " fk_product_type, duration, seuil_stock_alerte, canvas,";
$sql.= " stock_loc, weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished, hidden,";
$sql.= " stock, pmp,";
$sql.= " import_key";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
@ -929,6 +948,7 @@ class Product extends CommonObject
$this->type = $result["fk_product_type"];
$this->status = $result["envente"];
$this->finished = $result["finished"];
$this->hidden = $result["hidden"];
$this->duration = $result["duration"];
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
$this->duration_unit = substr($result["duration"],-1);
@ -937,6 +957,10 @@ class Product extends CommonObject
$this->stock_loc = $result["stock_loc"];
$this->weight = $result["weight"];
$this->weight_units = $result["weight_units"];
$this->length = $result["length"];
$this->length_units = $result["length_units"];
$this->surface = $result["surface"];
$this->surface_units = $result["surface_units"];
$this->volume = $result["volume"];
$this->volume_units = $result["volume_units"];
$this->barcode = $result["barcode"];
@ -991,7 +1015,8 @@ class Product extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
$sql.= " where price_level=".$i." and";
$sql.= " fk_product = '".$this->id."'";
$sql.= " order by date_price DESC limit 1";
$sql.= " ORDER BY date_price DESC";
$sql.= " LIMIT 1";
$resql = $this->db->query($sql) ;
if ($resql)
{
@ -2651,17 +2676,11 @@ class Product extends CommonObject
$sql = "SELECT count(p.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.fk_product_type <> 1";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND COALESCE(c.visible,1)=1";
}
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -79,6 +79,14 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
$_GET["type"] = $_POST["type"];
$error++;
}
if (empty($_POST["ref"]))
{
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'</div>';
$_GET["action"] = "create";
$_GET["canvas"] = $product->canvas;
$_GET["type"] = $_POST["type"];
$error++;
}
if (! $error)
{
@ -111,9 +119,14 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
$product->canvas = $_POST["canvas"];
$product->weight = $_POST["weight"];
$product->weight_units = $_POST["weight_units"];
$product->length = $_POST["size"];
$product->length_units = $_POST["size_units"];
$product->surface = $_POST["surface"];
$product->surface_units = $_POST["surface_units"];
$product->volume = $_POST["volume"];
$product->volume_units = $_POST["volume_units"];
$product->finished = $_POST["finished"];
$product->hidden = $_POST["hidden"]=='yes'?1:0;
// MultiPrix
if($conf->global->PRODUIT_MULTIPRICES)
{
@ -133,9 +146,6 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
if ( $value != $current_lang ) $e_product = $product;
// Specific product
// $_POST n'est pas utilise dans la classe Product
// mais dans des classes qui herite de Product
$id = $product->create($user);
if ($id > 0)
@ -177,9 +187,14 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig
$product->canvas = $_POST["canvas"];
$product->weight = $_POST["weight"];
$product->weight_units = $_POST["weight_units"];
$product->length = $_POST["size"];
$product->length_units = $_POST["size_units"];
$product->surface = $_POST["surface"];
$product->surface_units = $_POST["surface_units"];
$product->volume = $_POST["volume"];
$product->volume_units = $_POST["volume_units"];
$product->finished = $_POST["finished"];
$product->hidden = $_POST["hidden"]=='yes'?1:0;
if ($product->check())
{
@ -621,7 +636,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
print '<table class="border" width="100%">';
print '<tr>';
print '<td class="fieldrequired" width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="40" maxlength="32" value="'.$product->ref.'">';
print '<td class="fieldrequired" width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="40" maxlength="32" value="'.$_POST["ref"].'">';
if ($_error == 1)
{
print $langs->trans("RefAlreadyExists");
@ -629,7 +644,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$_POST["libelle"].'"></td></tr>';
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>';
@ -641,7 +656,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
if ($_GET["type"] != 1 && $conf->stock->enabled)
{
print '<tr><td>'.$langs->trans("StockLimit").'</td><td>';
print '<input name="seuil_stock_alerte" size="4" value="0">';
print '<input name="seuil_stock_alerte" size="4" value="'.$_POST["seuil_stock_alerte"].'">';
print '</td></tr>';
}
else
@ -655,12 +670,13 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false);
$doleditor=new DolEditor('desc',$_POST["desc"],160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" rows="4" cols="90">';
print $_POST["desc"];
print '</textarea>';
}
@ -687,31 +703,51 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
print '</td></tr>';
}
// Weight - Volume
if ($_GET["type"] != 1)
if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services
{
// Le poids et le volume ne concerne que les produits et pas les services
// Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
print '<input name="weight" size="4" value="">';
print '<input name="weight" size="4" value="'.$_POST["weight"].'">';
print $formproduct->select_measuring_units("weight_units","weight");
print '</td></tr>';
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td>';
print '<input name="size" size="4" value="'.$_POST["size"].'">';
print $formproduct->select_measuring_units("size_units","size");
print '</td></tr>';
// Surface
print '<tr><td>'.$langs->trans("Surface").'</td><td>';
print '<input name="surface" size="4" value="'.$_POST["surface"].'">';
print $formproduct->select_measuring_units("surface_units","surface");
print '</td></tr>';
// Volume
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
print '<input name="volume" size="4" value="">';
print '<input name="volume" size="4" value="'.$_POST["volume"].'">';
print $formproduct->select_measuring_units("volume_units","volume");
print '</td></tr>';
}
// Hidden
if (($_GET["type"] != 1 && $user->rights->produit->hidden)
|| ($_GET["type"] == 1 && $user->rights->service->hidden))
{
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
print $html->selectyesno($product->hidden);
print '</td></tr>';
}
// Note (invisible sur facture, propales...)
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note','',180,'dolibarr_notes','',false);
$doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="note" rows="8" cols="70">';
print $_POST["note"];
print '</textarea>';
}
print "</td></tr>";
@ -719,14 +755,15 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
print '<br>';
print '<table class="border" width="100%">';
if($conf->global->PRODUIT_MULTIPRICES)
if ($conf->global->PRODUIT_MULTIPRICES)
{
// We do no show price array on create when multiprices enabled.
// We must set them on prices tab.
}
else
{
print '<table class="border" width="100%">';
// PRIX
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
print '<td><input name="price" size="10" value="'.$product->price.'">';
@ -742,22 +779,20 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
print '<tr><td width="20%">'.$langs->trans("VATRate").'</td><td>';
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
print '</td></tr>';
print '</table>';
print '<br>';
}
print '</table>';
print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>';
print '</form>';
}
else
{
//RODO
// On assigne les valeurs meme en creation car elles sont definies si
// on revient en erreur
//
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/templates/'.$_GET["canvas"].'/';
$tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'');
$smarty->assign('tva_taux_value', $tvaarray['value']);
@ -1016,7 +1051,7 @@ if ($_GET["id"] || $_GET["ref"])
}
else
{
// Weight / Volume
// Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="2">';
if ($product->weight != '')
{
@ -1027,7 +1062,29 @@ if ($_GET["id"] || $_GET["ref"])
print '&nbsp;';
}
print "</td></tr>\n";
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="2">';
if ($product->length != '')
{
print $product->length." ".measuring_units_string($product->length_units,"size");
}
else
{
print '&nbsp;';
}
print "</td></tr>\n";
// Surface
print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">';
if ($product->surface != '')
{
print $product->surface." ".measuring_units_string($product->surface_units,"surface");
}
else
{
print '&nbsp;';
}
print "</td></tr>\n";
// Volume
print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">';
if ($product->volume != '')
{
@ -1040,6 +1097,15 @@ if ($_GET["id"] || $_GET["ref"])
print "</td></tr>\n";
}
// Hidden
if ((! $product->isservice() && $user->rights->produit->hidden)
|| ($product->isservice() && $user->rights->service->hidden))
{
print '<tr><td>'.$langs->trans("Hidden").'</td><td colspan="2">';
print yn($product->hidden);
print "</td></tr>\n";
}
// Note
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.nl2br($product->note).'</td></tr>';
@ -1148,18 +1214,37 @@ if ($_GET["id"] || $_GET["ref"])
}
else
{
// Weight / Volume
// Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
print '<input name="weight" size="5" value="'.$product->weight.'"> ';
print $formproduct->select_measuring_units("weight_units", "weight", $product->weight_units);
print '</td></tr>';
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td>';
print '<input name="size" size="5" value="'.$product->length.'"> ';
print $formproduct->select_measuring_units("size_units", "size", $product->length_units);
print '</td></tr>';
// Surface
print '<tr><td>'.$langs->trans("Surface").'</td><td>';
print '<input name="surface" size="5" value="'.$product->surface.'"> ';
print $formproduct->select_measuring_units("surface_units", "surface", $product->surface_units);
print '</td></tr>';
// Volume
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
print '<input name="volume" size="5" value="'.$product->volume.'"> ';
print $formproduct->select_measuring_units("volume_units", "volume", $product->volume_units);
print '</td></tr>';
}
// Hidden
if ((! $product->isservice() && $user->rights->produit->hidden)
|| ($product->isservice() && $user->rights->service->hidden))
{
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
print $html->selectyesno('hidden',$product->hidden);
print '</td></tr>';
}
// Note
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
@ -1175,10 +1260,13 @@ if ($_GET["id"] || $_GET["ref"])
print "</textarea>";
}
print "</td></tr>";
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>';
print "<!-- CUT HERE -->\n";
}
@ -1233,22 +1321,6 @@ if ($_GET["action"] == '')
print '<a class="butAction" href="fiche.php?action=clone&amp;id='.$product->id.'">'.$langs->trans("ToClone").'</a>';
}
/*
if ($product->isproduct() && $user->rights->commande->creer)
{
$langs->load('orders');
print '<a class="butAction" href="fiche.php?action=fastappro&amp;id='.$product->id.'">';
print $langs->trans("CreateCustomerOrder").'</a>';
}
if ($product->isproduct() && $user->rights->fournisseur->commande->creer)
{
$langs->load('orders');
print '<a class="butAction" href="fiche.php?action=fastappro&amp;id='.$product->id.'">';
print $langs->trans("CreateSupplierOrder").'</a>';
}
*/
$product_is_used = $product->verif_prod_use($product->id);
if ($user->rights->produit->supprimer)
{

View File

@ -365,7 +365,7 @@ if ($_GET["id"] || $_GET["ref"])
$sql.= " WHERE pf.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND pf.fk_product = ".$product->id;
$sql.= " ORDER BY lower(s.nom), pfp.quantity";
$sql.= " ORDER BY s.nom, pfp.quantity";
$resql="";
$resql=$db->query($sql);

View File

@ -165,15 +165,12 @@ $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_subproduct as sp ON p.rowid = sp.fk_product_subproduct";
$sql.= " WHERE sp.fk_product_subproduct IS NULL";
$sql.= " AND p.entity = ".$conf->entity;
/*if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
$sql.= " AND COALESCE(c.visible,1)=1 ";
}*/
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if ($type != '') $sql.= " AND p.fk_product_type = ".$type;
$sql.= $db->order("p.tms","DESC");
$sql.= $db->plimit($max,0);
//print $sql;
$result = $db->query($sql) ;
if ($result)

View File

@ -104,11 +104,6 @@ $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc
$sql.= ' p.fk_product_type, p.tms as datem,';
$sql.= ' p.duration, p.envente as statut, p.seuil_stock_alerte';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
if ($conf->categorie->enabled && ($catid || !$user->rights->categorie->voir))
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
if ($_GET["fourn_id"] > 0)
{
@ -116,6 +111,8 @@ if ($_GET["fourn_id"] > 0)
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf";
}
$sql.= " WHERE p.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if ($sall)
{
$sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')";
@ -144,10 +141,6 @@ if($catid)
{
$sql.= " AND cp.fk_categorie = ".$catid;
}
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
if ($fourn_id > 0)
{
$sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;

View File

@ -73,7 +73,7 @@ if (isset($_GET['type']))
$param = '&amp;type='.$_GET['type'];
$title = $langs->trans("ListProductByPopularity");
if ($_GET['type'] == 1) $title = $langs->trans("ListServiceByPopularity");
}
}
print_barre_liste($title, $page, "popuprop.php",$param,"","","",$num);
@ -90,21 +90,14 @@ print "</tr>\n";
$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, count(*) as c";
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd";
$sql.= ", ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.rowid = pd.fk_product";
$sql.= " AND p.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type'];
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
$sql.= " GROUP BY (p.rowid)";
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit( $limit ,$offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit ,$offset);
$result=$db->query($sql) ;
if ($result)
@ -125,7 +118,7 @@ if ($result)
$sql.= " WHERE fk_product=".$objp->rowid;
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
$sql.= " LIMIT 1";
$resultp = $db->query($sql);
if ($resultp)
{

View File

@ -78,11 +78,6 @@ $sql.= ' p.duration, p.envente as statut, p.seuil_stock_alerte,';
$sql.= ' SUM(s.reel) as stock_physique';
$sql.= ' FROM '.MAIN_DB_PREFIX.'product_stock as s,';
$sql.= ' '.MAIN_DB_PREFIX.'product as p';
if ($catid || ($conf->categorie->enabled && ! $user->rights->categorie->voir))
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
if ($_GET["fourn_id"] > 0)
{
@ -91,6 +86,8 @@ if ($_GET["fourn_id"] > 0)
}
$sql.= " WHERE p.rowid = s.fk_product";
$sql.= " AND p.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if ($sall)
{
$sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')";
@ -119,16 +116,12 @@ if($catid)
{
$sql.= " AND cp.fk_categorie = ".$catid;
}
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
if ($fourn_id > 0)
{
$sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id;
}
$sql.= " GROUP BY p.rowid";
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql) ;
@ -237,7 +230,7 @@ if ($resql)
$sql.= " WHERE fk_product=".$objp->rowid;
$sql.= " AND lang='". $langs->getDefaultLang() ."'";
$sql.= " LIMIT 1";
$result = $db->query($sql);
if ($result)
{

View File

@ -41,14 +41,10 @@ $mesg = '';
*/
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.fk_product_type <> 1";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= ' AND COALESCE(c.visible,1)=1';
if ($db->query($sql))
{
@ -60,15 +56,11 @@ $db->free();
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.envente = 0";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND p.fk_product_type <> '1'";
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= ' AND COALESCE(c.visible,1)=1';
if ($db->query($sql))
{
@ -77,14 +69,18 @@ if ($db->query($sql))
}
$db->free();
if ($conf->service->enabled)
if ($conf->produit->enabled && $conf->service->enabled)
{
print_fiche_titre($langs->trans("ProductsAndServicesStatistics"), $mesg);
}
else
elseif ($conf->produit->enabled)
{
print_fiche_titre($langs->trans("ProductsStatistics"), $mesg);
}
elseif ($conf->service->enabled)
{
print_fiche_titre($langs->trans("ServicesStatistics"), $mesg);
}
print '<br>';
print '<table class="noborder" width="100%">';
@ -106,14 +102,10 @@ if ($conf->service->enabled)
{
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.fk_product_type = '1'";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= ' AND COALESCE(c.visible,1)=1';
if ($db->query($sql))
{
@ -124,15 +116,11 @@ if ($conf->service->enabled)
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.envente = 0";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " AND p.fk_product_type = '1'";
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir) $sql.= ' AND COALESCE(c.visible,1)=1';
if ($db->query($sql))
{

View File

@ -357,17 +357,10 @@ class Entrepot extends CommonObject
$ret=array();
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value";
$sql .= " FROM llx_product_stock as ps";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql .= " WHERE ps.fk_entrepot = ".$this->id;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE ps.fk_entrepot = ".$this->id." AND ps.fk_product=p.rowid";
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
//print $sql;
$result = $this->db->query($sql) ;

View File

@ -65,7 +65,7 @@ if ($_POST["action"] == 'add' && $user->rights->stock->creer)
if ($entrepot->libelle) {
$id = $entrepot->create($user);
if ($id > 0)
if ($id > 0)
{
header("Location: fiche.php?id=".$id);
exit;
@ -89,7 +89,7 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
if ($result > 0)
{
header("Location: ".DOL_URL_ROOT.'/product/stock/liste.php');
exit;
exit;
}
else
{
@ -241,7 +241,7 @@ else
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$entrepot->id,$langs->trans("DeleteAWarehouse"),$langs->trans("ConfirmDeleteWarehouse",$entrepot->libelle),"confirm_delete",'',0,2);
if ($ret == 'html') print '<br>';
}
print '<table class="border" width="100%">';
// Ref
@ -355,18 +355,11 @@ else
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type,";
$sql.= " ps.pmp, ps.reel as value";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql .= " WHERE ps.fk_product = p.rowid";
$sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse)
$sql .= " AND ps.fk_entrepot = ".$entrepot->id;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= ' AND COALESCE(c.visible,1)=1';
}
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " ORDER BY " . $sortfield . " " . $sortorder;
//$sql .= $db->plimit($limit + 1 ,$offset);

View File

@ -114,18 +114,11 @@ $sql.= " m.value, ".$db->pdate("m.datem")." as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s";
$sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m";
$sql.= ", ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE m.fk_product = p.rowid";
$sql.= " AND m.fk_entrepot = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND COALESCE(c.visible,1)=1";
}
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$sql.= " ORDER BY datem DESC";
$sql.= $db->plimit($max,0);

View File

@ -82,22 +82,15 @@ $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as s,";
$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m,";
$sql.= " ".MAIN_DB_PREFIX."product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE m.fk_product = p.rowid";
$sql.= " AND m.fk_entrepot = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
if ($_GET["id"])
{
$sql.= " AND s.rowid ='".$_GET["id"]."'";
}
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND COALESCE(c.visible,1)=1";
}
if ($month > 0)
{
if ($year > 0)

View File

@ -407,7 +407,7 @@ $sql.= " WHERE ps.reel != 0";
$sql.= " AND ps.fk_entrepot = e.rowid";
$sql.= " AND e.entity = ".$conf->entity;
$sql.= " AND ps.fk_product = ".$product->id;
$sql.= " ORDER BY lower(e.label)";
$sql.= " ORDER BY e.label";
$entrepotstatic=new Entrepot($db);
$total=0;

View File

@ -141,7 +141,7 @@ if ($_GET["id"])
$sql .= " WHERE ue.fk_user = u.rowid ";
$sql .= " AND ue.fk_entrepot = ".$entrepot->id;
//$sql .= " ORDER BY " . $sortfield . " " . $sortorder;
//$sql .= $db->order($sortfield,$sortorder);
//$sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql) ;

View File

@ -93,7 +93,8 @@ if ($_GET["search_societe"])
{
$sql.= " AND s.nom LIKE '%".addslashes($_GET["search_societe"])."%'";
}
$sql.= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$var=true;
$resql = $db->query($sql);

View File

@ -85,8 +85,8 @@ $sql = "SELECT rowid, prenom, nom, societe, cp, ville, email, naiss, photo";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent";
$sql.= " WHERE statut = 1";
$sql.= " AND public = 1";
$sql.= " ORDER BY $sortfield $sortorder";
$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($conf->liste_limit+1, $offset);
//$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, cp, ville, d.email, t.libelle as type, d.morphy, d.statut, t.cotisation";
//$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
//$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut";

View File

@ -23,13 +23,14 @@
* \brief Fichier de la classe des services predefinis
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
/**
* \class Service
* \brief Classe permettant la gestion des services predefinis
*/
class Service
class Service extends CommonObject
{
var $db;
@ -64,17 +65,11 @@ class Service
$sql = "SELECT count(p.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE p.fk_product_type = 1";
$sql.= " AND p.entity = ".$conf->entity;
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND COALESCE(c.visible,1)=1";
}
if (!$user->rights->produit->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)';
if (!$user->rights->service->voir) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)';
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -44,7 +44,7 @@ if(isset($_POST['pays']) && !empty($_POST['pays']))
$sql = "SELECT rowid, code, libelle, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE active = 1 AND libelle LIKE '%" . utf8_decode($_POST['pays']) . "%'";
$sql.= " ORDER BY libelle ASC;";
$sql.= " ORDER BY libelle ASC";
$resql=$db->query($sql);
if ($resql)

View File

@ -189,7 +189,8 @@ if($_GET["socid"])
{
$sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'";
}
$sql .= " ORDER BY s.nom ASC " . $db->plimit($conf->liste_limit+1, $offset);
$sql.= $db->order("s.nom","ASC");
$sql.= $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
if ($resql)

View File

@ -66,7 +66,8 @@ if ($socid > 0)
{
$sql .= " AND s.rowid = " . $user->societe_id;
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
$sql .= $db->order($sortfield,$sortorder);
$sql .= $db->plimit($conf->liste_limit, $offset);
$result = $db->query($sql);
if ($result)

View File

@ -221,7 +221,7 @@ class Webcal {
$sql.= " cal_date, cal_time, cal_mod_date,";
$sql.= " cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name, cal_description";
$sql.= " FROM webcal_entry";
$sql.= " order by cal_date";
$sql.= " ORDER BY cal_date";
dol_syslog("Webcal::build_vcal select events sql=".$sql);
$resql=$this->localdb->query($sql);

View File

@ -98,7 +98,7 @@ $countries=array();
$sql = "SELECT rowid, code, libelle, active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE active = 1";
$sql.= " ORDER BY code ASC;";
$sql.= " ORDER BY code ASC";
$resql=$db->query($sql);
if ($resql)
{