clean indent

This commit is contained in:
Frédéric FRANCE 2019-10-27 11:18:36 +01:00
parent 16f58f1eee
commit e203f87c84
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
9 changed files with 378 additions and 384 deletions

View File

@ -12,7 +12,7 @@
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr> * Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.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> * Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* *
* This program is free software; you can redistribute it and/or modify * 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); $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 $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 // Increase limit for PDF build
$err=error_reporting(); $err=error_reporting();
error_reporting(0); error_reporting(0);
@set_time_limit(120); @set_time_limit(120);
error_reporting($err); error_reporting($err);
// If selected model is a filename template (then $modele="modelname" or "modelname:filename") // If selected model is a filename template (then $modele="modelname" or "modelname:filename")
$tmp=explode(':', $modele, 2); $tmp=explode(':', $modele, 2);
if (! empty($tmp[1])) if (! empty($tmp[1]))
{ {
$modele=$tmp[0]; $modele=$tmp[0];
$srctemplatepath=$tmp[1]; $srctemplatepath=$tmp[1];
} }
// Search template files // Search template files
$file=''; $classname=''; $filefound=0; $file='';
$dirmodels=array('/'); $classname='';
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); $filefound=0;
foreach($dirmodels as $reldir) $dirmodels=array('/');
{ if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
foreach(array('doc','pdf') as $prefix) foreach($dirmodels as $reldir)
{ {
if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php foreach(array('doc','pdf') as $prefix)
else $file = $prefix."_".$modele.".modules.php"; {
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 // On verifie l'emplacement du modele
$file=dol_buildpath($reldir.$modelspath.$file, 0); $file=dol_buildpath($reldir.$modelspath.$file, 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound=1; $filefound=1;
$classname=$prefix.'_'.$modele; $classname=$prefix.'_'.$modele;
break; break;
} }
} }
if ($filefound) break; if ($filefound) break;
} }
// If generator was found // If generator was found
if ($filefound) if ($filefound)
{ {
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. 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 generator is ODT, we must have srctemplatepath defined, if not we set it.
if ($obj->type == 'odt' && empty($srctemplatepath)) if ($obj->type == 'odt' && empty($srctemplatepath))
{ {
$varfortemplatedir=$obj->scandir; $varfortemplatedir=$obj->scandir;
if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
{ {
$dirtoscan=$conf->global->$varfortemplatedir; $dirtoscan=$conf->global->$varfortemplatedir;
$listoffiles=array(); $listoffiles=array();
// Now we add first model found in directories scanned // Now we add first model found in directories scanned
$listofdir=explode(',', $dirtoscan); $listofdir=explode(',', $dirtoscan);
foreach($listofdir as $key => $tmpdir) foreach($listofdir as $key => $tmpdir)
{ {
$tmpdir=trim($tmpdir); $tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (! $tmpdir) { unset($listofdir[$key]); continue; } if (! $tmpdir) { unset($listofdir[$key]); continue; }
if (is_dir($tmpdir)) if (is_dir($tmpdir))
{ {
$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles);
} }
} }
if (count($listoffiles)) if (count($listoffiles))
{ {
foreach($listoffiles as $record) foreach($listoffiles as $record)
{ {
$srctemplatepath=$record['fullname']; $srctemplatepath=$record['fullname'];
break; break;
} }
} }
} }
if (empty($srctemplatepath)) if (empty($srctemplatepath))
{ {
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
return -1; return -1;
} }
} }
if ($obj->type == 'odt' && ! empty($srctemplatepath)) if ($obj->type == 'odt' && ! empty($srctemplatepath))
{ {
if (! dol_is_file($srctemplatepath)) if (! dol_is_file($srctemplatepath))
{ {
$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
return -1; return -1;
} }
} }
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output; $sav_charset_output=$outputlangs->charset_output;
if (in_array(get_class($this), array('Adherent'))) if (in_array(get_class($this), array('Adherent')))
{ {
$arrayofrecords = array(); // The write_file of templates of adherent class need this var $arrayofrecords = array(); // The write_file of templates of adherent class need this var
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
} }
else else
{ {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); $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. // 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) if ($resultwritefile > 0)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
// We delete old preview // We delete old preview
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_delete_preview($this); dol_delete_preview($this);
// Index file in database // Index file in database
if (! empty($obj->result['fullpath'])) if (! empty($obj->result['fullpath']))
{ {
$destfull = $obj->result['fullpath']; $destfull = $obj->result['fullpath'];
$upload_dir = dirname($destfull); $upload_dir = dirname($destfull);
$destfile = basename($destfull); $destfile = basename($destfull);
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
{ {
$filename = basename($destfile); $filename = basename($destfile);
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($this->db); $ecmfile=new EcmFiles($this->db);
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
// Set the public "share" key // Set the public "share" key
$setsharekey = false; $setsharekey = false;
if ($this->element == 'propal') if ($this->element == 'propal')
{ {
$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
if ($useonlinesignature) $setsharekey=true; if ($useonlinesignature) $setsharekey=true;
if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
} }
if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true; $setsharekey=true;
} }
if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true; $setsharekey=true;
} }
if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) {
$setsharekey=true; $setsharekey=true;
} }
if ($setsharekey) if ($setsharekey) {
{ if (empty($ecmfile->share)) // Because object not found or share not set yet
if (empty($ecmfile->share)) // Because object not found or share not set yet {
{ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $ecmfile->share = getRandomPassword(true);
$ecmfile->share = getRandomPassword(true); }
} }
}
if ($result > 0) if ($result > 0)
{ {
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->fullpath_orig = ''; $ecmfile->fullpath_orig = '';
$ecmfile->gen_or_uploaded = 'generated'; $ecmfile->gen_or_uploaded = 'generated';
$ecmfile->description = ''; // indexed content $ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content $ecmfile->keyword = ''; // keyword content
$result = $ecmfile->update($user); $result = $ecmfile->update($user);
if ($result < 0) if ($result < 0) {
{ setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); }
} }
} else
else {
{ $ecmfile->entity = $conf->entity;
$ecmfile->entity = $conf->entity; $ecmfile->filepath = $rel_dir;
$ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename;
$ecmfile->filename = $filename; $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->fullpath_orig = '';
$ecmfile->fullpath_orig = ''; $ecmfile->gen_or_uploaded = 'generated';
$ecmfile->gen_or_uploaded = 'generated'; $ecmfile->description = ''; // indexed content
$ecmfile->description = ''; // indexed content $ecmfile->keyword = ''; // keyword content
$ecmfile->keyword = ''; // keyword content $ecmfile->src_object_type = $this->table_element;
$ecmfile->src_object_type = $this->table_element; $ecmfile->src_object_id = $this->id;
$ecmfile->src_object_id = $this->id;
$result = $ecmfile->create($user); $result = $ecmfile->create($user);
if ($result < 0) if ($result < 0) {
{ setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); }
} }
}
/*$this->result['fullname']=$destfull; /*$this->result['fullname']=$destfull;
$this->result['filepath']=$ecmfile->filepath; $this->result['filepath']=$ecmfile->filepath;
$this->result['filename']=$ecmfile->filename;*/ $this->result['filename']=$ecmfile->filename;*/
//var_dump($obj->update_main_doc_field);exit; //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 the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
$update_main_doc_field=0; $update_main_doc_field=0;
if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
if ($update_main_doc_field && ! empty($this->table_element)) 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 = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) dol_print_error($this->db); if (! $resql) {
else dol_print_error($this->db);
{ } else {
$this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename;
} }
} }
} }
} }
else 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); 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. // Success in building document. We build meta file.
dol_meta_create($this); dol_meta_create($this);
return 1; return 1;
} }
else else
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
return -1; return -1;
} }
} }
else else
{ {
$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
dol_print_error('', $this->error); dol_print_error('', $this->error);
return -1; return -1;
} }
} }
else return $reshook; else return $reshook;
} }
@ -6063,18 +6062,19 @@ abstract class CommonObject
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
} }
} }
if (empty($labeltoshow)) if (empty($labeltoshow)) {
$labeltoshow = '(not defined)'; $labeltoshow = '(not defined)';
}
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { 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; $data[$obj->rowid]=$labeltoshow;
}
if (! empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName . ':' . $obj->{$parentField};
}
$data[$obj->rowid]=$labeltoshow;
} }
$i ++; $i ++;

