Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-09-17 22:05:36 +02:00
commit 4065b52441
19 changed files with 108 additions and 85 deletions

View File

@ -47,25 +47,16 @@ function dol_basename($pathfile)
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size") * @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
* @param int $nohook Disable all hooks
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file') * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
*/ */
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0) function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false)
{ {
global $db, $hookmanager; global $db, $hookmanager;
global $object; global $object;
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter)); dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
if (! is_object($hookmanager))
{
if (! class_exists('HookManager')) {
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
}
}
$hookmanager->initHooks(array('fileslib'));
$loaddate=($mode==1||$mode==2)?true:false; $loaddate=($mode==1||$mode==2)?true:false;
$loadsize=($mode==1||$mode==3)?true:false; $loadsize=($mode==1||$mode==3)?true:false;
@ -73,23 +64,35 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$path=preg_replace('/([\\/]+)$/i','',$path); $path=preg_replace('/([\\/]+)$/i','',$path);
$newpath=dol_osencode($path); $newpath=dol_osencode($path);
$parameters=array( if (! $nohook) {
'path' => $newpath, if (! is_object($hookmanager))
'types'=> $types, {
'recursive' => $recursive, if (! class_exists('HookManager')) {
'filter' => $filter, // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
'excludefilter' => $excludefilter, require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
'sortcriteria' => $sortcriteria, $hookmanager=new HookManager($db);
'sortorder' => $sortorder, }
'loaddate' => $loaddate, }
'loadsize' => $loadsize $hookmanager->initHooks(array('fileslib'));
);
$reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object); $parameters=array(
'path' => $newpath,
'types'=> $types,
'recursive' => $recursive,
'filter' => $filter,
'excludefilter' => $excludefilter,
'sortcriteria' => $sortcriteria,
'sortorder' => $sortorder,
'loaddate' => $loaddate,
'loadsize' => $loadsize
);
$reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object);
}
// $reshook may contain returns stacked by other modules // $reshook may contain returns stacked by other modules
// $reshook is always empty with an array for can not lose returns stacked with other modules // $reshook is always empty with an array for can not lose returns stacked with other modules
// $hookmanager->resArray may contain array stacked by other modules // $hookmanager->resArray may contain array stacked by other modules
if (! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty if (! $nohook && ! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty
{ {
return $hookmanager->resArray['nodes']; return $hookmanager->resArray['nodes'];
} }

View File

@ -4003,7 +4003,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
if (verifCond($values[4])) if (verifCond($values[4]))
{ {
if ($values[3]) $langs->load($values[3]); if ($values[3]) $langs->load($values[3]);
$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[5]),1); $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[5]), 1);
$head[$h][1] = $langs->trans($values[2]); $head[$h][1] = $langs->trans($values[2]);
$head[$h][2] = str_replace('+','',$values[1]); $head[$h][2] = str_replace('+','',$values[1]);
$h++; $h++;
@ -4013,7 +4013,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
{ {
if ($values[0] != $type) continue; if ($values[0] != $type) continue;
if ($values[3]) $langs->load($values[3]); if ($values[3]) $langs->load($values[3]);
$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[4]),1); $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[4]), 1);
$head[$h][1] = $langs->trans($values[2]); $head[$h][1] = $langs->trans($values[2]);
$head[$h][2] = str_replace('+','',$values[1]); $head[$h][2] = str_replace('+','',$values[1]);
$h++; $h++;
@ -4022,7 +4022,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
{ {
if ($values[0] != $type) continue; if ($values[0] != $type) continue;
if ($values[2]) $langs->load($values[2]); if ($values[2]) $langs->load($values[2]);
$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[3]),1); $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[3]), 1);
$head[$h][1] = $langs->trans($values[1]); $head[$h][1] = $langs->trans($values[1]);
$head[$h][2] = 'tab'.$values[1]; $head[$h][2] = 'tab'.$values[1];
$h++; $h++;

View File

@ -1230,7 +1230,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
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,'\.odt'); $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
} }
} }

View File

