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

This commit is contained in:
Laurent Destailleur 2011-12-31 11:10:22 +01:00
commit 28754deb10
18 changed files with 683 additions and 557 deletions

View File

@ -35,22 +35,23 @@ For users:
- Fix: Can use POS module with several concurrent users. - Fix: Can use POS module with several concurrent users.
For developers: For developers:
- New: Add webservice to get or create a product, service. - New: Can add a left menu (first level) into an existing top menu.
- New: Add webservice to get a user.
- New: Add hooks to change way of showing/editing lines into dictionnaries.
- New: Add webservice to get or create a product or service. - New: Add webservice to get or create a product or service.
- New: Add webservice to get a user.
- New: Add more "hooks" (like hooks to change way of showing/editing lines into dictionnaries).
- New: Log module outputs can be setup with "or" rule (not only "xor"). - New: Log module outputs can be setup with "or" rule (not only "xor").
- New: Add FirePHP output for logging module. - New: Add FirePHP output for logging module.
- New: Add trigger ACTION_DELETE and ACTION_MODIFY - New: Add trigger ACTION_DELETE and ACTION_MODIFY.
- New: Can define different requests according to database type into migration files. - New: Can define different requests according to database type into migration files.
- New: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours.
- Qual: Add a lot of more PHPUnit tests.
- Qual: Data structure for supplier prices is simpler. - Qual: Data structure for supplier prices is simpler.
- Qual: Removed no more used external libraries. - Qual: Removed no more used external libraries.
- Qual: Cleaned a lot of dead code. - Qual: Cleaned a lot of dead code.
- Qual: Add more "hooks".
- Qual: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours.
- Qual: More OOP (usage of "abstract", "static", ...), uniformize constructors. - Qual: More OOP (usage of "abstract", "static", ...), uniformize constructors.
- Qual: task #216 : Move /lib in /core/lib directory - Qual: Fix a lot of checkstyle warnings.
- Qual: task #217 : Move core files in core directory (login, menus, triggers, boxes, modules) - Qual: task #216 : Move /lib into /core/lib directory
- Qual: task #217 : Move core files into core directory (login, menus, triggers, boxes, modules)
***** ChangeLog for 3.1 compared to 3.0 ***** ***** ChangeLog for 3.1 compared to 3.0 *****

View File

@ -205,7 +205,10 @@
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" /> <rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace" /> <rule ref="PEAR.WhiteSpace.ScopeClosingBrace">
<severity>0</severity>
</rule>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace.Line"> <rule ref="PEAR.WhiteSpace.ScopeClosingBrace.Line">
<severity>0</severity> <severity>0</severity>
</rule> </rule>

View File