View File

@ -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->title)) $this->stringtoshow.='<div class="center dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
if (! empty($this->shownographyet)) if (! empty($this->shownographyet))
{ {
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>'; $this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>'; $this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
return; 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"; $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";

View File

@ -248,12 +248,12 @@ class Fiscalyear extends CommonObject
} }
} }
/** /**
* Delete record * Delete record
* *
* @param int $id Id of record to delete * @param int $id Id of record to delete
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete($id) public function delete($id)
{ {
$this->db->begin(); $this->db->begin();

View File

@ -227,14 +227,14 @@ class Form
} }
elseif (preg_match('/^select;/', $typeofdata)) elseif (preg_match('/^select;/', $typeofdata))
{ {
$arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata)); $arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata));
foreach($arraydata as $val) foreach($arraydata as $val)
{ {
$tmp=explode(':', $val); $tmp=explode(':', $val);
$tmpkey=str_replace('|', ':', $tmp[0]); $tmpkey=str_replace('|', ':', $tmp[0]);
$arraylist[$tmpkey]=$tmp[1]; $arraylist[$tmpkey]=$tmp[1];
} }
$ret.=$this->selectarray($htmlname, $arraylist, $value); $ret.=$this->selectarray($htmlname, $arraylist, $value);
} }
elseif (preg_match('/^ckeditor/', $typeofdata)) elseif (preg_match('/^ckeditor/', $typeofdata))
{ {
@ -5458,9 +5458,9 @@ class Form
dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."',
autoclose: true, autoclose: true,
todayHighlight: true,"; todayHighlight: true,";
if (! empty($conf->dol_use_jmobile)) if (! empty($conf->dol_use_jmobile))
{ {
$retstring.=" $retstring.="
beforeShow: function (input, datePicker) { beforeShow: function (input, datePicker) {
input.disabled = true; input.disabled = true;
}, },
@ -5468,16 +5468,16 @@ class Form
this.disabled = false; 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 // 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)) if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
{ {
$retstring.=" $retstring.="
showOn: 'button', showOn: 'button',
buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png', buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png',
buttonImageOnly: true"; buttonImageOnly: true";
} }
$retstring.=" $retstring.="
}) });"; }) });";
$retstring.="</script>"; $retstring.="</script>";
} }
@ -6563,19 +6563,19 @@ class Form
foreach($array as $key => $val) foreach($array as $key => $val)
{ {
/* var_dump($val); /* var_dump($val);
var_dump(array_key_exists('enabled', $val)); var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/ var_dump(!$val['enabled']);*/
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled'])
{ {
unset($array[$key]); // We don't want this field unset($array[$key]); // We don't want this field
continue; continue;
} }
if ($val['label']) 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>'; $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.','); $listcheckedstring.=(empty($val['checked'])?'':$key.',');
} }
} }
$out ='<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' --> $out ='<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' -->
@ -6970,7 +6970,7 @@ class Form
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print '<!-- Add js to show linkto box --> print '<!-- Add js to show linkto box -->
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery(".linkto").click(function() { jQuery(".linkto").click(function() {
@ -6980,7 +6980,7 @@ class Form
}); });
}); });
</script> </script>
'; ';
} }
return $linktoelem; return $linktoelem;
@ -7017,7 +7017,7 @@ class Form
$resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n"; $resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n";
} }
else else
{ {
$selected=(($useempty && $value != '0' && $value != 'no')?'':' selected'); $selected=(($useempty && $value != '0' && $value != 'no')?'':' selected');
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n"; $resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
$resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n"; $resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n";

View File

@ -45,11 +45,11 @@ class FormAccounting extends Form
*/ */
public $error=''; public $error='';
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@ -1292,7 +1292,7 @@ class FormOther
$resultautomanual .= '<option value="'.$manual.'">'.$langs->trans("Manual").'</option>'."\n"; $resultautomanual .= '<option value="'.$manual.'">'.$langs->trans("Manual").'</option>'."\n";
} }
else else
{ {
$selected=(($useempty && $value != '0' && $value != 'manual')?'':' selected'); $selected=(($useempty && $value != '0' && $value != 'manual')?'':' selected');
$resultautomanual .= '<option value="'.$automatic.'">'.$langs->trans("Automatic").'</option>'."\n"; $resultautomanual .= '<option value="'.$automatic.'">'.$langs->trans("Automatic").'</option>'."\n";
$resultautomanual .= '<option value="'.$manual.'"'.$selected.'>'.$langs->trans("Manual").'</option>'."\n"; $resultautomanual .= '<option value="'.$manual.'"'.$selected.'>'.$langs->trans("Manual").'</option>'."\n";

View File

@ -560,12 +560,12 @@ if (empty($reshook))
{ {
if ($lines[$i]->id == $line_id) if ($lines[$i]->id == $line_id)
{ {
// delete single warehouse line // delete single warehouse line
$line->id = $line_id; $line->id = $line_id;
if (! $error && $line->delete($user) < 0) if (! $error && $line->delete($user) < 0)
{ {
$error++; $error++;
} }
} }
unset($_POST["lineid"]); unset($_POST["lineid"]);
} }
@ -949,31 +949,28 @@ if ($action == 'create')
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#autofill").click(function() {'; jQuery("#autofill").click(function() {';
$i=1; $i=1;
while($i <= $numAsked) while($i <= $numAsked)
{ {
print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n"; print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n";
$i++; $i++;
} }
print '}); print '});
jQuery("#autoreset").click(function() {'; jQuery("#autoreset").click(function() {';
$i=1; $i=1;
while($i <= $numAsked) while($i <= $numAsked)
{ {
print 'jQuery("#qtyl'.$i.'").val(0);'."\n"; print 'jQuery("#qtyl'.$i.'").val(0);'."\n";
$i++; $i++;
} }
print '}); print '});
}); });
</script>'; </script>';
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Load receptions already done for same order // Load receptions already done for same order
$object->loadReceptions(); $object->loadReceptions();
@ -1113,59 +1110,57 @@ if ($action == 'create')
$stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number
$deliverableQty=$dispatchLines[$indiceAsked]['qty']; $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>';
// Stock
// Quantity to send if (! empty($conf->stock->enabled))
print '<td class="center">'; {
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) 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'); // Show warehouse combo list
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; $ent = "entl".$indiceAsked;
print '<input name="qtyl'.$indiceAsked.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">'; $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"); else
print '</td>';
// Stock
if (! empty($conf->stock->enabled))
{ {
print '<td class="left">'; print $langs->trans("Service");
if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? }
{ print '</td>';
// Show warehouse combo list }
$ent = "entl".$indiceAsked;
$idl = "idl".$indiceAsked; if (!empty($conf->productbatch->enabled))
$tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; {
if ($line->fk_product > 0) if (!empty($product->status_batch))
{ {
print '<!-- Show warehouse selection -->'; print '<td><input name="batch'.$indiceAsked.'" value="'.$dispatchLines[$indiceAsked]['lot'].'"></td>';
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); print '<td>';
} print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, "");
} print '</td>';
else print '<td>';
{ print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, "");
print $langs->trans("Service");
}
print '</td>'; print '</td>';
} }
else {
if (!empty($conf->productbatch->enabled)) print '<td colspan="3"></td>';
{
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>';
}
} }
print "</tr>\n"; }
print "</tr>\n";
} }
//Display lines extrafields //Display lines extrafields