@ -227,7 +227,7 @@ class pdf_einstein extends ModelePDFCommandes
$tab_top = 90; $tab_top = 90;
$tab_top_newpage = 10; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130; $tab_height = 130;
$tab_height_newpage = 150; $tab_height_newpage = 150;
@ -277,10 +277,10 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage; $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
} }
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
@ -355,6 +355,7 @@ if ($pageposafter > $pageposbefore) {
$pagenb++; $pagenb++;
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{ {
@ -371,6 +372,7 @@ if ($pageposafter > $pageposbefore) {
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
} }

View File

@ -357,6 +357,7 @@ class pdf_crabe extends ModelePDFFactures
$pagenb++; $pagenb++;
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{ {
@ -373,6 +374,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
} }

View File

@ -147,7 +147,7 @@ class pdf_azur extends ModelePDFPropales
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$deja_regle = ""; // $deja_regle = 0;
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
@ -355,6 +355,7 @@ class pdf_azur extends ModelePDFPropales
$pagenb++; $pagenb++;
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{ {
@ -371,6 +372,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
} }
} }
@ -393,10 +395,12 @@ class pdf_azur extends ModelePDFPropales
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
/*
if ($deja_regle) if ($deja_regle)
{ {
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
} }
*/
// Pied de page // Pied de page
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
@ -793,8 +797,10 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
/*
$resteapayer = $object->total_ttc - $deja_regle; $resteapayer = $object->total_ttc - $deja_regle;
if ($object->paye) $resteapayer=0; if (! empty($object->paye)) $resteapayer=0;
*/
if ($deja_regle > 0) if ($deja_regle > 0)
{ {
@ -806,6 +812,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
/*
if ($object->close_code == 'discount_vat') if ($object->close_code == 'discount_vat')
{ {
$index++; $index++;
@ -819,6 +826,7 @@ class pdf_azur extends ModelePDFPropales
$resteapayer=0; $resteapayer=0;
} }
*/
$index++; $index++;
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);

View File

@ -109,7 +109,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else else
{ {
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt'); $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,20 +20,20 @@
<!-- BEGIN PHP TEMPLATE admin_extrafields.tpl.php --> <!-- BEGIN PHP TEMPLATE admin_extrafields.tpl.php -->
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
function init_typeoffields() function init_typeoffields(type)
{ {
if (jQuery("#type").val() == 'date') { jQuery("#size").val(''); jQuery("#size").attr('disabled','disabled'); } var size = jQuery("#size");
else if (jQuery("#type").val() == 'datetime') { jQuery("#size").val(''); jQuery("#size").attr('disabled','disabled'); } if (type == 'date') { size.val('').attr('disabled','disabled'); }
else if (jQuery("#type").val() == 'double') { jQuery("#size").val('24,8'); jQuery("#size").removeAttr('disabled'); } else if (type == 'datetime') { size.val('').attr('disabled','disabled'); }
else if (jQuery("#type").val() == 'int') { jQuery("#size").val('10'); jQuery("#size").removeAttr('disabled'); } else if (type == 'double') { size.val('24,8').removeAttr('disabled'); }
else if (jQuery("#type").val() == 'text') { jQuery("#size").val('2000'); jQuery("#size").removeAttr('disabled'); } else if (type == 'int') { size.val('10').removeAttr('disabled'); }
else if (jQuery("#type").val() == 'varchar') { jQuery("#size").val('255'); jQuery("#size").removeAttr('disabled'); } else if (type == 'text') { size.val('2000').removeAttr('disabled'); }
else if (jQuery("#type").val() == '') { jQuery("#size").val(''); jQuery("#size").attr('disabled','disabled'); } else if (type == 'varchar') { size.val('255').removeAttr('disabled'); }
else jQuery("#size").attr('disabled','disabled'); else size.val('').attr('disabled','disabled');
} }
init_typeoffields(); init_typeoffields();
jQuery("#type").change(function() { jQuery("#type").change(function() {
init_typeoffields(); init_typeoffields($(this).val());
}); });
}); });
</script> </script>

View File

