2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' into commercial-name

Conflicts:
	htdocs/societe/class/societe.class.php
This commit is contained in:
Marcos García de La Fuente
2015-03-15 18:20:17 +01:00
533 changed files with 26732 additions and 7926 deletions

View File

@@ -39,166 +39,166 @@ abstract class DolibarrModules
*/
public $db;
/**
* @var string Relative path to module style sheet
* @deprecated
*/
public $style_sheet = '';
/**
* @var string Relative path to module style sheet
* @deprecated
*/
public $style_sheet = '';
/**
* @var array Paths to create when module is activated
*/
public $dirs = array();
/**
* @var array Paths to create when module is activated
*/
public $dirs = array();
/**
* @var array Module boxes
*/
public $boxes = array();
/**
* @var array Module boxes
*/
public $boxes = array();
/**
* @var array Module constants
*/
public $const = array();
/**
* @var array Module constants
*/
public $const = array();
/**
* @var array Module access rights
*/
public $rights;
/**
* @var array Module access rights
*/
public $rights;
/**
* @var string Module access rights family
*/
public $rights_class;
/**
* @var string Module access rights family
*/
public $rights_class;
/**
* @var array Module menu entries
*/
public $menu = array();
/**
* @var array Module menu entries
*/
public $menu = array();
/**
* @var array Module parts
* array(
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
* 'triggers' => 0,
* // Set this to 1 if module has its own login method directory (/mymodule/core/login)
/**
* @var array Module parts
* array(
* // Set this to 1 if module has its own trigger directory (/mymodule/core/triggers)
* 'triggers' => 0,
* // Set this to 1 if module has its own login method directory (/mymodule/core/login)
* 'login' => 0,
* // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
* // Set this to 1 if module has its own substitution function file (/mymodule/core/substitutions)
* 'substitutions' => 0,
* // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
* // Set this to 1 if module has its own menus handler directory (/mymodule/core/menus)
* 'menus' => 0,
* // Set this to 1 if module has its own theme directory (/mymodule/theme)
* // Set this to 1 if module has its own theme directory (/mymodule/theme)
* 'theme' => 0,
* // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
* 'tpl' => 0,
* // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
* // Set this to 1 if module overwrite template dir (/mymodule/core/tpl)
* 'tpl' => 0,
* // Set this to 1 if module has its own barcode directory (/mymodule/core/modules/barcode)
* 'barcode' => 0,
* // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
* // Set this to 1 if module has its own models directory (/mymodule/core/modules/xxx)
* 'models' => 0,
* // Set this to relative path of css file if module has its own css file
* // Set this to relative path of css file if module has its own css file
* 'css' => '/mymodule/css/mymodule.css.php',
* // Set this to relative path of js file if module must load a js on all pages
* // Set this to relative path of js file if module must load a js on all pages
* 'js' => '/mymodule/js/mymodule.js',
* // Set here all hooks context managed by module
* // Set here all hooks context managed by module
* 'hooks' => array('hookcontext1','hookcontext2'),
* // Set here all workflow context managed by module
* // Set here all workflow context managed by module
* 'workflow' => array(
* 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
* 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
* 'picto'=>'yourpicto@mymodule'
* )
* )
* )
*/
public $module_parts = array();
* 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array(
* 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)',
* 'picto'=>'yourpicto@mymodule'
* )
* )
* )
*/
public $module_parts = array();
/**
* @var string Module documents ?
* @deprecated Seems unused anywhere
*/
public $docs;
/**
* @var string Module documents ?
* @deprecated Seems unused anywhere
*/
public $docs;
/**
* @var string ?
* @deprecated Seems unused anywhere
*/
public $dbversion = "-";
/**
* @var string ?
* @deprecated Seems unused anywhere
*/
public $dbversion = "-";
/**
* @var string Error message
*/
public $error;
/**
* @var string Error message
*/
public $error;
/**
* @var int Module unique ID
*/
public $numero;
/**
* @var int Module unique ID
*/
public $numero;
/**
* @var string Module name
*/
public $name;
/**
* @var string Module name
*/
public $name;
/**
* @var string Module version
*/
public $version;
/**
* @var string Module version
*/
public $version;
/**
* @var string Module description
*/
public $description;
/**
* @var string Module description
*/
public $description;
/**
* @var string[] Module language files
*/
public $langfiles;
/**
* @var string[] Module language files
*/
public $langfiles;
/**
* @var string Module export code
*/
public $export_code;
/**
* @var string Module export code
*/
public $export_code;
/**
* @var string Module export label
*/
public $export_label;
/**
* @var string Module export label
*/
public $export_label;
/**
* @var string Module import code
*/
public $import_code;
/**
* @var string Module import code
*/
public $import_code;
/**
* @var string Module import label
*/
public $import_label;
/**
* @var string Module import label
*/
public $import_label;
/**
* @var string Module constant name
*/
public $const_name;
/**
* @var string Module constant name
*/
public $const_name;
/**
* @var bool Module can't be disabled
*/
public $always_enabled;
/**
* @var bool Module can't be disabled
*/
public $always_enabled;
/**
* @var bool Module is enabled globally (Multicompany support)
*/
public $core_enabled;
/**
* @var bool Module is enabled globally (Multicompany support)
*/
public $core_enabled;
/**
* Enables a module.
* Inserts all informations into database
*
/**
* Enables a module.
* Inserts all informations into database
*
* @param array $array_sql SQL requests to be executed when enabling module
* @param string $options String with options when disabling module:
* 'noboxes' = Do not insert boxes
* 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
*
* @return int 1 if OK, 0 if KO
*/
* @param string $options String with options when disabling module:
* 'noboxes' = Do not insert boxes
* 'newboxdefonly' = For boxes, insert def of boxes only and not boxes activation
*
* @return int 1 if OK, 0 if KO
*/
function _init($array_sql, $options='')
{
global $conf;
@@ -232,12 +232,12 @@ abstract class DolibarrModules
// Execute addons requests
$num=count($array_sql);
for ($i = 0; $i < $num; $i++)
for ($i = 0; $i < $num; $i++)
{
if (! $err)
{
$val=$array_sql[$i];
$sql=$val;
$sql=$val;
$ignoreerror=0;
if (is_array($val))
{
@@ -367,12 +367,12 @@ abstract class DolibarrModules
// If module name translation using it's unique id does not exists, we take use its name to find translation
if (is_array($this->langfiles))
{
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
}
return $langs->trans($this->name);
return $langs->trans($this->name);
}
}
@@ -389,20 +389,20 @@ abstract class DolibarrModules
if ($langs->trans("Module".$this->numero."Desc") != ("Module".$this->numero."Desc"))
{
// If module description translation exists
// If module description translation exists
return $langs->trans("Module".$this->numero."Desc");
}
else
{
{
// If module description translation using it's unique id does not exists, we take use its name to find translation
if (is_array($this->langfiles))
{
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
foreach($this->langfiles as $val)
{
if ($val) $langs->load($val);
}
}
return $langs->trans($this->description);
return $langs->trans($this->description);
}
}
@@ -429,7 +429,7 @@ abstract class DolibarrModules
else $ret=$langs->trans("VersionUnknown");
if (preg_match('/_deprecated/',$this->version)) $ret.=' ('.$langs->trans("Deprecated").')';
return $ret;
return $ret;
}
@@ -582,9 +582,9 @@ abstract class DolibarrModules
global $conf;
$error=0;
$dirfound=0;
$dirfound=0;
if (empty($reldir)) return 1;
if (empty($reldir)) return 1;
include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
@@ -599,10 +599,10 @@ abstract class DolibarrModules
$handle=@opendir($dir); // Dir may not exists
if (is_resource($handle))
{
$dirfound++;
$dirfound++;
// Run llx_mytable.sql files
while (($file = readdir($handle))!==false)
// Run llx_mytable.sql files
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
{
@@ -613,8 +613,8 @@ abstract class DolibarrModules
rewinddir($handle);
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql)
while (($file = readdir($handle))!==false)
// Run llx_mytable.key.sql files (Must be done after llx_mytable.sql)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
{
@@ -626,7 +626,7 @@ abstract class DolibarrModules
rewinddir($handle);
// Run data_xxx.sql files (Must be done after llx_mytable.key.sql)
while (($file = readdir($handle))!==false)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data')
{
@@ -638,7 +638,7 @@ abstract class DolibarrModules
rewinddir($handle);
// Run update_xxx.sql files
while (($file = readdir($handle))!==false)
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update')
{
@@ -671,9 +671,9 @@ abstract class DolibarrModules
*/
function insert_boxes($option='')
{
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php';
global $conf;
global $conf;
$err=0;
@@ -681,8 +681,8 @@ abstract class DolibarrModules
{
$pos_name = InfoBox::getListOfPagesForBoxes();
foreach ($this->boxes as $key => $value)
{
foreach ($this->boxes as $key => $value)
{
$file = isset($this->boxes[$key]['file'])?$this->boxes[$key]['file']:'';
$note = isset($this->boxes[$key]['note'])?$this->boxes[$key]['note']:'';
$enabledbydefaulton = isset($this->boxes[$key]['enabledbydefaulton'])?$this->boxes[$key]['enabledbydefaulton']:'Home';
@@ -724,15 +724,15 @@ abstract class DolibarrModules
foreach ($pos_name as $key2 => $val2)
{
//print 'key2='.$key2.'-val2='.$val2."<br>\n";
//print 'key2='.$key2.'-val2='.$val2."<br>\n";
if ($enabledbydefaulton && $val2 != $enabledbydefaulton) continue; // Not enabled by default onto this page.
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)";
$sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (box_id,position,box_order,fk_user,entity)";
$sql.= " VALUES (".$lastid.", ".$key2.", '0', 0, ".$conf->entity.")";
dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $err++;
dol_syslog(get_class($this)."::insert_boxes onto page ".$key2."=".$val2."", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) $err++;
}
}
@@ -741,7 +741,7 @@ abstract class DolibarrModules
$this->db->commit();
}
else
{
{
$this->error=$this->db->lasterror();
$this->db->rollback();
}
@@ -781,11 +781,22 @@ abstract class DolibarrModules
if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";
$sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
if ($this->db->type == 'sqlite3') {
// sqlite doesn't support "USING" syntax.
// TODO: remove this dependency.
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes ";
$sql .= "WHERE ".MAIN_DB_PREFIX."boxes.box_id IN (";
$sql .= "SELECT ".MAIN_DB_PREFIX."boxes_def.rowid ";
$sql .= "FROM ".MAIN_DB_PREFIX."boxes_def ";
$sql .= "WHERE ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."') ";
$sql .= "AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
} else {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
$sql.= " USING ".MAIN_DB_PREFIX."boxes, ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE ".MAIN_DB_PREFIX."boxes.box_id = ".MAIN_DB_PREFIX."boxes_def.rowid";
$sql.= " AND ".MAIN_DB_PREFIX."boxes_def.file = '".$this->db->escape($file)."'";
$sql.= " AND ".MAIN_DB_PREFIX."boxes.entity = ".$conf->entity;
}
dol_syslog(get_class($this)."::delete_boxes", LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -1012,7 +1023,7 @@ abstract class DolibarrModules
if ($resql)
{
$obj=$this->db->fetch_object($resql);
if (! empty($obj->value) && ! empty($this->rights))
if ($obj !== null && ! empty($obj->value) && ! empty($this->rights))
{
// Si module actif
foreach ($this->rights as $key => $value)
@@ -1027,54 +1038,54 @@ abstract class DolibarrModules
if (empty($r_type)) $r_type='w';
// Search if perm already present
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
$resqlselect=$this->db->query($sql);
// Search if perm already present
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def";
$sql.= " WHERE id = ".$r_id." AND entity = ".$entity;
$resqlselect=$this->db->query($sql);
$obj = $this->db->fetch_object($resqlselect);
$obj = $this->db->fetch_object($resqlselect);
if ($obj->nb == 0)
{
if (dol_strlen($r_perms) )
{
if (dol_strlen($r_subperms) )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
}
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
$sql .= " (id, entity, libelle, module, type, bydefault)";
$sql .= " VALUES ";
$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
}
if (dol_strlen($r_perms) )
{
if (dol_strlen($r_subperms) )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')";
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def";
$sql.= " (id, entity, libelle, module, type, bydefault, perms)";
$sql.= " VALUES ";
$sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')";
}
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def ";
$sql .= " (id, entity, libelle, module, type, bydefault)";
$sql .= " VALUES ";
$sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")";
}
$resqlinsert=$this->db->query($sql,1);
$resqlinsert=$this->db->query($sql,1);
if (! $resqlinsert)
{
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
{
$this->error=$this->db->lasterror();
$err++;
break;
}
else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
if (! $resqlinsert)
{
if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS")
{
$this->error=$this->db->lasterror();
$err++;
break;
}
else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO);
}
}
$this->db->free($resqlinsert);
$this->db->free($resqlinsert);
}
$this->db->free($resqlselect);
@@ -1082,9 +1093,9 @@ abstract class DolibarrModules
// If we want to init permissions on admin users
if ($reinitadminperms)
{
if (! class_exists('User')) {
require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
}
if (! class_exists('User')) {
require DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
}
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1";
dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG);
$resqlseladmin=$this->db->query($sql,1);
@@ -1099,7 +1110,7 @@ abstract class DolibarrModules
$tmpuser=new User($this->db);
$tmpuser->fetch($obj2->rowid);
if (!empty($tmpuser->id)) {
$tmpuser->addrights($r_id);
$tmpuser->addrights($r_id);
}
$i++;
}
@@ -1158,7 +1169,7 @@ abstract class DolibarrModules
*/
function insert_menus()
{
global $user;
global $user;
require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
@@ -1415,68 +1426,68 @@ abstract class DolibarrModules
*/
function insert_module_parts()
{
global $conf;
global $conf;
$error=0;
$entity=$conf->entity;
$error=0;
$entity=$conf->entity;
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
if (is_array($value) && count($value) == 0) continue; // Discard empty arrays
$newvalue = $value;
$newvalue = $value;
// Serialize array parameters
if (is_array($value))
{
// Can defined other parameters
if (is_array($value['data']) && ! empty($value['data']))
{
$newvalue = json_encode($value['data']);
if (isset($value['entity'])) $entity = $value['entity'];
}
else
{
$newvalue = json_encode($value);
}
}
// Serialize array parameters
if (is_array($value))
{
// Can defined other parameters
if (is_array($value['data']) && ! empty($value['data']))
{
$newvalue = json_encode($value['data']);
if (isset($value['entity'])) $entity = $value['entity'];
}
else
{
$newvalue = json_encode($value);
}
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
$sql.= "name";
$sql.= ", type";
$sql.= ", value";
$sql.= ", note";
$sql.= ", visible";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES (";
$sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1);
$sql.= ", 'chaine'";
$sql.= ", ".$this->db->encrypt($newvalue, 1);
$sql.= ", null";
$sql.= ", '0'";
$sql.= ", ".$entity;
$sql.= ")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (";
$sql.= "name";
$sql.= ", type";
$sql.= ", value";
$sql.= ", note";
$sql.= ", visible";
$sql.= ", entity";
$sql.= ")";
$sql.= " VALUES (";
$sql.= $this->db->encrypt($this->const_name."_".strtoupper($key), 1);
$sql.= ", 'chaine'";
$sql.= ", ".$this->db->encrypt($newvalue, 1);
$sql.= ", null";
$sql.= ", '0'";
$sql.= ", ".$entity;
$sql.= ")";
dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG);
$resql=$this->db->query($sql,1);
if (! $resql)
{
if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$error++;
$this->error=$this->db->lasterror();
}
else
{
dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING);
}
}
}
}
return $error;
dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG);
$resql=$this->db->query($sql,1);
if (! $resql)
{
if ($this->db->lasterrno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$error++;
$this->error=$this->db->lasterror();
}
else
{
dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING);
}
}
}
}
return $error;
}
/**
@@ -1486,31 +1497,31 @@ abstract class DolibarrModules
*/
function delete_module_parts()
{
global $conf;
global $conf;
$err=0;
$entity=$conf->entity;
$err=0;
$entity=$conf->entity;
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
// If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
if (is_array($this->module_parts) && ! empty($this->module_parts))
{
foreach($this->module_parts as $key => $value)
{
// If entity is defined
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'";
$sql.= " AND entity = ".$entity;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." LIKE '".$this->const_name."_".strtoupper($key)."'";
$sql.= " AND entity = ".$entity;
dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);
if (! $this->db->query($sql))
{
$this->error=$this->db->lasterror();
$err++;
}
}
}
return $err;
dol_syslog(get_class($this)."::delete_const_".$key."", LOG_DEBUG);
if (! $this->db->query($sql))
{
$this->error=$this->db->lasterror();
$err++;
}
}
}
return $err;
}
}

