clean indent
This commit is contained in:
parent
16f58f1eee
commit
e203f87c84
@ -12,7 +12,7 @@
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -4612,252 +4612,251 @@ abstract class CommonObject
|
||||
$parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams);
|
||||
$reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
if(empty($reshook))
|
||||
if (empty($reshook))
|
||||
{
|
||||
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null'));
|
||||
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null'));
|
||||
|
||||
// Increase limit for PDF build
|
||||
$err=error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
// Increase limit for PDF build
|
||||
$err=error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
|
||||
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
||||
$tmp=explode(':', $modele, 2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
|
||||
$tmp=explode(':', $modele, 2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
||||
else $file = $prefix."_".$modele.".modules.php";
|
||||
// Search template files
|
||||
$file='';
|
||||
$classname='';
|
||||
$filefound=0;
|
||||
$dirmodels=array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
||||
else $file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file=dol_buildpath($reldir.$modelspath.$file, 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
// On verifie l'emplacement du modele
|
||||
$file=dol_buildpath($reldir.$modelspath.$file, 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// If generator was found
|
||||
if ($filefound)
|
||||
{
|
||||
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
|
||||
// If generator was found
|
||||
if ($filefound)
|
||||
{
|
||||
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
|
||||
|
||||
require_once $file;
|
||||
require_once $file;
|
||||
|
||||
$obj = new $classname($this->db);
|
||||
$obj = new $classname($this->db);
|
||||
|
||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||
{
|
||||
$varfortemplatedir=$obj->scandir;
|
||||
if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
|
||||
{
|
||||
$dirtoscan=$conf->global->$varfortemplatedir;
|
||||
// If generator is ODT, we must have srctemplatepath defined, if not we set it.
|
||||
if ($obj->type == 'odt' && empty($srctemplatepath))
|
||||
{
|
||||
$varfortemplatedir=$obj->scandir;
|
||||
if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
|
||||
{
|
||||
$dirtoscan=$conf->global->$varfortemplatedir;
|
||||
|
||||
$listoffiles=array();
|
||||
$listoffiles=array();
|
||||
|
||||
// Now we add first model found in directories scanned
|
||||
$listofdir=explode(',', $dirtoscan);
|
||||
foreach($listofdir as $key => $tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
||||
if (is_dir($tmpdir))
|
||||
{
|
||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
// Now we add first model found in directories scanned
|
||||
$listofdir=explode(',', $dirtoscan);
|
||||
foreach($listofdir as $key => $tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
|
||||
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
||||
if (is_dir($tmpdir))
|
||||
{
|
||||
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
|
||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($listoffiles))
|
||||
{
|
||||
foreach($listoffiles as $record)
|
||||
{
|
||||
$srctemplatepath=$record['fullname'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($listoffiles))
|
||||
{
|
||||
foreach($listoffiles as $record)
|
||||
{
|
||||
$srctemplatepath=$record['fullname'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($obj->type == 'odt' && ! empty($srctemplatepath))
|
||||
{
|
||||
if (! dol_is_file($srctemplatepath))
|
||||
{
|
||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ($obj->type == 'odt' && ! empty($srctemplatepath))
|
||||
{
|
||||
if (! dol_is_file($srctemplatepath))
|
||||
{
|
||||
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
|
||||
if (in_array(get_class($this), array('Adherent')))
|
||||
{
|
||||
$arrayofrecords = array(); // The write_file of templates of adherent class need this var
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
|
||||
if (in_array(get_class($this), array('Adherent')))
|
||||
{
|
||||
$arrayofrecords = array(); // The write_file of templates of adherent class need this var
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
|
||||
}
|
||||
else
|
||||
{
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
|
||||
|
||||
if ($resultwritefile > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
if ($resultwritefile > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
|
||||
// We delete old preview
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($this);
|
||||
// We delete old preview
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($this);
|
||||
|
||||
// Index file in database
|
||||
if (! empty($obj->result['fullpath']))
|
||||
{
|
||||
$destfull = $obj->result['fullpath'];
|
||||
$upload_dir = dirname($destfull);
|
||||
$destfile = basename($destfull);
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
||||
// Index file in database
|
||||
if (! empty($obj->result['fullpath']))
|
||||
{
|
||||
$destfull = $obj->result['fullpath'];
|
||||
$upload_dir = dirname($destfull);
|
||||
$destfile = basename($destfull);
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
|
||||
|
||||
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($this->db);
|
||||
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($this->db);
|
||||
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
|
||||
|
||||
// Set the public "share" key
|
||||
$setsharekey = false;
|
||||
if ($this->element == 'propal')
|
||||
{
|
||||
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
||||
if ($useonlinesignature) $setsharekey=true;
|
||||
if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
// Set the public "share" key
|
||||
$setsharekey = false;
|
||||
if ($this->element == 'propal')
|
||||
{
|
||||
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
|
||||
if ($useonlinesignature) $setsharekey=true;
|
||||
if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
|
||||
$setsharekey=true;
|
||||
}
|
||||
|
||||
if ($setsharekey)
|
||||
{
|
||||
if (empty($ecmfile->share)) // Because object not found or share not set yet
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$ecmfile->share = getRandomPassword(true);
|
||||
}
|
||||
}
|
||||
if ($setsharekey) {
|
||||
if (empty($ecmfile->share)) // Because object not found or share not set yet
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$ecmfile->share = getRandomPassword(true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ecmfile->entity = $conf->entity;
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$ecmfile->src_object_type = $this->table_element;
|
||||
$ecmfile->src_object_id = $this->id;
|
||||
if ($result > 0)
|
||||
{
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ecmfile->entity = $conf->entity;
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$ecmfile->src_object_type = $this->table_element;
|
||||
$ecmfile->src_object_id = $this->id;
|
||||
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0) {
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
|
||||
/*$this->result['fullname']=$destfull;
|
||||
$this->result['filepath']=$ecmfile->filepath;
|
||||
$this->result['filename']=$ecmfile->filename;*/
|
||||
//var_dump($obj->update_main_doc_field);exit;
|
||||
/*$this->result['fullname']=$destfull;
|
||||
$this->result['filepath']=$ecmfile->filepath;
|
||||
$this->result['filename']=$ecmfile->filename;*/
|
||||
//var_dump($obj->update_main_doc_field);exit;
|
||||
|
||||
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
||||
$update_main_doc_field=0;
|
||||
if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
|
||||
if ($update_main_doc_field && ! empty($this->table_element))
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
|
||||
$update_main_doc_field=0;
|
||||
if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
|
||||
if ($update_main_doc_field && ! empty($this->table_element))
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) dol_print_error($this->db);
|
||||
else
|
||||
{
|
||||
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
||||
}
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) {
|
||||
dol_print_error($this->db);
|
||||
} else {
|
||||
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
||||
}
|
||||
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($this);
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($this);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
|
||||
dol_print_error('', $this->error);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
|
||||
dol_print_error('', $this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else return $reshook;
|
||||
}
|
||||
@ -6063,18 +6062,19 @@ abstract class CommonObject
|
||||
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
|
||||
}
|
||||
}
|
||||
if (empty($labeltoshow))
|
||||
if (empty($labeltoshow)) {
|
||||
$labeltoshow = '(not defined)';
|
||||
}
|
||||
|
||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||
$data[$obj->rowid]=$labeltoshow;
|
||||
}
|
||||
|
||||
if (! empty($InfoFieldList[3]) && $parentField) {
|
||||
$parent = $parentName . ':' . $obj->{$parentField};
|
||||
}
|
||||
|
||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||
$data[$obj->rowid]=$labeltoshow;
|
||||
}
|
||||
|
||||
if (! empty($InfoFieldList[3]) && $parentField) {
|
||||
$parent = $parentName . ':' . $obj->{$parentField};
|
||||
}
|
||||
|
||||
$data[$obj->rowid]=$labeltoshow;
|
||||
}
|
||||
|
||||
$i ++;
|
||||
|
||||
@ -944,9 +944,9 @@ class DolGraph
|
||||
if (! empty($this->title)) $this->stringtoshow.='<div class="center dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
|
||||
if (! empty($this->shownographyet))
|
||||
{
|
||||
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
|
||||
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
return;
|
||||
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
|
||||
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
return;
|
||||
}
|
||||
$this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).' center"></div>'."\n";
|
||||
|
||||
|
||||
@ -248,12 +248,12 @@ class Fiscalyear extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete record
|
||||
*
|
||||
* @param int $id Id of record to delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
/**
|
||||
* Delete record
|
||||
*
|
||||
* @param int $id Id of record to delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
@ -227,14 +227,14 @@ class Form
|
||||
}
|
||||
elseif (preg_match('/^select;/', $typeofdata))
|
||||
{
|
||||
$arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata));
|
||||
foreach($arraydata as $val)
|
||||
{
|
||||
$tmp=explode(':', $val);
|
||||
$tmpkey=str_replace('|', ':', $tmp[0]);
|
||||
$arraylist[$tmpkey]=$tmp[1];
|
||||
}
|
||||
$ret.=$this->selectarray($htmlname, $arraylist, $value);
|
||||
$arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata));
|
||||
foreach($arraydata as $val)
|
||||
{
|
||||
$tmp=explode(':', $val);
|
||||
$tmpkey=str_replace('|', ':', $tmp[0]);
|
||||
$arraylist[$tmpkey]=$tmp[1];
|
||||
}
|
||||
$ret.=$this->selectarray($htmlname, $arraylist, $value);
|
||||
}
|
||||
elseif (preg_match('/^ckeditor/', $typeofdata))
|
||||
{
|
||||
@ -5458,9 +5458,9 @@ class Form
|
||||
dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."',
|
||||
autoclose: true,
|
||||
todayHighlight: true,";
|
||||
if (! empty($conf->dol_use_jmobile))
|
||||
{
|
||||
$retstring.="
|
||||
if (! empty($conf->dol_use_jmobile))
|
||||
{
|
||||
$retstring.="
|
||||
beforeShow: function (input, datePicker) {
|
||||
input.disabled = true;
|
||||
},
|
||||
@ -5468,16 +5468,16 @@ class Form
|
||||
this.disabled = false;
|
||||
},
|
||||
";
|
||||
}
|
||||
// Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
|
||||
if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
|
||||
{
|
||||
}
|
||||
// Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
|
||||
if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
|
||||
{
|
||||
$retstring.="
|
||||
showOn: 'button',
|
||||
buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png',
|
||||
buttonImageOnly: true";
|
||||
}
|
||||
$retstring.="
|
||||
}
|
||||
$retstring.="
|
||||
}) });";
|
||||
$retstring.="</script>";
|
||||
}
|
||||
@ -6563,19 +6563,19 @@ class Form
|
||||
|
||||
foreach($array as $key => $val)
|
||||
{
|
||||
/* var_dump($val);
|
||||
/* var_dump($val);
|
||||
var_dump(array_key_exists('enabled', $val));
|
||||
var_dump(!$val['enabled']);*/
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled'])
|
||||
{
|
||||
unset($array[$key]); // We don't want this field
|
||||
continue;
|
||||
}
|
||||
if ($val['label'])
|
||||
{
|
||||
$lis.='<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked'])?'':' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listcheckedstring.=(empty($val['checked'])?'':$key.',');
|
||||
}
|
||||
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled'])
|
||||
{
|
||||
unset($array[$key]); // We don't want this field
|
||||
continue;
|
||||
}
|
||||
if ($val['label'])
|
||||
{
|
||||
$lis.='<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked'])?'':' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listcheckedstring.=(empty($val['checked'])?'':$key.',');
|
||||
}
|
||||
}
|
||||
|
||||
$out ='<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' -->
|
||||
@ -6970,7 +6970,7 @@ class Form
|
||||
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<!-- Add js to show linkto box -->
|
||||
print '<!-- Add js to show linkto box -->
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
jQuery(".linkto").click(function() {
|
||||
@ -6980,7 +6980,7 @@ class Form
|
||||
});
|
||||
});
|
||||
</script>
|
||||
';
|
||||
';
|
||||
}
|
||||
|
||||
return $linktoelem;
|
||||
@ -7017,7 +7017,7 @@ class Form
|
||||
$resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$selected=(($useempty && $value != '0' && $value != 'no')?'':' selected');
|
||||
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
|
||||
$resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n";
|
||||
|
||||
@ -45,11 +45,11 @@ class FormAccounting extends Form
|
||||
*/
|
||||
public $error='';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
@ -1292,7 +1292,7 @@ class FormOther
|
||||
$resultautomanual .= '<option value="'.$manual.'">'.$langs->trans("Manual").'</option>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$selected=(($useempty && $value != '0' && $value != 'manual')?'':' selected');
|
||||
$resultautomanual .= '<option value="'.$automatic.'">'.$langs->trans("Automatic").'</option>'."\n";
|
||||
$resultautomanual .= '<option value="'.$manual.'"'.$selected.'>'.$langs->trans("Manual").'</option>'."\n";
|
||||
|
||||
@ -560,12 +560,12 @@ if (empty($reshook))
|
||||
{
|
||||
if ($lines[$i]->id == $line_id)
|
||||
{
|
||||
// delete single warehouse line
|
||||
$line->id = $line_id;
|
||||
if (! $error && $line->delete($user) < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
// delete single warehouse line
|
||||
$line->id = $line_id;
|
||||
if (! $error && $line->delete($user) < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
unset($_POST["lineid"]);
|
||||
}
|
||||
@ -949,31 +949,28 @@ if ($action == 'create')
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery("#autofill").click(function() {';
|
||||
$i=1;
|
||||
while($i <= $numAsked)
|
||||
{
|
||||
print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n";
|
||||
$i++;
|
||||
}
|
||||
print '});
|
||||
$i=1;
|
||||
while($i <= $numAsked)
|
||||
{
|
||||
print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n";
|
||||
$i++;
|
||||
}
|
||||
print '});
|
||||
jQuery("#autoreset").click(function() {';
|
||||
$i=1;
|
||||
while($i <= $numAsked)
|
||||
{
|
||||
print 'jQuery("#qtyl'.$i.'").val(0);'."\n";
|
||||
$i++;
|
||||
}
|
||||
print '});
|
||||
$i=1;
|
||||
while($i <= $numAsked)
|
||||
{
|
||||
print 'jQuery("#qtyl'.$i.'").val(0);'."\n";
|
||||
$i++;
|
||||
}
|
||||
print '});
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
|
||||
// Load receptions already done for same order
|
||||
$object->loadReceptions();
|
||||
|
||||
@ -1113,59 +1110,57 @@ if ($action == 'create')
|
||||
$stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number
|
||||
$deliverableQty=$dispatchLines[$indiceAsked]['qty'];
|
||||
|
||||
// Quantity to send
|
||||
print '<td class="center">';
|
||||
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int');
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">';
|
||||
}
|
||||
else print $langs->trans("NA");
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Quantity to send
|
||||
print '<td class="center">';
|
||||
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
// Stock
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<td class="left">';
|
||||
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ?
|
||||
{
|
||||
if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int');
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">';
|
||||
// Show warehouse combo list
|
||||
$ent = "entl".$indiceAsked;
|
||||
$idl = "idl".$indiceAsked;
|
||||
$tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id;
|
||||
if ($line->fk_product > 0)
|
||||
{
|
||||
print '<!-- Show warehouse selection -->';
|
||||
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1);
|
||||
}
|
||||
}
|
||||
else print $langs->trans("NA");
|
||||
print '</td>';
|
||||
|
||||
// Stock
|
||||
if (! empty($conf->stock->enabled))
|
||||
else
|
||||
{
|
||||
print '<td class="left">';
|
||||
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ?
|
||||
{
|
||||
// Show warehouse combo list
|
||||
$ent = "entl".$indiceAsked;
|
||||
$idl = "idl".$indiceAsked;
|
||||
$tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id;
|
||||
if ($line->fk_product > 0)
|
||||
{
|
||||
print '<!-- Show warehouse selection -->';
|
||||
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Service");
|
||||
}
|
||||
print $langs->trans("Service");
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($conf->productbatch->enabled))
|
||||
{
|
||||
if (!empty($product->status_batch))
|
||||
{
|
||||
print '<td><input name="batch'.$indiceAsked.'" value="'.$dispatchLines[$indiceAsked]['lot'].'"></td>';
|
||||
print '<td>';
|
||||
print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, "");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, "");
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($conf->productbatch->enabled))
|
||||
{
|
||||
if (!empty($product->status_batch))
|
||||
{
|
||||
print '<td><input name="batch'.$indiceAsked.'" value="'.$dispatchLines[$indiceAsked]['lot'].'"></td>';
|
||||
print '<td>';
|
||||
print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, "");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, "");
|
||||
print '</td>';
|
||||
}
|
||||
else {
|
||||
print '<td colspan="3"></td>';
|
||||
}
|
||||
else {
|
||||
print '<td colspan="3"></td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
//Display lines extrafields
|
||||
|
||||
@ -305,29 +305,28 @@ if (empty($reshook))
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
'HT',
|
||||
$product_type,
|
||||
$i,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
$lines[$i]->rowid,
|
||||
0,
|
||||
$lines[$i]->ref_supplier
|
||||
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
'HT',
|
||||
$product_type,
|
||||
$i,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
$lines[$i]->rowid,
|
||||
0,
|
||||
$lines[$i]->ref_supplier
|
||||
);
|
||||
|
||||
$rcp->add_object_linked('facture_fourn_det', $result);
|
||||
@ -533,9 +532,9 @@ if ($resql)
|
||||
}
|
||||
|
||||
|
||||
$arrayofmassactions = array(
|
||||
// 'presend'=>$langs->trans("SendByMail"),
|
||||
);
|
||||
$arrayofmassactions = array(
|
||||
// 'presend'=>$langs->trans("SendByMail"),
|
||||
);
|
||||
|
||||
if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier");
|
||||
if($massaction == 'createbills') $arrayofmassactions=array();
|
||||
|
||||
@ -42,38 +42,38 @@ $langs->load("receptions");
|
||||
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
|
||||
|
||||
$total=0; $ilink=0;
|
||||
foreach($linkedObjectBlock as $key => $objectlink)
|
||||
foreach ($linkedObjectBlock as $key => $objectlink)
|
||||
{
|
||||
$ilink++;
|
||||
|
||||
$trclass='oddeven';
|
||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
|
||||
?>
|
||||
?>
|
||||
<tr class="<?php echo $trclass; ?>">
|
||||
<td class="linkedcol-element"><?php echo $langs->trans("Reception"); ?>
|
||||
<?php if(!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?>
|
||||
<?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?>
|
||||
</td>
|
||||
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||
<td class="linkedcol-ref" align="center"></td>
|
||||
<td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
|
||||
<td class="linkedcol-ref center"></td>
|
||||
<td class="linkedcol-date center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
|
||||
<td class="linkedcol-amount right"><?php
|
||||
if ($user->rights->reception->lire) {
|
||||
$total = $total + $objectlink->total_ht;
|
||||
echo price($objectlink->total_ht);
|
||||
} ?></td>
|
||||
if ($user->rights->reception->lire) {
|
||||
$total = $total + $objectlink->total_ht;
|
||||
echo price($objectlink->total_ht);
|
||||
} ?></td>
|
||||
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
|
||||
<td class="linkedcol-action right">
|
||||
<?php
|
||||
// For now, receptions must stay linked to order, so link is not deletable
|
||||
if($object->element != 'order_supplier') {
|
||||
?>
|
||||
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
// For now, receptions must stay linked to order, so link is not deletable
|
||||
if ($object->element != 'order_supplier') {
|
||||
?>
|
||||
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
if (count($linkedObjectBlock) > 1)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user