@ -631,7 +631,7 @@ if ($id > 0 || ! empty($ref))
print $formproduct->selectWarehouses(-1,'entrepot_id','',1); print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
if (count($formproduct->cache_warehouses) <= 0) if (count($formproduct->cache_warehouses) <= 0)
{ {
print ' &nbsp; No warehouse defined, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">add one</a>'; print ' &nbsp; '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">'.$langs->trans("AddOne").'</a>';
} }
print '</td>'; print '</td>';
} }

View File

@ -8,6 +8,8 @@ MenuNewWarehouse=New warehouse
WarehouseOpened=Warehouse opened WarehouseOpened=Warehouse opened
WarehouseClosed=Warehouse closed WarehouseClosed=Warehouse closed
WarehouseSource=Source warehouse WarehouseSource=Source warehouse
WarehouseSourceNotDefined=No warehouse defined,
AddOne=Add one
WarehouseTarget=Target warehouse WarehouseTarget=Target warehouse
ValidateSending=Delete sending ValidateSending=Delete sending
CancelSending=Cancel sending CancelSending=Cancel sending

View File

@ -8,6 +8,8 @@ MenuNewWarehouse=Nouvel entrepôt
WarehouseOpened=Entrepôt ouvert WarehouseOpened=Entrepôt ouvert
WarehouseClosed=Entrepôt fermé WarehouseClosed=Entrepôt fermé
WarehouseSource=Entrepôt source WarehouseSource=Entrepôt source
WarehouseSourceNotDefined=Aucun entrepôt défini,
AddOne=En ajouter un
WarehouseTarget=Entrepôt cible WarehouseTarget=Entrepôt cible
ValidateSending=Valider expédition ValidateSending=Valider expédition
CancelSending=Annuler expédition CancelSending=Annuler expédition

View File

@ -1817,7 +1817,7 @@ else
$var=true; $var=true;
$somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang,$hookmanager);
print '</td>'; print '</td>';
print '<td></td>'; print '<td></td>';

View File

@ -81,9 +81,9 @@ else
if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid; if (!empty($socid)) $sql.= " AND u.fk_societe = ".$socid;
if ($search_user) if ($search_user)
{ {
$sql.= " AND (u.login like '%".$search_user."%' OR u.name like '%".$search_user."%' OR u.firstname like '%".$search_user."%')"; $sql.= " AND (u.login LIKE '%".$search_user."%' OR u.name LIKE '%".$search_user."%' OR u.firstname LIKE '%".$search_user."%')";
} }
if ($sall) $sql.= " AND (u.login like '%".$db->escape($sall)."%' OR u.name like '%".$db->escape($sall)."%' OR u.firstname like '%".$db->escape($sall)."%' OR u.email like '%".$db->escape($sall)."%' OR u.note like '%".$db->escape($sall)."%')"; if ($sall) $sql.= " AND (u.login LIKE '%".$db->escape($sall)."%' OR u.name LIKE '%".$db->escape($sall)."%' OR u.firstname LIKE '%".$db->escape($sall)."%' OR u.email LIKE '%".$db->escape($sall)."%' OR u.note LIKE '%".$db->escape($sall)."%')";
$sql.=$db->order($sortfield,$sortorder); $sql.=$db->order($sortfield,$sortorder);
$result = $db->query($sql); $result = $db->query($sql);
@ -130,6 +130,7 @@ if ($result)
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1); print $companystatic->getNomUrl(1);
} }
// Multicompany enabled
else if (! empty($conf->multicompany->enabled)) else if (! empty($conf->multicompany->enabled))
{ {
if (! $obj->entity) if (! $obj->entity)
@ -138,6 +139,8 @@ if ($result)
} }
else else
{ {
// $mc is defined in conf.class.php if multicompany enabled.
// remove constante MAIN_MODULE_MULTICOMPANY if you have an error.
$mc->getInfo($obj->entity); $mc->getInfo($obj->entity);
print $mc->label; print $mc->label;
} }
@ -172,7 +175,7 @@ else
dol_print_error($db); dol_print_error($db);
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>