Fix: converting lines delimiter

This commit is contained in:
Regis Houssin 2012-07-02 17:20:20 +02:00
parent d593878c78
commit 897d59d8fa
41 changed files with 953 additions and 953 deletions

View File

@ -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'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
switch ($_SERVER['REQUEST_METHOD']) { switch ($_SERVER['REQUEST_METHOD']) {
case 'OPTIONS': case 'OPTIONS':
break; break;
case 'HEAD': case 'HEAD':
case 'GET': case 'GET':

View File

@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
$module = $subelement = $ext_element; $module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{ {
$module = $regs[1]; $module = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }

View File

@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
require('../../main.inc.php'); require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
$field = GETPOST('field','alpha',2); $field = GETPOST('field','alpha',2);
$element = GETPOST('element','alpha',2); $element = GETPOST('element','alpha',2);
$table_element = GETPOST('table_element','alpha',2); $table_element = GETPOST('table_element','alpha',2);
$fk_element = GETPOST('fk_element','alpha',2); $fk_element = GETPOST('fk_element','alpha',2);
/* /*
@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($
} }
else else
{ {
$module = $subelement = $ext_element; $module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
{ {
$module = $regs[1]; $module = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }
dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');

View File

@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname))
$soc->fetch($id); $soc->fetch($id);
$return=array(); $return=array();
$return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true);
$return['num'] = $form->num; $return['num'] = $form->num;
$return['error'] = $form->error; $return['error'] = $form->error;
echo json_encode($return); echo json_encode($return);
} }

View File

@ -206,28 +206,28 @@ class Conf
//var_dump($this->modules); //var_dump($this->modules);
//var_dump($this->modules_parts); //var_dump($this->modules_parts);
// Object $mc // Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{ {
global $mc; global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) $mc = new ActionsMulticompany($db); if ($ret) $mc = new ActionsMulticompany($db);
} }
// Second or others levels object // Second or others levels object
$this->propal->cloture = (object) array(); $this->propal->cloture = (object) array();
$this->propal->facturation = (object) array(); $this->propal->facturation = (object) array();
$this->commande->client = (object) array(); $this->commande->client = (object) array();
$this->commande->fournisseur = (object) array(); $this->commande->fournisseur = (object) array();
$this->facture->client = (object) array(); $this->facture->client = (object) array();
$this->facture->fournisseur = (object) array(); $this->facture->fournisseur = (object) array();
$this->fournisseur->commande = (object) array(); $this->fournisseur->commande = (object) array();
$this->fournisseur->facture = (object) array(); $this->fournisseur->facture = (object) array();
$this->contrat->services = (object) array(); $this->contrat->services = (object) array();
$this->contrat->services->inactifs = (object) array(); $this->contrat->services->inactifs = (object) array();
$this->contrat->services->expires = (object) array(); $this->contrat->services->expires = (object) array();
$this->adherent->cotisation = (object) array(); $this->adherent->cotisation = (object) array();
$this->bank->rappro = (object) array(); $this->bank->rappro = (object) array();
$this->bank->cheque = (object) array(); $this->bank->cheque = (object) array();
// Clean some variables // Clean some variables
@ -261,7 +261,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules // Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module) 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"); $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
// For backward compatibility // For backward compatibility
$this->$module->dir_output = $rootfordata."/".$module; $this->$module->dir_output = $rootfordata."/".$module;
@ -277,14 +277,14 @@ class Conf
$this->admin->dir_temp=$rootfordata.'/admin/temp'; $this->admin->dir_temp=$rootfordata.'/admin/temp';
// For user storage // 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"); $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility // For backward compatibility
$this->user->dir_output=$rootforuser."/users"; $this->user->dir_output=$rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp"; $this->user->dir_temp=$rootforuser."/users/temp";
// For propal storage // For propal storage
$this->propal->dir_output=$rootforuser."/propale"; $this->propal->dir_output=$rootforuser."/propale";
$this->propal->dir_temp=$rootforuser."/propale/temp"; $this->propal->dir_temp=$rootforuser."/propale/temp";
// Exception: Some dir are not the name of module. So we keep exception here // 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_output=array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp"); $this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility // For backward compatibility
$this->product->dir_output=$rootfordata."/produit"; $this->product->dir_output=$rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp"; $this->product->dir_temp =$rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit"; $this->service->dir_output=$rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp"; $this->service->dir_temp =$rootfordata."/produit/temp";
// Module contrat // Module contrat
@ -429,10 +429,10 @@ class Conf
if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php';
elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php';
// Object $mc // Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
{ {
if (is_object($mc)) $mc->setValues($this); if (is_object($mc)) $mc->setValues($this);
} }
} }
} }

View File

@ -65,9 +65,9 @@ class FileUpload
$pathname = 'compta/facture'; $pathname = 'compta/facture';
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
} }
elseif ($element == 'project') { elseif ($element == 'project') {
$element = $pathname = 'projet'; $element = $pathname = 'projet';
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
} }
elseif ($element == 'fichinter') { elseif ($element == 'fichinter') {
$element='ficheinter'; $element='ficheinter';
@ -108,11 +108,11 @@ class FileUpload
'accept_file_types' => '/.+$/i', 'accept_file_types' => '/.+$/i',
// The maximum number of files for the upload directory: // The maximum number of files for the upload directory:
'max_number_of_files' => null, 'max_number_of_files' => null,
// Image resolution restrictions: // Image resolution restrictions:
'max_width' => null, 'max_width' => null,
'max_height' => null, 'max_height' => null,
'min_width' => 1, 'min_width' => 1,
'min_height' => 1, 'min_height' => 1,
// Set the following option to false to enable resumable uploads: // Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true, 'discard_aborted_uploads' => true,
'image_versions' => array( 'image_versions' => array(
@ -131,7 +131,7 @@ class FileUpload
'thumbnail' => array( 'thumbnail' => array(
'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/', 'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/',
'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$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 'max_height' => 80
) )
) )
@ -148,14 +148,14 @@ class FileUpload
*/ */
protected function getFullUrl() protected function getFullUrl()
{ {
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
return return
($https ? 'https://' : 'http://'). ($https ? 'https://' : 'http://').
(!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : '').
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].
($https && $_SERVER['SERVER_PORT'] === 443 || ($https && $_SERVER['SERVER_PORT'] === 443 ||
$_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))).
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
} }
/** /**
@ -165,13 +165,13 @@ class FileUpload
* @return void * @return void
*/ */
protected function setFileDeleteUrl($file) protected function setFileDeleteUrl($file)
{ {
$file->delete_url = $this->options['script_url'] $file->delete_url = $this->options['script_url']
.'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
$file->delete_type = $this->options['delete_type']; $file->delete_type = $this->options['delete_type'];
if ($file->delete_type !== 'DELETE') { if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE'; $file->delete_url .= '&_method=DELETE';
} }
} }
/** /**
@ -260,9 +260,9 @@ class FileUpload
$file->error = $error; $file->error = $error;
return false; return false;
} }
if (!$file->name) { if (!$file->name) {
$file->error = 'missingFileName'; $file->error = 'missingFileName';
return false; return false;
} }
if (!preg_match($this->options['accept_file_types'], $file->name)) { if (!preg_match($this->options['accept_file_types'], $file->name)) {
$file->error = 'acceptFileTypes'; $file->error = 'acceptFileTypes';
@ -314,10 +314,10 @@ class FileUpload
* @return string ??? * @return string ???
*/ */
protected function upcountNameCallback($matches) protected function upcountNameCallback($matches)
{ {
$index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1;
$ext = isset($matches[2]) ? $matches[2] : ''; $ext = isset($matches[2]) ? $matches[2] : '';
return ' ('.$index.')'.$ext; return ' ('.$index.')'.$ext;
} }
/** /**
@ -327,8 +327,8 @@ class FileUpload
* @return string ??? * @return string ???
*/ */
protected function upcountName($name) 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 * @return void
*/ */
protected function trimFileName($name, $type, $index) protected function trimFileName($name, $type, $index)
{ {
// Remove path information and dots around the filename, to prevent uploading // Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files. // into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename: // Also remove control characters and spaces (\x00..\x20) around the filename:
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); $file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
// Add missing file extension for known image types: // Add missing file extension for known image types:
if (strpos($file_name, '.') === false && if (strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1]; $file_name .= '.'.$matches[1];
} }
if ($this->options['discard_aborted_uploads']) if ($this->options['discard_aborted_uploads'])
{ {
while(is_file($this->options['upload_dir'].$file_name)) while(is_file($this->options['upload_dir'].$file_name))
{ {
$file_name = $this->upcountName($file_name); $file_name = $this->upcountName($file_name);
} }
} }
return $file_name; return $file_name;
} }
/** /**
@ -367,33 +367,33 @@ class FileUpload
* @return int Success or not * @return int Success or not
*/ */
protected function orientImage($file_path) protected function orientImage($file_path)
{ {
$exif = @exif_read_data($file_path); $exif = @exif_read_data($file_path);
if ($exif === false) { if ($exif === false) {
return false; return false;
} }
$orientation = intval(@$exif['Orientation']); $orientation = intval(@$exif['Orientation']);
if (!in_array($orientation, array(3, 6, 8))) { if (!in_array($orientation, array(3, 6, 8))) {
return false; return false;
} }
$image = @imagecreatefromjpeg($file_path); $image = @imagecreatefromjpeg($file_path);
switch ($orientation) { switch ($orientation) {
case 3: case 3:
$image = @imagerotate($image, 180, 0); $image = @imagerotate($image, 180, 0);
break; break;
case 6: case 6:
$image = @imagerotate($image, 270, 0); $image = @imagerotate($image, 270, 0);
break; break;
case 8: case 8:
$image = @imagerotate($image, 90, 0); $image = @imagerotate($image, 90, 0);
break; break;
default: default:
return false; return false;
} }
$success = imagejpeg($image, $file_path); $success = imagejpeg($image, $file_path);
// Free up memory (imagedestroy does not delete files): // Free up memory (imagedestroy does not delete files):
@imagedestroy($image); @imagedestroy($image);
return $success; return $success;
} }
/** /**
@ -416,40 +416,40 @@ class FileUpload
$file->type = $type; $file->type = $type;
if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0) if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0)
{ {
$file_path = $this->options['upload_dir'].$file->name; $file_path = $this->options['upload_dir'].$file->name;
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache(); clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) { if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads) // multipart/formdata uploads (POST method uploads)
if ($append_file) if ($append_file)
{ {
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
} else { } else {
dol_move_uploaded_file($uploaded_file, $file_path, 1); dol_move_uploaded_file($uploaded_file, $file_path, 1);
} }
} }
else else
{ {
// Non-multipart uploads (PUT method support) // Non-multipart uploads (PUT method support)
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
} }
$file_size = filesize($file_path); $file_size = filesize($file_path);
if ($file_size === $file->size) if ($file_size === $file->size)
{ {
$file->url = $this->options['upload_url'].rawurlencode($file->name); $file->url = $this->options['upload_url'].rawurlencode($file->name);
foreach($this->options['image_versions'] as $version => $options) foreach($this->options['image_versions'] as $version => $options)
{ {
if ($this->createScaledImage($file->name, $options)) if ($this->createScaledImage($file->name, $options))
{ {
$tmp=explode('.',$file->name); $tmp=explode('.',$file->name);
$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
} }
} }
} }
else if ($this->options['discard_aborted_uploads']) else if ($this->options['discard_aborted_uploads'])
{ {
unlink($file_path); unlink($file_path);
$file->error = 'abort'; $file->error = 'abort';
} }
$file->size = $file_size; $file->size = $file_size;
$this->setFileDeleteUrl($file); $this->setFileDeleteUrl($file);
@ -486,15 +486,15 @@ class FileUpload
public function post() public function post()
{ {
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE')
{ {
return $this->delete(); return $this->delete();
} }
$upload = isset($_FILES[$this->options['param_name']]) ? $upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : null; $_FILES[$this->options['param_name']] : null;
$info = array(); $info = array();
if ($upload && is_array($upload['tmp_name'])) 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: // $_FILES is a multi-dimensional array:
foreach ($upload['tmp_name'] as $index => $value) { foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handleFileUpload( $info[] = $this->handleFileUpload(
@ -507,7 +507,7 @@ class FileUpload
); );
} }
} elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { } 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: // $_FILES is a one-dimensional array:
$info[] = $this->handleFileUpload( $info[] = $this->handleFileUpload(
isset($upload['tmp_name']) ? $upload['tmp_name'] : null, isset($upload['tmp_name']) ? $upload['tmp_name'] : null,
@ -519,11 +519,11 @@ class FileUpload
} }
header('Vary: Accept'); header('Vary: Accept');
$json = json_encode($info); $json = json_encode($info);
$redirect = isset($_REQUEST['redirect']) ? $redirect = isset($_REQUEST['redirect']) ?
stripslashes($_REQUEST['redirect']) : null; stripslashes($_REQUEST['redirect']) : null;
if ($redirect) { if ($redirect) {
header('Location: '.sprintf($redirect, rawurlencode($json))); header('Location: '.sprintf($redirect, rawurlencode($json)));
return; return;
} }
if (isset($_SERVER['HTTP_ACCEPT']) && if (isset($_SERVER['HTTP_ACCEPT']) &&
(strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) { (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {

View File

@ -285,12 +285,12 @@ class Form
if (! empty($tmp[2])) $savemethod=$tmp[2]; if (! empty($tmp[2])) $savemethod=$tmp[2];
if (! empty($tmp[3])) $button_only=true; if (! empty($tmp[3])) $button_only=true;
} }
else if (preg_match('/^textarea/',$inputType)) else if (preg_match('/^textarea/',$inputType))
{ {
$tmp=explode(':',$inputType); $tmp=explode(':',$inputType);
$inputType=$tmp[0]; $inputType=$tmp[0];
if (! empty($tmp[1])) $rows=$tmp[1]; if (! empty($tmp[1])) $rows=$tmp[1];
if (! empty($tmp[2])) $cols=$tmp[2]; if (! empty($tmp[2])) $cols=$tmp[2];
} }
else if (preg_match('/^ckeditor/',$inputType)) else if (preg_match('/^ckeditor/',$inputType))
{ {
@ -790,20 +790,20 @@ class Form
} }
} }
/** /**
* Return list of all contacts (for a third party or all) * Return list of all contacts (for a third party or all)
* *
* @param int $socid Id ot third party or 0 for all * @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne * @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field) * @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 int $showempty 0=no empty value, 1=add an empty value
* @param string $exclude List of contacts id to exclude * @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list * @param string $limitto Disable answers that are not id in this array list
* @param string $showfunction Add function into label * @param string $showfunction Add function into label
* @param string $moreclass Add more class to class style * @param string $moreclass Add more class to class style
* @return int <0 if KO, Nb of contact in list if OK * @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='') 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); print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass);
return $this->num; return $this->num;
@ -2725,50 +2725,50 @@ class Form
print $this->selectcurrency($selected,$htmlname); print $this->selectcurrency($selected,$htmlname);
} }
/** /**
* Load into the cache all currencies * Load into the cache all currencies
* *
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/ */
function load_cache_currencies() function load_cache_currencies()
{ {
global $langs; global $langs;
$langs->load("dict"); $langs->load("dict");
if (count($this->cache_currencies)) return 0; // Cache deja charge if (count($this->cache_currencies)) return 0; // Cache deja charge
$sql = "SELECT code_iso, label, unicode"; $sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1"; $sql.= " WHERE active = 1";
$sql.= " ORDER BY code_iso ASC"; $sql.= " ORDER BY code_iso ASC";
dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG); dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // 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]['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); $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++; $i++;
} }
array_multisort($label, SORT_ASC, $this->cache_currencies); array_multisort($label, SORT_ASC, $this->cache_currencies);
return $num; return $num;
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
/** /**
@ -2833,33 +2833,33 @@ class Form
print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type);
} }
/** /**
* Load into the cache vat rates of a country * Load into the cache vat rates of a country
* *
* @param string $country_code Country code * @param string $country_code Country code
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @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; global $langs;
$num = count($this->cache_vatrates); $num = count($this->cache_vatrates);
if ($num > 0) return $num; // Cache deja charge if ($num > 0) return $num; // Cache deja charge
$sql = "SELECT DISTINCT t.taux, t.recuperableonly"; $sql = "SELECT DISTINCT t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.fk_pays = p.rowid"; $sql.= " WHERE t.fk_pays = p.rowid";
$sql.= " AND t.active = 1"; $sql.= " AND t.active = 1";
$sql.= " AND p.code IN (".$country_code.")"; $sql.= " AND p.code IN (".$country_code.")";
$sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num)
{ {
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->cache_vatrates[$i]['txtva'] = $obj->taux; $this->cache_vatrates[$i]['txtva'] = $obj->taux;
@ -2879,7 +2879,7 @@ class Form
{ {
$this->error = '<font class="error">'.$this->db->error().'</font>'; $this->error = '<font class="error">'.$this->db->error().'</font>';
return -2; return -2;
} }
} }
/** /**
@ -2975,32 +2975,32 @@ class Form
if ($num > 0) if ($num > 0)
{ {
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{ {
$defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod);
$defaultnpr=get_default_npr($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. // 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 // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
{ {
$defaulttx = $this->cache_vatrates[$num-1]['txtva']; $defaulttx = $this->cache_vatrates[$num-1]['txtva'];
} }
if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
foreach ($this->cache_vatrates as $rate) foreach ($this->cache_vatrates as $rate)
{ {
$return.= '<option value="'.$rate['txtva']; $return.= '<option value="'.$rate['txtva'];
$return.= $rate['nprtva'] ? '*': ''; $return.= $rate['nprtva'] ? '*': '';
$return.= '"'; $return.= '"';
if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
{ {
$return.= ' selected="selected"'; $return.= ' selected="selected"';
} }
$return.= '>'.vatrate($rate['libtva']); $return.= '>'.vatrate($rate['libtva']);
$return.= $rate['nprtva'] ? ' *': ''; $return.= $rate['nprtva'] ? ' *': '';
$return.= '</option>'; $return.= '</option>';
@ -3391,79 +3391,79 @@ class Form
return $out; return $out;
} }
/** /**
* Show a multiselect form from an array. * Show a multiselect form from an array.
* *
* @param string $htmlname Name of select * @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 array $selected Preselected keys
* @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" * @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 int $value_as_key 1 to use value as key
* @param string $option Valeur de l'option en fonction du type choisi * @param string $option Valeur de l'option en fonction du type choisi
* @param int $translate Translate and encode value * @param int $translate Translate and encode value
* @return string HTML multiselect string * @return string HTML multiselect string
*/ */
function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0) function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0)
{ {
global $conf, $langs; global $conf, $langs;
$out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n"; $out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n";
if (is_array($array) && ! empty($array)) if (is_array($array) && ! empty($array))
{ {
if ($value_as_key) $array=array_combine($array, $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 ($selected as $selected_value)
{ {
foreach($array as $key => $value) foreach($array as $key => $value)
{ {
if ($selected_value == $key) if ($selected_value == $key)
{ {
$value=$array[$selected_value]; $value=$array[$selected_value];
$out.= '<option value="'.$key.'" selected="selected">'; $out.= '<option value="'.$key.'" selected="selected">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
unset($array[$key]); unset($array[$key]);
} }
} }
} }
if (! empty($array)) if (! empty($array))
{ {
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$out.= '<option value="'.$key.'">'; $out.= '<option value="'.$key.'">';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
} }
} }
} }
else else
{ {
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$out.= '<option value="'.$key.'"'; $out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected)) if (is_array($selected) && ! empty($selected) && in_array($key, $selected))
{ {
$out.= ' selected="selected"'; $out.= ' selected="selected"';
} }
$out.= '>'; $out.= '>';
$newval = ($translate ? $langs->trans(ucfirst($value)) : $value); $newval = ($translate ? $langs->trans(ucfirst($value)) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval); $newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out.= dol_htmlentitiesbr($newval); $out.= dol_htmlentitiesbr($newval);
$out.= '</option>'."\n"; $out.= '</option>'."\n";
} }
} }
} }
$out.= '</select>'."\n"; $out.= '</select>'."\n";
return $out; return $out;
} }