@ -37,13 +37,13 @@ class modMyModule extends DolibarrModules
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function modMyModule($DB) function modMyModule($db)
{ {
global $langs,$conf; global $langs,$conf;
$this->db = $DB; $this->db = $db;
// Id for module (must be unique). // Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
@ -169,7 +169,8 @@ class modMyModule extends DolibarrModules
$r=0; $r=0;
// Add here entries to declare new menus // Add here entries to declare new menus
// Example to declare the Top Menu entry: //
// Example to declare a new Top Menu entry and its Left menu entry:
// $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
// 'type'=>'top', // This is a Top menu entry // 'type'=>'top', // This is a Top menu entry
// 'titre'=>'MyModule top menu', // 'titre'=>'MyModule top menu',
@ -182,11 +183,9 @@ class modMyModule extends DolibarrModules
// 'target'=>'', // 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++; // $r++;
//
// Example to declare a Left Menu entry:
// $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) // $this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
// 'type'=>'left', // This is a Left menu entry // 'type'=>'left', // This is a Left menu entry
// 'titre'=>'MyModule left menu 1', // 'titre'=>'MyModule left menu',
// 'mainmenu'=>'mymodule', // 'mainmenu'=>'mymodule',
// 'url'=>'/mymodule/pagelevel1.php', // 'url'=>'/mymodule/pagelevel1.php',
// 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
@ -197,10 +196,10 @@ class modMyModule extends DolibarrModules
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++; // $r++;
// //
// Example to declare another Left Menu entry: // Example to declare a Left Menu entry into an existing Top menu entry:
// $this->menu[$r]=array( 'fk_menu'=>'r=1', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=mainmenucode', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
// 'type'=>'left', // This is a Left menu entry // 'type'=>'left', // This is a Left menu entry
// 'titre'=>'MyModule left menu 2', // 'titre'=>'MyModule left menu',
// 'mainmenu'=>'mymodule', // 'mainmenu'=>'mymodule',
// 'url'=>'/mymodule/pagelevel2.php', // 'url'=>'/mymodule/pagelevel2.php',
// 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.

View File

@ -80,7 +80,7 @@ class Adherent extends CommonObject
var $morphy; var $morphy;
var $public; var $public;
var $note; // Note var $note; // Private note
var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye
var $photo; var $photo;
@ -115,11 +115,11 @@ class Adherent extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Adherent($DB) function Adherent($db)
{ {
$this->db = $DB ; $this->db = $db;
$this->statut = -1; $this->statut = -1;
// l'adherent n'est pas public par defaut // l'adherent n'est pas public par defaut
$this->public = 0; $this->public = 0;
@ -388,8 +388,15 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email); dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email);
// Clean parameters // Clean parameters
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->nom=ucwords(trim($this->nom)); $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->nom);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->prenom=ucwords(trim($this->prenom)); $this->firstname=trim($this->firstname)?trim($this->firstname):trim($this->prenom);
$this->address=($this->address?$this->address:$this->adresse);
$this->zip=($this->zip?$this->zip:$this->cp);
$this->town=($this->town?$this->town:$this->ville);
$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname));
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname));
// Check parameters // Check parameters
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
@ -403,16 +410,16 @@ class Adherent extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null"); $sql.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null");
$sql.= ", prenom = ".($this->prenom?"'".$this->db->escape($this->prenom)."'":"null"); $sql.= ", prenom = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
$sql.= ", nom=" .($this->nom?"'".$this->db->escape($this->nom)."'":"null"); $sql.= ", nom=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null"); $sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null");
$sql.= ", adresse=" .($this->adresse?"'".$this->db->escape($this->adresse)."'":"null"); $sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", cp=" .($this->cp?"'".$this->db->escape($this->cp)."'":"null"); $sql.= ", cp=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", ville=" .($this->ville?"'".$this->db->escape($this->ville)."'":"null"); $sql.= ", ville=" .($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null"); $sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null");
$sql.= ", fk_departement=".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ", fk_departement=".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ", email='".$this->email."'"; $sql.= ", email='".$this->email."'";
$sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
$sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
@ -433,7 +440,12 @@ class Adherent extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$nbrowsaffected+=$this->db->affected_rows($resql); unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
$nbrowsaffected+=$this->db->affected_rows($resql);
// Actions on extra fields (by external module) // Actions on extra fields (by external module)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
@ -953,7 +965,7 @@ class Adherent extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as name, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,"; $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,";
$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy,";
$sql.= " d.datec as datec,"; $sql.= " d.datec as datec,";
@ -990,8 +1002,8 @@ class Adherent extends CommonObject
$this->civilite_id = $obj->civilite; $this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname; $this->prenom = $obj->firstname;
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->nom = $obj->name; $this->nom = $obj->lastname;
$this->lastname = $obj->name; $this->lastname = $obj->lastname;
$this->login = $obj->login; $this->login = $obj->login;
$this->pass = $obj->pass; $this->pass = $obj->pass;
$this->societe = $obj->societe; $this->societe = $obj->societe;
@ -1755,14 +1767,23 @@ class Adherent extends CommonObject
/** /**
* Return full address of member * Return full address of member
* *
* @param int $withcountry 1=Add country into address string *
* @param string $sep Separator to use to build string * @param int $withcountry 1=Add country into address string
* @return string Full address string * @param string $sep Separator to use to build string
* @return string Full address string
*/ */
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
@ -1777,7 +1798,6 @@ class Adherent extends CommonObject
return trim($ret); return trim($ret);
} }
/** /**
* Retourne le libelle du statut d'un adherent (brouillon, valide, resilie) * Retourne le libelle du statut d'un adherent (brouillon, valide, resilie)
* *

View File

@ -52,13 +52,13 @@ $specimenthirdparty->initAsSpecimen();
if ($action == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstorder=$_POST['maskconstorder']; $maskconstorder=$_POST['maskconstorder'];
$maskorder=$_POST['maskorder']; $maskorder=$_POST['maskorder'];
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
if (! $error) if (! $error)
{ {
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
@ -70,76 +70,76 @@ if ($action == 'updateMask')
if ($action == 'specimen') // For orders if ($action == 'specimen') // For orders
{ {
$modele=GETPOST("module"); $modele=GETPOST("module");
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();
$commande->thirdparty=$specimenthirdparty; $commande->thirdparty=$specimenthirdparty;
// Charge le modele // Charge le modele
$dir = "/core/modules/supplier_order/pdf/"; $dir = "/core/modules/supplier_order/pdf/";
$file = "pdf_".$modele.".modules.php"; $file = "pdf_".$modele.".modules.php";
$file = dol_buildpath($dir.$file); $file = dol_buildpath($dir.$file);
if (file_exists($file)) if (file_exists($file))
{ {
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
require_once($file); require_once($file);
$obj = new $classname($db,$commande); $obj = new $classname($db,$commande);
if ($obj->write_file($commande,$langs) > 0) if ($obj->write_file($commande,$langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
return; return;
} }
else else
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<div class="error">'.$obj->error.'</div>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($obj->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
if ($action == 'specimenfacture') // For invoices if ($action == 'specimenfacture') // For invoices
{ {
$modele=GETPOST("module"); $modele=GETPOST("module");
$facture = new FactureFournisseur($db); $facture = new FactureFournisseur($db);
$facture->initAsSpecimen(); $facture->initAsSpecimen();
$facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier) $facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier)
// Charge le modele // Charge le modele
$dir = "/core/modules/supplier_invoice/pdf/"; $dir = "/core/modules/supplier_invoice/pdf/";
$file = "pdf_".$modele.".modules.php"; $file = "pdf_".$modele.".modules.php";
$file = dol_buildpath($dir.$file); $file = dol_buildpath($dir.$file);
if (file_exists($file)) if (file_exists($file))
{ {
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
require_once($file); require_once($file);
$obj = new $classname($db,$facture); $obj = new $classname($db,$facture);
if ($obj->write_file($facture,$langs) > 0) if ($obj->write_file($facture,$langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
return; return;
} }
else else
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<div class="error">'.$obj->error.'</div>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($obj->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
if ($action == 'set') if ($action == 'set')
@ -149,87 +149,87 @@ if ($action == 'set')
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null");
$sql.= ")"; $sql.= ")";
$res=$db->query($sql); $res=$db->query($sql);
if ($res) if ($res)
{ {
} }
// else dol_print_error($db); // else dol_print_error($db);
} }
if ($action == 'del') if ($action == 'del')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$value."'"; $sql.= " WHERE nom = '".$value."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$db->query($sql); $db->query($sql);
if ($res) if ($res)
{ {
} }
// else dol_print_error($db); // else dol_print_error($db);
} }
if ($action == 'setdoc') if ($action == 'setdoc')
{ {
$db->begin(); $db->begin();
if ($_GET["type"] == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if ($_GET["type"] == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{ {
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value; $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
} }
if ($_GET["type"] == 'invoice_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) if ($_GET["type"] == 'invoice_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{ {
$conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
} }
// On active le modele // On active le modele
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del.= " WHERE nom = '".$db->escape($value)."'"; $sql_del.= " WHERE nom = '".$db->escape($value)."'";
$sql_del.= " AND type = '".$type."'"; $sql_del.= " AND type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity; $sql_del.= " AND entity = ".$conf->entity;
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null");
$sql.= ")"; $sql.= ")";
$result2=$db->query($sql); $result2=$db->query($sql);
if ($result1 && $result2) if ($result1 && $result2)
{ {
$db->commit(); $db->commit();
} }
else else
{ {
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'setmod') if ($action == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity); dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity);
} }
if ($action == 'addcat') if ($action == 'addcat')
{ {
$fourn = new Fournisseur($db); $fourn = new Fournisseur($db);
$fourn->CreateCategory($user,$_POST["cat"]); $fourn->CreateCategory($user,$_POST["cat"]);
} }
if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
{ {
$free = GETPOST("SUPPLIER_INVOICE_FREE_TEXT"); $free = GETPOST("SUPPLIER_INVOICE_FREE_TEXT");
$res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$free,'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++; if (! $res > 0) $error++;
if (! $error) if (! $error)
{ {
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
@ -238,6 +238,8 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }
/* /*
* View * View
*/ */
@ -269,87 +271,89 @@ clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot . "/core/modules/supplier_order/"; $dir = $dirroot . "/core/modules/supplier_order/";
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
$var=true; $var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php') if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{ {
$file = substr($file, 0, dol_strlen($file)-4); $file = substr($file, 0, dol_strlen($file)-4);
require_once($dir.$file.".php"); require_once($dir.$file.".php");
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled())
{ {
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n"; print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; } if (preg_match('/^Error/',$tmp)) {
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
}
elseif ($tmp=='NotConfigured') print $langs->trans($tmp); elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file") if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file")
{ {
print img_picto($langs->trans("Activated"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
$commande=new CommandeFournisseur($db); $commande=new CommandeFournisseur($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();
// Info // Info
$htmltooltip=''; $htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0; $facture->type=0;
$nextval=$module->getNextValue($mysoc,$commande); $nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{ {
$htmltooltip.=''.$langs->trans("NextValue").': '; $htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) if ($nextval)
{ {
$htmltooltip.=$nextval.'<br>'; $htmltooltip.=$nextval.'<br>';
} }
else else
{ {
$htmltooltip.=$langs->trans($module->error).'<br>'; $htmltooltip.=$langs->trans($module->error).'<br>';
} }
} }
print '<td align="center">'; print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0); print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
} }
} }
closedir($handle); closedir($handle);
} }
} }
} }
print '</table><br>'; print '</table><br>';
@ -374,18 +378,18 @@ $sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
$num_rows=$db->num_rows($resql); $num_rows=$db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows)
{ {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
} }
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
print '<table class="noborder" width="100%">'."\n"; print '<table class="noborder" width="100%">'."\n";
@ -401,90 +405,90 @@ clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot . "/core/modules/supplier_order/pdf/"; $dir = $dirroot . "/core/modules/supplier_order/pdf/";
if (is_dir($dir)) if (is_dir($dir))
{ {
$var=true; $var=true;
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12); $classname = substr($file, 0, dol_strlen($file) -12);
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
print "<td>".$name."</td>\n"; print "<td>".$name."</td>\n";
print "<td>\n"; print "<td>\n";
require_once($dir.$file); require_once($dir.$file);
$module = new $classname($db,$specimenthirdparty); $module = new $classname($db,$specimenthirdparty);
print $module->description; print $module->description;
print "</td>\n"; print "</td>\n";
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td align="center">'."\n"; print '<td align="center">'."\n";
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name")
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">';
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
} }
else else
{ {
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
} }
print "</td>"; print "</td>";
} }
else else
{ {
print '<td align="center">'."\n"; print '<td align="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print '<td align="center">'; print '<td align="center">';
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
print '<td align="center">'; print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0); print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
} }
} }
} }
print '</table><br/>'; print '</table><br/>';
@ -506,18 +510,18 @@ $sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
$num_rows=$db->num_rows($resql); $num_rows=$db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows)
{ {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
} }
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
@ -534,88 +538,88 @@ clearstatcache();
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot . "/core/modules/supplier_invoice/pdf/"; $dir = $dirroot . "/core/modules/supplier_invoice/pdf/";
if (is_dir($dir)) if (is_dir($dir))
{ {
$var=true; $var=true;
$handle=opendir($dir); $handle=opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_') if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{ {
$name = substr($file, 4, dol_strlen($file) -16); $name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12); $classname = substr($file, 0, dol_strlen($file) -12);
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
print "<td>".$name."</td>\n"; print "<td>".$name."</td>\n";
print "<td>"; print "<td>";
require_once($dir.$file); require_once($dir.$file);
$module = new $classname($db,$specimenthirdparty); $module = new $classname($db,$specimenthirdparty);
print $module->description; print $module->description;
print "</td>\n"; print "</td>\n";
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name")
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">';
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
} }
else else
{ {
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'switch_on');
} }
print "</td>"; print "</td>";
} }
else else
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Defaut // Defaut
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
print '<td align="center">'; print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0); print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimenfacture&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimenfacture&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
} }
} }
} }
print '</table><br/>'; print '</table><br/>';
@ -641,7 +645,7 @@ print '</form>';
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -123,7 +123,7 @@ if ($conf->stock->enabled)
</table> </table>
<br> <br>
<center><span class="bouton_login"><input name="sbmtConnexion" type="submit" value=<?php echo $langs->trans("Connection"); ?> /></span></center> <div align="center"><span class="bouton_login"><input name="sbmtConnexion" type="submit" value=<?php echo $langs->trans("Connection"); ?> /></span></div>
</form> </form>
</fieldset> </fieldset>

