Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-10-10 15:07:41 +02:00
commit 6a7a982688
26 changed files with 300 additions and 157 deletions

View File

@ -32,10 +32,11 @@ $langs->load("errors");
$langs->load("admin"); $langs->load("admin");
$mode=isset($_GET["mode"])?GETPOST("mode"):(isset($_SESSION['mode'])?$_SESSION['mode']:0); $mode=isset($_GET["mode"])?GETPOST("mode"):(isset($_SESSION['mode'])?$_SESSION['mode']:0);
$mesg=GETPOST("mesg"); $action=GETPOST('action','alpha');
$action=GETPOST('action'); $value=GETPOST('value');
if (!$user->admin) accessforbidden(); if (! $user->admin)
accessforbidden();
$specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional', 4=>'marketplace'); $specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional', 4=>'marketplace');
@ -46,19 +47,17 @@ $specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional'
if ($action == 'set' && $user->admin) if ($action == 'set' && $user->admin)
{ {
$result=activateModule($_GET["value"]); $result=activateModule($value);
$mesg=''; if ($result) setEventMessage($result, 'errors');
if ($result) $mesg=$result; header("Location: modules.php?mode=".$mode);
header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
exit; exit;
} }
if ($action == 'reset' && $user->admin) if ($action == 'reset' && $user->admin)
{ {
$result=unActivateModule($_GET["value"]); $result=unActivateModule($value);
$mesg=''; if ($result) setEventMessage($result, 'errors');
if ($result) $mesg=$result; header("Location: modules.php?mode=".$mode);
header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
exit; exit;
} }
@ -129,7 +128,8 @@ foreach ($modulesdir as $dir)
if (! empty($modNameLoaded[$modName])) if (! empty($modNameLoaded[$modName]))
{ {
$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>"; $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
dol_syslog($mesg, LOG_ERR); setEventMessage($mesg, 'warnings');
dol_syslog($mesg, LOG_ERR);
continue; continue;
} }
@ -269,9 +269,6 @@ $h++;
dol_fiche_head($head, $mode, $langs->trans("Modules")); dol_fiche_head($head, $mode, $langs->trans("Modules"));
dol_htmloutput_errors($mesg);
if ($mode != 'marketplace') if ($mode != 'marketplace')
{ {
print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n"; print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";

View File

@ -39,7 +39,7 @@ $type = GETPOST('type');
$mesg = GETPOST('mesg'); $mesg = GETPOST('mesg');
$removecat = GETPOST('removecat','int'); $removecat = GETPOST('removecat','int');
$catMere=GETPOST('catMere','int'); $parent=GETPOST('parent','int');
$dbtablename = ''; $dbtablename = '';
@ -122,7 +122,7 @@ if ($removecat > 0)
} }
// Add object into a category // Add object into a category
if ($catMere > 0) if ($parent > 0)
{ {
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
@ -151,7 +151,7 @@ if ($catMere > 0)
$elementtype = 'member'; $elementtype = 'member';
} }
$cat = new Categorie($db); $cat = new Categorie($db);
$result=$cat->fetch($catMere); $result=$cat->fetch($parent);
$result=$cat->add_type($object,$elementtype); $result=$cat->add_type($object,$elementtype);
if ($result >= 0) if ($result >= 0)

View File