View File

@ -813,7 +813,7 @@ class FormFile
// Max file size // Max file size
$max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); $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(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php');
// Include template // Include template

View File

@ -170,9 +170,9 @@ class SMTPs
*/ */
var $_smtpsRelatedBoundary = null; var $_smtpsRelatedBoundary = null;
/** /**
* Alternative Boundary * Alternative Boundary
*/ */
var $_smtpsAlternativeBoundary = null; var $_smtpsAlternativeBoundary = null;
/** /**
@ -1223,8 +1223,8 @@ class SMTPs
if (key_exists('image', $this->_msgContent)) if (key_exists('image', $this->_msgContent))
{ {
$content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n";
$content .= "\r\n"; $content .= "\r\n";
$content .= "--" . $this->_getBoundary('alternative') . "\r\n"; $content .= "--" . $this->_getBoundary('alternative') . "\r\n";
} }
@ -1268,21 +1268,21 @@ class SMTPs
. $_data['data'] . "\r\n"; . $_data['data'] . "\r\n";
} }
// always end related and end alternative after inline images // always end related and end alternative after inline images
$content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n";
$content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n";
$content.= "\r\n"; $content.= "\r\n";
} }
else else
{ {
if (key_exists('image', $this->_msgContent)) if (key_exists('image', $this->_msgContent))
{ {
$content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n";
$content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message $content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message
$content.= "--" . $this->_getBoundary('alternative') . "\r\n"; $content.= "--" . $this->_getBoundary('alternative') . "\r\n";
$content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n";
$content.= "\r\n"; $content.= "\r\n";
$content.= "--" . $this->_getBoundary('related') . "\r\n"; $content.= "--" . $this->_getBoundary('related') . "\r\n";
} }
$content .= 'Content-Type: ' . $_content['mimeType'] . '; ' $content .= 'Content-Type: ' . $_content['mimeType'] . '; '
@ -1490,7 +1490,7 @@ class SMTPs
function _setBoundary() function _setBoundary()
{ {
$this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; $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")); $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"));
} }

View File

@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->depends); $num = count($objMod->depends);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
if (file_exists($dir.$objMod->depends[$i].".class.php")) if (file_exists($dir.$objMod->depends[$i].".class.php"))
{ {
activateModule($objMod->depends[$i]); activateModule($objMod->depends[$i]);
} }
} }
} }
@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1)
$num = count($objMod->conflictwith); $num = count($objMod->conflictwith);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
{ {
if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) if (file_exists($dir.$objMod->conflictwith[$i].".class.php"))
{ {
unActivateModule($objMod->conflictwith[$i],0); unActivateModule($objMod->conflictwith[$i],0);
} }
} }
} }
@ -1128,16 +1128,16 @@ function form_constantes($tableau)
print '</table>'; print '</table>';
} }
/** /**
* Add document model used by doc generator * Add document model used by doc generator
* *
* @param string $name Model name * @param string $name Model name
* @param string $type Model type * @param string $type Model type
* @param string $label Model label * @param string $label Model label
* @param string $description Model description * @param string $description Model description
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function addDocumentModel($name, $type, $label='', $description='') function addDocumentModel($name, $type, $label='', $description='')
{ {
global $db, $conf; global $db, $conf;
@ -1150,51 +1150,51 @@ function addDocumentModel($name, $type, $label='', $description='')
$sql.= ")"; $sql.= ")";
dol_syslog("admin.lib::addDocumentModel sql=".$sql); dol_syslog("admin.lib::addDocumentModel sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$db->commit(); $db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
/** /**
* Delete document model used by doc generator * Delete document model used by doc generator
* *
* @param string $name Model name * @param string $name Model name
* @param string $type Model type * @param string $type Model type
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delDocumentModel($name, $type) function delDocumentModel($name, $type)
{ {
global $db, $conf; global $db, $conf;
$db->begin(); $db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$db->escape($name)."'"; $sql.= " WHERE nom = '".$db->escape($name)."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
dol_syslog("admin.lib::delDocumentModel sql=".$sql); dol_syslog("admin.lib::delDocumentModel sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$db->commit(); $db->commit();
return 1; return 1;
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
$db->rollback(); $db->rollback();
return -1; return -1;
} }
} }
?> ?>

View File

@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
return $i; return $i;
} }
/** /**
* Show html area for list of addresses * Show html area for list of addresses
* *
* @param Conf $conf Object conf * @param Conf $conf Object conf
* @param Translate $langs Object langs * @param Translate $langs Object langs
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param Object $object Third party object * @param Object $object Third party object
* @param string $backtopage Url to go once address is created * @param string $backtopage Url to go once address is created
* @return void * @return void
*/ */
function show_addresses($conf,$langs,$db,$object,$backtopage='') function show_addresses($conf,$langs,$db,$object,$backtopage='')
{ {
global $user; global $user;
global $bc; 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); $addressstatic = new Address($db);
$num = $addressstatic->fetch_lines($object->id); $num = $addressstatic->fetch_lines($object->id);
$buttoncreate=''; $buttoncreate='';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n"; $buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
} }
print "\n"; print "\n";
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,''); print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
print "\n".'<table class="noborder" width="100%">'."\n"; print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("CompanyName").'</td>'; print '<td>'.$langs->trans("CompanyName").'</td>';
print '<td>'.$langs->trans("Town").'</td>'; print '<td>'.$langs->trans("Town").'</td>';
print '<td>'.$langs->trans("Country").'</td>'; print '<td>'.$langs->trans("Country").'</td>';
print '<td>'.$langs->trans("Tel").'</td>'; print '<td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td>'; print '<td>'.$langs->trans("Fax").'</td>';
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
if ($num > 0) if ($num > 0)
{ {
$var=true; $var=true;
foreach ($addressstatic->lines as $address) foreach ($addressstatic->lines as $address)
{ {
$var = !$var; $var = !$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td>'; print '<td>';
$addressstatic->id = $address->id; $addressstatic->id = $address->id;
$addressstatic->label = $address->label; $addressstatic->label = $address->label;
print $addressstatic->getNomUrl(1); print $addressstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'.$address->name.'</td>'; print '<td>'.$address->name.'</td>';
print '<td>'.$address->town.'</td>'; print '<td>'.$address->town.'</td>';
$img=picto_from_langcode($address->country_code); $img=picto_from_langcode($address->country_code);
print '<td>'.($img?$img.' ':'').$address->country.'</td>'; print '<td>'.($img?$img.' ':'').$address->country.'</td>';
// Lien click to dial // Lien click to dial
print '<td>'; print '<td>';
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL'); print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX'); print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
print '</td>'; print '</td>';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<td align="right">'; print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">'; print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
} }
else else
{ {
//print "<tr ".$bc[$var].">"; //print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>'; //print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
//print "</tr>\n"; //print "</tr>\n";
} }
print "\n</table>\n"; print "\n</table>\n";
print "<br>\n"; print "<br>\n";
return $num; return $num;
} }
/** /**

View File

@ -39,11 +39,11 @@ function contract_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $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][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans("ContactsAddresses"); $head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $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 // $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'); 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][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note"); $head[$h][1] = $langs->trans("Note");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -43,11 +43,11 @@ function fichinter_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $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][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('InterventionContact'); $head[$h][1] = $langs->trans('InterventionContact');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $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 // $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'); 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][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -507,9 +507,9 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
*/ */
function dol_unescapefile($filename) function dol_unescapefile($filename)
{ {
// Remove path information and dots around the filename, to prevent uploading // Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files. // into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename: // Also remove control characters and spaces (\x00..\x20) around the filename:
return trim(basename($filename), ".\x00..\x20"); 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)) if (is_object($object))
{ {
$object->src_file=$dest_file; $object->src_file=$dest_file;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf); $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $errors=$interface->errors; $error++; $errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
} }
else else