View File

@@ -0,0 +1,484 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
* \ingroup societe
* \brief File of class to build ODT documents for third parties
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/askpricesupplier/modules_askpricesupplier.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
class doc_generic_askpricesupplier_odt extends ModelePDFAskPriceSupplier
{
var $emetteur; // Objet societe qui emet
var $phpmin = array(5,2,0); // Minimum version of PHP required by module
var $version = 'dolibarr';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("companies");
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Dimension page pour format A4
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
}
/**
* Return description of a module
*
* @param Translate $langs Lang object to use for output
* @return string Description
*/
function info($langs)
{
global $conf,$langs;
$langs->load("companies");
$langs->load("errors");
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED">';
}
$texte.= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
if (! $tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else
{
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
if (count($listofdir))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
if ($conf->global->MAIN_ASKPRICESUPPLIER_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
$liste=ModelePDFAskPriceSupplier::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelAskPriceSupplierClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4',$liste,$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
}
}
$texte.= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Function to build a document on disk using the generic odt module.
*
* @param Propale $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc,$hookmanager;
if (empty($srctemplatepath))
{
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->askpricesupplier->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
{
$id = $object;
$object = new AskPriceSupplier($this->db);
$result=$object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db,$object->error);
return -1;
}
}
$dir = $conf->askpricesupplier->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
{
$filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
dol_mkdir($conf->askpricesupplier->dir_temp);
// If BILLING contact defined on invoice, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external','BILLING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (! empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else $socobject = $object->client;
}
else
{
$socobject=$object->client;
}
// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='ASKPRICESUPPLIER_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
}
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->askpricesupplier->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
}
catch(OdfException $e)
{
}
// Make substitutions into odt
$array_user=$this->get_substitutionarray_user($user,$outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Replace tags of lines
try
{
$listlines = $odfHandler->setSegment('lines');
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
}
$listlines->merge();
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
{
$this->error=$e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
{
}
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
else {
try {
$odfHandler->saveToDisk($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
return -1;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,153 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/mod_propale_marbre.php
* \ingroup propale
* \brief File of class to manage commercial proposal numbering rules Marbre
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php';
/**
* Class to manage customer order numbering rules Marbre
*/
class mod_askpricesupplier_marbre extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $prefix='DF';
var $error='';
var $nom = "Marbre";
/**
* Return description of numbering module
*
* @return string Text with description
*/
function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Test si les numeros deje en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
global $conf,$langs,$db;
$pryymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
}
if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $askpricesupplier Object commercial proposal
* @return string Next value
*/
function getNextValue($objsoc,$askpricesupplier)
{
global $db,$conf;
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
else
{
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
return -1;
}
$date = time();
$yymm = strftime("%y%m",$date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);
dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
/**
* Return next free value
*
* @param Societe $objsoc Object third party
* @param Object $objforref Object for number to search
* @return string Next free value
*/
function getNumRef($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}

View File

@@ -0,0 +1,131 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/mod_propale_saphir.php
* \ingroup propale
* \brief File that contains the numbering module rules Saphir
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/askpricesupplier/modules_askpricesupplier.php';
/**
* Class of file that contains the numbering module rules Saphir
*/
class mod_askpricesupplier_saphir extends ModeleNumRefAskPriceSupplier
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';
var $nom = 'Saphir';
/**
* Return description of module
*
* @return string Texte descripif
*/
function info()
{
global $conf,$langs;
$langs->load("bills");
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstaskpricesupplier" value="ASKPRICESUPPLIER_SAPHIR_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
$tooltip.=$langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskaskpricesupplier" value="'.$conf->global->ASKPRICESUPPLIER_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $conf,$langs,$mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
if (! $numExample)
{
$numExample = 'NotConfigured';
}
return $numExample;
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $askpricesupplier Object askpricesupplier
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$askpricesupplier)
{
global $db,$conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask=$conf->global->ASKPRICESUPPLIER_SAPHIR_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$date=$askpricesupplier->datep;
$customercode=$objsoc->code_client;
$numFinal=get_next_value($db,$mask,'askpricesupplier','ref','',$customercode,$date);
return $numFinal;
}
}

View File

@@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/modules_propale.php
* \ingroup propale
* \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
/**
* Classe mere des modeles de propale
*/
abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator
{
var $error='';
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
$type='askpricesupplier';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db,$type,$maxfilenamelength);
return $liste;
}
}
/**
* Classe mere des modeles de numerotation des references de propales
*/
abstract class ModeleNumRefAskPriceSupplier
{
var $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
function info()
{
global $langs;
$langs->load("askpricesupplier");
return $langs->trans("NoDescription");
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $langs;
$langs->load("askpricesupplier");
return $langs->trans("NoExample");
}
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Valeur
*/
function getNextValue($objsoc,$propal)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}
/**
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param AskPriceSupplier $object Object askpricesupplier
* @param string $modele Force model to use ('' to not force)
* @param Translate $outputlangs Object langs to use for output
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
* @deprecated Use the new function generateDocument of Propal class
*/
function askpricesupplier_pdf_create(DoliDB $db, AskPriceSupplier $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View File

@@ -265,6 +265,29 @@ class pdf_einstein extends ModelePDFCommandes
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@@ -280,7 +303,7 @@ class pdf_einstein extends ModelePDFCommandes
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
@@ -719,19 +742,20 @@ class pdf_einstein extends ModelePDFCommandes
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
{
if (! empty($conf->global->FACTURE_RIB_NUMBER))
{
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_RIB_NUMBER);
if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
{
$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
$account = new Account($this->db);
$account->fetch($bankid);
$curx=$this->marge_gauche;
$cury=$posy;
$curx=$this->marge_gauche;
$cury=$posy;
$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
$posy+=2;
}
}
$posy+=2;
}
}
return $posy;
}