View File

@ -53,6 +53,9 @@ class Contact extends CommonObject
var $fk_departement; // Id of department var $fk_departement; // Id of department
var $departement_code; // Code of department var $departement_code; // Code of department
var $departement; // Label of department var $departement; // Label of department
var $state_id; // Id of department
var $state_code; // Code of department
var $state; // Label of department
var $fk_pays; // Id of country var $fk_pays; // Id of country
var $pays_code; // Code of country var $pays_code; // Code of country
@ -68,6 +71,7 @@ class Contact extends CommonObject
var $email; var $email;
var $birthday; var $birthday;
var $default_lang; var $default_lang;
var $note; // Private note
var $ref_facturation; // Nb de reference facture pour lequel il est contact var $ref_facturation; // Nb de reference facture pour lequel il est contact
var $ref_contrat; // Nb de reference contrat pour lequel il est contact var $ref_contrat; // Nb de reference contrat pour lequel il est contact
@ -83,11 +87,11 @@ class Contact extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Contact($DB) function Contact($db)
{ {
$this->db = $DB; $this->db = $db;
} }
/** /**
@ -106,9 +110,9 @@ class Contact extends CommonObject
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters
$this->name=trim($this->name); $this->lastname=$this->lastname?trim($this->lastname):$this->name;
$this->firstname=trim($this->firstname); $this->firstname=trim($this->firstname);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname);
if (! $this->socid) $this->socid = 0; if (! $this->socid) $this->socid = 0;
if (! $this->priv) $this->priv = 0; if (! $this->priv) $this->priv = 0;
@ -209,9 +213,8 @@ class Contact extends CommonObject
$this->id = $id; $this->id = $id;
// Clean parameters // Clean parameters
$this->name=trim($this->name); $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->name);
$this->firstname=trim($this->firstname); $this->firstname=trim($this->firstname);
$this->email=trim($this->email); $this->email=trim($this->email);
$this->phone_pro=trim($this->phone_pro); $this->phone_pro=trim($this->phone_pro);
$this->phone_perso=trim($this->phone_perso); $this->phone_perso=trim($this->phone_perso);
@ -228,7 +231,7 @@ class Contact extends CommonObject
if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
if ($this->socid == -1) $sql .= " fk_soc=null,"; if ($this->socid == -1) $sql .= " fk_soc=null,";
$sql .= " civilite='".$this->db->escape($this->civilite_id)."'"; $sql .= " civilite='".$this->db->escape($this->civilite_id)."'";
$sql .= ", name='".$this->db->escape($this->name)."'"; $sql .= ", name='".$this->db->escape($this->lastname)."'";
$sql .= ", firstname='".$this->db->escape($this->firstname)."'"; $sql .= ", firstname='".$this->db->escape($this->firstname)."'";
$sql .= ", address='".$this->db->escape($this->address)."'"; $sql .= ", address='".$this->db->escape($this->address)."'";
$sql .= ", cp='".$this->db->escape($this->zip)."'"; $sql .= ", cp='".$this->db->escape($this->zip)."'";
@ -252,6 +255,11 @@ class Contact extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Appel des triggers // Appel des triggers
@ -453,14 +461,14 @@ class Contact extends CommonObject
$langs->load("companies"); $langs->load("companies");
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,"; $sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name as lastname, c.firstname,";
$sql.= " c.address, c.cp, c.ville,"; $sql.= " c.address, c.cp as zip, c.ville as town,";
$sql.= " c.fk_pays,"; $sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement,"; $sql.= " c.fk_departement,";
$sql.= " c.birthday,"; $sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
$sql.= " c.priv, c.note, c.default_lang, c.canvas,"; $sql.= " c.priv, c.note, c.default_lang, c.canvas,";
$sql.= " p.libelle as pays, p.code as pays_code,"; $sql.= " p.libelle as country, p.code as country_code,";
$sql.= " d.nom as departement, d.code_departement as departement_code,"; $sql.= " d.nom as departement, d.code_departement as departement_code,";
$sql.= " u.rowid as user_id, u.login as user_login,"; $sql.= " u.rowid as user_id, u.login as user_login,";
$sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang"; $sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang";
@ -482,31 +490,32 @@ class Contact extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->civilite_id = $obj->civilite_id; $this->civilite_id = $obj->civilite_id;
$this->name = $obj->name; $this->lastname = $obj->lastname;
$this->name = $obj->lastname; // TODO deprecated
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->nom = $obj->name; // TODO deprecated $this->nom = $obj->lastname; // TODO deprecated
$this->prenom = $obj->firstname; // TODO deprecated $this->prenom = $obj->firstname; // TODO deprecated
$this->address = $obj->address; $this->address = $obj->address;
$this->adresse = $obj->address; // TODO deprecated $this->adresse = $obj->address; // TODO deprecated
$this->cp = $obj->cp; // TODO deprecated $this->cp = $obj->zip; // TODO deprecated
$this->zip = $obj->cp; $this->zip = $obj->zip;
$this->ville = $obj->ville; // TODO deprecated $this->ville = $obj->town; // TODO deprecated
$this->town = $obj->ville; $this->town = $obj->town;
$this->fk_departement = $obj->fk_departement; $this->fk_departement = $obj->fk_departement;
$this->state_id = $obj->fk_departement; $this->state_id = $obj->fk_departement;
$this->departement_code = $obj->departement_code; // TODO deprecated $this->departement_code = $obj->departement_code; // TODO deprecated
$this->state_code = $obj->departement_code; $this->state_code = $obj->departement_code;
$this->departement = $obj->departement; // TODO deprecated $this->departement = $obj->departement; // TODO deprecated
$this->state = $obj->departement; $this->state = $obj->departement;
$this->fk_pays = $obj->fk_pays; $this->fk_pays = $obj->country_id;
$this->country_id = $obj->fk_pays; $this->country_id = $obj->country_id;
$this->pays_code = $obj->fk_pays?$obj->pays_code:''; $this->pays_code = $obj->country_id?$obj->country_code:'';
$this->country_code = $obj->fk_pays?$obj->pays_code:''; $this->country_code = $obj->country_id?$obj->country_code:'';
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):''; $this->pays = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->country = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):''; $this->country = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->socname = $obj->socname; $this->socname = $obj->socname;
@ -850,7 +859,15 @@ class Contact extends CommonObject
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
@ -878,13 +895,6 @@ class Contact extends CommonObject
$code=$this->civilite_id; $code=$this->civilite_id;
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : '';
/*if (empty($ret))
{
$ret=$code;
$langs->getLabelFromKey($this->db,$reg[1],'c_civilite','code','civilite');
//$ret=dol_getIdFromCode($this->db,$code,'c_civilite',
}
return $ret;*/
} }