View File

@ -305,29 +305,28 @@ if (empty($reshook))
{ {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
$result = $object->addline( $result = $object->addline(
$desc, $desc,
$lines[$i]->subprice, $lines[$i]->subprice,
$lines[$i]->tva_tx, $lines[$i]->tva_tx,
$lines[$i]->localtax1_tx, $lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx, $lines[$i]->localtax2_tx,
$lines[$i]->qty, $lines[$i]->qty,
$lines[$i]->fk_product, $lines[$i]->fk_product,
$lines[$i]->remise_percent, $lines[$i]->remise_percent,
$date_start, $date_start,
$date_end, $date_end,
0, 0,
$lines[$i]->info_bits, $lines[$i]->info_bits,
'HT', 'HT',
$product_type, $product_type,
$i, $i,
false, false,
0, 0,
null, null,
$lines[$i]->rowid, $lines[$i]->rowid,
0, 0,
$lines[$i]->ref_supplier $lines[$i]->ref_supplier
); );
$rcp->add_object_linked('facture_fourn_det', $result); $rcp->add_object_linked('facture_fourn_det', $result);
@ -533,9 +532,9 @@ if ($resql)
} }
$arrayofmassactions = array( $arrayofmassactions = array(
// 'presend'=>$langs->trans("SendByMail"), // 'presend'=>$langs->trans("SendByMail"),
); );
if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier"); if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier");
if($massaction == 'createbills') $arrayofmassactions=array(); if($massaction == 'createbills') $arrayofmassactions=array();