View File

@@ -121,7 +121,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
return 0;
}
$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client,$object->date);
$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$object->date);
return $numFinal;
}

View File

@@ -45,7 +45,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@@ -153,7 +153,7 @@ abstract class ModeleNumRefCommandes
* Create a document onto disk accordign to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object order
* @param Commande $object Object order
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@@ -112,7 +112,7 @@ class mod_contract_magre extends ModelNumRefContracts
return 0;
}
$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc->code_client,$contract->date_contrat);
$numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat);
return $numFinal;
}

View File

@@ -44,7 +44,7 @@ abstract class ModelePDFContract extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@@ -148,7 +148,7 @@ class ModelNumRefContracts
* Create a contract document on disk using template defined into CONTRACT_ADDON_PDF
*
* @param DoliDB $db objet base de donnee
* @param Object $object Object contract
* @param Contrat $object Object contract
* @param string $modele force le modele a utiliser ('' par defaut)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@@ -40,7 +40,7 @@ abstract class ModeleDon extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)

View File

@@ -191,9 +191,32 @@ class pdf_rouget extends ModelePdfExpedition
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
if (! empty($object->note_public) || ! empty($object->tracking_number))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$tab_top_alt = $tab_top;
$pdf->SetFont('','B', $default_font_size - 2);