@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
/** /**
* \class Categorie * Class to manage categories
* \brief Class to manage categories
*/ */
class Categorie class Categorie
{ {
@ -45,6 +44,7 @@ class Categorie
var $description; var $description;
var $socid; var $socid;
var $type; // 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member var $type; // 0=Product, 1=Supplier, 2=Customer/Prospect, 3=Member
var $import_key;
var $cats=array(); // Tableau en memoire des categories var $cats=array(); // Tableau en memoire des categories
@ -71,7 +71,7 @@ class Categorie
$sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
dol_syslog("Categorie::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -114,6 +114,9 @@ class Categorie
$error=0; $error=0;
// Clean parameters // Clean parameters
$this->label = trim($this->label);
$this->description = trim($this->description);
$this->import_key = trim($this->import_key);
if (empty($this->visible)) $this->visible=0; if (empty($this->visible)) $this->visible=0;
$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
@ -128,21 +131,30 @@ class Categorie
$this->db->begin(); $this->db->begin();
dol_syslog(get_class($this).'::create sql='.$sql); dol_syslog(get_class($this).'::create sql='.$sql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (fk_parent, label, description,"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (";
$sql.= "fk_parent,";
$sql.= " label,";
$sql.= " description,";
if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{ {
$sql.= "fk_soc,"; $sql.= "fk_soc,";
} }
$sql.= " visible,"; $sql.= " visible,";
$sql.= " type,"; $sql.= " type,";
$sql.= " import_key,";
$sql.= " entity"; $sql.= " entity";
$sql.= ")"; $sql.= ") VALUES (";
$sql.= " VALUES (".$this->fk_parent.",'".$this->db->escape($this->label)."', '".$this->db->escape($this->description)."',"; $sql.= $this->fk_parent.",";
$sql.= "'".$this->db->escape($this->label)."',";
$sql.= "'".$this->db->escape($this->description)."',";
if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{ {
$sql.= ($this->socid != -1 ? $this->socid : 'null').","; $sql.= ($this->socid != -1 ? $this->socid : 'null').",";
} }
$sql.= "'".$this->visible."',".$this->type.",".$conf->entity; $sql.= "'".$this->visible."',";
$sql.= $this->type.",";
$sql.= (! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":'null').",";
$sql.= $conf->entity;
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this).'::create sql='.$sql); dol_syslog(get_class($this).'::create sql='.$sql);
@ -223,7 +235,7 @@ class Categorie
$sql .= ", fk_parent = ".$this->fk_parent; $sql .= ", fk_parent = ".$this->fk_parent;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog("Categorie::update sql=".$sql); dol_syslog(get_class($this)."::update sql=".$sql);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->db->commit(); $this->db->commit();
@ -257,7 +269,7 @@ class Categorie
$error=0; $error=0;
dol_syslog("Categorie::remove"); dol_syslog(get_class($this)."::remove");
$this->db->begin(); $this->db->begin();
@ -537,7 +549,7 @@ class Categorie
$sql.= " WHERE c.entity IN (".getEntity('category',1).")"; $sql.= " WHERE c.entity IN (".getEntity('category',1).")";
$sql.= " AND c.type = ".$type; $sql.= " AND c.type = ".$type;
dol_syslog("Categorie::get_full_arbo get category list sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::get_full_arbo get category list sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -559,7 +571,7 @@ class Categorie
} }
// We add the fullpath property to each elements of first level (no parent exists) // We add the fullpath property to each elements of first level (no parent exists)
dol_syslog("Categorie::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
foreach($this->cats as $key => $val) foreach($this->cats as $key => $val)
{ {
$this->build_path_from_id_categ($key,0); // Process a branch from the root category key (this category has no parent) $this->build_path_from_id_categ($key,0); // Process a branch from the root category key (this category has no parent)
@ -585,7 +597,7 @@ class Categorie
} }
} }
dol_syslog("Categorie::get_full_arbo dol_sort_array", LOG_DEBUG); dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG);
$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); $this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
//$this->debug_cats(); //$this->debug_cats();
@ -602,12 +614,12 @@ class Categorie
*/ */
function build_path_from_id_categ($id_categ,$protection=0) function build_path_from_id_categ($id_categ,$protection=0)
{ {
dol_syslog("Categorie::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
//if (! empty($this->cats[$id_categ]['fullpath'])) //if (! empty($this->cats[$id_categ]['fullpath']))
//{ //{
// Already defined // Already defined
// dol_syslog("Categorie::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); // dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
// return; // return;
//} //}
@ -637,7 +649,7 @@ class Categorie
// Protection when a category has itself as a child (should not happen) // Protection when a category has itself as a child (should not happen)
if ($idchild == $id_categ) if ($idchild == $id_categ)
{ {
dol_syslog("Categorie::build_path_from_id_categ bad couple (".$idchild.",".$id_categ.") in association table: An entry should not have itself has child", LOG_WARNING); dol_syslog(get_class($this)."::build_path_from_id_categ bad couple (".$idchild.",".$id_categ.") in association table: An entry should not have itself has child", LOG_WARNING);
continue; continue;
} }
@ -990,12 +1002,13 @@ class Categorie
* @param int $id Id * @param int $id Id
* @param string $nom Name * @param string $nom Name
* @param string $type Type * @param string $type Type
* @param boolean $exact Ture or false * @param boolean $exact Exact string search (true/false)
* @return array Array of category id * @param boolean $case Case sensitive (true/false)
* @return array Array of category id
*/ */
function rechercher($id, $nom, $type, $exact = false) function rechercher($id, $nom, $type, $exact = false, $case = false)
{ {
$cats = array (); $cats = array();
// Generation requete recherche // Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
@ -1004,14 +1017,15 @@ class Categorie
if ($nom) if ($nom)
{ {
if (! $exact) if (! $exact)
{
$nom = '%'.str_replace('*', '%', $nom).'%'; $nom = '%'.str_replace('*', '%', $nom).'%';
} if (! $case)
$sql.= "AND label LIKE '".$nom."'"; $sql.= " AND label LIKE '".$this->db->escape($nom)."'";
else
$sql.= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
} }
if ($id) if ($id)
{ {
$sql.="AND rowid = '".$id."'"; $sql.=" AND rowid = '".$id."'";
} }
$res = $this->db->query($sql); $res = $this->db->query($sql);
@ -1029,7 +1043,7 @@ class Categorie
else else
{ {
$this->error=$this->db->error().' sql='.$sql; $this->error=$this->db->error().' sql='.$sql;
dol_syslog("Categorie::rechercher ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::rechercher ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }

View File

@ -257,7 +257,7 @@ foreach($fulltree as $key => $val)
$categstatic->id=$val['id']; $categstatic->id=$val['id'];
$categstatic->ref=$val['label']; $categstatic->ref=$val['label'];
$categstatic->type=$type; $categstatic->type=$type;
print ' &nbsp;'.$categstatic->getNomUrl(0,'',28); print ' &nbsp;'.$categstatic->getNomUrl(0,'',60);
//print ' &nbsp;'.dol_trunc($val['label'],28); //print ' &nbsp;'.dol_trunc($val['label'],28);
//if ($section == $val['id']) print '</u>'; //if ($section == $val['id']) print '</u>';

View File

@ -296,6 +296,7 @@ class DoliDBPgsql
// To have postgresql case sensitive // To have postgresql case sensitive
$line=str_replace(' LIKE \'',' ILIKE \'',$line); $line=str_replace(' LIKE \'',' ILIKE \'',$line);
$line=str_replace(' LIKE BINARY \'',' LIKE \'',$line);
// Delete using criteria on other table must not declare twice the deleted table // Delete using criteria on other table must not declare twice the deleted table
// DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable // DELETE FROM tabletodelete USING tabletodelete, othertable -> DELETE FROM tabletodelete USING othertable

View File

@ -959,7 +959,15 @@ class pdf_einstein extends ModelePDFCommandes
$posy+=1; $posy+=1;
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$posy+=5; if ($object->ref_client)
{
$posy+=5;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
$posy+=4;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');

View File

@ -525,8 +525,8 @@ class pdf_expedition_rouget extends ModelePdfExpedition
$text=$linkedobject->ref; $text=$linkedobject->ref;
if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
$Yoff = $Yoff+8; $Yoff = $Yoff+8;
$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); $pdf->SetXY($this->page_largeur - $this->marge_droite - 100,$Yoff);
$pdf->MultiCell(60, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
$Yoff = $Yoff+4; $Yoff = $Yoff+4;
$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
$pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"daytext",false,$outputlangs,true), 0, 'R'); $pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"daytext",false,$outputlangs,true), 0, 'R');
@ -576,7 +576,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
// If SHIPPING contact defined, we use it // If SHIPPING contact defined, we use it
$usecontact=false; $usecontact=false;
$arrayidcontact=$object->getIdContact('external','SHIPPING'); $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)
{ {
$usecontact=true; $usecontact=true;

View File

@ -1099,6 +1099,14 @@ class pdf_crabe extends ModelePDFFactures
$posy+=1; $posy+=1;
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
if ($object->ref_client)
{
$posy+=5;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
$objectidnext=$object->getIdReplacingInvoice('validated'); $objectidnext=$object->getIdReplacingInvoice('validated');
if ($object->type == 0 && $objectidnext) if ($object->type == 0 && $objectidnext)
{ {

View File

@ -90,6 +90,7 @@ class modProduct extends DolibarrModules
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array();
$this->boxes[0][1] = "box_produits.php"; $this->boxes[0][1] = "box_produits.php";
$this->boxes[1][1] = "box_produits_alerte_stock.php";
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@ -29,8 +29,8 @@ define('DONOTLOADCONF',1); // To avoid loading conf by file inc.php
include 'inc.php'; include 'inc.php';
$action=GETPOST('action'); $action=GETPOST('action','alpha');
$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto'); $setuplang=(GETPOST('selectlang','',3)?GETPOST('selectlang','',3):'auto');
$langs->setDefaultLang($setuplang); $langs->setDefaultLang($setuplang);
$langs->load("admin"); $langs->load("admin");
@ -38,10 +38,19 @@ $langs->load("install");
$langs->load("errors"); $langs->load("errors");
// Recuparation des information de connexion // Recuparation des information de connexion
$userroot=isset($_POST["db_user_root"])?$_POST["db_user_root"]:""; $userroot=GETPOST('db_user_root');
$passroot=isset($_POST["db_pass_root"])?$_POST["db_pass_root"]:""; $passroot=GETPOST('db_pass_root');
// Repertoire des pages dolibarr // Repertoire des pages dolibarr
$main_dir=isset($_POST["main_dir"])?trim($_POST["main_dir"]):''; $main_dir=GETPOST('main_dir');
$main_url=GETPOST('main_url');
// Database server
$db_type=GETPOST('db_type','alpha');
$db_host=GETPOST('db_host','alpha');
$db_name=GETPOST('db_name','alpha');
$db_user=GETPOST('db_user','alpha');
$db_pass=GETPOST('db_pass');
$db_port=GETPOST('db_port','int');
$db_prefix=GETPOST('db_prefix','alpha');
// Now we load forced value from install.forced.php file. // Now we load forced value from install.forced.php file.
$useforcedwizard=false; $useforcedwizard=false;
@ -71,34 +80,34 @@ if (! is_writable($conffile))
// Check parameters // Check parameters
if (empty($_POST["db_type"])) if (empty($db_type))
{ {
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>'; print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseType")).'</div>';
$error++; $error++;
} }
if (empty($_POST["db_host"])) if (empty($db_host))
{ {
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>'; print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Server")).'</div>';
$error++; $error++;
} }
if (empty($_POST["db_name"])) if (empty($db_name))
{ {
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>'; print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DatabaseName")).'</div>';
$error++; $error++;
} }
if (empty($_POST["db_user"])) if (empty($db_user))
{ {
print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>'; print '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Login")).'</div>';
$error++; $error++;
} }
if (! empty($_POST["db_port"]) && ! is_numeric($_POST["db_port"])) if (! empty($db_port) && ! is_numeric($db_port))
{ {
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$_POST["db_port"],$langs->transnoentities("Port")).'</div>'; print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$db_port,$langs->transnoentities("Port")).'</div>';
$error++; $error++;
} }
if (! empty($_POST["db_prefix"]) && ! preg_match('/^[a-z0-9]+_$/i', $_POST["db_prefix"])) if (! empty($db_prefix) && ! preg_match('/^[a-z0-9]+_$/i', $db_prefix))
{ {
print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$_POST["db_prefix"],$langs->transnoentities("DatabasePrefix")).'</div>'; print '<div class="error">'.$langs->trans("ErrorBadValueForParameter",$db_prefix,$langs->transnoentities("DatabasePrefix")).'</div>';
$error++; $error++;
} }
@ -110,9 +119,9 @@ if (substr($main_dir, dol_strlen($main_dir) -1) == "/")
} }
// Remove last / into dans main_url // Remove last / into dans main_url
if (! empty($_POST["main_url"]) && substr($_POST["main_url"], dol_strlen($_POST["main_url"]) -1) == "/") if (! empty($main_url) && substr($main_url, dol_strlen($main_url) -1) == "/")
{ {
$_POST["main_url"] = substr($_POST["main_url"], 0, dol_strlen($_POST["main_url"])-1); $main_url = substr($main_url, 0, dol_strlen($main_url)-1);
} }
// Directory for generated documents (invoices, orders, ecm, etc...) // Directory for generated documents (invoices, orders, ecm, etc...)
@ -123,13 +132,13 @@ if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
// Test database connexion // Test database connexion
if (! $error) if (! $error)
{ {
$result=@include_once $main_dir."/core/db/".$_POST["db_type"].'.class.php'; $result=@include_once $main_dir."/core/db/".$db_type.'.class.php';
if ($result) if ($result)
{ {
// If we ask database or user creation we need to connect as root, so we need root login // If we ask database or user creation we need to connect as root, so we need root login
if (! empty($_POST["db_create_database"]) && ! $userroot) if (! empty($_POST["db_create_database"]) && ! $userroot)
{ {
print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$_POST["db_name"]).'</div>'; print '<div class="error">'.$langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$db_name).'</div>';
print '<br>'; print '<br>';
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>'; print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
@ -137,7 +146,7 @@ if (! $error)
} }
if (! empty($_POST["db_create_user"]) && ! $userroot) if (! empty($_POST["db_create_user"]) && ! $userroot)
{ {
print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$_POST["db_user"]).'</div>'; print '<div class="error">'.$langs->trans("YouAskLoginCreationSoDolibarrNeedToConnect",$db_user).'</div>';
print '<br>'; print '<br>';
print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>'; print $langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
@ -147,14 +156,14 @@ if (! $error)
// If we need root access // If we need root access
if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"]))) if (! $error && (! empty($_POST["db_create_database"]) || ! empty($_POST["db_create_user"])))
{ {
$databasefortest=$_POST["db_name"]; $databasefortest=$db_name;
if (! empty($_POST["db_create_database"])) if (! empty($_POST["db_create_database"]))
{ {
if ($_POST["db_type"] == 'mysql' || $_POST["db_type"] == 'mysqli') if ($db_type == 'mysql' || $db_type == 'mysqli')
{ {
$databasefortest='mysql'; $databasefortest='mysql';
} }
elseif ($_POST["db_type"] == 'pgsql') elseif ($db_type == 'pgsql')
{ {
$databasefortest='postgres'; $databasefortest='postgres';
} }
@ -165,14 +174,14 @@ if (! $error)
} }
//print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"]; //print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
$db=getDoliDBInstance($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]); $db=getDoliDBInstance($db_type, $db_host, $userroot, $passroot, $databasefortest, $db_port);
dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG); dol_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected; //print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected) if (empty($_POST["db_create_database"]) && $db->connected && ! $db->database_selected)
{ {
print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$_POST["db_name"]).'</div>'; print '<div class="error">'.$langs->trans("ErrorConnectedButDatabaseNotFound",$db_name).'</div>';
print '<br>'; print '<br>';
if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>'; if (! $db->connected) print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
@ -191,7 +200,7 @@ if (! $error)
// If we need simple access // If we need simple access
if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"]))) if (! $error && (empty($_POST["db_create_database"]) && empty($_POST["db_create_user"])))
{ {
$db=getDoliDBInstance($_POST["db_type"],$_POST["db_host"],$_POST["db_user"],$_POST["db_pass"],$_POST["db_name"],$_POST["db_port"]); $db=getDoliDBInstance($db_type, $db_host, $db_user, $db_pass, $db_name, $db_port);
if ($db->error) if ($db->error)
{ {
@ -204,7 +213,7 @@ if (! $error)
} }
else else
{ {
print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$_POST["db_type"].".class.php\")<br>\n"; print "<br>\nFailed to include_once(\"".$main_dir."/core/db/".$db_type.".class.php\")<br>\n";
print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>'; print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++; $error++;
@ -223,10 +232,10 @@ if (! $error && $db->connected)
{ {
if (! empty($_POST["db_create_database"])) if (! empty($_POST["db_create_database"]))
{ {
$result=$db->select_db($_POST["db_name"]); $result=$db->select_db($db_name);
if ($result) if ($result)
{ {
print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists",$_POST["db_name"]).'</div>'; print '<div class="error">'.$langs->trans("ErrorDatabaseAlreadyExists", $db_name).'</div>';
print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>'; print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate").'<br><br>';
print $langs->trans("ErrorGoBackAndCorrectParameters"); print $langs->trans("ErrorGoBackAndCorrectParameters");
$error++; $error++;
@ -259,9 +268,10 @@ if (! $error && $db->connected)
if (! $error && $db->connected && $action == "set") if (! $error && $db->connected && $action == "set")
{ {
umask(0); umask(0);
foreach($_POST as $cle=>$valeur) foreach($_POST as $key => $value)
{ {
if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur); if (! preg_match('/^db_pass/i', $key))
dolibarr_install_syslog("Choice for ".$key." = ".$value);
} }
// Show title of step // Show title of step
@ -399,7 +409,7 @@ if (! $error && $db->connected && $action == "set")
} }
// Table prefix // Table prefix
$main_db_prefix = ((GETPOST("db_prefix") && GETPOST("db_prefix") != '') ? GETPOST("db_prefix") : 'llx_'); $main_db_prefix = (! empty($db_prefix) ? $db_prefix : 'llx_');
// Force https // Force https
$main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1)) ? '1' : '0'); $main_force_https = ((GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1)) ? '1' : '0');
@ -766,6 +776,7 @@ function write_conf_file($conffile)
global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host; global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass; global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication; global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
global $db_host,$db_port,$db_name,$db_user,$db_pass,$db_type;
global $conffile,$conffiletoshow,$conffiletoshowshort; global $conffile,$conffiletoshow,$conffiletoshowshort;
global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH; global $force_dolibarr_lib_ADODB_PATH, $force_dolibarr_lib_NUSOAP_PATH;
global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH; global $force_dolibarr_lib_TCPDF_PATH, $force_dolibarr_lib_FPDI_PATH;
@ -791,13 +802,13 @@ function write_conf_file($conffile)
fputs($fp,'// and explanations for all possibles parameters.'."\n"); fputs($fp,'// and explanations for all possibles parameters.'."\n");
fputs($fp,'//'."\n"); fputs($fp,'//'."\n");
fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",($_POST["main_url"])).'\';'); fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",($main_url)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",($main_dir)).'\';'); fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",($main_dir)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",($_POST["main_url"]."/".$main_alt_dir_name)).'\';'); fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",($main_url."/".$main_alt_dir_name)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",($main_dir."/".$main_alt_dir_name)).'\';'); fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",($main_dir."/".$main_alt_dir_name)).'\';');
@ -806,24 +817,24 @@ function write_conf_file($conffile)
fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'","\'",($main_data_dir)).'\';'); fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'","\'",($main_data_dir)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'","\'",($_POST["db_host"])).'\';'); fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'","\'",($db_host)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'","\'",($_POST["db_port"])).'\';'); fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'","\'",($db_port)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'","\'",($_POST["db_name"])).'\';'); fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'","\'",($db_name)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'","\'",($main_db_prefix)).'\';'); fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'","\'",($main_db_prefix)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'","\'",($_POST["db_user"])).'\';'); fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'","\'",($db_user)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'","\'",($_POST["db_pass"])).'\';'); fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'","\'",($db_pass)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'","\'",($_POST["db_type"])).'\';'); fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'","\'",($db_type)).'\';');
fputs($fp,"\n"); fputs($fp,"\n");
fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'","\'",($_POST["dolibarr_main_db_character_set"])).'\';'); fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'","\'",($_POST["dolibarr_main_db_character_set"])).'\';');