View File

@ -42,38 +42,38 @@ $langs->load("receptions");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total=0; $ilink=0; $total=0; $ilink=0;
foreach($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink)
{ {
$ilink++; $ilink++;
$trclass='oddeven'; $trclass='oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
?> ?>
<tr class="<?php echo $trclass; ?>"> <tr class="<?php echo $trclass; ?>">
<td class="linkedcol-element"><?php echo $langs->trans("Reception"); ?> <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).'&amp;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).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?>
</td> </td>
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td> <td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
<td class="linkedcol-ref" align="center"></td> <td class="linkedcol-ref center"></td>
<td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td> <td class="linkedcol-date center"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
<td class="linkedcol-amount right"><?php <td class="linkedcol-amount right"><?php
if ($user->rights->reception->lire) { if ($user->rights->reception->lire) {
$total = $total + $objectlink->total_ht; $total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht); echo price($objectlink->total_ht);
} ?></td> } ?></td>
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="linkedcol-action right"> <td class="linkedcol-action right">
<?php <?php
// For now, receptions must stay linked to order, so link is not deletable // For now, receptions must stay linked to order, so link is not deletable
if($object->element != 'order_supplier') { 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
}
?> ?>
<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> </td>
</tr> </tr>
<?php <?php
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1)
{ {