View File

@@ -43,7 +43,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@@ -146,7 +146,7 @@ abstract class ModelNumRefExpedition
* Cree un bon d'expedition sur disque
*
* @param DoliDB $db Objet base de donnee
* @param Object $object Object expedition
* @param Expedition $object Object expedition
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs Objet lang a utiliser pour traduction
* @return int <=0 if KO, >0 if OK

View File

@@ -508,7 +508,7 @@ class pdf_standard extends ModeleExpenseReport
*/
// Filligrane brouillon
if ($object->fk_c_expensereport_statuts==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
if ($object->fk_statut==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT);
}
@@ -640,7 +640,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L');
}
if ($object->fk_c_expensereport_statuts==99)
if ($object->fk_statut==99)
{
if ($object->fk_user_refuse > 0)
{
@@ -656,7 +656,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L');
}
}
else if($object->fk_c_expensereport_statuts==4)
else if($object->fk_statut==4)
{
if ($object->fk_user_cancel > 0)
{
@@ -686,7 +686,7 @@ class pdf_standard extends ModeleExpenseReport
}
}
if($object->fk_c_expensereport_statuts==6)
if($object->fk_statut==6)
{
if ($object->fk_user_paid > 0)
{

View File

@@ -30,7 +30,7 @@ class ModeleExpenseReport extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@@ -52,7 +52,7 @@ class ModeleExpenseReport extends CommonDocGenerator
* expensereport_pdf_create
*
* @param DoliDB $db Database handler
* @param Object $object Object order
* @param ExpenseReport $object Object order
* @param string $message Message
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction

View File

@@ -43,7 +43,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac
* Load into memory list of available export format
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates (same content than array this->driverlabel)
*/
function liste_modeles($db,$maxfilenamelength=0)

View File

@@ -320,6 +320,29 @@ class pdf_crabe extends ModelePDFFactures
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@@ -335,7 +358,7 @@ class pdf_crabe extends ModelePDFFactures
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);

View File

@@ -43,7 +43,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
@@ -148,7 +148,7 @@ abstract class ModeleNumRefFactures
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param Object $object Object invoice
* @param Facture $object Object invoice
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines

View File

@@ -120,7 +120,7 @@ class mod_arctic extends ModeleNumRefFicheinter
return 0;
}
$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$object->datec);
$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec);
return $numFinal;
}

