Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop
This commit is contained in:
commit
24ede26dd7
@ -57,7 +57,7 @@ header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
|
||||
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
|
||||
|
||||
switch ($_SERVER['REQUEST_METHOD']) {
|
||||
case 'OPTIONS':
|
||||
case 'OPTIONS':
|
||||
break;
|
||||
case 'HEAD':
|
||||
case 'GET':
|
||||
|
||||
@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
$module = $subelement = $ext_element;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
|
||||
{
|
||||
$module = $regs[1];
|
||||
$module = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
|
||||
@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
require('../../main.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
|
||||
|
||||
$field = GETPOST('field','alpha',2);
|
||||
$element = GETPOST('element','alpha',2);
|
||||
$table_element = GETPOST('table_element','alpha',2);
|
||||
$field = GETPOST('field','alpha',2);
|
||||
$element = GETPOST('element','alpha',2);
|
||||
$table_element = GETPOST('table_element','alpha',2);
|
||||
$fk_element = GETPOST('fk_element','alpha',2);
|
||||
|
||||
/*
|
||||
@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
|
||||
}
|
||||
else
|
||||
{
|
||||
$module = $subelement = $ext_element;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
|
||||
{
|
||||
$module = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
$module = $subelement = $ext_element;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
|
||||
{
|
||||
$module = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
|
||||
|
||||
@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
|
||||
|
||||
$soc->fetch($id);
|
||||
|
||||
$return=array();
|
||||
|
||||
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
|
||||
$return['num'] = $form->num;
|
||||
$return['error'] = $form->error;
|
||||
|
||||
$return=array();
|
||||
|
||||
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
|
||||
$return['num'] = $form->num;
|
||||
$return['error'] = $form->error;
|
||||
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
|
||||
@ -1646,7 +1646,7 @@ abstract class CommonObject
|
||||
|
||||
$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
|
||||
$targetid = (! empty($targetid) ? $targetid : $this->id);
|
||||
$sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element));
|
||||
$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
|
||||
$targettype = (! empty($targettype) ? $targettype : $this->element);
|
||||
|
||||
// Links beetween objects are stored in this table
|
||||
|
||||
@ -206,28 +206,28 @@ class Conf
|
||||
//var_dump($this->modules);
|
||||
//var_dump($this->modules_parts);
|
||||
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
{
|
||||
global $mc;
|
||||
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($ret) $mc = new ActionsMulticompany($db);
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
{
|
||||
global $mc;
|
||||
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($ret) $mc = new ActionsMulticompany($db);
|
||||
}
|
||||
|
||||
// Second or others levels object
|
||||
$this->propal->cloture = (object) array();
|
||||
$this->propal->cloture = (object) array();
|
||||
$this->propal->facturation = (object) array();
|
||||
$this->commande->client = (object) array();
|
||||
$this->commande->client = (object) array();
|
||||
$this->commande->fournisseur = (object) array();
|
||||
$this->facture->client = (object) array();
|
||||
$this->facture->client = (object) array();
|
||||
$this->facture->fournisseur = (object) array();
|
||||
$this->fournisseur->commande = (object) array();
|
||||
$this->fournisseur->commande = (object) array();
|
||||
$this->fournisseur->facture = (object) array();
|
||||
$this->contrat->services = (object) array();
|
||||
$this->contrat->services->inactifs = (object) array();
|
||||
$this->contrat->services = (object) array();
|
||||
$this->contrat->services->inactifs = (object) array();
|
||||
$this->contrat->services->expires = (object) array();
|
||||
$this->adherent->cotisation = (object) array();
|
||||
$this->bank->rappro = (object) array();
|
||||
$this->bank->rappro = (object) array();
|
||||
$this->bank->cheque = (object) array();
|
||||
|
||||
// Clean some variables
|
||||
@ -261,7 +261,7 @@ class Conf
|
||||
// Define default dir_output and dir_temp for directories of modules
|
||||
foreach($this->modules as $module)
|
||||
{
|
||||
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
|
||||
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
|
||||
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
|
||||
// For backward compatibility
|
||||
$this->$module->dir_output = $rootfordata."/".$module;
|
||||
@ -277,14 +277,14 @@ class Conf
|
||||
$this->admin->dir_temp=$rootfordata.'/admin/temp';
|
||||
|
||||
// For user storage
|
||||
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
|
||||
$this->user->multidir_output = array($this->entity => $rootfordata."/users");
|
||||
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
|
||||
// For backward compatibility
|
||||
$this->user->dir_output=$rootforuser."/users";
|
||||
$this->user->dir_temp=$rootforuser."/users/temp";
|
||||
|
||||
// For propal storage
|
||||
$this->propal->dir_output=$rootforuser."/propale";
|
||||
// For propal storage
|
||||
$this->propal->dir_output=$rootforuser."/propale";
|
||||
$this->propal->dir_temp=$rootforuser."/propale/temp";
|
||||
|
||||
// Exception: Some dir are not the name of module. So we keep exception here
|
||||
@ -307,9 +307,9 @@ class Conf
|
||||
$this->service->multidir_output=array($this->entity => $rootfordata."/produit");
|
||||
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
|
||||
// For backward compatibility
|
||||
$this->product->dir_output=$rootfordata."/produit";
|
||||
$this->product->dir_temp =$rootfordata."/produit/temp";
|
||||
$this->service->dir_output=$rootfordata."/produit";
|
||||
$this->product->dir_output=$rootfordata."/produit";
|
||||
$this->product->dir_temp =$rootfordata."/produit/temp";
|
||||
$this->service->dir_output=$rootfordata."/produit";
|
||||
$this->service->dir_temp =$rootfordata."/produit/temp";
|
||||
|
||||
// Module contrat
|
||||
@ -429,10 +429,10 @@ class Conf
|
||||
if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
|
||||
elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
|
||||
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
{
|
||||
if (is_object($mc)) $mc->setValues($this);
|
||||
if (is_object($mc)) $mc->setValues($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ class FileUpload
|
||||
$pathname = 'compta/facture';
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
}
|
||||
elseif ($element == 'project') {
|
||||
elseif ($element == 'project') {
|
||||
$element = $pathname = 'projet';
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
}
|
||||
elseif ($element == 'fichinter') {
|
||||
$element='ficheinter';
|
||||
@ -108,11 +108,11 @@ class FileUpload
|
||||
'accept_file_types' => '/.+$/i',
|
||||
// The maximum number of files for the upload directory:
|
||||
'max_number_of_files' => null,
|
||||
// Image resolution restrictions:
|
||||
'max_width' => null,
|
||||
'max_height' => null,
|
||||
'min_width' => 1,
|
||||
'min_height' => 1,
|
||||
// Image resolution restrictions:
|
||||
'max_width' => null,
|
||||
'max_height' => null,
|
||||
'min_width' => 1,
|
||||
'min_height' => 1,
|
||||
// Set the following option to false to enable resumable uploads:
|
||||
'discard_aborted_uploads' => true,
|
||||
'image_versions' => array(
|
||||
@ -131,7 +131,7 @@ class FileUpload
|
||||
'thumbnail' => array(
|
||||
'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/',
|
||||
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/',
|
||||
'max_width' => 80,
|
||||
'max_width' => 80,
|
||||
'max_height' => 80
|
||||
)
|
||||
)
|
||||
@ -148,14 +148,14 @@ class FileUpload
|
||||
*/
|
||||
protected function getFullUrl()
|
||||
{
|
||||
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
|
||||
return
|
||||
($https ? 'https://' : 'http://').
|
||||
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
|
||||
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
|
||||
($https && $_SERVER['SERVER_PORT'] === 443 ||
|
||||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
|
||||
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
|
||||
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
|
||||
return
|
||||
($https ? 'https://' : 'http://').
|
||||
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
|
||||
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
|
||||
($https && $_SERVER['SERVER_PORT'] === 443 ||
|
||||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
|
||||
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,13 +165,13 @@ class FileUpload
|
||||
* @return void
|
||||
*/
|
||||
protected function setFileDeleteUrl($file)
|
||||
{
|
||||
$file->delete_url = $this->options['script_url']
|
||||
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
|
||||
$file->delete_type = $this->options['delete_type'];
|
||||
if ($file->delete_type !== 'DELETE') {
|
||||
$file->delete_url .= '&_method=DELETE';
|
||||
}
|
||||
{
|
||||
$file->delete_url = $this->options['script_url']
|
||||
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
|
||||
$file->delete_type = $this->options['delete_type'];
|
||||
if ($file->delete_type !== 'DELETE') {
|
||||
$file->delete_url .= '&_method=DELETE';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -260,9 +260,9 @@ class FileUpload
|
||||
$file->error = $error;
|
||||
return false;
|
||||
}
|
||||
if (!$file->name) {
|
||||
$file->error = 'missingFileName';
|
||||
return false;
|
||||
if (!$file->name) {
|
||||
$file->error = 'missingFileName';
|
||||
return false;
|
||||
}
|
||||
if (!preg_match($this->options['accept_file_types'], $file->name)) {
|
||||
$file->error = 'acceptFileTypes';
|
||||
@ -314,10 +314,10 @@ class FileUpload
|
||||
* @return string ???
|
||||
*/
|
||||
protected function upcountNameCallback($matches)
|
||||
{
|
||||
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
|
||||
$ext = isset($matches[2]) ? $matches[2] : '';
|
||||
return ' ('.$index.')'.$ext;
|
||||
{
|
||||
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
|
||||
$ext = isset($matches[2]) ? $matches[2] : '';
|
||||
return ' ('.$index.')'.$ext;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,8 +327,8 @@ class FileUpload
|
||||
* @return string ???
|
||||
*/
|
||||
protected function upcountName($name)
|
||||
{
|
||||
return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1);
|
||||
{
|
||||
return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -340,24 +340,24 @@ class FileUpload
|
||||
* @return void
|
||||
*/
|
||||
protected function trimFileName($name, $type, $index)
|
||||
{
|
||||
// Remove path information and dots around the filename, to prevent uploading
|
||||
// into different directories or replacing hidden system files.
|
||||
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
||||
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
|
||||
// Add missing file extension for known image types:
|
||||
if (strpos($file_name, '.') === false &&
|
||||
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
|
||||
$file_name .= '.'.$matches[1];
|
||||
}
|
||||
{
|
||||
// Remove path information and dots around the filename, to prevent uploading
|
||||
// into different directories or replacing hidden system files.
|
||||
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
||||
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
|
||||
// Add missing file extension for known image types:
|
||||
if (strpos($file_name, '.') === false &&
|
||||
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
|
||||
$file_name .= '.'.$matches[1];
|
||||
}
|
||||
if ($this->options['discard_aborted_uploads'])
|
||||
{
|
||||
{
|
||||
while(is_file($this->options['upload_dir'].$file_name))
|
||||
{
|
||||
$file_name = $this->upcountName($file_name);
|
||||
}
|
||||
}
|
||||
return $file_name;
|
||||
{
|
||||
$file_name = $this->upcountName($file_name);
|
||||
}
|
||||
}
|
||||
return $file_name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,33 +367,33 @@ class FileUpload
|
||||
* @return int Success or not
|
||||
*/
|
||||
protected function orientImage($file_path)
|
||||
{
|
||||
$exif = @exif_read_data($file_path);
|
||||
if ($exif === false) {
|
||||
return false;
|
||||
}
|
||||
$orientation = intval(@$exif['Orientation']);
|
||||
if (!in_array($orientation, array(3, 6, 8))) {
|
||||
return false;
|
||||
}
|
||||
$image = @imagecreatefromjpeg($file_path);
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$image = @imagerotate($image, 180, 0);
|
||||
break;
|
||||
case 6:
|
||||
$image = @imagerotate($image, 270, 0);
|
||||
break;
|
||||
case 8:
|
||||
$image = @imagerotate($image, 90, 0);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
$success = imagejpeg($image, $file_path);
|
||||
// Free up memory (imagedestroy does not delete files):
|
||||
@imagedestroy($image);
|
||||
return $success;
|
||||
{
|
||||
$exif = @exif_read_data($file_path);
|
||||
if ($exif === false) {
|
||||
return false;
|
||||
}
|
||||
$orientation = intval(@$exif['Orientation']);
|
||||
if (!in_array($orientation, array(3, 6, 8))) {
|
||||
return false;
|
||||
}
|
||||
$image = @imagecreatefromjpeg($file_path);
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$image = @imagerotate($image, 180, 0);
|
||||
break;
|
||||
case 6:
|
||||
$image = @imagerotate($image, 270, 0);
|
||||
break;
|
||||
case 8:
|
||||
$image = @imagerotate($image, 90, 0);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
$success = imagejpeg($image, $file_path);
|
||||
// Free up memory (imagedestroy does not delete files):
|
||||
@imagedestroy($image);
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -416,40 +416,40 @@ class FileUpload
|
||||
$file->type = $type;
|
||||
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0)
|
||||
{
|
||||
$file_path = $this->options['upload_dir'].$file->name;
|
||||
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
|
||||
$file_path = $this->options['upload_dir'].$file->name;
|
||||
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
|
||||
clearstatcache();
|
||||
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
||||
// multipart/formdata uploads (POST method uploads)
|
||||
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
|
||||
// multipart/formdata uploads (POST method uploads)
|
||||
if ($append_file)
|
||||
{
|
||||
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
|
||||
} else {
|
||||
dol_move_uploaded_file($uploaded_file, $file_path, 1);
|
||||
}
|
||||
{
|
||||
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
|
||||
} else {
|
||||
dol_move_uploaded_file($uploaded_file, $file_path, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Non-multipart uploads (PUT method support)
|
||||
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
|
||||
}
|
||||
{
|
||||
// Non-multipart uploads (PUT method support)
|
||||
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
|
||||
}
|
||||
$file_size = filesize($file_path);
|
||||
if ($file_size === $file->size)
|
||||
{
|
||||
$file->url = $this->options['upload_url'].rawurlencode($file->name);
|
||||
foreach($this->options['image_versions'] as $version => $options)
|
||||
{
|
||||
if ($this->createScaledImage($file->name, $options))
|
||||
{
|
||||
$tmp=explode('.',$file->name);
|
||||
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
||||
}
|
||||
}
|
||||
{
|
||||
$file->url = $this->options['upload_url'].rawurlencode($file->name);
|
||||
foreach($this->options['image_versions'] as $version => $options)
|
||||
{
|
||||
if ($this->createScaledImage($file->name, $options))
|
||||
{
|
||||
$tmp=explode('.',$file->name);
|
||||
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($this->options['discard_aborted_uploads'])
|
||||
{
|
||||
unlink($file_path);
|
||||
$file->error = 'abort';
|
||||
{
|
||||
unlink($file_path);
|
||||
$file->error = 'abort';
|
||||
}
|
||||
$file->size = $file_size;
|
||||
$this->setFileDeleteUrl($file);
|
||||
@ -486,15 +486,15 @@ class FileUpload
|
||||
public function post()
|
||||
{
|
||||
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE')
|
||||
{
|
||||
return $this->delete();
|
||||
{
|
||||
return $this->delete();
|
||||
}
|
||||
$upload = isset($_FILES[$this->options['param_name']]) ?
|
||||
$_FILES[$this->options['param_name']] : null;
|
||||
$info = array();
|
||||
if ($upload && is_array($upload['tmp_name']))
|
||||
{
|
||||
// param_name is an array identifier like "files[]",
|
||||
// param_name is an array identifier like "files[]",
|
||||
// $_FILES is a multi-dimensional array:
|
||||
foreach ($upload['tmp_name'] as $index => $value) {
|
||||
$info[] = $this->handleFileUpload(
|
||||
@ -507,7 +507,7 @@ class FileUpload
|
||||
);
|
||||
}
|
||||
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) {
|
||||
// param_name is a single object identifier like "file",
|
||||
// param_name is a single object identifier like "file",
|
||||
// $_FILES is a one-dimensional array:
|
||||
$info[] = $this->handleFileUpload(
|
||||
isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
|
||||
@ -519,11 +519,11 @@ class FileUpload
|
||||
}
|
||||
header('Vary: Accept');
|
||||
$json = json_encode($info);
|
||||
$redirect = isset($_REQUEST['redirect']) ?
|
||||
stripslashes($_REQUEST['redirect']) : null;
|
||||
if ($redirect) {
|
||||
header('Location: '.sprintf($redirect, rawurlencode($json)));
|
||||
return;
|
||||
$redirect = isset($_REQUEST['redirect']) ?
|
||||
stripslashes($_REQUEST['redirect']) : null;
|
||||
if ($redirect) {
|
||||
header('Location: '.sprintf($redirect, rawurlencode($json)));
|
||||
return;
|
||||
}
|
||||
if (isset($_SERVER['HTTP_ACCEPT']) &&
|
||||
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {
|
||||
|
||||
@ -285,12 +285,12 @@ class Form
|
||||
if (! empty($tmp[2])) $savemethod=$tmp[2];
|
||||
if (! empty($tmp[3])) $button_only=true;
|
||||
}
|
||||
else if (preg_match('/^textarea/',$inputType))
|
||||
{
|
||||
$tmp=explode(':',$inputType);
|
||||
else if (preg_match('/^textarea/',$inputType))
|
||||
{
|
||||
$tmp=explode(':',$inputType);
|
||||
$inputType=$tmp[0];
|
||||
if (! empty($tmp[1])) $rows=$tmp[1];
|
||||
if (! empty($tmp[2])) $cols=$tmp[2];
|
||||
if (! empty($tmp[1])) $rows=$tmp[1];
|
||||
if (! empty($tmp[2])) $cols=$tmp[2];
|
||||
}
|
||||
else if (preg_match('/^ckeditor/',$inputType))
|
||||
{
|
||||
@ -790,20 +790,20 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of all contacts (for a third party or all)
|
||||
*
|
||||
* @param int $socid Id ot third party or 0 for all
|
||||
* @param string $selected Id contact pre-selectionne
|
||||
* @param string $htmlname Name of HTML field ('none' for a not editable field)
|
||||
* @param int $showempty 0=no empty value, 1=add an empty value
|
||||
* @param string $exclude List of contacts id to exclude
|
||||
* @param string $limitto Disable answers that are not id in this array list
|
||||
* @param string $showfunction Add function into label
|
||||
* @param string $moreclass Add more class to class style
|
||||
* @return int <0 if KO, Nb of contact in list if OK
|
||||
*/
|
||||
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='')
|
||||
/**
|
||||
* Return list of all contacts (for a third party or all)
|
||||
*
|
||||
* @param int $socid Id ot third party or 0 for all
|
||||
* @param string $selected Id contact pre-selectionne
|
||||
* @param string $htmlname Name of HTML field ('none' for a not editable field)
|
||||
* @param int $showempty 0=no empty value, 1=add an empty value
|
||||
* @param string $exclude List of contacts id to exclude
|
||||
* @param string $limitto Disable answers that are not id in this array list
|
||||
* @param string $showfunction Add function into label
|
||||
* @param string $moreclass Add more class to class style
|
||||
* @return int <0 if KO, Nb of contact in list if OK
|
||||
*/
|
||||
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='')
|
||||
{
|
||||
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass);
|
||||
return $this->num;
|
||||
@ -2725,50 +2725,50 @@ class Form
|
||||
print $this->selectcurrency($selected,$htmlname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load into the cache all currencies
|
||||
*
|
||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||
*/
|
||||
function load_cache_currencies()
|
||||
{
|
||||
/**
|
||||
* Load into the cache all currencies
|
||||
*
|
||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||
*/
|
||||
function load_cache_currencies()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$langs->load("dict");
|
||||
|
||||
if (count($this->cache_currencies)) return 0; // Cache deja charge
|
||||
|
||||
$langs->load("dict");
|
||||
|
||||
if (count($this->cache_currencies)) return 0; // Cache deja charge
|
||||
|
||||
$sql = "SELECT code_iso, label, unicode";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
|
||||
$sql.= " WHERE active = 1";
|
||||
$sql.= " ORDER BY code_iso ASC";
|
||||
|
||||
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
|
||||
|
||||
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
|
||||
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
|
||||
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
|
||||
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
|
||||
$i++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
array_multisort($label, SORT_ASC, $this->cache_currencies);
|
||||
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2833,33 +2833,33 @@ class Form
|
||||
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Load into the cache vat rates of a country
|
||||
*
|
||||
* @param string $country_code Country code
|
||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||
* @param string $country_code Country code
|
||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||
*/
|
||||
function load_cache_vatrates($country_code)
|
||||
function load_cache_vatrates($country_code)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$num = count($this->cache_vatrates);
|
||||
$num = count($this->cache_vatrates);
|
||||
if ($num > 0) return $num; // Cache deja charge
|
||||
|
||||
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql.= " WHERE t.fk_pays = p.rowid";
|
||||
$sql.= " AND t.active = 1";
|
||||
$sql.= " AND p.code IN (".$country_code.")";
|
||||
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
$sql = "SELECT DISTINCT t.taux, t.recuperableonly";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql.= " WHERE t.fk_pays = p.rowid";
|
||||
$sql.= " AND t.active = 1";
|
||||
$sql.= " AND p.code IN (".$country_code.")";
|
||||
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->cache_vatrates[$i]['txtva'] = $obj->taux;
|
||||
@ -2879,7 +2879,7 @@ class Form
|
||||
{
|
||||
$this->error = '<font class="error">'.$this->db->error().'</font>';
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2975,32 +2975,32 @@ class Form
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
|
||||
{
|
||||
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
|
||||
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
|
||||
}
|
||||
|
||||
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
|
||||
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
|
||||
{
|
||||
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
|
||||
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
|
||||
{
|
||||
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
|
||||
$defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod);
|
||||
}
|
||||
|
||||
// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
|
||||
// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
|
||||
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
|
||||
{
|
||||
$defaulttx = $this->cache_vatrates[$num-1]['txtva'];
|
||||
}
|
||||
|
||||
if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
|
||||
foreach ($this->cache_vatrates as $rate)
|
||||
{
|
||||
$return.= '<option value="'.$rate['txtva'];
|
||||
$return.= $rate['nprtva'] ? '*': '';
|
||||
$return.= '<option value="'.$rate['txtva'];
|
||||
$return.= $rate['nprtva'] ? '*': '';
|
||||
$return.= '"';
|
||||
if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
|
||||
{
|
||||
$return.= ' selected="selected"';
|
||||
}
|
||||
$return.= '>'.vatrate($rate['libtva']);
|
||||
}
|
||||
$return.= '>'.vatrate($rate['libtva']);
|
||||
$return.= $rate['nprtva'] ? ' *': '';
|
||||
$return.= '</option>';
|
||||
|
||||
@ -3391,79 +3391,79 @@ class Form
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a multiselect form from an array.
|
||||
*
|
||||
/**
|
||||
* Show a multiselect form from an array.
|
||||
*
|
||||
* @param string $htmlname Name of select
|
||||
* @param array $array Array with key+value
|
||||
* @param array $array Array with key+value
|
||||
* @param array $selected Preselected keys
|
||||
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value"
|
||||
* @param int $value_as_key 1 to use value as key
|
||||
* @param string $option Valeur de l'option en fonction du type choisi
|
||||
* @param int $translate Translate and encode value
|
||||
* @return string HTML multiselect string
|
||||
*/
|
||||
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
|
||||
{
|
||||
* @param int $translate Translate and encode value
|
||||
* @return string HTML multiselect string
|
||||
*/
|
||||
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
|
||||
if (is_array($array) && ! empty($array))
|
||||
|
||||
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
|
||||
if (is_array($array) && ! empty($array))
|
||||
{
|
||||
if ($value_as_key) $array=array_combine($array, $array);
|
||||
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected))
|
||||
{
|
||||
foreach ($selected as $selected_value)
|
||||
{
|
||||
foreach($array as $key => $value)
|
||||
{
|
||||
if ($selected_value == $key)
|
||||
{
|
||||
$value=$array[$selected_value];
|
||||
$out.= '<option value="'.$key.'" selected="selected">';
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
unset($array[$key]);
|
||||
if ($selected_value == $key)
|
||||
{
|
||||
$value=$array[$selected_value];
|
||||
$out.= '<option value="'.$key.'" selected="selected">';
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
unset($array[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($array))
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$out.= '<option value="'.$key.'">';
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
$out.= '<option value="'.$key.'">';
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$out.= '<option value="'.$key.'"';
|
||||
if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
|
||||
{
|
||||
$out.= ' selected="selected"';
|
||||
}
|
||||
$out.= '>';
|
||||
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$out.= '<option value="'.$key.'"';
|
||||
if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
|
||||
{
|
||||
$out.= ' selected="selected"';
|
||||
}
|
||||
$out.= '>';
|
||||
|
||||
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
|
||||
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
|
||||
$out.= dol_htmlentitiesbr($newval);
|
||||
$out.= '</option>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$out.= '</select>'."\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
$out.= '</select>'."\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -813,7 +813,7 @@ class FormFile
|
||||
// Max file size
|
||||
$max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
|
||||
|
||||
// Include main
|
||||
// Include main
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php');
|
||||
|
||||
// Include template
|
||||
|
||||
@ -170,9 +170,9 @@ class SMTPs
|
||||
*/
|
||||
var $_smtpsRelatedBoundary = null;
|
||||
|
||||
/**
|
||||
* Alternative Boundary
|
||||
*/
|
||||
/**
|
||||
* Alternative Boundary
|
||||
*/
|
||||
var $_smtpsAlternativeBoundary = null;
|
||||
|
||||
/**
|
||||
@ -1223,8 +1223,8 @@ class SMTPs
|
||||
|
||||
if (key_exists('image', $this->_msgContent))
|
||||
{
|
||||
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
|
||||
$content .= "\r\n";
|
||||
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
|
||||
$content .= "\r\n";
|
||||
$content .= "--" . $this->_getBoundary('alternative') . "\r\n";
|
||||
}
|
||||
|
||||
@ -1268,21 +1268,21 @@ class SMTPs
|
||||
. $_data['data'] . "\r\n";
|
||||
}
|
||||
|
||||
// always end related and end alternative after inline images
|
||||
$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
|
||||
$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
|
||||
// always end related and end alternative after inline images
|
||||
$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
|
||||
$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
|
||||
$content.= "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key_exists('image', $this->_msgContent))
|
||||
{
|
||||
$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
|
||||
$content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message
|
||||
$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
|
||||
$content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
|
||||
$content.= "\r\n";
|
||||
$content.= "--" . $this->_getBoundary('related') . "\r\n";
|
||||
if (key_exists('image', $this->_msgContent))
|
||||
{
|
||||
$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
|
||||
$content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message
|
||||
$content.= "--" . $this->_getBoundary('alternative') . "\r\n";
|
||||
$content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
|
||||
$content.= "\r\n";
|
||||
$content.= "--" . $this->_getBoundary('related') . "\r\n";
|
||||
}
|
||||
|
||||
$content .= 'Content-Type: ' . $_content['mimeType'] . '; '
|
||||
@ -1490,7 +1490,7 @@ class SMTPs
|
||||
function _setBoundary()
|
||||
{
|
||||
$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary";
|
||||
$this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"));
|
||||
$this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"));
|
||||
$this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"));
|
||||
}
|
||||
|
||||
|
||||
@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1)
|
||||
$num = count($objMod->depends);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
foreach ($modulesdir as $dir)
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
if (file_exists($dir.$objMod->depends[$i].".class.php"))
|
||||
{
|
||||
activateModule($objMod->depends[$i]);
|
||||
if (file_exists($dir.$objMod->depends[$i].".class.php"))
|
||||
{
|
||||
activateModule($objMod->depends[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1)
|
||||
$num = count($objMod->conflictwith);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
foreach ($modulesdir as $dir)
|
||||
foreach ($modulesdir as $dir)
|
||||
{
|
||||
if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
|
||||
{
|
||||
unActivateModule($objMod->conflictwith[$i],0);
|
||||
if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
|
||||
{
|
||||
unActivateModule($objMod->conflictwith[$i],0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1128,16 +1128,16 @@ function form_constantes($tableau)
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add document model used by doc generator
|
||||
*
|
||||
/**
|
||||
* Add document model used by doc generator
|
||||
*
|
||||
* @param string $name Model name
|
||||
* @param string $type Model type
|
||||
* @param string $label Model label
|
||||
* @param string $description Model description
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function addDocumentModel($name, $type, $label='', $description='')
|
||||
* @param string $type Model type
|
||||
* @param string $label Model label
|
||||
* @param string $description Model description
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function addDocumentModel($name, $type, $label='', $description='')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
@ -1150,51 +1150,51 @@ function addDocumentModel($name, $type, $label='', $description='')
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog("admin.lib::addDocumentModel sql=".$sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
return -1;
|
||||
}
|
||||
$db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete document model used by doc generator
|
||||
*
|
||||
* @param string $name Model name
|
||||
* @param string $type Model type
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delDocumentModel($name, $type)
|
||||
{
|
||||
/**
|
||||
* Delete document model used by doc generator
|
||||
*
|
||||
* @param string $name Model name
|
||||
* @param string $type Model type
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delDocumentModel($name, $type)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE nom = '".$db->escape($name)."'";
|
||||
$sql.= " AND type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("admin.lib::delDocumentModel sql=".$sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("admin.lib::delDocumentModel sql=".$sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
return -1;
|
||||
}
|
||||
$db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show html area for list of addresses
|
||||
*
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Object $object Third party object
|
||||
* @param string $backtopage Url to go once address is created
|
||||
* @return void
|
||||
*/
|
||||
function show_addresses($conf,$langs,$db,$object,$backtopage='')
|
||||
{
|
||||
global $user;
|
||||
/**
|
||||
* Show html area for list of addresses
|
||||
*
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Object $object Third party object
|
||||
* @param string $backtopage Url to go once address is created
|
||||
* @return void
|
||||
*/
|
||||
function show_addresses($conf,$langs,$db,$object,$backtopage='')
|
||||
{
|
||||
global $user;
|
||||
global $bc;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
|
||||
|
||||
$addressstatic = new Address($db);
|
||||
$num = $addressstatic->fetch_lines($object->id);
|
||||
|
||||
$buttoncreate='';
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
|
||||
|
||||
print "\n".'<table class="noborder" width="100%">'."\n";
|
||||
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
$num = $addressstatic->fetch_lines($object->id);
|
||||
|
||||
$buttoncreate='';
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
|
||||
|
||||
print "\n".'<table class="noborder" width="100%">'."\n";
|
||||
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td>'.$langs->trans("CompanyName").'</td>';
|
||||
print '<td>'.$langs->trans("Town").'</td>';
|
||||
print '<td>'.$langs->trans("Country").'</td>';
|
||||
print '<td>'.$langs->trans("Tel").'</td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td>';
|
||||
print "<td> </td>";
|
||||
print "</tr>";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=true;
|
||||
|
||||
foreach ($addressstatic->lines as $address)
|
||||
{
|
||||
$var = !$var;
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td>'.$langs->trans("Tel").'</td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td>';
|
||||
print "<td> </td>";
|
||||
print "</tr>";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=true;
|
||||
|
||||
foreach ($addressstatic->lines as $address)
|
||||
{
|
||||
$var = !$var;
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td>';
|
||||
$addressstatic->id = $address->id;
|
||||
$addressstatic->label = $address->label;
|
||||
print $addressstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
$addressstatic->label = $address->label;
|
||||
print $addressstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.$address->name.'</td>';
|
||||
|
||||
print '<td>'.$address->town.'</td>';
|
||||
|
||||
$img=picto_from_langcode($address->country_code);
|
||||
print '<td>'.($img?$img.' ':'').$address->country.'</td>';
|
||||
|
||||
// Lien click to dial
|
||||
print '<td>';
|
||||
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
|
||||
print '</td>';
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<td align="right">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&id='.$address->id.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//print "<tr ".$bc[$var].">";
|
||||
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
|
||||
//print "</tr>\n";
|
||||
}
|
||||
print "\n</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
return $num;
|
||||
print '<td>'.($img?$img.' ':'').$address->country.'</td>';
|
||||
|
||||
// Lien click to dial
|
||||
print '<td>';
|
||||
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
|
||||
print '</td>';
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<td align="right">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&id='.$address->id.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//print "<tr ".$bc[$var].">";
|
||||
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
|
||||
//print "</tr>\n";
|
||||
}
|
||||
print "\n</table>\n";
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -39,11 +39,11 @@ function contract_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ContactsAddresses");
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ContactsAddresses");
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -53,11 +53,11 @@ function contract_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -43,11 +43,11 @@ function fichinter_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('InterventionContact');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('InterventionContact');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -65,11 +65,11 @@ function fichinter_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -507,9 +507,9 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
|
||||
*/
|
||||
function dol_unescapefile($filename)
|
||||
{
|
||||
// Remove path information and dots around the filename, to prevent uploading
|
||||
// into different directories or replacing hidden system files.
|
||||
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
||||
// Remove path information and dots around the filename, to prevent uploading
|
||||
// into different directories or replacing hidden system files.
|
||||
// Also remove control characters and spaces (\x00..\x20) around the filename:
|
||||
return trim(basename($filename), ".\x00..\x20");
|
||||
}
|
||||
|
||||
@ -628,15 +628,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
||||
{
|
||||
if (is_object($object))
|
||||
{
|
||||
$object->src_file=$dest_file;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $errors=$interface->errors;
|
||||
}
|
||||
$object->src_file=$dest_file;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $errors=$interface->errors;
|
||||
}
|
||||
// Fin appel triggers
|
||||
}
|
||||
else
|
||||
|
||||
@ -41,11 +41,11 @@ function facturefourn_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -55,11 +55,11 @@ function facturefourn_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -121,11 +121,11 @@ function ordersupplier_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -4007,36 +4007,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
|
||||
if (! is_array($arraycolor)) return $colorifnotfound;
|
||||
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a currency code into its symbol
|
||||
*
|
||||
* @param string $currency_code Currency code
|
||||
* @return string Currency symbol encoded into UTF8
|
||||
*/
|
||||
function getCurrencySymbol($currency_code)
|
||||
{
|
||||
global $db, $form;
|
||||
|
||||
$currency_sign = '';
|
||||
|
||||
if (! is_object($form)) $form = new Form($db);
|
||||
|
||||
$form->load_cache_currencies();
|
||||
|
||||
if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
|
||||
{
|
||||
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
{
|
||||
|
||||
/**
|
||||
* Convert a currency code into its symbol
|
||||
*
|
||||
* @param string $currency_code Currency code
|
||||
* @return string Currency symbol encoded into UTF8
|
||||
*/
|
||||
function getCurrencySymbol($currency_code)
|
||||
{
|
||||
global $db, $form;
|
||||
|
||||
$currency_sign = '';
|
||||
|
||||
if (! is_object($form)) $form = new Form($db);
|
||||
|
||||
$form->load_cache_currencies();
|
||||
|
||||
if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
|
||||
{
|
||||
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
{
|
||||
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_sign = $currency_code;
|
||||
}
|
||||
|
||||
return $currency_sign;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_sign = $currency_code;
|
||||
}
|
||||
|
||||
return $currency_sign;
|
||||
}
|
||||
|
||||
if (! function_exists('getmypid'))
|
||||
|
||||
@ -185,7 +185,7 @@ function dol_print_object_info($object)
|
||||
$deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
|
||||
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
|
||||
$deltadateforuser=round($deltadateforclient-$deltadateforserver);
|
||||
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
|
||||
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
|
||||
|
||||
// Import key
|
||||
if (isset($object->import_key))
|
||||
|
||||
@ -40,11 +40,11 @@ function facture_prepare_head($object)
|
||||
$head[$h][2] = 'compta';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -71,11 +71,11 @@ function facture_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -25,60 +25,60 @@
|
||||
|
||||
if (! function_exists('json_encode'))
|
||||
{
|
||||
/**
|
||||
* Implement json_encode for PHP that does not support it
|
||||
*
|
||||
* @param mixed $elements PHP Object to json encode
|
||||
* @return string Json encoded string
|
||||
*/
|
||||
function json_encode($elements)
|
||||
/**
|
||||
* Implement json_encode for PHP that does not support it
|
||||
*
|
||||
* @param mixed $elements PHP Object to json encode
|
||||
* @return string Json encoded string
|
||||
*/
|
||||
function json_encode($elements)
|
||||
{
|
||||
return dol_json_encode($elements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement json_encode for PHP that does not support it
|
||||
*
|
||||
* @param mixed $elements PHP Object to json encode
|
||||
* @return string Json encoded string
|
||||
*/
|
||||
function dol_json_encode($elements)
|
||||
{
|
||||
$num = count($elements);
|
||||
|
||||
// determine type
|
||||
if (is_numeric(key($elements)))
|
||||
{
|
||||
// indexed (list)
|
||||
$output = '[';
|
||||
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
|
||||
{
|
||||
if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
|
||||
else $output .= _val($elements[$i]);
|
||||
if($i !== $last) $output.= ',';
|
||||
}
|
||||
$output.= ']';
|
||||
}
|
||||
else
|
||||
{
|
||||
// associative (object)
|
||||
$output = '{';
|
||||
$last = $num - 1;
|
||||
$i = 0;
|
||||
foreach($elements as $key => $value)
|
||||
{
|
||||
$output .= '"'.$key.'":';
|
||||
if (is_array($value)) $output.= json_encode($value);
|
||||
else $output .= _val($value);
|
||||
if ($i !== $last) $output.= ',';
|
||||
++$i;
|
||||
}
|
||||
$output.= '}';
|
||||
}
|
||||
|
||||
// return
|
||||
return $output;
|
||||
/**
|
||||
* Implement json_encode for PHP that does not support it
|
||||
*
|
||||
* @param mixed $elements PHP Object to json encode
|
||||
* @return string Json encoded string
|
||||
*/
|
||||
function dol_json_encode($elements)
|
||||
{
|
||||
$num = count($elements);
|
||||
|
||||
// determine type
|
||||
if (is_numeric(key($elements)))
|
||||
{
|
||||
// indexed (list)
|
||||
$output = '[';
|
||||
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
|
||||
{
|
||||
if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
|
||||
else $output .= _val($elements[$i]);
|
||||
if($i !== $last) $output.= ',';
|
||||
}
|
||||
$output.= ']';
|
||||
}
|
||||
else
|
||||
{
|
||||
// associative (object)
|
||||
$output = '{';
|
||||
$last = $num - 1;
|
||||
$i = 0;
|
||||
foreach($elements as $key => $value)
|
||||
{
|
||||
$output .= '"'.$key.'":';
|
||||
if (is_array($value)) $output.= json_encode($value);
|
||||
else $output .= _val($value);
|
||||
if ($i !== $last) $output.= ',';
|
||||
++$i;
|
||||
}
|
||||
$output.= '}';
|
||||
}
|
||||
|
||||
// return
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,70 +189,70 @@ function _val($val)
|
||||
|
||||
if (! function_exists('json_decode'))
|
||||
{
|
||||
/**
|
||||
* Implement json_decode for PHP that does not support it
|
||||
*
|
||||
* @param string $json Json encoded to PHP Object or Array
|
||||
* @param bool $assoc False return an object, true return an array
|
||||
* @return mixed Object or Array
|
||||
*/
|
||||
function json_decode($json, $assoc=false)
|
||||
/**
|
||||
* Implement json_decode for PHP that does not support it
|
||||
*
|
||||
* @param string $json Json encoded to PHP Object or Array
|
||||
* @param bool $assoc False return an object, true return an array
|
||||
* @return mixed Object or Array
|
||||
*/
|
||||
function json_decode($json, $assoc=false)
|
||||
{
|
||||
return dol_json_decode($json, $assoc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement json_decode for PHP that does not support it
|
||||
*
|
||||
* @param string $json Json encoded to PHP Object or Array
|
||||
* @param bool $assoc False return an object, true return an array. Try to always use it with true !
|
||||
* @return mixed Object or Array
|
||||
*/
|
||||
function dol_json_decode($json, $assoc=false)
|
||||
{
|
||||
$comment = false;
|
||||
|
||||
/**
|
||||
* Implement json_decode for PHP that does not support it
|
||||
*
|
||||
* @param string $json Json encoded to PHP Object or Array
|
||||
* @param bool $assoc False return an object, true return an array. Try to always use it with true !
|
||||
* @return mixed Object or Array
|
||||
*/
|
||||
function dol_json_decode($json, $assoc=false)
|
||||
{
|
||||
$comment = false;
|
||||
|
||||
$out='';
|
||||
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
|
||||
for ($i=0; $i<$strLength; $i++)
|
||||
{
|
||||
if (! $comment)
|
||||
{
|
||||
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
|
||||
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
|
||||
else if ($json[$i] == ':') $out.= ' => ';
|
||||
else $out.=$json[$i];
|
||||
}
|
||||
else $out.= $json[$i];
|
||||
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
|
||||
}
|
||||
|
||||
$out=_unval($out);
|
||||
|
||||
// Return an array
|
||||
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
|
||||
for ($i=0; $i<$strLength; $i++)
|
||||
{
|
||||
if (! $comment)
|
||||
{
|
||||
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
|
||||
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
|
||||
else if ($json[$i] == ':') $out.= ' => ';
|
||||
else $out.=$json[$i];
|
||||
}
|
||||
else $out.= $json[$i];
|
||||
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
|
||||
}
|
||||
|
||||
$out=_unval($out);
|
||||
|
||||
// Return an array
|
||||
if ($out != '') eval('$array = '.$out.';');
|
||||
else $array=array();
|
||||
|
||||
// Return an object
|
||||
if (! $assoc)
|
||||
{
|
||||
if (! empty($array))
|
||||
{
|
||||
$object = false;
|
||||
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$object->{$key} = $value;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $array;
|
||||
else $array=array();
|
||||
|
||||
// Return an object
|
||||
if (! $assoc)
|
||||
{
|
||||
if (! empty($array))
|
||||
{
|
||||
$object = false;
|
||||
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
$object->{$key} = $value;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -68,11 +68,11 @@ function commande_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -91,11 +91,11 @@ function commande_prepare_head($object)
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Show linked objects for PDF generation
|
||||
*
|
||||
* @param PDF &$pdf Object PDF
|
||||
@ -728,8 +728,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
|
||||
* @param string $default_font_size Font size
|
||||
* @param HookManager $hookmanager Hook manager object
|
||||
* @return void
|
||||
*/
|
||||
function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false)
|
||||
*/
|
||||
function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false)
|
||||
{
|
||||
$linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager);
|
||||
if (! empty($linkedobjects))
|
||||
@ -743,14 +743,14 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al
|
||||
|
||||
if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
|
||||
{
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$posy+=3;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pdf->getY();
|
||||
|
||||
return $pdf->getY();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1354,26 +1354,26 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
|
||||
*/
|
||||
function pdf_getCurrencySymbol(&$pdf, $currency_code)
|
||||
{
|
||||
global $db, $form;
|
||||
|
||||
$currency_sign = '';
|
||||
|
||||
if (! is_object($form)) $form = new Form($db);
|
||||
|
||||
$form->load_cache_currencies();
|
||||
|
||||
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
|
||||
{
|
||||
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
{
|
||||
$currency_sign.= $pdf->unichr($unicode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_sign = $currency_code;
|
||||
}
|
||||
|
||||
global $db, $form;
|
||||
|
||||
$currency_sign = '';
|
||||
|
||||
if (! is_object($form)) $form = new Form($db);
|
||||
|
||||
$form->load_cache_currencies();
|
||||
|
||||
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
|
||||
{
|
||||
foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
|
||||
{
|
||||
$currency_sign.= $pdf->unichr($unicode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currency_sign = $currency_code;
|
||||
}
|
||||
|
||||
return $currency_sign;
|
||||
}
|
||||
|
||||
@ -1417,25 +1417,25 @@ function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false)
|
||||
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
|
||||
}
|
||||
}
|
||||
else if ($objecttype == 'contrat')
|
||||
{
|
||||
$outputlangs->load('contracts');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
else if ($objecttype == 'contrat')
|
||||
{
|
||||
$outputlangs->load('contracts');
|
||||
$num=count($objects);
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
|
||||
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
|
||||
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
|
||||
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For add external linked objects
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
|
||||
$action='';
|
||||
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
|
||||
$action='';
|
||||
$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
|
||||
}
|
||||
|
||||
@ -155,9 +155,9 @@ function product_admin_prepare_head($object=null)
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php';
|
||||
$head[$h][1] = $langs->trans("Tools");
|
||||
$head[$h][2] = 'tools';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php';
|
||||
$head[$h][1] = $langs->trans("Tools");
|
||||
$head[$h][2] = 'tools';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -65,9 +65,9 @@ function propal_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT dbt.".$dbt_select;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
|
||||
$sql = "SELECT dbt.".$dbt_select;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,14 +72,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
$mode=trim($mode);
|
||||
$authfile='functions_'.$mode.'.php';
|
||||
$fullauthfile='';
|
||||
|
||||
$dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']);
|
||||
foreach($dirlogin as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if file found (do not use dol_is_file to avoid loading files.lib.php)
|
||||
|
||||
$dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']);
|
||||
foreach($dirlogin as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if file found (do not use dol_is_file to avoid loading files.lib.php)
|
||||
if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile;
|
||||
}
|
||||
|
||||
@ -130,12 +130,12 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
global $dolibarr_main_demo,$db;
|
||||
global $smartphone,$hookmanager;
|
||||
|
||||
// Instantiate hooks of thirdparty module only if not already define
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||
$hookmanager=new HookManager($db);
|
||||
}
|
||||
// Instantiate hooks of thirdparty module only if not already define
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||
$hookmanager=new HookManager($db);
|
||||
}
|
||||
$hookmanager->initHooks(array('mainloginpage'));
|
||||
|
||||
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));
|
||||
@ -205,8 +205,8 @@ function dol_loginfunction($langs,$conf,$mysoc)
|
||||
}
|
||||
|
||||
// Execute hook getLoginPageOptions
|
||||
// Should be an array with differents options in $hookmanager->resArray
|
||||
$parameters=array('entity' => $_POST['entity']);
|
||||
// Should be an array with differents options in $hookmanager->resArray
|
||||
$parameters=array('entity' => $_POST['entity']);
|
||||
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
// Login
|
||||
|
||||
@ -45,12 +45,17 @@ function shipping_prepare_head($object)
|
||||
$head[$h][2] = 'shipping';
|
||||
$h++;
|
||||
|
||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && ! empty($object->linkedObjectsIds['delivery'][0]))
|
||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
|
||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||
$head[$h][2] = 'delivery';
|
||||
$h++;
|
||||
// delivery link
|
||||
$object->fetchObjectLinked($object->id,$object->element);
|
||||
if (! empty($object->linkedObjectsIds['delivery'][0]))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
|
||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||
$head[$h][2] = 'delivery';
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
|
||||
|
||||
@ -219,53 +219,53 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
|
||||
foreach($dirthemes as $dir)
|
||||
{
|
||||
$dirtheme=dol_buildpath($dir,0);
|
||||
$dirtheme=dol_buildpath($dir,0);
|
||||
$urltheme=dol_buildpath($dir,1);
|
||||
|
||||
if (is_dir($dirtheme))
|
||||
if (is_dir($dirtheme))
|
||||
{
|
||||
$handle=opendir($dirtheme);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
{
|
||||
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
{
|
||||
// Disable not stable themes
|
||||
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
|
||||
|
||||
if ($i % $thumbsbyrow == 0)
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
}
|
||||
|
||||
print '<td align="center">';
|
||||
$file=$dirtheme."/".$subdir."/thumb.png";
|
||||
$url=$urltheme."/".$subdir."/thumb.png";
|
||||
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
|
||||
print '<table><tr><td>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
|
||||
else $title=$langs->trans("ShowPreview");
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
|
||||
print '</a>';
|
||||
print '</td></tr><tr><td align="center">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</td></tr></table></td>';
|
||||
|
||||
$i++;
|
||||
|
||||
if ($i % $thumbsbyrow == 0) print '</tr>';
|
||||
}
|
||||
}
|
||||
$handle=opendir($dirtheme);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
{
|
||||
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
{
|
||||
// Disable not stable themes
|
||||
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
|
||||
|
||||
if ($i % $thumbsbyrow == 0)
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
}
|
||||
|
||||
print '<td align="center">';
|
||||
$file=$dirtheme."/".$subdir."/thumb.png";
|
||||
$url=$urltheme."/".$subdir."/thumb.png";
|
||||
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
|
||||
print '<table><tr><td>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
|
||||
else $title=$langs->trans("ShowPreview");
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
|
||||
print '</a>';
|
||||
print '</td></tr><tr><td align="center">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</td></tr></table></td>';
|
||||
|
||||
$i++;
|
||||
|
||||
if ($i % $thumbsbyrow == 0) print '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1370,7 +1370,7 @@ abstract class DolibarrModules
|
||||
{
|
||||
foreach($this->module_parts as $key => $value)
|
||||
{
|
||||
// If entity is defined
|
||||
// If entity is defined
|
||||
if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
|
||||
|
||||
@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
if (! is_object($hookmanager))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
|
||||
$hookmanager=new HookManager($this->db);
|
||||
}
|
||||
$hookmanager->initHooks(array('pdfgeneration'));
|
||||
@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes
|
||||
|
||||
|
||||
$posy+=1;
|
||||
|
||||
|
||||
// Show list of linked objects
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
|
||||
}
|
||||
|
||||
@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
|
||||
|
||||
$posy+=2;
|
||||
|
||||
$posy+=2;
|
||||
|
||||
// Show list of linked objects
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
|
||||
|
||||
|
||||
@ -154,37 +154,37 @@ class MailingTargets // This can't be abstract as it is used for some method
|
||||
{
|
||||
if (! empty($cibles[$i]['email'])) // avoid empty email address
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing,";
|
||||
$sql .= " fk_contact,";
|
||||
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
||||
$sql.= " source_type)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// Si erreur autre que doublon
|
||||
dol_syslog($this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " (fk_mailing,";
|
||||
$sql .= " fk_contact,";
|
||||
$sql .= " nom, prenom, email, other, source_url, source_id,";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
|
||||
$sql.= " source_type)";
|
||||
$sql .= " VALUES (".$mailing_id.",";
|
||||
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
|
||||
$sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// Si erreur autre que doublon
|
||||
dol_syslog($this->db->error());
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ class modMailing extends DolibarrModules
|
||||
// Permissions
|
||||
$this->rights = array();
|
||||
$this->rights_class = 'mailing';
|
||||
$r=0;
|
||||
|
||||
$r=0;
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 221; // id de la permission
|
||||
$this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission
|
||||
@ -104,28 +104,28 @@ class modMailing extends DolibarrModules
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'supprimer';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 237;
|
||||
$this->rights[$r][1] = 'View recipients and info';
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$r++;
|
||||
$this->rights[$r][0] = 237;
|
||||
$this->rights[$r][1] = 'View recipients and info';
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$this->rights[$r][5] = 'recipient';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 238;
|
||||
$this->rights[$r][1] = 'Manually send mailings';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$r++;
|
||||
$this->rights[$r][0] = 238;
|
||||
$this->rights[$r][1] = 'Manually send mailings';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$this->rights[$r][5] = 'send';
|
||||
|
||||
$r++;
|
||||
$this->rights[$r][0] = 239;
|
||||
$this->rights[$r][1] = 'Delete mailings after validation and/or sent';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$r++;
|
||||
$this->rights[$r][0] = 239;
|
||||
$this->rights[$r][1] = 'Delete mailings after validation and/or sent';
|
||||
$this->rights[$r][2] = 'd';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
|
||||
$this->rights[$r][5] = 'delete';
|
||||
|
||||
}
|
||||
|
||||
@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
|
||||
}
|
||||
|
||||
$posy+=2;
|
||||
|
||||
// Show list of linked objects
|
||||
$posy+=2;
|
||||
|
||||
// Show list of linked objects
|
||||
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
|
||||
|
||||
if ($showaddress)
|
||||
|
||||
@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
|
||||
if ($result < 0) {
|
||||
$error++; $this->errors=$interface->errors;
|
||||
}
|
||||
// Fin appel triggers
|
||||
|
||||
return 1;
|
||||
|
||||
@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
$langs->load("products");
|
||||
$langs->load("other");
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$id=GETPOST('id','int');
|
||||
$action=GETPOST('action','alpha');
|
||||
$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service';
|
||||
$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):'';
|
||||
@ -65,12 +65,12 @@ if (! $accessallowed)
|
||||
}
|
||||
|
||||
$object = new Product($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
if ($result <= 0) dol_print_error($db,'Failed to load object');
|
||||
$dir=$conf->product->multidir_output[$object->entity]; // By default
|
||||
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
|
||||
$dir=$conf->product->multidir_output[$object->entity]; // By default
|
||||
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
|
||||
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
|
||||
}
|
||||
|
||||
|
||||
@ -16,17 +16,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
$module = $object->element;
|
||||
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
|
||||
|
||||
// Special cases
|
||||
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
|
||||
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
|
||||
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
|
||||
$module = $object->element;
|
||||
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
|
||||
|
||||
// Special cases
|
||||
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
|
||||
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
|
||||
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
|
||||
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
|
||||
|
||||
$companystatic=new Societe($db);
|
||||
$contactstatic=new Contact($db);
|
||||
$contactstatic=new Contact($db);
|
||||
$userstatic=new User($db);
|
||||
|
||||
?>
|
||||
@ -73,8 +73,8 @@ $userstatic=new User($db);
|
||||
<?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?>
|
||||
<td>
|
||||
<?php
|
||||
$events=array();
|
||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
||||
$events=array();
|
||||
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
|
||||
print $form->select_company($object->socid,'socid','',1,0,0,$events);
|
||||
?>
|
||||
</td>
|
||||
@ -113,12 +113,12 @@ $userstatic=new User($db);
|
||||
<?php $var=true; ?>
|
||||
|
||||
<?php
|
||||
foreach(array('internal','external') as $source) {
|
||||
$tab = $object->liste_contact(-1,$source);
|
||||
$num=count($tab);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
foreach(array('internal','external') as $source) {
|
||||
$tab = $object->liste_contact(-1,$source);
|
||||
$num=count($tab);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$var = !$var;
|
||||
?>
|
||||
|
||||
@ -129,36 +129,36 @@ $userstatic=new User($db);
|
||||
</td>
|
||||
<td align="left">
|
||||
<?php
|
||||
if ($tab[$i]['socid'] > 0)
|
||||
{
|
||||
$companystatic->fetch($tab[$i]['socid']);
|
||||
echo $companystatic->getNomUrl(1);
|
||||
}
|
||||
if ($tab[$i]['socid'] < 0)
|
||||
{
|
||||
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
}
|
||||
if (! $tab[$i]['socid'])
|
||||
{
|
||||
echo ' ';
|
||||
if ($tab[$i]['socid'] > 0)
|
||||
{
|
||||
$companystatic->fetch($tab[$i]['socid']);
|
||||
echo $companystatic->getNomUrl(1);
|
||||
}
|
||||
if ($tab[$i]['socid'] < 0)
|
||||
{
|
||||
echo $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
}
|
||||
if (! $tab[$i]['socid'])
|
||||
{
|
||||
echo ' ';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if ($tab[$i]['source']=='internal')
|
||||
{
|
||||
$userstatic->id=$tab[$i]['id'];
|
||||
$userstatic->lastname=$tab[$i]['lastname'];
|
||||
$userstatic->firstname=$tab[$i]['firstname'];
|
||||
echo $userstatic->getNomUrl(1);
|
||||
}
|
||||
if ($tab[$i]['source']=='external')
|
||||
{
|
||||
$contactstatic->id=$tab[$i]['id'];
|
||||
$contactstatic->lastname=$tab[$i]['lastname'];
|
||||
$contactstatic->firstname=$tab[$i]['firstname'];
|
||||
echo $contactstatic->getNomUrl(1);
|
||||
if ($tab[$i]['source']=='internal')
|
||||
{
|
||||
$userstatic->id=$tab[$i]['id'];
|
||||
$userstatic->lastname=$tab[$i]['lastname'];
|
||||
$userstatic->firstname=$tab[$i]['firstname'];
|
||||
echo $userstatic->getNomUrl(1);
|
||||
}
|
||||
if ($tab[$i]['source']=='external')
|
||||
{
|
||||
$contactstatic->id=$tab[$i]['id'];
|
||||
$contactstatic->lastname=$tab[$i]['lastname'];
|
||||
$contactstatic->firstname=$tab[$i]['firstname'];
|
||||
echo $contactstatic->getNomUrl(1);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
@ -35,7 +35,7 @@ print '<!-- Includes for JQuery (Ajax library) -->'."\n";
|
||||
if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery
|
||||
else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery
|
||||
// JQuery. Must be before other includes
|
||||
$ext='.js';
|
||||
$ext='.js';
|
||||
if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz';
|
||||
print '<!-- Includes JS for JQuery -->'."\n";
|
||||
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";
|
||||
|
||||
@ -111,37 +111,37 @@ class InterfacePaypalWorkflow
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $path = $filename = $object->source;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
|
||||
{
|
||||
$element = $path = $regs[1];
|
||||
$filename = $regs[2];
|
||||
}
|
||||
// For compatibility
|
||||
if ($element == 'order') {
|
||||
$path = $filename = 'commande';
|
||||
}
|
||||
if ($element == 'invoice') {
|
||||
$path = 'compta/facture'; $filename = 'facture';
|
||||
}
|
||||
|
||||
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
|
||||
|
||||
$classname = ucfirst($filename);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
$ret = $obj->fetch('',$object->ref);
|
||||
if ($ret < 0) return -1;
|
||||
|
||||
// Add payer id
|
||||
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
|
||||
|
||||
// Add transaction id
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $path = $filename = $object->source;
|
||||
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
|
||||
{
|
||||
$element = $path = $regs[1];
|
||||
$filename = $regs[2];
|
||||
}
|
||||
// For compatibility
|
||||
if ($element == 'order') {
|
||||
$path = $filename = 'commande';
|
||||
}
|
||||
if ($element == 'invoice') {
|
||||
$path = 'compta/facture'; $filename = 'facture';
|
||||
}
|
||||
|
||||
dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
|
||||
|
||||
$classname = ucfirst($filename);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
$ret = $obj->fetch('',$object->ref);
|
||||
if ($ret < 0) return -1;
|
||||
|
||||
// Add payer id
|
||||
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
|
||||
|
||||
// Add transaction id
|
||||
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
|
||||
}
|
||||
|
||||
|
||||
@ -73,11 +73,11 @@ class Expedition extends CommonObject
|
||||
var $date_creation;
|
||||
var $date_valid;
|
||||
|
||||
// For Invoicing
|
||||
var $total_ht; // Total net of tax
|
||||
var $total_ttc; // Total with tax
|
||||
var $total_tva; // Total VAT
|
||||
var $total_localtax1; // Total Local tax 1
|
||||
// For Invoicing
|
||||
var $total_ht; // Total net of tax
|
||||
var $total_ttc; // Total with tax
|
||||
var $total_tva; // Total VAT
|
||||
var $total_localtax1; // Total Local tax 1
|
||||
var $total_localtax2; // Total Local tax 2
|
||||
|
||||
|
||||
@ -871,10 +871,10 @@ class Expedition extends CommonObject
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$this->total_ht = 0;
|
||||
$this->total_tva = 0;
|
||||
$this->total_ttc = 0;
|
||||
$this->total_localtax1 = 0;
|
||||
$this->total_ht = 0;
|
||||
$this->total_tva = 0;
|
||||
$this->total_ttc = 0;
|
||||
$this->total_localtax1 = 0;
|
||||
$this->total_localtax2 = 0;
|
||||
|
||||
while ($i < $num)
|
||||
@ -915,11 +915,11 @@ class Expedition extends CommonObject
|
||||
$line->subprice = $obj->subprice;
|
||||
$line->remise_percent = $obj->remise_percent;
|
||||
|
||||
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits);
|
||||
$this->total_ht+= $tabprice[0];
|
||||
$this->total_tva+= $tabprice[1];
|
||||
$this->total_ttc+= $tabprice[2];
|
||||
$this->total_localtax1+= $tabprice[9];
|
||||
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits);
|
||||
$this->total_ht+= $tabprice[0];
|
||||
$this->total_tva+= $tabprice[1];
|
||||
$this->total_ttc+= $tabprice[2];
|
||||
$this->total_localtax1+= $tabprice[9];
|
||||
$this->total_localtax2+= $tabprice[10];
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
@ -1212,28 +1212,28 @@ class Expedition extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify the shipping as invoiced
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function set_billed()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
|
||||
if ($this->db->query($sql) )
|
||||
/**
|
||||
* Classify the shipping as invoiced
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function set_billed()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
//TODO: Option to set order billed if 100% of order is shipped
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//TODO: Option to set order billed if 100% of order is shipped
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1257,11 +1257,11 @@ class ExpeditionLigne
|
||||
var $ref;
|
||||
|
||||
// Invoicing
|
||||
var $remise_percent;
|
||||
var $total_ht; // Total net of tax
|
||||
var $total_ttc; // Total with tax
|
||||
var $total_tva; // Total VAT
|
||||
var $total_localtax1; // Total Local tax 1
|
||||
var $remise_percent;
|
||||
var $total_ht; // Total net of tax
|
||||
var $total_ttc; // Total with tax
|
||||
var $total_tva; // Total VAT
|
||||
var $total_localtax1; // Total Local tax 1
|
||||
var $total_localtax2; // Total Local tax 2
|
||||
|
||||
|
||||
|
||||
@ -119,11 +119,11 @@ else if ($action == 'deleteline' && $user->rights->expedition->creer)
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'setaddress' && $user->rights->expedition->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setDeliveryAddress($_POST['fk_address']);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
else if ($action == 'setaddress' && $user->rights->expedition->creer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->setDeliveryAddress($_POST['fk_address']);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
}
|
||||
|
||||
|
||||
@ -210,27 +210,27 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Delivery address
|
||||
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
if ($action == 'editdelivery_address')
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
// Delivery address
|
||||
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
if ($action == 'editdelivery_address')
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -60,7 +60,7 @@ $result=restrictedArea($user,$origin,$origin_id);
|
||||
$action = GETPOST('action','alpha');
|
||||
$confirm = GETPOST('confirm','alpha');
|
||||
|
||||
//PDF
|
||||
//PDF
|
||||
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
||||
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
|
||||
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||
@ -509,10 +509,10 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'classifybilled')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->set_billed();
|
||||
else if ($action == 'classifybilled')
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->set_billed();
|
||||
}
|
||||
|
||||
|
||||
@ -872,9 +872,6 @@ else
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($object->socid);
|
||||
|
||||
// delivery link
|
||||
$object->fetchObjectLinked($object->id,$object->element,-1,-1);
|
||||
|
||||
$head=shipping_prepare_head($object);
|
||||
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
|
||||
|
||||
@ -1343,9 +1340,9 @@ else
|
||||
|
||||
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
|
||||
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
/*
|
||||
* Linked object block
|
||||
*/
|
||||
$somethingshown=$object->showLinkedObjectBlock();
|
||||
|
||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||
|
||||
@ -226,8 +226,8 @@ $sql = "SELECT e.rowid, e.ref";
|
||||
$sql.= ", s.nom, s.rowid as socid";
|
||||
$sql.= ", c.ref as commande_ref, c.rowid as commande_id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.sourcetype IN ('commande')";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.targettype IN ('shipping')";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||
$sql.= " WHERE e.entity = ".$conf->entity;
|
||||
|
||||
@ -345,7 +345,7 @@ class Livraison extends CommonObject
|
||||
if (is_readable(DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php'))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/modules/livraison/'.$modName.'.php';
|
||||
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Recuperation de la nouvelle reference
|
||||
@ -552,7 +552,7 @@ class Livraison extends CommonObject
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
|
||||
@ -562,7 +562,7 @@ class Livraison extends CommonObject
|
||||
// Delete linked object
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) $error++;
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
|
||||
@ -807,7 +807,7 @@ class Livraison extends CommonObject
|
||||
global $langs;
|
||||
|
||||
// Get the linked object
|
||||
$this->fetchObjectLinked(-1,-1,$this->id,$this->element);
|
||||
$this->fetchObjectLinked('','',$this->id,$this->element);
|
||||
//var_dump($this->linkedObjectIds);
|
||||
// Get the product ref and qty in source
|
||||
$sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
|
||||
|
||||
@ -138,7 +138,7 @@ class Product extends CommonObject
|
||||
|
||||
//! Contains detail of stock of product into each warehouse
|
||||
var $stock_warehouse=array();
|
||||
|
||||
|
||||
var $oldcopy;
|
||||
|
||||
|
||||
@ -405,7 +405,7 @@ class Product extends CommonObject
|
||||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Verification parametres
|
||||
@ -508,7 +508,7 @@ class Product extends CommonObject
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
|
||||
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
|
||||
{
|
||||
// We remove directory
|
||||
@ -527,7 +527,7 @@ class Product extends CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
@ -618,7 +618,7 @@ class Product extends CommonObject
|
||||
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// We remove directory
|
||||
@ -2405,9 +2405,12 @@ class Product extends CommonObject
|
||||
{
|
||||
$this->stock_reel = 0;
|
||||
|
||||
$sql = "SELECT reel, fk_entrepot, pmp";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock";
|
||||
$sql.= " WHERE fk_product = '".$this->id."'";
|
||||
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."entrepot as w";
|
||||
$sql.= " WHERE w.entity = (".getEntity('warehouse', 1).")";
|
||||
$sql.= " AND w.rowid = ps.fk_entrepot";
|
||||
$sql.= " AND ps.fk_product = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::load_stock sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -76,6 +76,8 @@ class Entrepot extends CommonObject
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Si libelle non defini, erreur
|
||||
if ($this->libelle == '')
|
||||
{
|
||||
@ -87,8 +89,8 @@ class Entrepot extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author, label)";
|
||||
$sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)";
|
||||
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
@ -99,7 +101,7 @@ class Entrepot extends CommonObject
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
if ( $this->update($id, $user) > 0)
|
||||
if ($this->update($id, $user) > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $id;
|
||||
@ -184,7 +186,6 @@ class Entrepot extends CommonObject
|
||||
*/
|
||||
function delete($user)
|
||||
{
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement";
|
||||
@ -338,7 +339,8 @@ class Entrepot extends CommonObject
|
||||
|
||||
$sql = "SELECT rowid, label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||
$sql.= " WHERE statut = ".$status;
|
||||
$sql.= " WHERE entity IN (".getEntity('warehouse', 1).")";
|
||||
$sql.= " AND statut = ".$status;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$i = 0;
|
||||
@ -363,13 +365,13 @@ class Entrepot extends CommonObject
|
||||
*/
|
||||
function nb_products()
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
$ret=array();
|
||||
|
||||
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
|
||||
$sql .= " WHERE ps.fk_entrepot = ".$this->id." AND ps.fk_product=p.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " WHERE ps.fk_entrepot = ".$this->id;
|
||||
$sql.= " AND ps.fk_product = p.rowid";
|
||||
|
||||
//print $sql;
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@ -44,7 +44,7 @@ $id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
|
||||
$ref = GETPOST('ref');
|
||||
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'produit&stock',$id,'product','','',$fieldid);
|
||||
$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid);
|
||||
|
||||
$mesg = '';
|
||||
|
||||
@ -217,6 +217,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '</tr>';
|
||||
|
||||
// Real stock
|
||||
$product->load_stock();
|
||||
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
|
||||
print '<td>'.$product->stock_reel;
|
||||
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user