View File

@ -41,7 +41,7 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$cancel=GETPOST('cancel','alpha'); $cancel=GETPOST('cancel','alpha');
$key=GETPOST('key'); $key=GETPOST('key');
$catMere=GETPOST('catMere'); $parent=GETPOST('parent');
// Security check // Security check
if (! empty($user->societe_id)) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
@ -144,9 +144,9 @@ if ($action == 'search')
$sql.= " OR p.label LIKE '%".$key."%')"; $sql.= " OR p.label LIKE '%".$key."%')";
} }
} }
if (! empty($conf->categorie->enabled) && $catMere != -1 and $catMere) if (! empty($conf->categorie->enabled) && ! empty($parent) && $parent != -1)
{ {
$sql.= " AND cp.fk_categorie ='".$db->escape($catMere)."'"; $sql.= " AND cp.fk_categorie ='".$db->escape($parent)."'";
} }
$sql.= " ORDER BY p.ref ASC"; $sql.= " ORDER BY p.ref ASC";
@ -366,7 +366,7 @@ if ($id || $ref)
if (! empty($conf->categorie->enabled)) if (! empty($conf->categorie->enabled))
{ {
print '<tr><td>'.$langs->trans("CategoryFilter").' &nbsp; </td>'; print '<tr><td>'.$langs->trans("CategoryFilter").' &nbsp; </td>';
print '<td>'.$form->select_all_categories(0,$catMere).'</td></tr>'; print '<td>'.$form->select_all_categories(0, $parent).'</td></tr>';
} }
print '</table>'; print '</table>';