View File

@ -85,9 +85,9 @@ class Menubase
$this->menu_handler=trim($this->menu_handler); $this->menu_handler=trim($this->menu_handler);
$this->module=trim($this->module); $this->module=trim($this->module);
$this->type=trim($this->type); $this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu); $this->mainmenu=trim($this->mainmenu); // If type='top'
$this->leftmenu=trim($this->leftmenu); $this->leftmenu=trim($this->leftmenu);
$this->fk_menu=trim($this->fk_menu); $this->fk_menu=trim($this->fk_menu); // If -1, fk_mainmenu and fk_leftmenu must be defined
$this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu=trim($this->fk_leftmenu);
$this->position=trim($this->position); $this->position=trim($this->position);
@ -146,8 +146,8 @@ class Menubase
$sql.= " '".$conf->entity."',"; $sql.= " '".$conf->entity."',";
$sql.= " '".$this->module."',"; $sql.= " '".$this->module."',";
$sql.= " '".$this->type."',"; $sql.= " '".$this->type."',";
$sql.= " '".$this->mainmenu."',"; $sql.= " ".($this->mainmenu?"'".$this->mainmenu."'":"''").","; // Can't be null
$sql.= " '".$this->leftmenu."',"; $sql.= " ".($this->leftmenu?"'".$this->leftmenu."'":"null").",";
$sql.= " '".$this->fk_menu."',"; $sql.= " '".$this->fk_menu."',";
$sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").","; $sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").",";
$sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").","; $sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").",";
@ -392,24 +392,11 @@ class Menubase
for ($x = 0; $x < $num; $x++) for ($x = 0; $x < $num; $x++)
{ {
//si un element a pour pere : $pere //si un element a pour pere : $pere
if ($tab[$x][1] == $pere) if ($tab[$x]['fk_menu'] == $pere && $tab[$x]['enabled'])
{ {
if ($tab[$x][7]) //print 'mainmenu='.$tab[$x]['mainmenu'];
{ $this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], $rang - 1, $tab[$x]['perms'], $tab[$x]['atarget'], $tab[$x]['mainmenu']);
$leftmenuConstraint = true; $this->recur($tab, $tab[$x]['rowid'], $rang + 1, $leftmenu);
if ($tab[$x][6])
{
$leftmenuConstraint = verifCond($tab[$x][6]);
}
if ($leftmenuConstraint)
{
//print 'name='.$tab[$x][3].' pere='.$pere." ".$tab[$x][6];
$this->newmenu->add((! preg_match("/^(http:\/\/|https:\/\/)/i",$tab[$x][2])) ? $tab[$x][2] : $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5], $tab[$x][8]);
$this->recur($tab, $tab[$x][0], $rang +1, $leftmenu);
}
}
} }
} }
} }
@ -443,20 +430,20 @@ class Menubase
{ {
foreach($tabMenu as $val) foreach($tabMenu as $val)
{ {
if ($val[9]=='top') if ($val['type']=='top')
{ {
$newTabMenu[$i]['rowid']=$val['rowid'];
$newTabMenu[$i]['fk_menu']=$val['fk_menu'];
$newTabMenu[$i]['url']=$val['url'];
$newTabMenu[$i]['titre']=$val['titre'];
$newTabMenu[$i]['right']=$val['perms'];
$newTabMenu[$i]['atarget']=$val['atarget'];
$newTabMenu[$i]['leftmenu']=$val['leftmenu'];
$newTabMenu[$i]['enabled']=$val['enabled'];
$newTabMenu[$i]['mainmenu']=$val['mainmenu'];
$newTabMenu[$i]['type']=$val['type'];
$newTabMenu[$i]['lang']=$val['langs'];
$newTabMenu[$i]['rowid']=$val[0];
$newTabMenu[$i]['fk_menu']=$val[1];
$newTabMenu[$i]['url']=$val[2];
$newTabMenu[$i]['titre']=$val[3];
$newTabMenu[$i]['right']=$val[4];
$newTabMenu[$i]['atarget']=$val[5];
$newTabMenu[$i]['leftmenu']=$val[6];
$newTabMenu[$i]['enabled']=$val[7];
$newTabMenu[$i]['mainmenu']=$val[8];
$newTabMenu[$i]['type']=$val[9];
$newTabMenu[$i]['lang']=$val[10];
$i++; $i++;
} }
} }
@ -469,7 +456,7 @@ class Menubase
* Load entries found in database in a menu array. * Load entries found in database in a menu array.
* *
* @param array $newmenu Menu array to complete (in most cases, it's empty, may be already initialized with some menu manager like eldy) * @param array $newmenu Menu array to complete (in most cases, it's empty, may be already initialized with some menu manager like eldy)
* @param string $mainmenu Value for mainmenu that defines top menu of left menu * @param string $mainmenu Value for mainmenu that defines top menu of left menu to load
* @param string $myleftmenu Value that defines leftmenu * @param string $myleftmenu Value that defines leftmenu
* @param int $type_user 0=Internal,1=External,2=All * @param int $type_user 0=Internal,1=External,2=All
* @param string $menu_handler Name of menu_handler used (auguria, eldy...) * @param string $menu_handler Name of menu_handler used (auguria, eldy...)
@ -483,43 +470,84 @@ class Menubase
$leftmenu=$myleftmenu; // To export to dol_eval function $leftmenu=$myleftmenu; // To export to dol_eval function
// We initialize newmenu with first already found menu entries
$this->newmenu = $newmenu; $this->newmenu = $newmenu;
// Load datas into tabMenu // Load datas from database into $tabMenu, then we will complete this->newmenu with values into $tabMenu
if (count($tabMenu) == 0) if (count($tabMenu) == 0)
{ {
$this->menuLoad($leftmenu, $type_user, $menu_handler, $tabMenu); $this->menuLoad($leftmenu, $type_user, $menu_handler, $tabMenu);
} }
//var_dump($tabMenu); //var_dump($tabMenu);
// Define menutopid
$menutopid=''; $menutopid='';
if (is_array($tabMenu)) if (is_array($tabMenu))
{ {
foreach($tabMenu as $val) foreach($tabMenu as $key => $val)
{ {
if ($val[9] == 'top' && $val[8] == $mainmenu) // Define menutopid of mainmenu
if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) // 9 is type, 8 is mainmenu
{ {
$menutopid=$val[0]; $menutopid=$val['rowid'];
break; break;
} }
} }
} }
// Now edit this->newmenu->list to add entries found into tabMenu that are in childs of mainmenu claimed // Update fk_menu when value is -1 (left menu added by modules with no top menu)
if (is_array($tabMenu))
{
foreach($tabMenu as $key => $val)
{
if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu)
{
if (empty($val['fk_leftmenu']))
{
//print 'Try to find fk_menu for '.join(',',$val);
//var_dump($this->newmenu->liste);exit;
$tabMenu[$key]['fk_menu']=$menutopid;
}
else if ($val['fk_leftmenu'] == $fk_leftmenu)
{
// TODO
/*
foreach($this->newmenu as $keyparent => $valparent)
{
if (empty($val['fk_leftmenu']) && $valparent['type'] == 'top' && $valparent['mainmenu'] == $val['fk_mainmenu'])
{
$tabMenu[$key]['fk_menu']=$valparent['rowid'];
break;
}
//var_dump($tabMenu);exit;
if (! empty($val['fk_leftmenu']) && $valparent['type'] == 'left' && $valparent['mainmenu'] == $val['fk_mainmenu'] && $valparent['leftmenu'] == $val['fk_leftmenu'])
{
print 'eeee';
$tabMenu[$key]['fk_menu']=$valparent['rowid'];
break;
}
}
*/
//exit;
}
}
}
}
// Now edit this->newmenu->list to add entries found into tabMenu that are childs of mainmenu claimed
$this->recur($tabMenu, $menutopid, 1, $leftmenu); $this->recur($tabMenu, $menutopid, 1, $leftmenu);
//var_dump($this->newmenu->liste);exit;
return $this->newmenu; return $this->newmenu;
} }
/** /**
* Load entries found in database in a menu array. * Load entries found in database to $tabMenu.
* *
* @param string $myleftmenu Value for left that defined leftmenu * @param string $myleftmenu Value for left that defined leftmenu
* @param int $type_user 0=Internal,1=External,2=All * @param int $type_user 0=Internal,1=External,2=All
* @param string $menu_handler Name of menu_handler used (auguria, eldy...) * @param string $menu_handler Name of menu_handler used (auguria, eldy...)
* @param array &$tabMenu If array with menu entries already load, we put this array here (in most cases, it's empty) * @param array &$tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled)
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu) function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu)
@ -530,7 +558,7 @@ class Menubase
$menutopid=0; $menutopid=0;
$leftmenu=$myleftmenu; // To export to dol_eval function $leftmenu=$myleftmenu; // To export to dol_eval function
$sql = "SELECT m.rowid, m.type, m.fk_menu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu"; $sql = "SELECT m.rowid, m.type, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE m.entity = ".$conf->entity; $sql.= " WHERE m.entity = ".$conf->entity;
$sql.= " AND m.menu_handler in('".$menu_handler."','all')"; $sql.= " AND m.menu_handler in('".$menu_handler."','all')";
@ -539,7 +567,7 @@ class Menubase
// If type_user == 2, no test required // If type_user == 2, no test required
$sql.= " ORDER BY m.position, m.rowid"; $sql.= " ORDER BY m.position, m.rowid";
dol_syslog("Menubase::menuLeftCharger sql=".$sql); dol_syslog(get_class($this)."::menuLeftCharger sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -595,6 +623,7 @@ class Menubase
//print "verifCond chaine=".$chaine." rowid=".$menu['rowid']." ".$menu['enabled'].":".$enabled."<br>\n"; //print "verifCond chaine=".$chaine." rowid=".$menu['rowid']." ".$menu['enabled'].":".$enabled."<br>\n";
} }
/*
// 0=rowid, 1=fk_menu, 2=url, 3=text, 4=perms, 5=target, 8=mainmenu // 0=rowid, 1=fk_menu, 2=url, 3=text, 4=perms, 5=target, 8=mainmenu
$tabMenu[$b][0] = $menu['rowid']; $tabMenu[$b][0] = $menu['rowid'];
$tabMenu[$b][1] = $menu['fk_menu']; $tabMenu[$b][1] = $menu['fk_menu'];
@ -614,6 +643,28 @@ class Menubase
$tabMenu[$b][8] = $menu['mainmenu']; $tabMenu[$b][8] = $menu['mainmenu'];
$tabMenu[$b][9] = $menu['type']; $tabMenu[$b][9] = $menu['type'];
$tabMenu[$b][10] = $menu['langs']; $tabMenu[$b][10] = $menu['langs'];
*/
// We complete tabMenu
$tabMenu[$b]['rowid'] = $menu['rowid'];
$tabMenu[$b]['fk_menu'] = $menu['fk_menu'];
$tabMenu[$b]['url'] = $menu['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i",$tabMenu[$b]['url']))
{
if (preg_match('/\?/',$tabMenu[$b]['url'])) $tabMenu[$b]['url'].='&amp;idmenu='.$menu['rowid'];
else $tabMenu[$b]['url'].='?idmenu='.$menu['rowid'];
}
$tabMenu[$b]['titre'] = $chaine;
$tabMenu[$b]['target'] = $menu['target'];
$tabMenu[$b]['leftmenu'] = $menu['leftmenu'];
if (! isset($tabMenu[$b]['perms'])) $tabMenu[$b]['perms'] = $perms;
else $tabMenu[$b]['perms'] = ($tabMenu[$b]['perms'] && $perms);
if (! isset($tabMenu[$b]['enabled'])) $tabMenu[$b]['enabled'] = $enabled;
else $tabMenu[$b]['enabled'] = ($tabMenu[$b]['enabled'] && $enabled);
$tabMenu[$b]['mainmenu'] = $menu['mainmenu'];
$tabMenu[$b]['type'] = $menu['type'];
$tabMenu[$b]['langs'] = $menu['langs'];
$tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu'];
$tabMenu[$b]['fk_leftmenu'] = $menu['fk_leftmenu'];
$b++; $b++;
$a++; $a++;

View File

@ -237,7 +237,7 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
if (preg_match('/\.xlt(x)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xlt(x)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; }
if (preg_match('/\.xla(m)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xla(m)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; }
if (preg_match('/\.xls$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xls$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; }
if (preg_match('/\.xls(b|m|x)?$/i',$tmpfile)) { $mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime='xls.png'; } if (preg_match('/\.xls(b|m|x)$/i',$tmpfile)) { $mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime='xls.png'; }
if (preg_match('/\.pps(m|x)?$/i',$tmpfile)) { $mime='application/vnd.ms-powerpoint'; $imgmime='ppt.png'; } if (preg_match('/\.pps(m|x)?$/i',$tmpfile)) { $mime='application/vnd.ms-powerpoint'; $imgmime='ppt.png'; }
if (preg_match('/\.ppt(m|x)?$/i',$tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; } if (preg_match('/\.ppt(m|x)?$/i',$tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; }
// Other // Other

View File

@ -1256,23 +1256,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$newmenu->add("/imports/index.php?leftmenu=import",$langs->trans("FormatedImport"),0, $user->rights->import->run); $newmenu->add("/imports/index.php?leftmenu=import",$langs->trans("FormatedImport"),0, $user->rights->import->run);
$newmenu->add("/imports/import.php?leftmenu=import",$langs->trans("NewImport"),1, $user->rights->import->run); $newmenu->add("/imports/import.php?leftmenu=import",$langs->trans("NewImport"),1, $user->rights->import->run);
} }
if (! empty($conf->domain->enabled))
{
$langs->load("domains");
$newmenu->add("/domain/index.php?leftmenu=export",$langs->trans("DomainNames"),0, $user->rights->domain->read);
$newmenu->add("/domain/fiche.php?action=create&leftmenu=export",$langs->trans("NewDomain"),1, $user->rights->domain->create);
$newmenu->add("/domain/index.php?leftmenu=export",$langs->trans("List"),1, $user->rights->domain->read);
}
if (! empty($conf->submiteverywhere->enabled))
{
$langs->load("submiteverywhere@submiteverywhere");
$newmenu->add("/submiteverywhere/index.php?leftmenu=submiteverywhere", $langs->trans("News"), 0, $user->rights->submiteverywhere->read);
$newmenu->add("/submiteverywhere/fiche.php?leftmenu=submiteverywhere&amp;action=create", $langs->trans("NewNews"), 1, $user->rights->submiteverywhere->create);
$newmenu->add("/submiteverywhere/liste.php?leftmenu=submiteverywhere", $langs->trans("List"), 1, $user->rights->submiteverywhere->read);
}
} }
/* /*

View File

@ -92,7 +92,7 @@ abstract class DolibarrModules
// Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user.
if (! $err) $err+=$this->insert_permissions(1); if (! $err) $err+=$this->insert_permissions(1);
// Insere les constantes associees au module dans llx_const // Insert specific menus entries into database
if (! $err) $err+=$this->insert_menus(); if (! $err) $err+=$this->insert_menus();
// Create module's directories // Create module's directories
@ -1122,13 +1122,20 @@ abstract class DolibarrModules
$foundparent=1; $foundparent=1;
} }
} }
elseif (preg_match('/mainmenu=(.*),leftmenu=(.*)/',$fk_parent,$reg)) elseif (preg_match('/fk_mainmenu=(.*),fk_leftmenu=(.*)/',$fk_parent,$reg))
{ {
$menu->fk_menu=-1; $menu->fk_menu=-1;
$menu->fk_mainmenu=$reg[1]; $menu->fk_mainmenu=$reg[1];
$menu->fk_leftmenu=$reg[2]; $menu->fk_leftmenu=$reg[2];
$foundparent=1; $foundparent=1;
} }
elseif (preg_match('/fk_mainmenu=(.*)/',$fk_parent,$reg))
{
$menu->fk_menu=-1;
$menu->fk_mainmenu=$reg[1];
$menu->fk_leftmenu='';
$foundparent=1;
}
if (! $foundparent) if (! $foundparent)
{ {
$this->error="ErrorBadDefinitionOfMenuArrayInModuleDescriptor (bad value for key fk_menu)"; $this->error="ErrorBadDefinitionOfMenuArrayInModuleDescriptor (bad value for key fk_menu)";
@ -1138,15 +1145,14 @@ abstract class DolibarrModules
} }
$menu->type=$this->menu[$key]['type']; $menu->type=$this->menu[$key]['type'];
$menu->mainmenu=$this->menu[$key]['mainmenu']; $menu->mainmenu=$this->menu[$key]['mainmenu'];
$menu->leftmenu=isset($this->menu[$key]['leftmenu'])?$this->menu[$key]['leftmenu']:'';
$menu->titre=$this->menu[$key]['titre']; $menu->titre=$this->menu[$key]['titre'];
$menu->leftmenu=isset($this->menu[$key]['leftmenu'])?$this->menu[$key]['leftmenu']:0;
$menu->url=$this->menu[$key]['url']; $menu->url=$this->menu[$key]['url'];
$menu->langs=$this->menu[$key]['langs']; $menu->langs=$this->menu[$key]['langs'];
$menu->position=$this->menu[$key]['position']; $menu->position=$this->menu[$key]['position'];
$menu->perms=$this->menu[$key]['perms']; $menu->perms=$this->menu[$key]['perms'];
$menu->target=$this->menu[$key]['target']; $menu->target=$this->menu[$key]['target'];
$menu->user=$this->menu[$key]['user']; $menu->user=$this->menu[$key]['user'];
//$menu->constraint=$this->menu[$key]['constraint'];
$menu->enabled=isset($this->menu[$key]['enabled'])?$this->menu[$key]['enabled']:0; $menu->enabled=isset($this->menu[$key]['enabled'])?$this->menu[$key]['enabled']:0;
if (! $err) if (! $err)
@ -1159,7 +1165,7 @@ abstract class DolibarrModules
else else
{ {
$this->error=$menu->error; $this->error=$menu->error;
dol_syslog('DolibarrModules::insert_menus result='.$result." ".$this->error, LOG_ERR); dol_syslog(get_class($this).'::insert_menus result='.$result." ".$this->error, LOG_ERR);
$err++; $err++;
break; break;
} }

View File

@ -535,15 +535,19 @@ else // Open and return file
// Les drois sont ok et fichier trouve, on l'envoie // Les drois sont ok et fichier trouve, on l'envoie
header('Content-Description: File Transfer');
if ($encoding) header('Content-Encoding: '.$encoding); if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type.(preg_match('/text/',$type)?'; charset="'.$conf->file->character_set_client:'')); if ($type) header('Content-Type: '.$type.(preg_match('/text/',$type)?'; charset="'.$conf->file->character_set_client:''));
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Length: ' . dol_filesize($original_file));
// Ajout directives pour resoudre bug IE // Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate'); header('Cache-Control: Public, must-revalidate');
header('Pragma: public'); header('Pragma: public');
//ob_clean();
//flush();
readfile($original_file_osencoded); readfile($original_file_osencoded);
} }

View File

@ -82,19 +82,21 @@ class Fournisseur extends Societe
} }
/** /**
* FIXME This returns number of prices, not number of products. Is it what we want ? * Returns number of ref prices (not number of products).
*
* @return int Nb of ref prices, or <0 if error
*/ */
function NbProduct() function nbOfProductRefs()
{ {
$sql = "SELECT count(pfp.rowid)"; $sql = "SELECT count(pfp.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.fk_soc = ".$this->id; $sql .= " WHERE pfp.fk_soc = ".$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ( $resql ) if ( $resql )
{ {
$row = $this->db->fetch_row($resql); $obj = $this->db->fetch_object($resql);
return $row[0]; return $obj->nb;
} }
else else
{ {

View File

@ -229,7 +229,7 @@ if ($object->fetch($id))
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">'; print '<td>'.$langs->trans("ProductsAndServices").'</td><td align="right">';
print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$object->id.'">'.$langs->trans("All").' ('.$object->NbProduct().')'; print '<a href="'.DOL_URL_ROOT.'/fourn/product/liste.php?fourn_id='.$object->id.'">'.$langs->trans("All").' ('.$object->nbOfProductRefs().')';
print '</a></td></tr></table>'; print '</a></td></tr></table>';
} }

View File

@ -377,7 +377,7 @@ class Societe extends CommonObject
$error=0; $error=0;
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
// For triggers // For triggers
if ($call_trigger) if ($call_trigger)
@ -456,7 +456,7 @@ class Societe extends CommonObject
if ($result >= 0) if ($result >= 0)
{ {
dol_syslog("Societe::Update verify ok"); dol_syslog(get_class($this)."::Update verify ok");
$sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire $sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
@ -534,6 +534,11 @@ class Societe extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
// Si le fournisseur est classe on l'ajoute // Si le fournisseur est classe on l'ajoute
$this->AddFournisseurInCategory($this->fournisseur_categorie); $this->AddFournisseurInCategory($this->fournisseur_categorie);
@ -1426,24 +1431,33 @@ class Societe extends CommonObject
/** /**
* Return full address of third party * Return full address of third party
* @param withcountry 1=Add country into address string *
* @param sep Separator to use to build string * @param int $withcountry 1=Add country into address string
* @return string Full address string * @param string $sep Separator to use to build string
* @return string Full address string
*/ */
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{ {
$ret.=($this->address?$this->address.$sep:''); require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$ret.=trim($this->zip.' '.$this->town); $tmparray=getCountry($this->country_id,'all');
if ($withcountry) $ret.=($this->country?$sep.$this->country:''); $this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
} }
else else
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:''); if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
} }
return trim($ret); return trim($ret);
} }
@ -1913,10 +1927,11 @@ class Societe extends CommonObject
/** /**
* Verify if a profid exists into database for others thirds * Verify if a profid exists into database for others thirds
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) *
* @param value value of profid * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param socid id of society if update * @param string $value Value of profid
* @return boolean true if exists, false if not * @param int $socid Id of society if update
* @return boolean true if exists, false if not
*/ */
function id_prof_exists($idprof,$value,$socid=0) function id_prof_exists($idprof,$value,$socid=0)
{ {

View File

@ -158,10 +158,52 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject->login='newlogin';
$localobject->societe='New company';
$localobject->note='New note after update'; $localobject->note='New note after update';
$result=$localobject->update($user); //$localobject->note_public='New note public after update';
print __METHOD__." id=".$localobject->id." result=".$result."\n"; $localobject->lastname='New name';
$this->assertLessThan($result, 0); $localobject->firstname='New firstname';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
$localobject->statut=0;
$localobject->phone='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->email='newemail@newemail.com';
$result=$localobject->update($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Adherent($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->login, $newobject->login);
$this->assertEquals($localobject->societe, $newobject->societe);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->lastname, $newobject->lastname);
$this->assertEquals($localobject->firstname, $newobject->firstname);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->statut, $newobject->statut);
$this->assertEquals($localobject->phone, $newobject->phone);
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
$this->assertEquals($localobject->email, $newobject->email);
return $localobject; return $localobject;
} }

View File

@ -27,7 +27,8 @@ global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
require_once 'PHPUnit/Autoload.php'; require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php'; require_once dirname(__FILE__).'/../../htdocs/contact/class/contact.class.php';
$langs->load("dict");
if (empty($user->id)) if (empty($user->id))
{ {
@ -145,10 +146,6 @@ class ContactTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
$result=$localobject->verify();
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertEquals($result, 0);
return $localobject; return $localobject;
} }
@ -166,20 +163,20 @@ class ContactTest extends PHPUnit_Framework_TestCase
$localobject->note='New note after update'; $localobject->note='New note after update';
//$localobject->note_public='New note public after update'; //$localobject->note_public='New note public after update';
$localobject->name='New name'; $localobject->lastname='New name';
$localobject->firstname='New firstname';
$localobject->address='New address'; $localobject->address='New address';
$localobject->zip='New zip'; $localobject->zip='New zip';
$localobject->town='New town'; $localobject->town='New town';
$localobject->country_id=2; $localobject->country_id=2;
$localobject->status=0; $localobject->status=0;
$localobject->tel='New tel'; $localobject->phone_pro='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->fax='New fax'; $localobject->fax='New fax';
$localobject->email='New email'; $localobject->email='newemail@newemail.com';
$localobject->url='New url'; $localobject->jabberid='New im id';
$localobject->idprof1='new idprof1'; $localobject->default_lang='es_ES';
$localobject->idprof2='new idprof2';
$localobject->idprof3='new idprof3';
$localobject->idprof4='new idprof4';
$result=$localobject->update($localobject->id,$user); $result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
@ -197,20 +194,21 @@ class ContactTest extends PHPUnit_Framework_TestCase
$this->assertEquals($localobject->note, $newobject->note); $this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public); //$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->name, $newobject->name); $this->assertEquals($localobject->lastname, $newobject->lastname);
$this->assertEquals($localobject->firstname, $newobject->firstname);
$this->assertEquals($localobject->address, $newobject->address); $this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip); $this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town); $this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id); $this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->status, $newobject->status); $this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel); $this->assertEquals($localobject->phone_pro, $newobject->phone_pro);
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
$this->assertEquals($localobject->fax, $newobject->fax); $this->assertEquals($localobject->fax, $newobject->fax);
$this->assertEquals($localobject->email, $newobject->email); $this->assertEquals($localobject->email, $newobject->email);
$this->assertEquals($localobject->url, $newobject->url); $this->assertEquals($localobject->jabberid, $newobject->jabberid);
$this->assertEquals($localobject->idprof1, $newobject->idprof1); $this->assertEquals($localobject->default_lang, $newobject->default_lang);
$this->assertEquals($localobject->idprof2, $newobject->idprof2);
$this->assertEquals($localobject->idprof3, $newobject->idprof3);
$this->assertEquals($localobject->idprof4, $newobject->idprof4);
return $localobject; return $localobject;
} }
@ -227,30 +225,16 @@ class ContactTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
/* $result=$localobject->set_as_client(); //$localobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->set_price_level(1,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->set_remise_client(10,'Gift',$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->getNomUrl(1); $result=$localobject->getNomUrl(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, ''); $this->assertNotEquals($result, '');
$result=$localobject->getFullAddress(); $result=$localobject->getFullAddress(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town", $result); $this->assertContains("New address\nNew zip New town\nBelgium", $result);
$result=$localobject->isInEEC();
print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n";
$this->assertTrue(true, $result);
*/
$localobject->info($localobject->id); $localobject->info($localobject->id);
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, ''); $this->assertNotEquals($localobject->date_creation, '');