View File

@@ -270,10 +270,33 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);

View File

@@ -120,7 +120,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
return 0;
}
$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client,$object->date_livraison);
$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison);
return $numFinal;
}

View File

@@ -0,0 +1,237 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup askpricesupplier Module to request supplier price proposals
* \brief Module to request supplier price proposals
* \file htdocs/core/modules/modAskPriceSupplier.class.php
* \ingroup askpricesupplier
* \brief File to describe and activate module AskPriceSupplier
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Classe de description et activation du module AskPriceSupllier
*/
class modAskPriceSupplier extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf;
$this->db = $db;
$this->numero = 1120;
$this->family = "products";
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "askpricesupplierDESC";
$this->version = 'experimental';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
$this->picto='askpricesupplier';
$this->dirs = array();
// Dependancies
$this->depends = array('modFournisseur');
$this->requiredby = array();
$this->config_page_url = array("askpricesupplier.php");
$this->langfiles = array("askpricesupplier");
// Constants
$this->const = array();
$r=0;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "aurore";
$this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_askpricesupplier_marbre";
$this->const[$r][3] = 'Name of submodule to number supplier quotation request';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/askpricesupplier";
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
// Boxes
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'askpricesupplier';
$r=0;
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'lire';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'validate';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'send_advance';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'supprimer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'cloturer';
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'askpricesupplierMENU_LEFT_TITLE',
'leftmenu'=>'askpricesuppliersubmenu',
'url'=>'/comm/askpricesupplier/index.php',
'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->askpricesupplier->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'user'=>2 // 0=Menu for internal users, 1=external users, 2=both
);
$r++;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_NEW',
'url'=>'/comm/askpricesupplier/card.php?action=create',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->creer',
'user'=>2
);
$r++;
$this->menu[$r]=array(
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_LIST',
'url'=>'/comm/askpricesupplier/list.php',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->lire',
'user'=>2
);
$r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
global $conf,$langs;
// Remove permissions and default values
$this->remove($options);
//ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/askpricesupplier/template_askpricesupplier.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/askpricesupplier';
$dest=$dirodt.'/template_askpricesupplier.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src,$dest,0,0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0;
}
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','askpricesupplier',".$conf->entity.")",
);
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql,$options);
}
}