View File

@ -41,11 +41,11 @@ function facturefourn_prepare_head($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $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][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $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 // $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'); 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][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }
@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object)
$h++; $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][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $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 // $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'); 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][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Notes"); $head[$h][1] = $langs->trans("Notes");
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -4007,36 +4007,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
if (! is_array($arraycolor)) return $colorifnotfound; if (! is_array($arraycolor)) return $colorifnotfound;
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
} }
/** /**
* Convert a currency code into its symbol * Convert a currency code into its symbol
* *
* @param string $currency_code Currency code * @param string $currency_code Currency code
* @return string Currency symbol encoded into UTF8 * @return string Currency symbol encoded into UTF8
*/ */
function getCurrencySymbol($currency_code) function getCurrencySymbol($currency_code)
{ {
global $db, $form; global $db, $form;
$currency_sign = ''; $currency_sign = '';
if (! is_object($form)) $form = new Form($db); if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies(); $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'])) 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) foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{ {
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES'); $currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
} }
} }
else else
{ {
$currency_sign = $currency_code; $currency_sign = $currency_code;
} }
return $currency_sign; return $currency_sign;
} }
if (! function_exists('getmypid')) if (! function_exists('getmypid'))

View File

@ -185,7 +185,7 @@ function dol_print_object_info($object)
$deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
$deltadateforuser=round($deltadateforclient-$deltadateforserver); $deltadateforuser=round($deltadateforclient-$deltadateforserver);
//print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
// Import key // Import key
if (isset($object->import_key)) if (isset($object->import_key))