View File

@ -185,6 +185,7 @@ class Societe extends CommonObject
$this->nom=$this->name; // For backward compatibility $this->nom=$this->name; // For backward compatibility
if (empty($this->client)) $this->client=0; if (empty($this->client)) $this->client=0;
if (empty($this->fournisseur)) $this->fournisseur=0; if (empty($this->fournisseur)) $this->fournisseur=0;
$this->import_key = trim($this->import_key);
dol_syslog(get_class($this)."::create ".$this->name); dol_syslog(get_class($this)."::create ".$this->name);
@ -210,14 +211,15 @@ class Societe extends CommonObject
if ($result >= 0) if ($result >= 0)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, import_key)";
$sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'"; $sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'";
$sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null");
$sql.= ", ".(! empty($this->canvas) ? "'".$this->canvas."'":"null"); $sql.= ", ".(! empty($this->canvas) ? "'".$this->canvas."'":"null");
$sql.= ", ".$this->status; $sql.= ", ".$this->status;
$sql.= ", ".(! empty($this->ref_int) ? "'".$this->ref_int."'":"null"); $sql.= ", ".(! empty($this->ref_int) ? "'".$this->ref_int."'":"null");
$sql.= ", ".(! empty($this->ref_ext) ? "'".$this->ref_ext."'":"null"); $sql.= ", ".(! empty($this->ref_ext) ? "'".$this->ref_ext."'":"null");
$sql.= ", 0)"; $sql.= ", 0";
$sql.= ", ".(! empty($this->import_key) ? "'".$this->import_key."'":"null").")";
dol_syslog(get_class($this)."::create sql=".$sql); dol_syslog(get_class($this)."::create sql=".$sql);
$result=$this->db->query($sql); $result=$this->db->query($sql);
@ -832,6 +834,103 @@ class Societe extends CommonObject
return $result; return $result;
} }
/**
* Search and fetch thirparties by name
*
* @param string $name Name
* @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
* @param array $filters Array of couple field name/value to filter the companies with the same name
* @param boolean $exact Exact string search (true/false)
* @param boolean $case Case sensitive (true/false)
* @param string $clause Clause for filters
* @return array Array of thirdparties object
*/
function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND')
{
$thirdparties = array();
// Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE entity IN (".getEntity('category',1).")";
if (! empty($type))
{
if ($type == 1 || $type == 2)
$sql.= " AND client = ".$type;
elseif ($type == 3)
$sql.= " AND fournisseur = 1";
}
if (! empty($name))
{
if (! $exact)
{
if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1)
{
$name = str_replace('*', '%', $name);
}
else
{
$name = '%'.$name.'%';
}
}
$sql.= " AND ";
if (is_array($filters) && ! empty($filters))
$sql.= "(";
if ($similar)
{
// For test similitude
$sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)";
}
else
{
if (! $case)
$sql.= "nom LIKE '".$this->db->escape($name)."'";
else
$sql.= "nom LIKE BINARY '".$this->db->escape($name)."'";
}
}
if (is_array($filters) && ! empty($filters))
{
foreach($filters as $field => $value)
{
if (! $exact)
{
if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1)
{
$value = str_replace('*', '%', $value);
}
else
{
$value = '%'.$value.'%';
}
}
if (! $case)
$sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'";
else
$sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'";
}
if (! empty($name))
$sql.= ")";
}
$res = $this->db->query($sql);
if ($res)
{
while ($rec = $this->db->fetch_array($res))
{
$soc = new Societe($this->db);
$soc->fetch($rec['rowid']);
$thirdparties[] = $soc;
}
return $thirdparties;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::searchByName ".$this->error, LOG_ERR);
return -1;
}
}
/** /**
* Delete a third party from database and all its dependencies (contacts, rib...) * Delete a third party from database and all its dependencies (contacts, rib...)

View File

@ -69,7 +69,7 @@ $form = new Form($db);
llxHeader("","ClickToDial"); llxHeader("","ClickToDial");
if ($id) if ($id > 0)
{ {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($id); $fuser->fetch($id);
@ -113,7 +113,7 @@ if ($id)
if ($action == 'edit') if ($action == 'edit')
{ {
print '<form action="clicktodial.php?id='.$_GET["id"].'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -192,7 +192,7 @@ if ($id)
if (! empty($user->admin) && $action <> 'edit') if (! empty($user->admin) && $action <> 'edit')
{ {
print '<a class="butAction" href="clicktodial.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
} }
print "</div>\n"; print "</div>\n";

View File

@ -28,17 +28,18 @@ require '../../main.inc.php';
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{ {
if (! $user->rights->user->group_advance->read && ! $user->admin) accessforbidden(); if (! $user->rights->user->group_advance->read && ! $user->admin)
accessforbidden();
} }
$langs->load("users"); $langs->load("users");
$sall=GETPOST("sall"); $sall=GETPOST('sall');
$search_group=GETPOST('search_group'); $search_group=GETPOST('search_group');
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST('sortorder','alpha');
$page = GETPOST("page",'int'); $page = GETPOST('page','int');
if ($page == -1) { $page = 0; } if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page; $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
@ -67,9 +68,9 @@ else
{ {
$sql.= " WHERE g.entity IN (0,".$conf->entity.")"; $sql.= " WHERE g.entity IN (0,".$conf->entity.")";
} }
if ($search_group) if (! empty($search_group))
{ {
$sql .= " AND (g.nom LIKE '%".$db->escape($_POST["search_group"])."%' OR g.note LIKE '%".$db->escape($_POST["search_group"])."%')"; $sql .= " AND (g.nom LIKE '%".$db->escape($search_group)."%' OR g.note LIKE '%".$db->escape($search_group)."%')";
} }
if ($sall) $sql.= " AND (g.nom LIKE '%".$db->escape($sall)."%' OR g.note LIKE '%".$db->escape($sall)."%')"; if ($sall) $sql.= " AND (g.nom LIKE '%".$db->escape($sall)."%' OR g.note LIKE '%".$db->escape($sall)."%')";
$sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec"; $sql.= " GROUP BY g.rowid, g.nom, g.entity, g.datec";
@ -81,7 +82,7 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param="search_group=".$search_group."&amp;sall=".$sall; $param="&search_group=".urlencode($search_group)."&amp;sall=".urlencode($sall);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);

View File

@ -24,24 +24,27 @@
*/ */
require '../main.inc.php'; require '../main.inc.php';
if(! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php'); if (! empty($conf->multicompany->enabled))
dol_include_once('/multicompany/class/actions_multicompany.class.php', 'Multicompany');
if (! $user->rights->user->user->lire && ! $user->admin) accessforbidden(); if (! $user->rights->user->user->lire && ! $user->admin)
accessforbidden();
$langs->load("users"); $langs->load("users");
$langs->load("companies"); $langs->load("companies");
// Security check (for external users) // Security check (for external users)
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0)
$socid = $user->societe_id;
$sall=GETPOST('sall','alpha'); $sall=GETPOST('sall','alpha');
$search_user=GETPOST('search_user','alpha'); $search_user=GETPOST('search_user','alpha');
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST('sortorder','alpha');
$page = GETPOST("page",'int'); $page = GETPOST('page','int');
if ($page == -1) { $page = 0; } if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page; $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
@ -78,10 +81,10 @@ else
{ {
$sql.= " WHERE u.entity IN (0,".$conf->entity.")"; $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
} }
if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid; if (! empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
if ($search_user) if (! empty($search_user))
{ {
$sql.= " AND (u.login LIKE '%".$search_user."%' OR u.name LIKE '%".$search_user."%' OR u.firstname LIKE '%".$search_user."%')"; $sql.= " AND (u.login LIKE '%".$db->escape($search_user)."%' OR u.name LIKE '%".$db->escape($search_user)."%' OR u.firstname LIKE '%".$db->escape($search_user)."%')";
} }
if ($sall) $sql.= " AND (u.login LIKE '%".$db->escape($sall)."%' OR u.name LIKE '%".$db->escape($sall)."%' OR u.firstname LIKE '%".$db->escape($sall)."%' OR u.email LIKE '%".$db->escape($sall)."%' OR u.note LIKE '%".$db->escape($sall)."%')"; if ($sall) $sql.= " AND (u.login LIKE '%".$db->escape($sall)."%' OR u.name LIKE '%".$db->escape($sall)."%' OR u.firstname LIKE '%".$db->escape($sall)."%' OR u.email LIKE '%".$db->escape($sall)."%' OR u.note LIKE '%".$db->escape($sall)."%')";
$sql.=$db->order($sortfield,$sortorder); $sql.=$db->order($sortfield,$sortorder);