View File

@@ -197,14 +197,34 @@ class modCategorie extends DolibarrModules
'p.fax' => 'Fax',
'p.email' => 'Email',
'p.note_private' => 'NotePrivate',
'p.note_public' => 'NotePublic'
'p.note_public' => 'NotePublic',
's.nom'=>"Name",
's.client'=>"Customer",
's.fournisseur'=>"Supplier",
's.status'=>"Status",
's.address'=>"Address",
's.zip'=>"Zip",
's.town'=>"Town",
's.phone'=>"Phone",
's.fax'=>"Fax",
's.url'=>"Url",
's.email'=>"Email"
);
$this->export_TypeFields_array[$r] = array (
'u.label' => "Text",
'u.description' => "Text",
'p.rowid' => 'List:contact:lastname',
'p.lastname' => 'Text',
'p.firstname' => 'Text'
'p.firstname' => 'Text',
's.nom'=>"Text",
's.status'=>"Text",
's.address'=>"Text",
's.zip'=>"Text",
's.town'=>"Text",
's.phone'=>"Text",
's.fax'=>"Text",
's.url'=>"Text",
's.email'=>"Text"
);
$this->export_entities_array[$r] = array (
'u.rowid' => "category",
@@ -227,11 +247,23 @@ class modCategorie extends DolibarrModules
'p.fax' => 'contact',
'p.email' => 'contact',
'p.note_private' => 'contact',
'p.note_public' => 'contact'
'p.note_public' => 'contact',
's.nom'=>"company",
's.client'=>"company",
's.fournisseur'=>"company",
's.status'=>"company",
's.address'=>"company",
's.zip'=>"company",
's.town'=>"company",
's.phone'=>"company",
's.fax'=>"company",
's.url'=>"company",
's.email'=>"company"
); // We define here only fields that use another picto
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories

View File

@@ -151,8 +151,9 @@ class modCommande extends DolibarrModules
$this->rights[$r][1] = 'Annuler les commandes clients';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'annuler';
$this->rights[$r][4] = 'order_advance';
$this->rights[$r][5] = 'annuler';
$r++;
$this->rights[$r][0] = 89;
$this->rights[$r][1] = 'Supprimer les commandes clients';

View File

@@ -41,7 +41,7 @@ class modContrat extends DolibarrModules
*/
function __construct($db)
{
global $conf;
global $conf, $langs;
$this->db = $db;
$this->numero = 54;
@@ -118,10 +118,12 @@ class modContrat extends DolibarrModules
// Exports
//--------
$langs->load("contracts");
$r=1;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='ContractAndServices'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_label[$r]=$langs->trans('ContractsAndLine'); // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='contract';
$this->export_permission[$r]=array(array("contrat","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',

View File

@@ -84,7 +84,7 @@ class modExpenseReport extends DolibarrModules
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->conflictwith = array("modDeplacement");
// $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,3); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module
@@ -270,7 +270,7 @@ class modExpenseReport extends DolibarrModules
'titre'=>'ListToApprove',
'mainmenu'=>'hrm',
'leftmenu'=>'expensereport_detaillist_approve',
'url'=>'/expensereport/list.php?search_state=2',
'url'=>'/expensereport/list.php?search_status=2',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.

View File

@@ -235,10 +235,10 @@ class modFacture extends DolibarrModules
$this->export_label[$r]='CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='bill';
$this->export_permission[$r]=array(array("facture","facture","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','p.fk_bank'=>'IdTransaction');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number','p.fk_bank'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','p.fk_bank'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture'";

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
@@ -177,6 +177,14 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][4] = 'commande';
$this->rights[$r][5] = 'receptionner';
$r++;
$this->rights[$r][0] = 1189;
$this->rights[$r][1] = 'Check/Uncheck a supplier order reception';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'commande_advance';
$this->rights[$r][5] = 'check';
$r++;
$this->rights[$r][0] = 1188;
$this->rights[$r][1] = 'Supprimer une commande fournisseur';
@@ -251,50 +259,85 @@ class modFournisseur extends DolibarrModules
$this->export_icon[$r]='bill';
$this->export_permission[$r]=array(array("fournisseur","facture","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product');
$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
while ($obj=$this->db->fetch_object($resql))
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice';
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='facture_fourn';
}
}
// End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT ';
// End add extra fields
// Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice_line';
}
}
// End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
@@ -309,40 +352,40 @@ class modFournisseur extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
while ($obj=$this->db->fetch_object($resql))
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice';
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='facture_fourn';
}
}
// End add axtra fields
// End add extra fields object
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
@@ -353,20 +396,92 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
$this->export_icon[$r]='order';
$this->export_permission[$r]=array(array("fournisseur","commande","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Number','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_public'=>"order",'f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='order';
}
}
// End add extra fields object
// Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='order_line';
}
}
// End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f, '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')';