View File

@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.php'; require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php'; require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php';
$langs->load("dict");
if (empty($user->id)) if (empty($user->id))
{ {
@ -176,7 +177,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$localobject->status=0; $localobject->status=0;
$localobject->tel='New tel'; $localobject->tel='New tel';
$localobject->fax='New fax'; $localobject->fax='New fax';
$localobject->email='New email'; $localobject->email='newemail@newemail.com';
$localobject->url='New url'; $localobject->url='New url';
$localobject->idprof1='new idprof1'; $localobject->idprof1='new idprof1';
$localobject->idprof2='new idprof2'; $localobject->idprof2='new idprof2';
@ -204,6 +205,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$this->assertEquals($localobject->zip, $newobject->zip); $this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town); $this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id); $this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->status, $newobject->status); $this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel); $this->assertEquals($localobject->tel, $newobject->tel);
$this->assertEquals($localobject->fax, $newobject->fax); $this->assertEquals($localobject->fax, $newobject->fax);
@ -245,9 +247,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, ''); $this->assertNotEquals($result, '');
$result=$localobject->getFullAddress(); $result=$localobject->getFullAddress(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town", $result); $this->assertContains("New address\nNew zip New town\nBelgium", $result);
$result=$localobject->isInEEC(); $result=$localobject->isInEEC();
print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n"; print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n";