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.
For developers:
- New: Add webservice to get or create a product, service.
- New: Add webservice to get a user.
- New: Add hooks to change way of showing/editing lines into dictionnaries.
- New: Can add a left menu (first level) into an existing top menu.
- 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: 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: 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: Removed no more used external libraries.
- 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: task #216 : Move /lib in /core/lib directory
- Qual: task #217 : Move core files in core directory (login, menus, triggers, boxes, modules)
- Qual: Fix a lot of checkstyle warnings.
- 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 *****

View File

@ -205,7 +205,10 @@
<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">
<severity>0</severity>
</rule>

View File

@ -37,13 +37,13 @@ class modMyModule extends DolibarrModules
/**
* 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;
$this->db = $DB;
$this->db = $db;
// Id for module (must be unique).
// 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;
// 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
// 'type'=>'top', // This is a Top menu entry
// 'titre'=>'MyModule top menu',
@ -182,11 +183,9 @@ class modMyModule extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $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)
// 'type'=>'left', // This is a Left menu entry
// 'titre'=>'MyModule left menu 1',
// 'titre'=>'MyModule left menu',
// 'mainmenu'=>'mymodule',
// 'url'=>'/mymodule/pagelevel1.php',
// '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
// $r++;
//
// Example to declare another Left 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)
// Example to declare a Left Menu entry into an existing 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
// 'titre'=>'MyModule left menu 2',
// 'titre'=>'MyModule left menu',
// 'mainmenu'=>'mymodule',
// 'url'=>'/mymodule/pagelevel2.php',
// '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 $public;
var $note; // Note
var $note; // Private note
var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye
var $photo;
@ -115,11 +115,11 @@ class Adherent extends CommonObject
/**
* 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;
// l'adherent n'est pas public par defaut
$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);
// Clean parameters
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->nom=ucwords(trim($this->nom));
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->prenom=ucwords(trim($this->prenom));
$this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->nom);
$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
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.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null");
$sql.= ", prenom = ".($this->prenom?"'".$this->db->escape($this->prenom)."'":"null");
$sql.= ", nom=" .($this->nom?"'".$this->db->escape($this->nom)."'":"null");
$sql.= ", prenom = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
$sql.= ", nom=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null");
$sql.= ", adresse=" .($this->adresse?"'".$this->db->escape($this->adresse)."'":"null");
$sql.= ", cp=" .($this->cp?"'".$this->db->escape($this->cp)."'":"null");
$sql.= ", ville=" .($this->ville?"'".$this->db->escape($this->ville)."'":"null");
$sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", cp=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", ville=" .($this->town?"'".$this->db->escape($this->town)."'":"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.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"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);
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)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
@ -953,7 +965,7 @@ class Adherent extends CommonObject
{
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.photo, d.fk_adherent_type, d.morphy,";
$sql.= " d.datec as datec,";
@ -990,8 +1002,8 @@ class Adherent extends CommonObject
$this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname;
$this->firstname = $obj->firstname;
$this->nom = $obj->name;
$this->lastname = $obj->name;
$this->nom = $obj->lastname;
$this->lastname = $obj->lastname;
$this->login = $obj->login;
$this->pass = $obj->pass;
$this->societe = $obj->societe;
@ -1755,14 +1767,23 @@ class Adherent extends CommonObject
/**
* Return full address of member
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*/
function getFullAddress($withcountry=0,$sep="\n")
{
$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.=trim($this->zip.' '.$this->town);
@ -1777,7 +1798,6 @@ class Adherent extends CommonObject
return trim($ret);
}
/**
* Retourne le libelle du statut d'un adherent (brouillon, valide, resilie)
*

View File

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

View File

@ -123,7 +123,7 @@ if ($conf->stock->enabled)
</table>
<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>
</fieldset>

View File

@ -53,6 +53,9 @@ class Contact extends CommonObject
var $fk_departement; // Id of department
var $departement_code; // Code 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 $pays_code; // Code of country
@ -68,6 +71,7 @@ class Contact extends CommonObject
var $email;
var $birthday;
var $default_lang;
var $note; // Private note
var $ref_facturation; // Nb de reference facture 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
*
* @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();
// Clean parameters
$this->name=trim($this->name);
$this->lastname=$this->lastname?trim($this->lastname):$this->name;
$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 (! $this->socid) $this->socid = 0;
if (! $this->priv) $this->priv = 0;
@ -209,9 +213,8 @@ class Contact extends CommonObject
$this->id = $id;
// Clean parameters
$this->name=trim($this->name);
$this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->name);
$this->firstname=trim($this->firstname);
$this->email=trim($this->email);
$this->phone_pro=trim($this->phone_pro);
$this->phone_perso=trim($this->phone_perso);
@ -221,14 +224,14 @@ class Contact extends CommonObject
$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);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
if ($this->socid == -1) $sql .= " fk_soc=null,";
$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 .= ", address='".$this->db->escape($this->address)."'";
$sql .= ", cp='".$this->db->escape($this->zip)."'";
@ -252,6 +255,11 @@ class Contact extends CommonObject
$result = $this->db->query($sql);
if ($result)
{
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
if (! $error && ! $notrigger)
{
// Appel des triggers
@ -453,14 +461,14 @@ class Contact extends CommonObject
$langs->load("companies");
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,";
$sql.= " c.address, c.cp, c.ville,";
$sql.= " c.fk_pays,";
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name as lastname, c.firstname,";
$sql.= " c.address, c.cp as zip, c.ville as town,";
$sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement,";
$sql.= " c.birthday,";
$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.= " 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.= " 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";
@ -482,31 +490,32 @@ class Contact extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$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->nom = $obj->name; // TODO deprecated
$this->nom = $obj->lastname; // TODO deprecated
$this->prenom = $obj->firstname; // TODO deprecated
$this->address = $obj->address;
$this->adresse = $obj->address; // TODO deprecated
$this->cp = $obj->cp; // TODO deprecated
$this->zip = $obj->cp;
$this->ville = $obj->ville; // TODO deprecated
$this->town = $obj->ville;
$this->cp = $obj->zip; // TODO deprecated
$this->zip = $obj->zip;
$this->ville = $obj->town; // TODO deprecated
$this->town = $obj->town;
$this->fk_departement = $obj->fk_departement;
$this->state_id = $obj->fk_departement;
$this->departement_code = $obj->departement_code; // TODO deprecated
$this->state_code = $obj->departement_code;
$this->departement = $obj->departement; // TODO deprecated
$this->departement = $obj->departement; // TODO deprecated
$this->state = $obj->departement;
$this->fk_pays = $obj->fk_pays;
$this->country_id = $obj->fk_pays;
$this->pays_code = $obj->fk_pays?$obj->pays_code:'';
$this->country_code = $obj->fk_pays?$obj->pays_code:'';
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):'';
$this->country = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):'';
$this->fk_pays = $obj->country_id;
$this->country_id = $obj->country_id;
$this->pays_code = $obj->country_id?$obj->country_code:'';
$this->country_code = $obj->country_id?$obj->country_code:'';
$this->pays = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->country = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->socid = $obj->fk_soc;
$this->socname = $obj->socname;
@ -850,7 +859,15 @@ class Contact extends CommonObject
function getFullAddress($withcountry=0,$sep="\n")
{
$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.=trim($this->zip.' '.$this->town);
@ -878,13 +895,6 @@ class Contact extends CommonObject
$code=$this->civilite_id;
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->module=trim($this->module);
$this->type=trim($this->type);
$this->mainmenu=trim($this->mainmenu);
$this->mainmenu=trim($this->mainmenu); // If type='top'
$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_leftmenu=trim($this->fk_leftmenu);
$this->position=trim($this->position);
@ -146,8 +146,8 @@ class Menubase
$sql.= " '".$conf->entity."',";
$sql.= " '".$this->module."',";
$sql.= " '".$this->type."',";
$sql.= " '".$this->mainmenu."',";
$sql.= " '".$this->leftmenu."',";
$sql.= " ".($this->mainmenu?"'".$this->mainmenu."'":"''").","; // Can't be null
$sql.= " ".($this->leftmenu?"'".$this->leftmenu."'":"null").",";
$sql.= " '".$this->fk_menu."',";
$sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").",";
$sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").",";
@ -392,24 +392,11 @@ class Menubase
for ($x = 0; $x < $num; $x++)
{
//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])
{
$leftmenuConstraint = true;
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);
}
}
//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']);
$this->recur($tab, $tab[$x]['rowid'], $rang + 1, $leftmenu);
}
}
}
@ -443,20 +430,20 @@ class Menubase
{
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++;
}
}
@ -469,7 +456,7 @@ class Menubase
* 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 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 int $type_user 0=Internal,1=External,2=All
* @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
// We initialize newmenu with first already found menu entries
$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)
{
$this->menuLoad($leftmenu, $type_user, $menu_handler, $tabMenu);
}
//var_dump($tabMenu);
// Define menutopid
$menutopid='';
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;
}
}
}
// 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);
//var_dump($this->newmenu->liste);exit;
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 int $type_user 0=Internal,1=External,2=All
* @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
*/
function menuLoad($myleftmenu, $type_user, $menu_handler, &$tabMenu)
@ -530,7 +558,7 @@ class Menubase
$menutopid=0;
$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.= " WHERE m.entity = ".$conf->entity;
$sql.= " AND m.menu_handler in('".$menu_handler."','all')";
@ -539,7 +567,7 @@ class Menubase
// If type_user == 2, no test required
$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);
if ($resql)
{
@ -595,6 +623,7 @@ class Menubase
//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
$tabMenu[$b][0] = $menu['rowid'];
$tabMenu[$b][1] = $menu['fk_menu'];
@ -614,6 +643,28 @@ class Menubase
$tabMenu[$b][8] = $menu['mainmenu'];
$tabMenu[$b][9] = $menu['type'];
$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++;
$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('/\.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(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('/\.ppt(m|x)?$/i',$tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; }
// 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/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.
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();
// Create module's directories
@ -1090,7 +1090,7 @@ abstract class DolibarrModules
function insert_menus()
{
global $user;
require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
$err=0;
@ -1122,13 +1122,20 @@ abstract class DolibarrModules
$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_mainmenu=$reg[1];
$menu->fk_leftmenu=$reg[2];
$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)
{
$this->error="ErrorBadDefinitionOfMenuArrayInModuleDescriptor (bad value for key fk_menu)";
@ -1138,15 +1145,14 @@ abstract class DolibarrModules
}
$menu->type=$this->menu[$key]['type'];
$menu->mainmenu=$this->menu[$key]['mainmenu'];
$menu->leftmenu=isset($this->menu[$key]['leftmenu'])?$this->menu[$key]['leftmenu']:'';
$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->langs=$this->menu[$key]['langs'];
$menu->position=$this->menu[$key]['position'];
$menu->perms=$this->menu[$key]['perms'];
$menu->target=$this->menu[$key]['target'];
$menu->user=$this->menu[$key]['user'];
//$menu->constraint=$this->menu[$key]['constraint'];
$menu->enabled=isset($this->menu[$key]['enabled'])?$this->menu[$key]['enabled']:0;
if (! $err)
@ -1159,7 +1165,7 @@ abstract class DolibarrModules
else
{
$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++;
break;
}

View File

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

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -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 .= " WHERE pfp.fk_soc = ".$this->id;
$resql = $this->db->query($sql);
if ( $resql )
{
$row = $this->db->fetch_row($resql);
return $row[0];
$obj = $this->db->fetch_object($resql);
return $obj->nb;
}
else
{
@ -104,7 +106,7 @@ class Fournisseur extends Societe
/**
* Create the order from an existing
*
*
* @param User $user Creator user
* @param int $idc Id source
* @param int $comclientid Id thirdparty

View File

@ -229,7 +229,7 @@ if ($object->fetch($id))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
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>';
}

View File

@ -377,7 +377,7 @@ class Societe extends CommonObject
$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
if ($call_trigger)
@ -401,7 +401,7 @@ class Societe extends CommonObject
$this->ville=$this->town; // TODO obsolete
$this->state_id=trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id;
$this->pays_id = $this->country_id;
$this->pays_id = $this->country_id;
$this->tel = trim($this->tel);
$this->fax = trim($this->fax);
$this->tel = preg_replace("/\s/","",$this->tel);
@ -456,7 +456,7 @@ class Societe extends CommonObject
if ($result >= 0)
{
dol_syslog("Societe::Update verify ok");
dol_syslog(get_class($this)."::Update verify ok");
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
@ -534,6 +534,11 @@ class Societe extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
// Si le fournisseur est classe on l'ajoute
$this->AddFournisseurInCategory($this->fournisseur_categorie);
@ -698,7 +703,7 @@ class Societe extends CommonObject
$this->country_code = $obj->country_id?$obj->country_code:'';
$this->pays = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):''; // TODO obsolete
$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
$this->state_id = $obj->fk_departement;
$this->state_code = $obj->departement_code;
$this->state = $obj->departement;
@ -1426,24 +1431,33 @@ class Societe extends CommonObject
/**
* Return full address of third party
* @param withcountry 1=Add country into address string
* @param sep Separator to use to build string
* @return string Full address string
*
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to build string
* @return string Full address string
*/
function getFullAddress($withcountry=0,$sep="\n")
{
$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:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$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.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
else
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
}
return trim($ret);
}
@ -1913,10 +1927,11 @@ class Societe extends CommonObject
/**
* 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 socid id of society if update
* @return boolean true if exists, false if not
*
* @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param string $value Value of profid
* @param int $socid Id of society if update
* @return boolean true if exists, false if not
*/
function id_prof_exists($idprof,$value,$socid=0)
{

View File

@ -158,10 +158,52 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->login='newlogin';
$localobject->societe='New company';
$localobject->note='New note after update';
$result=$localobject->update($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$localobject->note_public='New note public after update';
$localobject->lastname='New name';
$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;
}

View File

@ -27,7 +27,8 @@ global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
require_once 'PHPUnit/Autoload.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))
{
@ -145,10 +146,6 @@ class ContactTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->verify();
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertEquals($result, 0);
return $localobject;
}
@ -166,20 +163,20 @@ class ContactTest extends PHPUnit_Framework_TestCase
$localobject->note='New note 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->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
$localobject->status=0;
$localobject->tel='New tel';
$localobject->status=0;
$localobject->phone_pro='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->fax='New fax';
$localobject->email='New email';
$localobject->url='New url';
$localobject->idprof1='new idprof1';
$localobject->idprof2='new idprof2';
$localobject->idprof3='new idprof3';
$localobject->idprof4='new idprof4';
$localobject->email='newemail@newemail.com';
$localobject->jabberid='New im id';
$localobject->default_lang='es_ES';
$result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
@ -197,20 +194,21 @@ class ContactTest extends PHPUnit_Framework_TestCase
$this->assertEquals($localobject->note, $newobject->note);
//$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->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->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->email, $newobject->email);
$this->assertEquals($localobject->url, $newobject->url);
$this->assertEquals($localobject->idprof1, $newobject->idprof1);
$this->assertEquals($localobject->idprof2, $newobject->idprof2);
$this->assertEquals($localobject->idprof3, $newobject->idprof3);
$this->assertEquals($localobject->idprof4, $newobject->idprof4);
$this->assertEquals($localobject->jabberid, $newobject->jabberid);
$this->assertEquals($localobject->default_lang, $newobject->default_lang);
return $localobject;
}
@ -227,30 +225,16 @@ class ContactTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$db=$this->savdb;
/* $result=$localobject->set_as_client();
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);
//$localobject->fetch($localobject->id);
$result=$localobject->getNomUrl(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, '');
$result=$localobject->getFullAddress();
$result=$localobject->getFullAddress(1);
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);
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, '');
@ -296,4 +280,4 @@ class ContactTest extends PHPUnit_Framework_TestCase
return;
}
}
?>
?>

View File

@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php';
$langs->load("dict");
if (empty($user->id))
{
@ -176,7 +177,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$localobject->status=0;
$localobject->tel='New tel';
$localobject->fax='New fax';
$localobject->email='New email';
$localobject->email='newemail@newemail.com';
$localobject->url='New url';
$localobject->idprof1='new idprof1';
$localobject->idprof2='new idprof2';
@ -204,6 +205,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$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->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel);
$this->assertEquals($localobject->fax, $newobject->fax);
@ -245,9 +247,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, '');
$result=$localobject->getFullAddress();
$result=$localobject->getFullAddress(1);
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";
@ -319,4 +321,4 @@ class SocieteTest extends PHPUnit_Framework_TestCase
return;
}
}
?>
?>