View File

@ -40,11 +40,11 @@ function facture_prepare_head($object)
$head[$h][2] = 'compta'; $head[$h][2] = 'compta';
$h++; $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][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $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 // $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'); 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][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -25,60 +25,60 @@
if (! function_exists('json_encode')) if (! function_exists('json_encode'))
{ {
/** /**
* Implement json_encode for PHP that does not support it * Implement json_encode for PHP that does not support it
* *
* @param mixed $elements PHP Object to json encode * @param mixed $elements PHP Object to json encode
* @return string Json encoded string * @return string Json encoded string
*/ */
function json_encode($elements) function json_encode($elements)
{ {
return dol_json_encode($elements); return dol_json_encode($elements);
} }
} }
/** /**
* Implement json_encode for PHP that does not support it * Implement json_encode for PHP that does not support it
* *
* @param mixed $elements PHP Object to json encode * @param mixed $elements PHP Object to json encode
* @return string Json encoded string * @return string Json encoded string
*/ */
function dol_json_encode($elements) function dol_json_encode($elements)
{ {
$num = count($elements); $num = count($elements);
// determine type // determine type
if (is_numeric(key($elements))) if (is_numeric(key($elements)))
{ {
// indexed (list) // indexed (list)
$output = '['; $output = '[';
for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i) for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i)
{ {
if (is_array($elements[$i])) $output.= json_encode($elements[$i]); if (is_array($elements[$i])) $output.= json_encode($elements[$i]);
else $output .= _val($elements[$i]); else $output .= _val($elements[$i]);
if($i !== $last) $output.= ','; if($i !== $last) $output.= ',';
} }
$output.= ']'; $output.= ']';
} }
else else
{ {
// associative (object) // associative (object)
$output = '{'; $output = '{';
$last = $num - 1; $last = $num - 1;
$i = 0; $i = 0;
foreach($elements as $key => $value) foreach($elements as $key => $value)
{ {
$output .= '"'.$key.'":'; $output .= '"'.$key.'":';
if (is_array($value)) $output.= json_encode($value); if (is_array($value)) $output.= json_encode($value);
else $output .= _val($value); else $output .= _val($value);
if ($i !== $last) $output.= ','; if ($i !== $last) $output.= ',';
++$i; ++$i;
} }
$output.= '}'; $output.= '}';
} }
// return // return
return $output; return $output;
} }
/** /**
@ -189,70 +189,70 @@ function _val($val)
if (! function_exists('json_decode')) if (! function_exists('json_decode'))
{ {
/** /**
* Implement json_decode for PHP that does not support it * Implement json_decode for PHP that does not support it
* *
* @param string $json Json encoded to PHP Object or Array * @param string $json Json encoded to PHP Object or Array
* @param bool $assoc False return an object, true return an array * @param bool $assoc False return an object, true return an array
* @return mixed Object or Array * @return mixed Object or Array
*/ */
function json_decode($json, $assoc=false) function json_decode($json, $assoc=false)
{ {
return dol_json_decode($json, $assoc); return dol_json_decode($json, $assoc);
} }
} }
/** /**
* Implement json_decode for PHP that does not support it * Implement json_decode for PHP that does not support it
* *
* @param string $json Json encoded to PHP Object or Array * @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 ! * @param bool $assoc False return an object, true return an array. Try to always use it with true !
* @return mixed Object or Array * @return mixed Object or Array
*/ */
function dol_json_decode($json, $assoc=false) function dol_json_decode($json, $assoc=false)
{ {
$comment = false; $comment = false;
$out=''; $out='';
$strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length
for ($i=0; $i<$strLength; $i++) for ($i=0; $i<$strLength; $i++)
{ {
if (! $comment) if (! $comment)
{ {
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
else if ($json[$i] == ':') $out.= ' => '; else if ($json[$i] == ':') $out.= ' => ';
else $out.=$json[$i]; else $out.=$json[$i];
} }
else $out.= $json[$i]; else $out.= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;
} }
$out=_unval($out); $out=_unval($out);
// Return an array // Return an array
if ($out != '') eval('$array = '.$out.';'); if ($out != '') eval('$array = '.$out.';');
else $array=array(); else $array=array();
// Return an object // Return an object
if (! $assoc) if (! $assoc)
{ {
if (! empty($array)) if (! empty($array))
{ {
$object = false; $object = false;
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$object->{$key} = $value; $object->{$key} = $value;
} }
return $object; return $object;
} }
return false; return false;
} }
return $array; return $array;
} }
/** /**

View File

@ -68,11 +68,11 @@ function commande_prepare_head($object)
$h++; $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][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }
@ -91,11 +91,11 @@ function commande_prepare_head($object)
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $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][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes'); $head[$h][1] = $langs->trans('Notes');
$head[$h][2] = 'note'; $head[$h][2] = 'note';
$h++; $h++;
} }

View File

@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
} }
} }
/** /**
* Show linked objects for PDF generation * Show linked objects for PDF generation
* *
* @param PDF &$pdf Object PDF * @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 string $default_font_size Font size
* @param HookManager $hookmanager Hook manager object * @param HookManager $hookmanager Hook manager object
* @return void * @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); $linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager);
if (! empty($linkedobjects)) 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"])) if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
{ {
$posy+=3; $posy+=3;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align); $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) function pdf_getCurrencySymbol(&$pdf, $currency_code)
{ {
global $db, $form; global $db, $form;
$currency_sign = ''; $currency_sign = '';
if (! is_object($form)) $form = new Form($db); if (! is_object($form)) $form = new Form($db);
$form->load_cache_currencies(); $form->load_cache_currencies();
if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) 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) foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
{ {
$currency_sign.= $pdf->unichr($unicode); $currency_sign.= $pdf->unichr($unicode);
} }
} }
else else
{ {
$currency_sign = $currency_code; $currency_sign = $currency_code;
} }
return $currency_sign; 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); $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs);
} }
} }
else if ($objecttype == 'contrat') else if ($objecttype == 'contrat')
{ {
$outputlangs->load('contracts'); $outputlangs->load('contracts');
$num=count($objects); $num=count($objects);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs); $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs);
} }
} }
} }
// For add external linked objects // For add external linked objects
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
$action=''; $action='';
$hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $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; if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
} }

View File

@ -155,9 +155,9 @@ function product_admin_prepare_head($object=null)
if ($conf->global->MAIN_FEATURES_LEVEL > 1) if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{ {
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php'; $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php';
$head[$h][1] = $langs->trans("Tools"); $head[$h][1] = $langs->trans("Tools");
$head[$h][2] = 'tools'; $head[$h][2] = 'tools';
$h++; $h++;
} }

View File

@ -65,9 +65,9 @@ function propal_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{ {
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact'; $head[$h][2] = 'contact';
$h++; $h++;
} }

View File

@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature
} }
else else
{ {
$sql = "SELECT dbt.".$dbt_select; $sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
} }
} }

View File

@ -72,14 +72,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
$mode=trim($mode); $mode=trim($mode);
$authfile='functions_'.$mode.'.php'; $authfile='functions_'.$mode.'.php';
$fullauthfile=''; $fullauthfile='';
$dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']);
foreach($dirlogin as $reldir) foreach($dirlogin as $reldir)
{ {
$dir=dol_buildpath($reldir,0); $dir=dol_buildpath($reldir,0);
$newdir=dol_osencode($dir); $newdir=dol_osencode($dir);
// Check if file found (do not use dol_is_file to avoid loading files.lib.php) // Check if file found (do not use dol_is_file to avoid loading files.lib.php)
if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile; if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile;
} }
@ -130,12 +130,12 @@ function dol_loginfunction($langs,$conf,$mysoc)
global $dolibarr_main_demo,$db; global $dolibarr_main_demo,$db;
global $smartphone,$hookmanager; global $smartphone,$hookmanager;
// Instantiate hooks of thirdparty module only if not already define // Instantiate hooks of thirdparty module only if not already define
if (! is_object($hookmanager)) 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($db); $hookmanager=new HookManager($db);
} }
$hookmanager->initHooks(array('mainloginpage')); $hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $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 // Execute hook getLoginPageOptions
// Should be an array with differents options in $hookmanager->resArray // Should be an array with differents options in $hookmanager->resArray
$parameters=array('entity' => $_POST['entity']); $parameters=array('entity' => $_POST['entity']);
$hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks
// Login // Login

View File

@ -47,13 +47,13 @@ function shipping_prepare_head($object)
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
{ {
// delivery link // delivery link
$object->fetchObjectLinked($object->id,$object->element); $object->fetchObjectLinked($object->id,$object->element);
if (! empty($object->linkedObjectsIds['delivery'][0])) if (! empty($object->linkedObjectsIds['delivery'][0]))
{ {
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$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][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery'; $head[$h][2] = 'delivery';
$h++; $h++;
} }
} }

View File

@ -219,53 +219,53 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
foreach($dirthemes as $dir) foreach($dirthemes as $dir)
{ {
$dirtheme=dol_buildpath($dir,0); $dirtheme=dol_buildpath($dir,0);
$urltheme=dol_buildpath($dir,1); $urltheme=dol_buildpath($dir,1);
if (is_dir($dirtheme)) if (is_dir($dirtheme))
{ {
$handle=opendir($dirtheme); $handle=opendir($dirtheme);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($subdir = readdir($handle))!==false) while (($subdir = readdir($handle))!==false)
{ {
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir)) && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
{ {
// Disable not stable themes // Disable not stable themes
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue; //if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
if ($i % $thumbsbyrow == 0) if ($i % $thumbsbyrow == 0)
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
} }
print '<td align="center">'; print '<td align="center">';
$file=$dirtheme."/".$subdir."/thumb.png"; $file=$dirtheme."/".$subdir."/thumb.png";
$url=$urltheme."/".$subdir."/thumb.png"; $url=$urltheme."/".$subdir."/thumb.png";
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg"; if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
print '<table><tr><td>'; 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").'">'; 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"); if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
else $title=$langs->trans("ShowPreview"); else $title=$langs->trans("ShowPreview");
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">'; print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
print '</a>'; print '</a>';
print '</td></tr><tr><td align="center">'; print '</td></tr><tr><td align="center">';
if ($subdir == $selected_theme) if ($subdir == $selected_theme)
{ {
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>'; print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
} }
else else
{ {
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir; print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
} }
print '</td></tr></table></td>'; print '</td></tr></table></td>';
$i++; $i++;
if ($i % $thumbsbyrow == 0) print '</tr>'; if ($i % $thumbsbyrow == 0) print '</tr>';
} }
} }
} }
} }
} }

View File

@ -1370,7 +1370,7 @@ abstract class DolibarrModules
{ {
foreach($this->module_parts as $key => $value) 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']; if (is_array($value) && isset($value['entity'])) $entity = $value['entity'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";

View File

@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
if (! is_object($hookmanager)) 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=new HookManager($this->db);
} }
$hookmanager->initHooks(array('pdfgeneration')); $hookmanager->initHooks(array('pdfgeneration'));
@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes
$posy+=1; $posy+=1;
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
} }

View File

@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); $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 // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);

View File

@ -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 if (! empty($cibles[$i]['email'])) // avoid empty email address
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " (fk_mailing,"; $sql .= " (fk_mailing,";
$sql .= " fk_contact,"; $sql .= " fk_contact,";
$sql .= " nom, prenom, email, other, source_url, source_id,"; $sql .= " nom, prenom, email, other, source_url, source_id,";
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,"; if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,";
$sql.= " source_type)"; $sql.= " source_type)";
$sql .= " VALUES (".$mailing_id.","; $sql .= " VALUES (".$mailing_id.",";
$sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .",";
$sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['name'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['email'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['other'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',";
$sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; $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))."',"; 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'])."')"; $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')";
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
$j++; $j++;
} }
else else
{ {
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
// Si erreur autre que doublon // Si erreur autre que doublon
dol_syslog($this->db->error()); dol_syslog($this->db->error());
$this->error=$this->db->error(); $this->error=$this->db->error();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
} }
} }

View File

@ -74,8 +74,8 @@ class modMailing extends DolibarrModules
// Permissions // Permissions
$this->rights = array(); $this->rights = array();
$this->rights_class = 'mailing'; $this->rights_class = 'mailing';
$r=0; $r=0;
$r++; $r++;
$this->rights[$r][0] = 221; // id de la permission $this->rights[$r][0] = 221; // id de la permission
$this->rights[$r][1] = 'Consulter les mailings'; // libelle 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][3] = 0;
$this->rights[$r][4] = 'supprimer'; $this->rights[$r][4] = 'supprimer';
$r++; $r++;
$this->rights[$r][0] = 237; $this->rights[$r][0] = 237;
$this->rights[$r][1] = 'View recipients and info'; $this->rights[$r][1] = 'View recipients and info';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'recipient'; $this->rights[$r][5] = 'recipient';
$r++; $r++;
$this->rights[$r][0] = 238; $this->rights[$r][0] = 238;
$this->rights[$r][1] = 'Manually send mailings'; $this->rights[$r][1] = 'Manually send mailings';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'send'; $this->rights[$r][5] = 'send';
$r++; $r++;
$this->rights[$r][0] = 239; $this->rights[$r][0] = 239;
$this->rights[$r][1] = 'Delete mailings after validation and/or sent'; $this->rights[$r][1] = 'Delete mailings after validation and/or sent';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'delete'; $this->rights[$r][5] = 'delete';
} }

View File

@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
} }
$posy+=2; $posy+=2;
// Show list of linked objects // Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress) if ($showaddress)

View File

@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf); $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
} }
// Fin appel triggers // Fin appel triggers
return 1; return 1;

View File

@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("other"); $langs->load("other");
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; $modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service';
$original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; $original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):'';
@ -65,12 +65,12 @@ if (! $accessallowed)
} }
$object = new Product($db); $object = new Product($db);
if ($id > 0) if ($id > 0)
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db,'Failed to load object'); if ($result <= 0) dol_print_error($db,'Failed to load object');
$dir=$conf->product->multidir_output[$object->entity]; // By default $dir=$conf->product->multidir_output[$object->entity]; // By default
if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity]; if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity];
if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity]; if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity];
} }

View File

@ -16,17 +16,17 @@
* *
*/ */
$module = $object->element; $module = $object->element;
$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page $permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page
// Special cases // Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer; } if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
$companystatic=new Societe($db); $companystatic=new Societe($db);
$contactstatic=new Contact($db); $contactstatic=new Contact($db);
$userstatic=new User($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) { ?> <?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?>
<td> <td>
<?php <?php
$events=array(); $events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); $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); print $form->select_company($object->socid,'socid','',1,0,0,$events);
?> ?>
</td> </td>
@ -113,12 +113,12 @@ $userstatic=new User($db);
<?php $var=true; ?> <?php $var=true; ?>
<?php <?php
foreach(array('internal','external') as $source) { foreach(array('internal','external') as $source) {
$tab = $object->liste_contact(-1,$source); $tab = $object->liste_contact(-1,$source);
$num=count($tab); $num=count($tab);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$var = !$var; $var = !$var;
?> ?>
@ -129,36 +129,36 @@ $userstatic=new User($db);
</td> </td>
<td align="left"> <td align="left">
<?php <?php
if ($tab[$i]['socid'] > 0) if ($tab[$i]['socid'] > 0)
{ {
$companystatic->fetch($tab[$i]['socid']); $companystatic->fetch($tab[$i]['socid']);
echo $companystatic->getNomUrl(1); echo $companystatic->getNomUrl(1);
} }
if ($tab[$i]['socid'] < 0) if ($tab[$i]['socid'] < 0)
{ {
echo $conf->global->MAIN_INFO_SOCIETE_NOM; echo $conf->global->MAIN_INFO_SOCIETE_NOM;
} }
if (! $tab[$i]['socid']) if (! $tab[$i]['socid'])
{ {
echo '&nbsp;'; echo '&nbsp;';
} }
?> ?>
</td> </td>
<td> <td>
<?php <?php
if ($tab[$i]['source']=='internal') if ($tab[$i]['source']=='internal')
{ {
$userstatic->id=$tab[$i]['id']; $userstatic->id=$tab[$i]['id'];
$userstatic->lastname=$tab[$i]['lastname']; $userstatic->lastname=$tab[$i]['lastname'];
$userstatic->firstname=$tab[$i]['firstname']; $userstatic->firstname=$tab[$i]['firstname'];
echo $userstatic->getNomUrl(1); echo $userstatic->getNomUrl(1);
} }
if ($tab[$i]['source']=='external') if ($tab[$i]['source']=='external')
{ {
$contactstatic->id=$tab[$i]['id']; $contactstatic->id=$tab[$i]['id'];
$contactstatic->lastname=$tab[$i]['lastname']; $contactstatic->lastname=$tab[$i]['lastname'];
$contactstatic->firstname=$tab[$i]['firstname']; $contactstatic->firstname=$tab[$i]['firstname'];
echo $contactstatic->getNomUrl(1); echo $contactstatic->getNomUrl(1);
} }
?> ?>
</td> </td>

View File

@ -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 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 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 // 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'; if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz';
print '<!-- Includes JS for JQuery -->'."\n"; print '<!-- Includes JS for JQuery -->'."\n";
if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n"; if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n";

View File

@ -111,37 +111,37 @@ class InterfacePaypalWorkflow
} }
else else
{ {
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
$soc = new Societe($this->db); $soc = new Societe($this->db);
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $path = $filename = $object->source; $element = $path = $filename = $object->source;
if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs))
{ {
$element = $path = $regs[1]; $element = $path = $regs[1];
$filename = $regs[2]; $filename = $regs[2];
} }
// For compatibility // For compatibility
if ($element == 'order') { if ($element == 'order') {
$path = $filename = 'commande'; $path = $filename = 'commande';
} }
if ($element == 'invoice') { if ($element == 'invoice') {
$path = 'compta/facture'; $filename = 'facture'; $path = 'compta/facture'; $filename = 'facture';
} }
dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); dol_include_once('/'.$path.'/class/'.$filename.'.class.php');
$classname = ucfirst($filename); $classname = ucfirst($filename);
$obj = new $classname($this->db); $obj = new $classname($this->db);
$ret = $obj->fetch('',$object->ref); $ret = $obj->fetch('',$object->ref);
if ($ret < 0) return -1; if ($ret < 0) return -1;
// Add payer id // Add payer id
$soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
// Add transaction id // Add transaction id
$obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]);
} }