View File

@@ -0,0 +1,142 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup mymodule Module MyModule
* \brief Example of a module descriptor.
* Such a file must be copied into htdocs/mymodule/core/modules directory.
* \file htdocs/mymodule/core/modules/modMyModule.class.php
* \ingroup mymodule
* \brief Description and activation file for module MyModule
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module MyModule
*/
class modIncoterm extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $langs,$conf;
$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).
$this->numero = 210009;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'incoterm';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
$this->family = "products";
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Incoterm management";
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 0;
$this->picto='generic';
$this->module_parts = array();
$this->dirs = array();
$this->config_page_url = array();
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(5,0); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("incoterm");
$this->const = array(
array('INCOTERM_ACTIVATE', 'chaine', 0, 'Description de INCOTERM_ACTIVATE')
);
$this->tabs = array();
// Dictionaries
if (! isset($conf->incoterm->enabled))
{
$conf->incoterm=new stdClass();
$conf->incoterm->enabled=0;
}
$this->dictionaries=array(
'langs'=>'incoterm',
'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor
'tablib'=>array("Incoterms"), // Label of tables
'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields
'tabsqlsort'=>array("rowid ASC"), // Sort order
'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionnary)
'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)
'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)
'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')
'tabcond'=>array($conf->incoterm->enabled)
);
$this->boxes = array(); // List of boxes
$r=0;
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
// Main menu entries
$this->menus = array(); // List of menus to add
$r=0;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
$sql = array();
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql, $options);
}
}

View File

@@ -289,6 +289,29 @@ class pdf_azur extends ModelePDFPropales
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
@@ -305,7 +328,7 @@ class pdf_azur extends ModelePDFPropales
}
if ($notetoshow)
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);

View File

@@ -123,7 +123,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
$date=$propal->datep;
$customercode=$objsoc->code_client;
$numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date);
$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date);
return $numFinal;
}

View File

@@ -126,7 +126,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
}
//Supplier invoices take invoice date instead of creation date for the mask
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date);
$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
return $numFinal;
}

View File

@@ -262,10 +262,33 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);

View File

@@ -121,7 +121,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
return 0;
}
$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande);
$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
return $numFinal;
}

View File

@@ -270,10 +270,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
$tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
if (! empty($object->note_public))
{
$tab_top = 88;
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);