View File

@ -73,11 +73,11 @@ class Expedition extends CommonObject
var $date_creation; var $date_creation;
var $date_valid; var $date_valid;
// For Invoicing // For Invoicing
var $total_ht; // Total net of tax var $total_ht; // Total net of tax
var $total_ttc; // Total with tax var $total_ttc; // Total with tax
var $total_tva; // Total VAT var $total_tva; // Total VAT
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2
@ -871,10 +871,10 @@ class Expedition extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
$this->total_ht = 0; $this->total_ht = 0;
$this->total_tva = 0; $this->total_tva = 0;
$this->total_ttc = 0; $this->total_ttc = 0;
$this->total_localtax1 = 0; $this->total_localtax1 = 0;
$this->total_localtax2 = 0; $this->total_localtax2 = 0;
while ($i < $num) while ($i < $num)
@ -915,11 +915,11 @@ class Expedition extends CommonObject
$line->subprice = $obj->subprice; $line->subprice = $obj->subprice;
$line->remise_percent = $obj->remise_percent; $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); $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_ht+= $tabprice[0];
$this->total_tva+= $tabprice[1]; $this->total_tva+= $tabprice[1];
$this->total_ttc+= $tabprice[2]; $this->total_ttc+= $tabprice[2];
$this->total_localtax1+= $tabprice[9]; $this->total_localtax1+= $tabprice[9];
$this->total_localtax2+= $tabprice[10]; $this->total_localtax2+= $tabprice[10];
$this->lines[$i] = $line; $this->lines[$i] = $line;
@ -1212,28 +1212,28 @@ class Expedition extends CommonObject
} }
} }
/** /**
* Classify the shipping as invoiced * Classify the shipping as invoiced
* *
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function set_billed() function set_billed()
{ {
global $conf; global $conf;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
//TODO: Option to set order billed if 100% of order is shipped //TODO: Option to set order billed if 100% of order is shipped
return 1; return 1;
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
} }
} }
@ -1257,11 +1257,11 @@ class ExpeditionLigne
var $ref; var $ref;
// Invoicing // Invoicing
var $remise_percent; var $remise_percent;
var $total_ht; // Total net of tax var $total_ht; // Total net of tax
var $total_ttc; // Total with tax var $total_ttc; // Total with tax
var $total_tva; // Total VAT var $total_tva; // Total VAT
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
var $total_localtax2; // Total Local tax 2 var $total_localtax2; // Total Local tax 2

View File

@ -119,11 +119,11 @@ else if ($action == 'deleteline' && $user->rights->expedition->creer)
} }
} }
else if ($action == 'setaddress' && $user->rights->expedition->creer) else if ($action == 'setaddress' && $user->rights->expedition->creer)
{ {
$object->fetch($id); $object->fetch($id);
$result=$object->setDeliveryAddress($_POST['fk_address']); $result=$object->setDeliveryAddress($_POST['fk_address']);
if ($result < 0) dol_print_error($db,$object->error); if ($result < 0) dol_print_error($db,$object->error);
} }
@ -210,27 +210,27 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Delivery address // Delivery address
if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)
{ {
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress'); print $langs->trans('DeliveryAddress');
print '</td>'; print '</td>';
if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>'; if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdelivery_address') if ($action == 'editdelivery_address')
{ {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id); $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id);
} }
else else
{ {
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id); $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id);
} }
print '</td></tr>'; print '</td></tr>';
} }
print "</table>"; print "</table>";

View File

@ -60,7 +60,7 @@ $result=restrictedArea($user,$origin,$origin_id);
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
//PDF //PDF
$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $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)); $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)); $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') else if ($action == 'classifybilled')
{ {
$object->fetch($id); $object->fetch($id);
$object->set_billed(); $object->set_billed();
} }
@ -1340,9 +1340,9 @@ else
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); $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(); $somethingshown=$object->showLinkedObjectBlock();
if ($genallowed && ! $somethingshown) $somethingshown=1; if ($genallowed && ! $somethingshown) $somethingshown=1;