From e86e46c6823c00b7c42a6ed47f102fe0c55604b3 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 28 Apr 2015 13:20:18 +0200 Subject: [PATCH 01/43] Add company icon for direct link Very usefull to create "on the fly" a new contact... --- htdocs/core/tpl/contacts.tpl.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 6aaf0f5f28d..a2522ecde72 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2013-2014 Laurent Destailleur +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2014 Laurent Destailleur + * Copyright (C) 201 Charlie BENKE * * 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 @@ -94,6 +95,14 @@ $userstatic=new User($db);
trans("ThirdPartyContacts"); ?>
socid; ?> + fetch($selectedCompany); + echo $companystatic->getNomUrl(2); + } + ?> selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?>
From 3b02bf14246250cfa9e9f94b36f9076033714de2 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 28 Apr 2015 13:25:38 +0200 Subject: [PATCH 02/43] fix : withpicto = 2 send only icon --- htdocs/societe/class/societe.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 93144e155c9..b31419974c8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1811,7 +1811,8 @@ class Societe extends CommonObject if ($withpicto) $result.=($link.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"')).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$link.($maxlen?dol_trunc($name,$maxlen):$name).$linkend; + $result.=$lien.($withpicto !=2?($maxlen?dol_trunc($name,$maxlen):$name):'').$lienfin; + return $result; } From 5b5918f60ce28dc67f72701779cd18ac0284ceb4 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 18 May 2015 01:00:06 +0200 Subject: [PATCH 03/43] Update societe.class.php --- htdocs/societe/class/societe.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b31419974c8..7a56868d76e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1811,8 +1811,7 @@ class Societe extends CommonObject if ($withpicto) $result.=($link.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip"')).$linkend); if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$lien.($withpicto !=2?($maxlen?dol_trunc($name,$maxlen):$name):'').$lienfin; - + $result.=$link.($withpicto !=2?($maxlen?dol_trunc($name,$maxlen):$name):'').$linkend; return $result; } From 750974ec5cb0fb9d390d47ffe824ae7d33e7ad86 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 15 Jul 2015 19:48:54 +0200 Subject: [PATCH 04/43] Update contacts.tpl.php your right i'm not so old ;-) --- htdocs/core/tpl/contacts.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index a2522ecde72..a868cf5eb4f 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Laurent Destailleur - * Copyright (C) 201 Charlie BENKE + * Copyright (C) 2015 Charlie BENKE * * 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 From 900c287de452712035034c90e39fe14f40701cc8 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 21 Jul 2015 12:29:09 +0200 Subject: [PATCH 05/43] NEW : conf to use next product/service ref when we clone a product/service Conflicts: htdocs/langs/en_US/admin.lang htdocs/langs/fr_FR/admin.lang htdocs/product/admin/product.php --- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/product/admin/product.php | 20 ++++++++++++++++++++ htdocs/product/card.php | 16 +++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 59b495d8a12..558d80be14a 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1392,6 +1392,7 @@ ModifyProductDescAbility=Personalization of product descriptions in forms ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip) MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the thirdparty language +UseMaskOnClone=Use product next ref when we clone a product%s (available if mask configured) UseSearchToSelectProductTooltip=Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. UseSearchToSelectProduct=Use a search form to choose a product (rather than a drop-down list). UseEcoTaxeAbility=Support Eco-Taxe (WEEE) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 51379c4caf2..ec8133df8bd 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1392,6 +1392,7 @@ ModifyProductDescAbility=Personnalisation des descriptions produits dans les for ViewProductDescInFormAbility=Visualisation des descriptions produits dans les formulaires (sinon en tant que bulle d'aide) MergePropalProductCard=Ajoute dans l'onglet Fichiers joints des produits/services, une option pour fusionner le document PDF du produit au PDF des propositions Azur si le produit/services est inclut dans la proposition. ViewProductDescInThirdpartyLanguageAbility=Visualisation des descriptions produits dans la langue du tiers +UseMaskOnClone=Utiliser la prochaine référence lors du clonage d'un produit%s (disponible si le masque est configuré ci-dessus) UseSearchToSelectProductTooltip=Si vous avez un nombre important de produits (>100 000), vous pourrez améliorer les performances en positionnant la constante PRODUCT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limité au début des chaines. UseSearchToSelectProduct=Utilisez un champ avec auto-complétion pour choisir les produits (plutôt qu'une liste déroulante). UseEcoTaxeAbility=Prise en charge des éco-taxes (DEEE) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index c8105c8b61a..e19f3001883 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -169,6 +169,11 @@ else if ($action == 'usesearchtoselectproduct') $usesearch = GETPOST('activate_usesearchtoselectproduct','alpha'); $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $usesearch,'chaine',0,'',$conf->entity); } +else if ($action == 'useMaskOnClone') +{ + $usemask = GETPOST('activate_useMaskOnClone','alpha'); + $res = dolibarr_set_const($db, "PRODUIT_USE_MASK_ON_CLONE", $usemask,'chaine',0,'',$conf->entity); +} else if ($action == 'set') { $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe','alpha')); @@ -439,6 +444,21 @@ print ''; print ''; print ''; +// Pouvoir utiliser la numérotation configurée dans le masque produit lors du clonage d'un produit +$var=!$var; +print '
'; +print ''; +print ''; +print ''; +print ''.$langs->trans("UseMaskOnClone", $conf->service->enabled ? '/service' : '').''; +print ''; +print $form->selectyesno("activate_useMaskOnClone",$conf->global->PRODUIT_USE_MASK_ON_CLONE,1); +print ''; +print ''; +print ''; +print ''; +print '
'; + // Activate propal merge produt card /* disabled. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works. $var=!$var; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 704a0db9442..36d79dc6d39 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1601,11 +1601,25 @@ else } } +// Load object modCodeProduct +$module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); +if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') +{ + $module = substr($module, 0, dol_strlen($module)-4); +} +$result=dol_include_once('/core/modules/product/'.$module.'.php'); +if ($result > 0) +{ + $modCodeProduct = new $module(); +} + +$tmpcode=''; +if (! empty($modCodeProduct->code_auto) && $conf->global->PRODUIT_USE_MASK_ON_CLONE) $tmpcode=$modCodeProduct->getNextValue($object,$object->type); // Define confirmation messages $formquestionclone=array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24), + array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true), array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1) From dd2f6997309893659563dca165fcce701cd9f8d0 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Thu, 13 Aug 2015 09:28:25 +0200 Subject: [PATCH 06/43] NEW : next ref on clone doesn't need conf, it's used if mask exists --- htdocs/product/admin/product.php | 20 -------------------- htdocs/product/card.php | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index e19f3001883..c8105c8b61a 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -169,11 +169,6 @@ else if ($action == 'usesearchtoselectproduct') $usesearch = GETPOST('activate_usesearchtoselectproduct','alpha'); $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $usesearch,'chaine',0,'',$conf->entity); } -else if ($action == 'useMaskOnClone') -{ - $usemask = GETPOST('activate_useMaskOnClone','alpha'); - $res = dolibarr_set_const($db, "PRODUIT_USE_MASK_ON_CLONE", $usemask,'chaine',0,'',$conf->entity); -} else if ($action == 'set') { $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe','alpha')); @@ -444,21 +439,6 @@ print ''; print ''; print ''; -// Pouvoir utiliser la numérotation configurée dans le masque produit lors du clonage d'un produit -$var=!$var; -print '
'; -print ''; -print ''; -print ''; -print ''.$langs->trans("UseMaskOnClone", $conf->service->enabled ? '/service' : '').''; -print ''; -print $form->selectyesno("activate_useMaskOnClone",$conf->global->PRODUIT_USE_MASK_ON_CLONE,1); -print ''; -print ''; -print ''; -print ''; -print '
'; - // Activate propal merge produt card /* disabled. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works. $var=!$var; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 36d79dc6d39..5fdba5958f2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1614,7 +1614,7 @@ if ($result > 0) } $tmpcode=''; -if (! empty($modCodeProduct->code_auto) && $conf->global->PRODUIT_USE_MASK_ON_CLONE) $tmpcode=$modCodeProduct->getNextValue($object,$object->type); +if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$object->type); // Define confirmation messages $formquestionclone=array( From 573773d95dd4be3a295fbbbb11ed2869cc5be081 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 15 Aug 2015 21:22:43 +0200 Subject: [PATCH 07/43] Add fichinter area add fichinter area --- htdocs/fichinter/index.php | 365 +++++++++++++++++++++++++++++++++++++ 1 file changed, 365 insertions(+) create mode 100644 htdocs/fichinter/index.php diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php new file mode 100644 index 00000000000..6885dca361a --- /dev/null +++ b/htdocs/fichinter/index.php @@ -0,0 +1,365 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Charlie Benke + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fichinter/index.php + * \ingroup commande + * \brief Home page of interventional module + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; +require_once DOL_DOCUMENT_ROOT .'/fichinter/class/fichinter.class.php'; + +if (!$user->rights->ficheinter->lire) accessforbidden(); + +$langs->load("interventions"); + +// Security check +$socid=GETPOST('socid','int'); +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + + + +/* + * View + */ + +$fichinterstatic=new Fichinter($db); +$form = new Form($db); +$formfile = new FormFile($db); +$help_url="EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones"; + +llxHeader("",$langs->trans("Interventions"),$help_url); + +print_fiche_titre($langs->trans("InterventionsArea")); + +//print ''; +//print '
'; +print '
'; + + +// Search ficheinter +$var=false; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "
'.$langs->trans("SearchAnIntervention").'
'; +print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; + + +/* + * Statistics + */ + +$sql = "SELECT count(f.rowid), f.fk_statut"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= ", ".MAIN_DB_PREFIX."fichinter as f"; +if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE f.fk_soc = s.rowid"; +$sql.= " AND f.entity IN (".getEntity('societe', 1).")"; +if ($user->societe_id) $sql.=' AND f.fk_soc = '.$user->societe_id; +if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " GROUP BY f.fk_statut"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $total=0; + $totalinprocess=0; + $dataseries=array(); + $vals=array(); + $bool=false; + // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + $bool=(! empty($row[2])?true:false); + if (! isset($vals[$row[1].$bool])) $vals[$row[1].$bool]=0; + $vals[$row[1].$bool]+=$row[0]; + $totalinprocess+=$row[0]; + } + $total+=$row[0]; + } + $i++; + } + $db->free($resql); + print ''; + print ''."\n"; + $listofstatus=array(0,1,2); + $bool=false; + foreach ($listofstatus as $status) + { + $dataseries[]=array('label'=>$fichinterstatic->LibStatut($status,$bool,1),'data'=>(isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); + if ($status==3 && $bool==false) $bool=true; + else $bool=false; + } + if ($conf->use_javascript_ajax) + { + print ''; + } + $var=true; + $bool=false; + foreach ($listofstatus as $status) + { + if (! $conf->use_javascript_ajax) + { + $var=!$var; + print ""; + print ''; + print ''; + print "\n"; + if ($status==3 && $bool==false) $bool=true; + else $bool=false; + } + } + //if ($totalinprocess != $total) + //print ''; + print ''; + print "
'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'
'; + $data=array('series'=>$dataseries); + dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'.$fichinterstatic->LibStatut($status,$bool,0).''.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' '; + print $fichinterstatic->LibStatut($status,$bool,3); + print ''; + print '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'

"; +} +else +{ + dol_print_error($db); +} + + +/* + * Draft orders + */ +if (! empty($conf->ficheinter->enabled)) +{ + $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.entity IN (".getEntity('fichinter', 1).")"; + $sql.= " AND f.fk_statut = 0"; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + + $resql=$db->query($sql); + if ($resql) + { + print ''; + print ''; + print ''; + $langs->load("fichinter"); + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print '"; + print ''; + $i++; + } + } + print "
'.$langs->trans("DraftFichinter").'
'; + print "rowid."\">".img_object($langs->trans("ShowFichinter"),"intervention").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'

"; + } +} + + +//print '
'; +print '
'; + + +$max=5; + +/* + * Last modified orders + */ + +$sql = "SELECT f.rowid, f.ref, f.fk_statut, f.date_valid as datec, f.tms as datem,"; +$sql.= " s.nom as name, s.rowid as socid"; +$sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f,"; +$sql.= " ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE f.fk_soc = s.rowid"; +$sql.= " AND f.entity IN (".getEntity('commande', 1).")"; +//$sql.= " AND c.fk_statut > 2"; +if ($socid) $sql .= " AND f.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " ORDER BY f.tms DESC"; +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + + print ""; + print ''; + + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + print "
'.$langs->trans("LastModifiedInterventions",$max).'
'; + + $fichinterstatic->id=$obj->rowid; + $fichinterstatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $fichinterstatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''.dol_print_date($db->jdate($obj->datem),'day').''.$fichinterstatic->LibStatut($obj->fk_statut,5).'

"; +} +else dol_print_error($db); + + +/* + * Orders to process + */ +if (! empty($conf->commande->enabled)) +{ + $sql = "SELECT f.rowid, f.ref, f.fk_statut, s.nom as name, s.rowid as socid"; + $sql.=" FROM ".MAIN_DB_PREFIX."fichinter as f"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.entity IN (".getEntity('commande', 1).")"; + $sql.= " AND f.fk_statut = 1"; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY f.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + + print "
'.$langs->trans("OrdersToProcess").' '.$num.'
'; + + $fichinterstatic->id=$obj->rowid; + $fichinterstatic->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $fichinterstatic->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($fichinterstatic->element, $filename, $filedir); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).''.$fichinterstatic->LibStatut($obj->fk_statut,5).'

"; + } + else dol_print_error($db); +} + + + + +//print '
'; +print '
'; + + +llxFooter(); + +$db->close(); From 82729744b58e5cba6774250347b35391d2d306d5 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 15 Aug 2015 21:24:30 +0200 Subject: [PATCH 08/43] add translation for intervention area --- htdocs/langs/fr_FR/interventions.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/fr_FR/interventions.lang b/htdocs/langs/fr_FR/interventions.lang index f43c8d44825..884efb38cfc 100644 --- a/htdocs/langs/fr_FR/interventions.lang +++ b/htdocs/langs/fr_FR/interventions.lang @@ -39,6 +39,9 @@ InterventionClassifiedUnbilledInDolibarr=Intervention %s positionné à non fact InterventionSentByEMail=Intervention %s envoyé par EMail InterventionDeletedInDolibarr=Intervention %s effacée SearchAnIntervention=Chercher une intervention +InterventionsArea=Espace interventions +DraftFichinter=Interventions brouillon +LastModifiedInterventions=Les %s dernières interventions modifiées ##### Types de contacts ##### TypeContact_fichinter_internal_INTERREPFOLL=Responsable suivi de l'intervention TypeContact_fichinter_internal_INTERVENING=Intervenant From d1c540157effb77f964adf00bb42bbd990cae5e4 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 15 Aug 2015 21:26:18 +0200 Subject: [PATCH 09/43] add link to fichinter area change inter menu --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 807f6759c51..423e906f73c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -734,7 +734,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); - $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 200); + $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); } From 04b3c23692947f7a2b882f0bf298b7f86c6ba696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9onard?= Date: Fri, 4 Sep 2015 18:16:43 +0200 Subject: [PATCH 10/43] Fix detailed information of BBAN for Germany --- htdocs/compta/bank/class/account.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 72aa176b7b6..e9796d7d671 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1086,8 +1086,8 @@ class Account extends CommonObject { $country_code=$this->getCountryCode(); - if (in_array($country_code,array('CH','DE','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon - if (in_array($country_code,array('AU','BE','CA','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, Great Britain... + if (in_array($country_code,array('CH','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon + if (in_array($country_code,array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, Great Britain... return 0; } From 11241c51f5b432c72ffb6d16d907af3fc137cbe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9onard?= Date: Fri, 4 Sep 2015 18:30:54 +0200 Subject: [PATCH 11/43] Fix detailed information of BBAN for Belgium --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 72aa176b7b6..0cc92a6db35 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1087,7 +1087,7 @@ class Account extends CommonObject $country_code=$this->getCountryCode(); if (in_array($country_code,array('CH','DE','FR','ES','GA','IT'))) return 1; // France, Spain, Gabon - if (in_array($country_code,array('AU','BE','CA','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, Great Britain... + if (in_array($country_code,array('AU','CA','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, Great Britain... return 0; } From d18b03840b44395b924df5e912eb1a3b12e7e382 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Fri, 4 Sep 2015 21:16:43 +0200 Subject: [PATCH 12/43] Adding Document tab into Bank Account --- htdocs/compta/bank/document.php | 233 +++++++++++++++++++++++++++++++ htdocs/core/class/conf.class.php | 3 + htdocs/core/lib/bank.lib.php | 5 + 3 files changed, 241 insertions(+) create mode 100644 htdocs/compta/bank/document.php diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php new file mode 100644 index 00000000000..a039a5f2337 --- /dev/null +++ b/htdocs/compta/bank/document.php @@ -0,0 +1,233 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2011 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/commande/document.php + * \ingroup order + * \brief Page de gestion des documents attachees a une commande + */ +require('../../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php"); +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; + +$langs->load("banks"); + + +$langs->load('companies'); +$langs->load('other'); + +$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + +$mesg = ''; +if (isset($_SESSION['DolMessage'])) { + $mesg = $_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + +// Security check +if ($user->societe_id) { + $action = ''; + $socid = $user->societe_id; +} +if ($user->societe_id) + $socid = $user->societe_id; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', + $fieldtype); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) + $sortorder = "ASC"; +if (!$sortfield) + $sortfield = "name"; + +$object = new Account($db); +if ($id) + $object->fetch($id); + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { + if ($object->fetch($id)) { + + $upload_dir = $conf->bank->dir_output . "/" . $object->ref; + + if (dol_mkdir($upload_dir) >= 0) { + $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], + $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), + 0, 0, $_FILES['userfile']['error']); + if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) + == 1) { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], + $maxwidthsmall, $maxheightsmall, '_small', $quality, + "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], + $maxwidthmini, $maxheightmini, '_mini', $quality, + "thumbs"); + } + $mesg = '
' . $langs->trans("FileTransferComplete") . '
'; + } + else { + $langs->load("errors"); + if ($resupload < 0) { // Unknown error + $mesg = '
' . $langs->trans("ErrorFileNotUploaded") . '
'; + } + else if (preg_match('/ErrorFileIsInfectedWithAVirus/', + $resupload)) { // Files infected by a virus + $mesg = '
' . $langs->trans("ErrorFileIsInfectedWithAVirus") . '
'; + } + else { // Known error + $mesg = '
' . $langs->trans($resupload) . '
'; + } + } + } + } +} + +// Delete +else if ($action == 'confirm_deletefile' && $confirm == 'yes') { + if ($object->fetch($id)) { + + $upload_dir = $conf->bank->dir_output; + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) { + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + } else { + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } + + Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit; + } +} + + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref)) { + + $upload_dir = $conf->bank->dir_output . '/' . $object->ref; + + // Onglets + $head = bank_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, + 'account'); + + + // Construit liste des fichiers + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', + $sortfield, + (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize+=$file['size']; + } + + + print ''; + + // Ref + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + // Status + print ''; + print ''; + print ''; + print ''; + print "
' . $langs->trans("Ref") . ''; + print $form->showrefnav($object, 'ref', '', 1, 'ref'); + print '
' . $langs->trans("Label") . '' . $object->label . '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' . $totalsize . ' ' . $langs->trans("bytes") . '
\n"; + print "\n"; + + dol_htmloutput_mesg($mesg, $mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') { + $ret = $form->form_confirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode($_GET["urlfile"]), + $langs->trans('DeleteFile'), + $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', + '', 0, 1); + if ($ret == 'html') + print '
'; + } + + // Affiche formulaire upload + $formfile = new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT . '/compta/bank/document.php?id=' . $object->id, + '', 0, 0, $user->rights->banque, 50, $object); + + + // List of document + $param = '&id=' . $object->id; + $formfile->list_of_documents($filearray, $object, 'bank', $param); + } + else { + dol_print_error($db); + } +} +else { + Header('Location: index.php'); +} + + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 01e092c842e..b3e5b843c28 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -346,6 +346,9 @@ class Conf // Module contrat $this->contrat->dir_output=$rootfordata."/contracts"; $this->contrat->dir_temp =$rootfordata."/contracts/temp"; + // Module bank + $this->bank->dir_output=$rootfordata."/bank"; + $this->bank->dir_temp =$rootfordata."/bank/temp"; // Set some default values diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index bca5b2f1bdf..66dab46b47a 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -72,6 +72,11 @@ function bank_prepare_head(Account $object) $h++; } + $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'document'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab From 692fdbaec479d325b2650997d09ad7b40e9e8a3b Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Fri, 4 Sep 2015 21:16:43 +0200 Subject: [PATCH 13/43] Adding Document tab into Bank Account --- htdocs/compta/bank/document.php | 233 +++++++++++++++++++++++++++++++ htdocs/core/class/conf.class.php | 3 + htdocs/core/lib/bank.lib.php | 5 + 3 files changed, 241 insertions(+) create mode 100644 htdocs/compta/bank/document.php diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php new file mode 100644 index 00000000000..a039a5f2337 --- /dev/null +++ b/htdocs/compta/bank/document.php @@ -0,0 +1,233 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2011 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/commande/document.php + * \ingroup order + * \brief Page de gestion des documents attachees a une commande + */ +require('../../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php"); +require_once(DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php"); +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; + +$langs->load("banks"); + + +$langs->load('companies'); +$langs->load('other'); + +$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); + +$mesg = ''; +if (isset($_SESSION['DolMessage'])) { + $mesg = $_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + +// Security check +if ($user->societe_id) { + $action = ''; + $socid = $user->societe_id; +} +if ($user->societe_id) + $socid = $user->societe_id; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', + $fieldtype); + +// Get parameters +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) + $sortorder = "ASC"; +if (!$sortfield) + $sortfield = "name"; + +$object = new Account($db); +if ($id) + $object->fetch($id); + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { + if ($object->fetch($id)) { + + $upload_dir = $conf->bank->dir_output . "/" . $object->ref; + + if (dol_mkdir($upload_dir) >= 0) { + $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], + $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), + 0, 0, $_FILES['userfile']['error']); + if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) + == 1) { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], + $maxwidthsmall, $maxheightsmall, '_small', $quality, + "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], + $maxwidthmini, $maxheightmini, '_mini', $quality, + "thumbs"); + } + $mesg = '
' . $langs->trans("FileTransferComplete") . '
'; + } + else { + $langs->load("errors"); + if ($resupload < 0) { // Unknown error + $mesg = '
' . $langs->trans("ErrorFileNotUploaded") . '
'; + } + else if (preg_match('/ErrorFileIsInfectedWithAVirus/', + $resupload)) { // Files infected by a virus + $mesg = '
' . $langs->trans("ErrorFileIsInfectedWithAVirus") . '
'; + } + else { // Known error + $mesg = '
' . $langs->trans($resupload) . '
'; + } + } + } + } +} + +// Delete +else if ($action == 'confirm_deletefile' && $confirm == 'yes') { + if ($object->fetch($id)) { + + $upload_dir = $conf->bank->dir_output; + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) { + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + } else { + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } + + Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit; + } +} + + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + +if ($id > 0 || !empty($ref)) { + if ($object->fetch($id, $ref)) { + + $upload_dir = $conf->bank->dir_output . '/' . $object->ref; + + // Onglets + $head = bank_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, + 'account'); + + + // Construit liste des fichiers + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', + $sortfield, + (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize+=$file['size']; + } + + + print ''; + + // Ref + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + // Status + print ''; + print ''; + print ''; + print ''; + print "
' . $langs->trans("Ref") . ''; + print $form->showrefnav($object, 'ref', '', 1, 'ref'); + print '
' . $langs->trans("Label") . '' . $object->label . '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' . $totalsize . ' ' . $langs->trans("bytes") . '
\n"; + print "\n"; + + dol_htmloutput_mesg($mesg, $mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') { + $ret = $form->form_confirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode($_GET["urlfile"]), + $langs->trans('DeleteFile'), + $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', + '', 0, 1); + if ($ret == 'html') + print '
'; + } + + // Affiche formulaire upload + $formfile = new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT . '/compta/bank/document.php?id=' . $object->id, + '', 0, 0, $user->rights->banque, 50, $object); + + + // List of document + $param = '&id=' . $object->id; + $formfile->list_of_documents($filearray, $object, 'bank', $param); + } + else { + dol_print_error($db); + } +} +else { + Header('Location: index.php'); +} + + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 01e092c842e..b3e5b843c28 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -346,6 +346,9 @@ class Conf // Module contrat $this->contrat->dir_output=$rootfordata."/contracts"; $this->contrat->dir_temp =$rootfordata."/contracts/temp"; + // Module bank + $this->bank->dir_output=$rootfordata."/bank"; + $this->bank->dir_temp =$rootfordata."/bank/temp"; // Set some default values diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index bca5b2f1bdf..66dab46b47a 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -72,6 +72,11 @@ function bank_prepare_head(Account $object) $h++; } + $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'document'; + $h++; + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab From a80b4703a9ccd886b43d0908c4acec56efd5682b Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Fri, 4 Sep 2015 21:42:14 +0200 Subject: [PATCH 14/43] Bugfix w/ Travis CI --- htdocs/compta/bank/document.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index a039a5f2337..c6b66dcacc7 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -230,4 +230,3 @@ else { llxFooter(); $db->close(); -?> From 2395c1ca11ce8ae7162983db176f20bee7e874e5 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Fri, 4 Sep 2015 21:58:09 +0200 Subject: [PATCH 15/43] fix comment in file description --- htdocs/compta/bank/document.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index c6b66dcacc7..0b588fa64d0 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/commande/document.php - * \ingroup order - * \brief Page de gestion des documents attachees a une commande + * \file htdocs/compta/bank/document.php + * \ingroup banque + * \brief Page de gestion des documents attaches a un compte bancaire */ require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php"); From 398e9bad942d2622c1a799eb1e39b36d0e79a086 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Sep 2015 18:35:18 +0200 Subject: [PATCH 16/43] Add ignore Conflicts: htdocs/.gitignore --- htdocs/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index e26ae1a0f45..0b4d7b82790 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -12,3 +12,4 @@ /test.php /ultimatepdf* /lead +/dolimed* From 8bea703363c927f99acf7a2cc595b59ebf49ad7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Sep 2015 19:42:07 +0200 Subject: [PATCH 17/43] Fix deadlock feature. Can't reconciliate cash bank account. Sometimes users need. I introduce a hidden option to fix this quickly. --- htdocs/compta/bank/class/account.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 72aa176b7b6..a7e55afb3cb 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -122,8 +122,10 @@ class Account extends CommonObject */ function canBeConciliated() { + global $conf; + if (empty($this->rappro)) return -1; - if ($this->courant == 2) return -2; + if ($this->courant == 2 && empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) return -2; if ($this->clos) return -3; return 1; } From 304a71710e0f2f47fd7d9d33b1903990543acfb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Sep 2015 00:57:11 +0200 Subject: [PATCH 18/43] Fix not complete info --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 298c580c170..a30c76e19d0 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -339,7 +339,7 @@ MinLength=Minimum length LanguageFilesCachedIntoShmopSharedMemory=Files .lang loaded in shared memory ExamplesWithCurrentSetup=Examples with current running setup ListOfDirectories=List of OpenDocument templates directories -ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.

Put here full path of directories.
Add a carriage return between eah directory.
To add a directory of the GED module, add here DOL_DATA_ROOT/ecm/yourdirectoryname.

Files in those directories must end with .odt. +ListOfDirectoriesForModelGenODT=List of directories containing templates files with OpenDocument format.

Put here full path of directories.
Add a carriage return between eah directory.
To add a directory of the GED module, add here DOL_DATA_ROOT/ecm/yourdirectoryname.

Files in those directories must end with .odt or .ods. NumberOfModelFilesFound=Number of ODT/ODS templates files found in those directories ExampleOfDirectoriesForModelGen=Examples of syntax:
c:\mydir
/home/mydir
DOL_DATA_ROOT/ecm/ecmdir FollowingSubstitutionKeysCanBeUsed=
To know how to create your odt document templates, before storing them in those directories, read wiki documentation: From 04e33fc92b13d804d6acdb3c021f4f60fa1ac95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 5 Sep 2015 02:38:40 +0200 Subject: [PATCH 19/43] Updated composer links --- composer.json | 6 ++++-- composer.lock | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index d5e2d7f411e..cddc166bb42 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,11 @@ "homepage": "http://www.dolibarr.org", "license": "GPL-3.0+", "support": { - "issues": "https://doliforge.org/projects/dolibarr", + "issues": "https://github.com/Dolibarr/dolibarr/issues", "forum": "http://www.dolibarr.org/forum", - "wiki": "http://wiki.dolibarr.org" + "wiki": "http://wiki.dolibarr.org", + "irc": "irc://chat.freenode.net/dolibarr", + "source": "https://github.com/Dolibarr/dolibarr" }, "require": { "php": ">=5.3.0", diff --git a/composer.lock b/composer.lock index 2856ef0b749..81c767d5e9b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "32e1fa78cc95c32b154a38e07706874c", + "hash": "2ab34d0ff69b48500c20621330c1bfd7", "packages": [ { "name": "ccampbell/chromephp", From 132a464df68cbf27cf5ca97acfed40b257c403b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Sep 2015 08:57:01 +0200 Subject: [PATCH 20/43] Update product.php --- htdocs/product/stock/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 44b17cac98f..eb010407ca3 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -655,7 +655,7 @@ if (empty($action) && $product->id) } //if (($user->rights->stock->mouvement->creer) && ! $product->hasbatch()) - if (($user->rights->stock->mouvement->creer)) + if ($user->rights->stock->mouvement->creer) { print ''.$langs->trans("StockMovement").''; } From 6a9933d9afeb071146bf03a2f02c4d2b2c27550c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Sep 2015 10:49:55 +0200 Subject: [PATCH 21/43] Update doc --- htdocs/core/tpl/contacts.tpl.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 382abbe81c0..1381b34fd44 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -1,6 +1,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2015 Charlie BENKE * * 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 @@ -94,6 +95,14 @@ $userstatic=new User($db);
trans("ThirdPartyContacts"); ?>
socid; ?> + fetch($selectedCompany); + echo $companystatic->getNomUrl(2); + } + ?> selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?>
From 873f33b8ab9d2ab47eafec29fdf64a219b801916 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Sep 2015 11:22:14 +0200 Subject: [PATCH 22/43] Missing translation --- htdocs/langs/en_US/interventions.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 67d4f61d9f1..de51b363616 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -39,6 +39,9 @@ InterventionClassifiedUnbilledInDolibarr=Intervention %s set as unbilled InterventionSentByEMail=Intervention %s sent by EMail InterventionDeletedInDolibarr=Intervention %s deleted SearchAnIntervention=Search an intervention +InterventionsArea=Interventions area +DraftFichinter=Draft interventions +LastModifiedInterventions=Last %s modified interventions ##### Types de contacts ##### TypeContact_fichinter_internal_INTERREPFOLL=Representative following-up intervention TypeContact_fichinter_internal_INTERVENING=Intervening From 389cb001646d909b5d4554a0006d41f4606ef9ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Sep 2015 20:02:38 +0200 Subject: [PATCH 23/43] Prepare code to mutualise buildodc and remove_file --- htdocs/core/actions_dellink.inc.php | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index 1ba98a8435a..8f3d3c5f277 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -25,6 +25,7 @@ // $action must be defined // $object must be defined // $permissiondellink must be defined +// $uploaddir (example $conf->projet->dir_output . "/";) $dellinkid = GETPOST('dellinkid','int'); @@ -34,3 +35,42 @@ if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel') & $result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid); if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); } + +// Build doc +/* TODO To mutualise code for builddoc and remove_file +if ($action == 'builddoc' && $permissiondellink) +{ + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + $outputlangs = $langs; + if (GETPOST('lang_id')) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang(GETPOST('lang_id')); + } + $result= $object->generateDocument($object->modelpdf, $outputlangs); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } +} + +// Delete file in doc form +if ($action == 'remove_file' && $permissiondellink) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + if ($object->id > 0) + { + $langs->load("other"); + $urlfile=GETPOST('urlfile','alpha'); + $file = $upload_dir . '/' . $filetodelete; + $ret=dol_delete_file($file); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); + } +} +*/ + From a21b015cbba100f55644e47bceb0b1e5c203e6aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Sep 2015 20:03:02 +0200 Subject: [PATCH 24/43] Fix XSS --- htdocs/holiday/list.php | 2 +- htdocs/projet/card.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index f5d67b13517..c350fb003e6 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -282,7 +282,7 @@ print "\n"; // FILTRES print ''; print ''; -print ''; +print ''; print ''; // DATE CREATE diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 49923afa2ea..24968839960 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -310,10 +310,11 @@ if (empty($reshook)) { $langs->load("other"); $upload_dir = $conf->projet->dir_output . "/"; - $file = $upload_dir . '/' . GETPOST('file'); + $urlfile=GETPOST('urlfile','alpha'); + $file = $upload_dir . '/' . $filetodelete; $ret=dol_delete_file($file); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); } } From 77ef046af462a5aa1a7837308ff46eb27c40856d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Sep 2015 12:30:41 +0200 Subject: [PATCH 25/43] Start to mutualize the builddoc and remove_file action. --- htdocs/core/actions_builddoc.inc.php | 108 ++++++++++++++++++ htdocs/core/actions_dellink.inc.php | 37 ------ htdocs/core/class/commonobject.class.php | 1 - .../cheque/pdf/modules_chequereceipts.php | 3 +- .../core/modules/facture/modules_facture.php | 4 +- .../modules/societe/modules_societe.class.php | 27 ++++- .../tpl/document_actions_pre_headers.tpl.php | 5 + .../install/mysql/migration/3.8.0-3.9.0.sql | 3 + htdocs/install/mysql/tables/llx_societe.sql | 1 + htdocs/livraison/class/livraison.class.php | 16 +-- htdocs/projet/class/task.class.php | 3 +- htdocs/societe/class/societe.class.php | 40 ++++++- htdocs/societe/soc.php | 57 +-------- 13 files changed, 199 insertions(+), 106 deletions(-) create mode 100644 htdocs/core/actions_builddoc.inc.php diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php new file mode 100644 index 00000000000..27e5d8f602b --- /dev/null +++ b/htdocs/core/actions_builddoc.inc.php @@ -0,0 +1,108 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/actions_builddoc.inc.php + * \brief Code for actions on building or deleting documents + */ + + +// $action must be defined +// $id must be defined +// $object must be defined and must have a method generateDocument. +// $permissioncreate must be defined +// $upload_dir must be defined (example $conf->projet->dir_output . "/";) +// $hidedetails, $hidedesc and $hideref may have been set or not. + + +// Build doc +if ($action == 'builddoc' && $permissioncreate) +{ + if (is_numeric(GETPOST('model'))) + { + $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); + } + else + { + // Reload to get all modified line records and be ready for hooks + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + /*if (empty($object->id) || ! $object->id > 0) + { + dol_print_error('Object must have been loaded by a fetch'); + exit; + }*/ + + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Special case for invoices + if (property_exists($object, 'fk_bank')) + { + if (GETPOST('fk_bank')) { // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + } else { + $object->fk_bank = $object->fk_account; + } + } + + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->client->default_lang)) $newlang=$object->client->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang; // for thirdparty + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails=0; + if (empty($hidedesc)) $hidedesc=0; + if (empty($hideref)) $hideref=0; + + $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; + } + } +} + +// Delete file in doc form +if ($action == 'remove_file' && $permissioncreate) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + if (empty($object->id) || ! $object->id > 0) + { + // Reload to get all modified line records and be ready for hooks + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + } + + $langs->load("other"); + $filetodelete=GETPOST('file','alpha'); + $file = $upload_dir . '/' . $filetodelete; + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", $filetodelete)); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", $filetodelete), 'errors'); +} + diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index 8f3d3c5f277..45fb8c5f9ec 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -36,41 +36,4 @@ if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel') & if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); } -// Build doc -/* TODO To mutualise code for builddoc and remove_file -if ($action == 'builddoc' && $permissiondellink) -{ - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - $outputlangs = $langs; - if (GETPOST('lang_id')) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang(GETPOST('lang_id')); - } - $result= $object->generateDocument($object->modelpdf, $outputlangs); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } -} - -// Delete file in doc form -if ($action == 'remove_file' && $permissiondellink) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - if ($object->id > 0) - { - $langs->load("other"); - $urlfile=GETPOST('urlfile','alpha'); - $file = $upload_dir . '/' . $filetodelete; - $ret=dol_delete_file($file); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); - } -} -*/ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a4136d880f0..42b8dba1da2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3432,7 +3432,6 @@ abstract class CommonObject require_once $file; $obj = new $classname($this->db); - //$obj->message = $message; // If generator is ODT, we must have srctemplatepath defined, if not we set it. if ($obj->type == 'odt' && empty($srctemplatepath)) diff --git a/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php b/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php index 11ff9b509ad..e4d68c525fa 100644 --- a/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/pdf/modules_chequereceipts.php @@ -71,7 +71,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Object lang a utiliser pour traduction * @return int <0 if KO, >0 if OK - * TODO + * TODO Use commonDocGenerator */ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs) { @@ -103,7 +103,6 @@ function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs) require_once $dir.$file; $obj = new $classname($db); - $obj->message = $message; // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index afae663b02b..23d55d0aa96 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -155,8 +155,8 @@ abstract class ModeleNumRefFactures * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int <0 if KO, >0 if OK - * @deprecated Use the new function generateDocument of Facture class - * @see Facture::generateDocument() + * @deprecated Use the new function generateDocument of Facture class + * @see Facture::generateDocument() */ function facture_pdf_create(DoliDB $db, Facture $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 72090a581ea..63208b1369c 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -363,6 +363,28 @@ abstract class ModeleAccountancyCode +/** + * Create a document onto disk according to template module. + * + * @param DoliDB $db Database handler + * @param Facture $object Object invoice + * @param string $message Message (not used, deprecated) + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int <0 if KO, >0 if OK + * @deprecated Use the new function generateDocument of Facture class + * @see Societe::generateDocument() + */ +function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +{ + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); +} + /** * Create a document for third party @@ -374,7 +396,7 @@ abstract class ModeleAccountancyCode * @param Translate $outputlangs Object lang to use for translation * @return int <0 if KO, >0 if OK */ -function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs) +/*function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs) { global $conf,$langs,$user; $langs->load("bills"); @@ -413,7 +435,6 @@ function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs) require_once $dir.'/'.$file; $obj = new $classname($db); - $obj->message = $message; // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. @@ -438,5 +459,5 @@ function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs) return -1; } } - +*/ diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php index 1e4dbc7c5bb..2bb6d930b84 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -17,6 +17,11 @@ * or see http://www.gnu.org/ */ + +// TODO This is an action include, not a presentation template. +// Move this file into htdocs/core/actions_document.inc.php + + // Variable $upload_dir must be defined when entering here // Send file/link diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 8b64acf2ce8..24d81f5f7e9 100644 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -23,3 +23,6 @@ INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXP ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); + +ALTER TABLE llx_societe ADD COLUMN model_pdf varchar(255); + diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 4dc1b3fe750..0244b9ea757 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -67,6 +67,7 @@ create table llx_societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- + model_pdf varchar(255), prefix_comm varchar(5), -- prefix commercial client tinyint DEFAULT 0, -- client 0/1/2 fournisseur tinyint DEFAULT 0, -- fournisseur 0/1 diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 3a1704f8d8d..c996c2a1bc5 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -35,8 +35,7 @@ if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande /** - * \class Livraison - * \brief Classe de gestion des bons de livraison + * Class to manage receptions */ class Livraison extends CommonObject { @@ -967,11 +966,14 @@ class Livraison extends CommonObject /** * Create object on disk * - * @param string $modele force le modele a utiliser ('' to not force) - * @param Translate $outputlangs objet lang a utiliser pour traduction - * @return int 0 if KO, 1 if OK + * @param string $modele force le modele a utiliser ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK */ - public function generateDocument($modele, $outputlangs='') + public function generateDocument($modele, $outputlangs='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $conf,$user,$langs; @@ -992,7 +994,7 @@ class Livraison extends CommonObject $modelpath = "core/modules/livraison/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, 0, 0, 0); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } /** diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index b938885adc9..a8dffb8c494 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1486,10 +1486,9 @@ class Task extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$langs; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7de6fdec844..c3dfeb7b226 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1012,7 +1012,7 @@ class Societe extends CommonObject $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification'; - $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.client, s.fournisseur'; + $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; $sql .= ', s.capital, s.tva_intra'; $sql .= ', s.fk_typent as typent_id'; @@ -1154,6 +1154,7 @@ class Societe extends CommonObject $this->note = $obj->note_private; // TODO Deprecated for backward comtability $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; $this->default_lang = $obj->default_lang; $this->logo = $obj->logo; @@ -3342,6 +3343,43 @@ class Societe extends CommonObject } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example. + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int <0 if KO, >0 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$user,$langs; + + // Positionne le modele sur le nom du modele a utiliser + if (! dol_strlen($modele)) + { + if (! empty($conf->global->COMPANY_ADDON_PDF)) + { + $modele = $conf->global->COMPANY_ADDON_PDF; + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined"); + return 0; + } + } + + $modelpath = "core/modules/societe/doc/"; + + $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + + return $result; + } + + /** * Function used to replace a thirdparty id with another one. * It must be used within a transaction to avoid trouble diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b80f0f2c086..bc19fbe3fd6 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -702,56 +702,11 @@ if (empty($reshook)) $mode='emailfromthirdparty'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - - /* - * Generate document - */ - if ($action == 'builddoc') // En get ou en post - { - if (is_numeric(GETPOST('model'))) - { - $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); - } - else - { - require_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php'; - - $object->fetch($socid); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=thirdparty_doc_create($db, $object, '', GETPOST('model','alpha'), $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - } - } - - // Remove file in doc form - else if ($action == 'remove_file') - { - if ($object->fetch($socid)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->societe->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - } - } + // Actions to build doc + $id = $socid; + $upload_dir = $conf->societe->dir_output; + $permissioncreate=$user->rights->societe->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -2556,7 +2511,7 @@ else $var=true; - $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang); print '
'; From 0d811dce6a939df7ec7551902ce244343696ee23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Sep 2015 14:21:42 +0200 Subject: [PATCH 26/43] Start to mutualize the builddoc and remove_file action. --- htdocs/comm/propal.php | 49 ++++++------------------------------------ 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5c3b77fc391..3549b122baa 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1053,49 +1053,6 @@ if (empty($reshook)) exit(); } - // Generation doc (depuis lien ou depuis cartouche doc) - else if ($action == 'builddoc' && $user->rights->propal->creer) { - if (GETPOST('model')) { - $object->setDocModel($user, GETPOST('model')); - } - if (GETPOST('fk_bank')) { // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank'); - } else { - $object->fk_bank = $object->fk_account; - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } - - // Remove file in doc form - else if ($action == 'remove_file' && $user->rights->propal->creer) { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); - } - } - // Set project else if ($action == 'classin' && $user->rights->propal->creer) { $object->setProject($_POST['projectid']); @@ -1211,6 +1168,12 @@ if (empty($reshook)) } } } + + // Actions to build doc + $upload_dir = $conf->propal->dir_output; + $permissioncreate=$user->rights->propal->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + } From 7c2b6e778074902894aa2a30086cf1185b083f11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Sep 2015 14:54:25 +0200 Subject: [PATCH 27/43] Fix error when mark rate is 100% and buying price is 0, no way to recalculate the unit price. Fix cancel button was disabled if mark rate was not valid Fix if mark rate is a number with space, does not hang. --- htdocs/core/tpl/objectline_edit.tpl.php | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 605b03d9c72..a9140c46dd0 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -23,7 +23,7 @@ * $object (invoice, order, ...) * $conf * $langs - * $seller, $nuyer + * $seller, $buyer * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 for supplier invoices/orders) @@ -259,6 +259,7 @@ if (! empty($conf->margin->enabled)) /* Init field buying_price and fournprice */ $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { + console.log(data); if (data && data.length > 0) { var options = ''; var trouve=false; @@ -302,9 +303,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_marginRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); - }); + });*/ global->DISPLAY_MARK_RATES)) @@ -313,9 +315,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_markRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); - }); + });*/ @@ -323,7 +326,7 @@ if (! empty($conf->margin->enabled)) /* If margin rate field empty, do nothing. */ - /* Force content of price_ht to 0 or if a discount is set recalculate it from margin rate */ + /* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */ function checkEditLine(e, npRate) { var buying_price = $("input[name='buying_price']:first"); @@ -332,16 +335,16 @@ if (! empty($conf->margin->enabled)) var rate = $("input[name='"+npRate+"']:first"); if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true; - if (! $.isNumeric(rate.val().replace(',','.'))) + if (! $.isNumeric(rate.val().replace(' ','').replace(',','.'))) { - alert('trans("rateMustBeNumeric"); ?>'); + alert('transnoentitiesnoconv("rateMustBeNumeric"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('trans("markRateShouldBeLesserThan100"); ?>'); + alert('transnoentitiesnoconv("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; @@ -354,14 +357,20 @@ if (! empty($conf->margin->enabled)) { bpjs=price2numjs(buying_price.val()); ratejs=price2numjs(rate.val()); - /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ if (npRate == "np_marginRate") - price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); + price = ((bpjs * (1 + (ratejs / 100))) / (1 - remisejs / 100)); else if (npRate == "np_markRate") - price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + { + if (ratejs != 100) + { + price = ((bpjs / (1 - (ratejs / 100))) / (1 - remisejs / 100)); + } + else price=$("input[name='price_ht']:first").val(); + } } + /* console.log("new price ht = "+price); */ $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; From aaa639a3ab6fbe3d63dd4e9f425445f04331f035 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Sep 2015 14:54:25 +0200 Subject: [PATCH 28/43] Fix error when mark rate is 100% and buying price is 0, no way to recalculate the unit price. Fix cancel button was disabled if mark rate was not valid Fix if mark rate is a number with space, does not hang. --- htdocs/core/tpl/objectline_edit.tpl.php | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 605b03d9c72..a9140c46dd0 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -23,7 +23,7 @@ * $object (invoice, order, ...) * $conf * $langs - * $seller, $nuyer + * $seller, $buyer * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 for supplier invoices/orders) @@ -259,6 +259,7 @@ if (! empty($conf->margin->enabled)) /* Init field buying_price and fournprice */ $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { + console.log(data); if (data && data.length > 0) { var options = ''; var trouve=false; @@ -302,9 +303,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_marginRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); - }); + });*/ global->DISPLAY_MARK_RATES)) @@ -313,9 +315,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_markRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); - }); + });*/ @@ -323,7 +326,7 @@ if (! empty($conf->margin->enabled)) /* If margin rate field empty, do nothing. */ - /* Force content of price_ht to 0 or if a discount is set recalculate it from margin rate */ + /* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */ function checkEditLine(e, npRate) { var buying_price = $("input[name='buying_price']:first"); @@ -332,16 +335,16 @@ if (! empty($conf->margin->enabled)) var rate = $("input[name='"+npRate+"']:first"); if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true; - if (! $.isNumeric(rate.val().replace(',','.'))) + if (! $.isNumeric(rate.val().replace(' ','').replace(',','.'))) { - alert('trans("rateMustBeNumeric"); ?>'); + alert('transnoentitiesnoconv("rateMustBeNumeric"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('trans("markRateShouldBeLesserThan100"); ?>'); + alert('transnoentitiesnoconv("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; @@ -354,14 +357,20 @@ if (! empty($conf->margin->enabled)) { bpjs=price2numjs(buying_price.val()); ratejs=price2numjs(rate.val()); - /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ if (npRate == "np_marginRate") - price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); + price = ((bpjs * (1 + (ratejs / 100))) / (1 - remisejs / 100)); else if (npRate == "np_markRate") - price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + { + if (ratejs != 100) + { + price = ((bpjs / (1 - (ratejs / 100))) / (1 - remisejs / 100)); + } + else price=$("input[name='price_ht']:first").val(); + } } + /* console.log("new price ht = "+price); */ $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; From 822d4d1b39f68af7fc5c3245d50b2559fbc09373 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Sep 2015 15:06:13 +0200 Subject: [PATCH 29/43] Fix remove log --- htdocs/core/tpl/objectline_edit.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index a9140c46dd0..4b024175423 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -259,8 +259,7 @@ if (! empty($conf->margin->enabled)) /* Init field buying_price and fournprice */ $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { - console.log(data); - if (data && data.length > 0) { + if (data && data.length > 0) { var options = ''; var trouve=false; $(data).each(function() { From e85921c82fe4c27b19efdb588cdcbda2ba716587 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 11:44:45 +0200 Subject: [PATCH 30/43] Start to introduce sftp --- htdocs/ftp/index.php | 209 +++++++++++++++++++++++++----------- htdocs/langs/en_US/ftp.lang | 2 + 2 files changed, 151 insertions(+), 60 deletions(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 4da37cde779..19c4b50dc7d 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -38,12 +38,13 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ftp',''); // Get parameters -$action = isset($_GET["action"])?$_GET["action"]:$_POST['action']; -$section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; +$action=GETPOST('action'); +$section=GETPOST('section'); if (! $section) $section='/'; $numero_ftp = GETPOST("numero_ftp"); -if (! $numero_ftp) $numero_ftp=1; -$file=isset($_GET["file"])?$_GET["file"]:$_POST['file']; +/* if (! $numero_ftp) $numero_ftp=1; */ +$file=GETPOST("file"); +$confirm=GETPOST('confirm'); $upload_dir = $conf->ftp->dir_temp; $download_dir = $conf->ftp->dir_temp; @@ -71,18 +72,19 @@ $ftp_user=$conf->global->$s_ftp_user; $ftp_password=$conf->global->$s_ftp_password; $ftp_passive=$conf->global->$s_ftp_passive; +// For result on connection +$ok=0; $conn_id=null; // FTP connection ID +$mesg=''; -/******************************************************************* +/* * ACTIONS - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ + */ -// Envoie fichier -if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +// Submit file +if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -127,7 +129,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } // Action ajout d'un rep -if ($_POST["action"] == 'add' && $user->rights->ftp->setup) +if ($action == 'add' && $user->rights->ftp->setup) { $ecmdir->ref = $_POST["ref"]; $ecmdir->label = $_POST["label"]; @@ -148,7 +150,7 @@ if ($_POST["action"] == 'add' && $user->rights->ftp->setup) } // Remove file -if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes') { // set up a connection or die if (! $conn_id) @@ -246,7 +248,7 @@ if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("De } // Remove directory -if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_deletesection' && $confirm == 'yes') { // set up a connection or die if (! $conn_id) @@ -286,7 +288,7 @@ if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'y } // Download directory -if ($_REQUEST['action'] == 'download') +if ($action == 'download') { // set up a connection or die if (! $conn_id) @@ -339,8 +341,7 @@ if ($_REQUEST['action'] == 'download') } else { - //TODO: Translate - setEventMessage('Failed to get file '.$remotefile, 'errors'); + setEventMessages($langs->trans('FailedToGetFile',$remotefile), null, 'errors'); } } @@ -355,11 +356,9 @@ if ($_REQUEST['action'] == 'download') -/******************************************************************* - * PAGE - * - * Put here all code to do according to value of "action" parameter - ********************************************************************/ +/* + * View + */ llxHeader(); @@ -383,10 +382,7 @@ $formfile=new FormFile($db); $userstatic = new User($db); - -//*********************** // List -//*********************** print_fiche_titre($langs->trans("FTPArea")); print $langs->trans("FTPAreaDesc")."
"; @@ -397,18 +393,17 @@ if (! function_exists('ftp_connect')) } else { - if (! empty($ftp_server)) + if (! empty($ftp_server)) { - // Confirm remove file - if ($_GET['action'] == 'delete') + if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1); } // Confirmation de la suppression d'une ligne categorie - if ($_GET['action'] == 'delete_section') + if ($action == 'delete_section') { print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode($_REQUEST["section"]).'&file='.urlencode($_GET["file"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1); @@ -417,8 +412,9 @@ else print $langs->trans("Server").': '.$ftp_server.'
'; print $langs->trans("Port").': '.$ftp_port.' '.($ftp_passive?"(Passive)":"(Active)").'
'; print $langs->trans("User").': '.$ftp_user.'
'; - - print $langs->trans("Directory").': '; + print $langs->trans("FTPs (FTP over SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SSL).'
'; + print $langs->trans("SFTP (FTP as a subsytem of SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SFTP).'
'; + print $langs->trans("Directory").': '; $sectionarray=preg_split('|[\/]|',$section); // For / $newsection='/'; @@ -465,24 +461,43 @@ else print ''."\n"; // set up a connection or die - if (! $conn_id) + if (empty($conn_id)) { $resultarray=dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive); + $conn_id=$resultarray['conn_id']; $ok=$resultarray['ok']; $mesg=$resultarray['mesg']; - } if ($ok) { //$type = ftp_systype($conn_id); - $newsectioniso=utf8_decode($section); - $buff = ftp_rawlist($conn_id, $newsectioniso); - $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist - //var_dump($contents); - //var_dump($buff); + $newsection=$section; + $newsectioniso=utf8_decode($section); + //$newsection='/home'; + + // List content of directory ($newsection = '/', '/home', ...) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + if ($newsection == '/') $newsection='/./'; # workaround for bug https://bugs.php.net/bug.php?id=64169 + //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection); + //var_dump($dirHandle); + $contents = scandir('ssh2.sftp://' . $conn_id . $newsection); + $buff=array(); + foreach($contents as $i => $key) + { + $buff[$i]="---------- - root root 1234 Aug 01 2000 ".$key; + } + } + else + { + $buff = ftp_rawlist($conn_id, $newsectioniso); + $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist + //var_dump($contents); + //var_dump($buff); + } $nboflines=count($contents); $var=true; @@ -590,9 +605,16 @@ else } - print ""; + + if (! $ok) + { + print $mesg.'
'."\n"; + setEventMessages($mesg, null, 'errors'); + } + + // Actions /* if ($user->rights->ftp->write && ! empty($section)) @@ -611,20 +633,43 @@ else } else { - print $langs->trans("SetupOfFTPClientModuleNotComplete"); + $s_ftp_server='FTP_SERVER_1'; + if (empty($s_ftp_server)) + { + print $langs->trans("SetupOfFTPClientModuleNotComplete"); + } + else + { + print $langs->trans("ChooseAFTPEntryIntoMenu"); + } } } print '
'; // Close FTP connection -if ($conn_id) ftp_close($conn_id); - -// End of page -$db->close(); +if ($conn_id) +{ + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + + } + else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) + { + ftp_close($conn_id); + } + else + { + ftp_close($conn_id); + } +} + llxFooter(); +$db->close(); + + /** * Connect to FTP server @@ -642,46 +687,90 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect global $langs, $conf; $ok=1; - + $conn_id=null; + if (! is_numeric($ftp_port)) { - $mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port); + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServer",$ftp_server,$ftp_port); $ok=0; } if ($ok) { $connecttimeout=(empty($conf->global->FTP_CONNECT_TIMEOUT)?40:$conf->global->FTP_CONNECT_TIMEOUT); - if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout); - else $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); - if ($conn_id) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) + { + dol_syslog('Try to connect with ssh2_ftp'); + $tmp_conn_id = ssh2_connect($ftp_server, $ftp_port); + } + else if (! empty($conf->global->FTP_CONNECT_WITH_SSL)) + { + dol_syslog('Try to connect with ftp_ssl_connect'); + $conn_id = ftp_ssl_connect($ftp_server, $ftp_port, $connecttimeout); + } + else + { + dol_syslog('Try to connect with ftp_connect'); + $conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout); + } + if ($conn_id || $tmp_conn_id) { if ($ftp_user) { - if (ftp_login($conn_id, $ftp_user, $ftp_password)) + if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { - // Turn on passive mode transfers (must be after a successful login - if ($ftp_passive) ftp_pasv($conn_id, true); - - // Change the dir - $newsectioniso=utf8_decode($section); - ftp_chdir($conn_id, $newsectioniso); - } + if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) + { + // Turn on passive mode transfers (must be after a successful login + //if ($ftp_passive) ftp_pasv($conn_id, true); + + // Change the dir + $newsectioniso=utf8_decode($section); + //ftp_chdir($conn_id, $newsectioniso); + $conn_id = ssh2_sftp($tmp_conn_id); + if (! $conn_id) + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication"); + $ok=0; + $error++; + } + } + else + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); + $ok=0; + $error++; + } + } else { - $mesg=$langs->trans("FailedToConnectToFTPServerWithCredentials"); - $ok=0; + if (ftp_login($conn_id, $ftp_user, $ftp_password)) + { + // Turn on passive mode transfers (must be after a successful login + if ($ftp_passive) ftp_pasv($conn_id, true); + + // Change the dir + $newsectioniso=utf8_decode($section); + ftp_chdir($conn_id, $newsectioniso); + } + else + { + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials"); + $ok=0; + $error++; + } } } } else { - $mesg=$langs->trans("FailedToConnectToFTPServer",$ftp_server,$ftp_port); + dol_syslog('FailedToConnectToFTPServer '.$ftp_server.' '.$ftp_port, LOG_ERR); + $mesg=$langs->transnoentitiesnoconv("FailedToConnectToFTPServer",$ftp_server,$ftp_port); $ok=0; } } - $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg); + $arrayresult=array('conn_id'=>$conn_id, 'ok'=>$ok, 'mesg'=>$mesg, 'curdir'=>$section, 'curdiriso'=>$newsectioniso); return $arrayresult; } diff --git a/htdocs/langs/en_US/ftp.lang b/htdocs/langs/en_US/ftp.lang index 9984ce689ee..d6b9d2ca070 100644 --- a/htdocs/langs/en_US/ftp.lang +++ b/htdocs/langs/en_US/ftp.lang @@ -10,3 +10,5 @@ FailedToConnectToFTPServerWithCredentials=Failed to login to FTP server with def FTPFailedToRemoveFile=Failed to remove file %s. FTPFailedToRemoveDir=Failed to remove directory %s (Check permissions and that directory is empty). FTPPassiveMode=Passive mode +ChooseAFTPEntryIntoMenu=Choose a FTP entry into menu... +FailedToGetFile=Failed to get files %s \ No newline at end of file From f3c71a9a5a77532af868ad69b85b27742d9cb0d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:09:42 +0200 Subject: [PATCH 31/43] Dolibarr must not contains autoload feature. The developer and user must decide which lib is used and it must not be a random feature that take a library "randomly" (first one found is same a randomly found). By default, library embedded of dolibarr must be used. If we want to use another one, an option to set the path of external libray must be available. --- .../core/modules/syslog/mod_syslog_sentry.php | 1 - htdocs/includes/autoload.php | 7 - htdocs/includes/composer/ClassLoader.php | 413 ------------------ htdocs/includes/composer/LICENSE | 21 - .../includes/composer/autoload_classmap.php | 24 - .../includes/composer/autoload_namespaces.php | 14 - htdocs/includes/composer/autoload_psr4.php | 9 - htdocs/includes/composer/autoload_real.php | 50 --- htdocs/includes/composer/installed.json | 400 ----------------- 9 files changed, 939 deletions(-) delete mode 100644 htdocs/includes/autoload.php delete mode 100644 htdocs/includes/composer/ClassLoader.php delete mode 100644 htdocs/includes/composer/LICENSE delete mode 100644 htdocs/includes/composer/autoload_classmap.php delete mode 100644 htdocs/includes/composer/autoload_namespaces.php delete mode 100644 htdocs/includes/composer/autoload_psr4.php delete mode 100644 htdocs/includes/composer/autoload_real.php delete mode 100644 htdocs/includes/composer/installed.json diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index 3625405aeaa..5edcca9e03e 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -17,7 +17,6 @@ * along with this program. If not, see . */ -require_once DOL_DOCUMENT_ROOT . '/includes/autoload.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/syslog/logHandler.php'; /** diff --git a/htdocs/includes/autoload.php b/htdocs/includes/autoload.php deleted file mode 100644 index be5223ff062..00000000000 --- a/htdocs/includes/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - - private $classMapAuthoritative = false; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative) { - return false; - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if ($file === null) { - // Remember that this class does not exist. - return $this->classMap[$class] = false; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/htdocs/includes/composer/LICENSE b/htdocs/includes/composer/LICENSE deleted file mode 100644 index c8d57af8b27..00000000000 --- a/htdocs/includes/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) 2015 Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/htdocs/includes/composer/autoload_classmap.php b/htdocs/includes/composer/autoload_classmap.php deleted file mode 100644 index 0d1abcbe041..00000000000 --- a/htdocs/includes/composer/autoload_classmap.php +++ /dev/null @@ -1,24 +0,0 @@ - $vendorDir . '/tecnick.com/tcpdf/include/barcodes/datamatrix.php', - 'Mobile_Detect' => $vendorDir . '/mobiledetect/mobiledetectlib/Mobile_Detect.php', - 'PDF417' => $vendorDir . '/tecnick.com/tcpdf/include/barcodes/pdf417.php', - 'QRcode' => $vendorDir . '/tecnick.com/tcpdf/include/barcodes/qrcode.php', - 'TCPDF' => $vendorDir . '/tecnick.com/tcpdf/tcpdf.php', - 'TCPDF2DBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_2d.php', - 'TCPDFBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_1d.php', - 'TCPDF_COLORS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_colors.php', - 'TCPDF_FILTERS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_filters.php', - 'TCPDF_FONTS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_fonts.php', - 'TCPDF_FONT_DATA' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_font_data.php', - 'TCPDF_IMAGES' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_images.php', - 'TCPDF_IMPORT' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_import.php', - 'TCPDF_PARSER' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_parser.php', - 'TCPDF_STATIC' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_static.php', -); diff --git a/htdocs/includes/composer/autoload_namespaces.php b/htdocs/includes/composer/autoload_namespaces.php deleted file mode 100644 index 27e1e79f483..00000000000 --- a/htdocs/includes/composer/autoload_namespaces.php +++ /dev/null @@ -1,14 +0,0 @@ - array($vendorDir . '/raven/raven/lib'), - 'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'), - 'Luracast\\Restler' => array($vendorDir . '/restler/framework'), - 'Detection' => array($vendorDir . '/mobiledetect/mobiledetectlib/namespaced'), - 'ChromePhp' => array($vendorDir . '/ccampbell/chromephp'), -); diff --git a/htdocs/includes/composer/autoload_psr4.php b/htdocs/includes/composer/autoload_psr4.php deleted file mode 100644 index 80607ee9774..00000000000 --- a/htdocs/includes/composer/autoload_psr4.php +++ /dev/null @@ -1,9 +0,0 @@ - $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - - $loader->register(true); - - return $loader; - } -} - -function composerRequire8837e679482b97ebb428daf0298d9535($file) -{ - require $file; -} diff --git a/htdocs/includes/composer/installed.json b/htdocs/includes/composer/installed.json deleted file mode 100644 index 88bf8b37f43..00000000000 --- a/htdocs/includes/composer/installed.json +++ /dev/null @@ -1,400 +0,0 @@ -[ - { - "name": "ccampbell/chromephp", - "version": "4.1.0", - "version_normalized": "4.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/ccampbell/chromephp.git", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ccampbell/chromephp/zipball/c3c297615d48ae5b2a86a82311152d1ed095fcef", - "reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "time": "2013-06-26 03:44:33", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "ChromePhp": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Craig Campbell", - "email": "iamcraigcampbell@gmail.com", - "homepage": "http://craig.is", - "role": "Developer" - } - ], - "description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).", - "homepage": "http://github.com/ccampbell/chromephp", - "keywords": [ - "log", - "logging" - ] - }, - { - "name": "ckeditor/ckeditor", - "version": "4.3.3", - "version_normalized": "4.3.3.0", - "source": { - "type": "git", - "url": "https://github.com/ckeditor/ckeditor-releases.git", - "reference": "0068dd540ce8bf1815abb7b5455c55354bc56334" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ckeditor/ckeditor-releases/zipball/0068dd540ce8bf1815abb7b5455c55354bc56334", - "reference": "0068dd540ce8bf1815abb7b5455c55354bc56334", - "shasum": "" - }, - "time": "2014-02-26 15:34:37", - "type": "library", - "installation-source": "dist", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+", - "LGPL-2.1+", - "MPL-1.1+" - ], - "authors": [ - { - "name": "CKSource - Frederico Knabben", - "homepage": "http://cksource.com" - } - ], - "description": "JavaScript WYSIWYG web text editor.", - "homepage": "http://ckeditor.com", - "keywords": [ - "CKEditor", - "editor", - "fckeditor", - "html", - "javascript", - "richtext", - "text", - "wysiwyg" - ] - }, - { - "name": "mobiledetect/mobiledetectlib", - "version": "2.8.3", - "version_normalized": "2.8.3.0", - "source": { - "type": "git", - "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "f5753e4b90daffe50c902e99df5ce3c58fca3fee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/f5753e4b90daffe50c902e99df5ce3c58fca3fee", - "reference": "f5753e4b90daffe50c902e99df5ce3c58fca3fee", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "time": "2014-07-10 20:00:25", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "Mobile_Detect.php" - ], - "psr-0": { - "Detection": "namespaced/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Serban Ghita", - "email": "serbanghita@gmail.com", - "homepage": "http://ghita.org", - "role": "Developer" - } - ], - "description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.", - "homepage": "https://github.com/serbanghita/Mobile-Detect", - "keywords": [ - "detect mobile devices", - "mobile", - "mobile detect", - "mobile detector", - "php mobile detect" - ] - }, - { - "name": "phpoffice/phpexcel", - "version": "1.8.0", - "version_normalized": "1.8.0.0", - "source": { - "type": "git", - "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/e69a5e4d0ffa7fb6f171859e0a04346e580df30b", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b", - "shasum": "" - }, - "require": { - "ext-xml": "*", - "ext-xmlwriter": "*", - "php": ">=5.2.0" - }, - "time": "2014-03-02 15:22:49", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "PHPExcel": "Classes/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL" - ], - "authors": [ - { - "name": "Maarten Balliauw", - "homepage": "http://blog.maartenballiauw.be" - }, - { - "name": "Mark Baker" - }, - { - "name": "Franck Lefevre", - "homepage": "http://blog.rootslabs.net" - }, - { - "name": "Erik Tilt" - } - ], - "description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", - "homepage": "http://phpexcel.codeplex.com", - "keywords": [ - "OpenXML", - "excel", - "php", - "spreadsheet", - "xls", - "xlsx" - ] - }, - { - "name": "restler/framework", - "version": "3.0.0", - "version_normalized": "3.0.0.0", - "target-dir": "Luracast/Restler", - "source": { - "type": "git", - "url": "https://github.com/Luracast/Restler-Framework.git", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler-Framework/zipball/6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "reference": "6ee10b3e5dbc6376916fed55ec2340a37cce436b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "replace": { - "luracast/restler": "3.*" - }, - "require-dev": { - "bshaffer/oauth2-server-php": "v1.0", - "luracast/explorer": "*", - "mustache/mustache": "dev-master", - "rodneyrehm/plist": "dev-master", - "symfony/yaml": "*", - "twig/twig": "v1.13.0", - "zendframework/zendamf": "dev-master" - }, - "suggest": { - "bshaffer/oauth2-server-php": "Restler can provide OAuth2 authentication using this library (see require-dev for details)", - "luracast/explorer": "Restler's very own api explorer (see require-dev for details)", - "mustache/mustache": "Restler can render HtmlView using mustache/handlebar templates (see require-dev for details)", - "rodneyrehm/plist": "Restler supports tho Apple plist xml format (see require-dev for details)", - "symfony/yaml": "Restler can produce content in yaml format as well (see require-dev for details)", - "twig/twig": "Restler can render HtmlView using twig templates (see require-dev for details)", - "zendframework/zendamf": "Support for the amf document format (see require-dev for details)" - }, - "time": "2015-08-04 07:52:49", - "type": "library", - "extra": { - "branch-alias": { - "master": "v3.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Luracast\\Restler": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1" - ], - "authors": [ - { - "name": "Luracast", - "email": "arul@luracast.com" - }, - { - "name": "Nick nickl- Lombard", - "email": "github@jigsoft.co.za" - } - ], - "description": "Just the Restler Framework without the tests and examples", - "homepage": "http://luracast.com/products/restler/", - "keywords": [ - "api", - "framework", - "rest", - "server" - ] - }, - { - "name": "tecnick.com/tcpdf", - "version": "6.2.6", - "version_normalized": "6.2.6.0", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", - "reference": "a2e8f5b505a7a14a4ed960313c4baf699fd1f4bb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2015-01-28 18:51:40", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "fonts", - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPLv3" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "homepage": "http://nicolaasuni.tecnick.com" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ] - }, - { - "name": "raven/raven", - "version": "0.12.1", - "version_normalized": "0.12.1.0", - "source": { - "type": "git", - "url": "https://github.com/getsentry/raven-php.git", - "reference": "b325984c792ff89f985b73da9a3ad8ed8b520bca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/getsentry/raven-php/zipball/b325984c792ff89f985b73da9a3ad8ed8b520bca", - "reference": "b325984c792ff89f985b73da9a3ad8ed8b520bca", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.2.4" - }, - "require-dev": { - "fabpot/php-cs-fixer": "^1.8.0", - "phpunit/phpunit": "^4.6.6" - }, - "time": "2015-08-25 22:38:46", - "bin": [ - "bin/raven" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Raven_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "authors": [ - { - "name": "David Cramer", - "email": "dcramer@gmail.com" - } - ], - "description": "A PHP client for Sentry (http://getsentry.com)", - "homepage": "http://getsentry.com", - "keywords": [ - "log", - "logging" - ] - } -] From 28c62fb214c215262f9fcaeca1836948ab0df41f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:21:26 +0200 Subject: [PATCH 32/43] Introduce a function to return a warning by loggers. --- htdocs/admin/syslog.php | 6 ++++- htdocs/core/modules/syslog/logHandler.php | 14 ++++++++++-- .../modules/syslog/logHandlerInterface.php | 7 ++++++ .../modules/syslog/mod_syslog_chromephp.php | 22 +++++++++++++++---- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 7d713760382..44002dc4c74 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -225,7 +225,11 @@ foreach ($syslogModules as $moduleName) print ''; if ($module->getInfo()) { - print $form->textwithpicto('', $module->getInfo()); + print $form->textwithpicto('', $module->getInfo(), 1, 'help'); + } + if ($module->getWarning()) + { + print $form->textwithpicto('', $module->getWarning(), 1, 'warning'); } print ''; print "\n"; diff --git a/htdocs/core/modules/syslog/logHandler.php b/htdocs/core/modules/syslog/logHandler.php index 1701ca2bdce..fa013f4b083 100644 --- a/htdocs/core/modules/syslog/logHandler.php +++ b/htdocs/core/modules/syslog/logHandler.php @@ -28,13 +28,23 @@ class LogHandler /** * Content of the info tooltip. * - * @return false|string + * @return string */ public function getInfo() { - return false; + return ''; } + /** + * Return warning if something is wrong with logger + * + * @return string + */ + public function getWarning() + { + return ''; + } + /** * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development') * diff --git a/htdocs/core/modules/syslog/logHandlerInterface.php b/htdocs/core/modules/syslog/logHandlerInterface.php index f0d78735155..6f59482a1c0 100644 --- a/htdocs/core/modules/syslog/logHandlerInterface.php +++ b/htdocs/core/modules/syslog/logHandlerInterface.php @@ -48,6 +48,13 @@ interface LogHandlerInterface */ public function getInfo(); + /** + * Return warning if something is wrong with logger + * + * @return string Warning message + */ + public function getWarning(); + /** * Return array of configuration data * diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index e47a0059828..adcaa9d7f00 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -32,19 +32,29 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface /** * Content of the info tooltip. * - * @return false|string + * @return string */ public function getInfo() + { + return ''; + } + + /** + * Return warning if something is wrong with logger + * + * @return string + */ + public function getWarning() { global $langs; return $this->isActive()?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php'); } - + /** * Is the module active ? * - * @return int + * @return int -1 if not active, 0 if active but lib/path not found, 1 if OK */ public function isActive() { @@ -65,6 +75,10 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface { return 1; } + else + { + return 0; + } } catch(Exception $e) { @@ -89,7 +103,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface 'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH', 'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/', 'attr' => 'size="60"', - 'example' =>'/usr/share/php' + 'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/' ) ); } From 5ffab9720f24b7f453282554fcb33c55dfe09f08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:38:39 +0200 Subject: [PATCH 33/43] More complete connexion profile --- htdocs/user/class/user.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 475b9d7fd2b..fc4abd88079 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1888,6 +1888,8 @@ class User extends CommonObject $s=picto_from_langcode($langs->getDefaultLang()); $label.= '
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); $label.= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')'; + $label.= '
'.$langs->trans("Layout").': '.$conf->browser->layout; + $label.= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; if (! empty($conf->browser->phone)) $label.= '
'.$langs->trans("Phone").': '.$conf->browser->phone; if (! empty($_SESSION["disablemodules"])) $label.= '
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); } From a44ab5168cd8b291470e944d0056a091f373a019 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 12:43:25 +0200 Subject: [PATCH 34/43] Save memory. --- htdocs/core/class/html.form.class.php | 3 ++- htdocs/main.inc.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bc831baeddf..fe4852d839b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -364,7 +364,8 @@ class Form } /** - * Show a text and picto with tooltip on text or picto + * Show a text and picto with tooltip on text or picto. + * Can be called by an instancied $form->textwithtooltip or by a static call Form::textwithtooltip * * @param string $text Text to show * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d4f27fb3145..ab1a16c9883 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1428,7 +1428,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $menumanager->showmenu('top'); // This contains a \n print "
\n"; - $form=new Form($db); + //$form=new Form($db); // Define link to login card $appli='Dolibarr'; @@ -1496,11 +1496,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $text =''; $text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer.png', 'class="printer"'); $text.=''; - $toprightmenu.=$form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); + $toprightmenu.=Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2); } // Logout link - $toprightmenu.=$form->textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2); + $toprightmenu.=Form::textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2); $toprightmenu.='
'; @@ -1509,7 +1509,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print "\n"; print ''; - unset($form); + //unset($form); } if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n"; From ff3968b07f965176e083f7312fe3b6b0ef1efd54 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Mon, 7 Sep 2015 12:46:49 +0200 Subject: [PATCH 35/43] translations missing --- htdocs/core/modules/modFournisseur.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 0db347f0df2..4f82710d3f5 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2015 Philippe Grand * * 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 @@ -20,17 +20,17 @@ */ /** - * \defgroup fournisseur Module suppliers - * \brief Module pour gerer des societes et contacts de type fournisseurs + * \defgroup fournisseur suppliers Module + * \brief Module to manage companies and contacts of supplier type * \file htdocs/core/modules/modFournisseur.class.php * \ingroup fournisseur - * \brief Fichier de description et activation du module Fournisseur + * \brief Description and activation file for module Fournisseur */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** - * Classe de description et activation du module Fournisseur + * Description and activation class for module Fournisseur */ class modFournisseur extends DolibarrModules { @@ -67,7 +67,7 @@ class modFournisseur extends DolibarrModules "/fournisseur/facture/temp" ); - // Dependances + // Dependencies $this->depends = array("modSociete"); $this->requiredby = array(); $this->langfiles = array('bills', 'companies', 'suppliers', 'orders'); @@ -75,7 +75,7 @@ class modFournisseur extends DolibarrModules // Config pages $this->config_page_url = array("supplier_order.php"); - // Constantes + // Constants $this->const = array(); $r=0; From 1b3db2ca41a4f8a405cd9fb0aed443e6d0f003b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:20:44 +0200 Subject: [PATCH 36/43] NEW Add none/all selection into list of files for FTP browser module --- htdocs/ftp/index.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 19c4b50dc7d..5e4dd33faed 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -369,11 +369,22 @@ if ($conf->use_javascript_ajax) + '.$langs->trans("Owner").''."\n"; print ''.$langs->trans("Group").''."\n"; print ''.$langs->trans("Permissions").''."\n"; - print ''; + print ''; + if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").' '; print ''.img_picto($langs->trans("Refresh"),'refresh').' '; print ''."\n"; print ''."\n"; From 3333970eb43d32d3120fa518add13fa5396991cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:23:51 +0200 Subject: [PATCH 37/43] Prepare 3.9 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c591359f424..08080b9388d 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -30,7 +30,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.8.0-beta'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0-beta'); if (! defined('EURO')) define('EURO',chr(128)); From 7f05e19e0d683f6eae0c15de33e661faf37500e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:24:52 +0200 Subject: [PATCH 38/43] Prepare 3.9 --- htdocs/install/check.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 0b9b08f3b68..c2abbc2a014 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -387,7 +387,8 @@ else array('from'=>'3.4.0', 'to'=>'3.5.0'), array('from'=>'3.5.0', 'to'=>'3.6.0'), array('from'=>'3.6.0', 'to'=>'3.7.0'), - array('from'=>'3.7.0', 'to'=>'3.8.0') + array('from'=>'3.7.0', 'to'=>'3.8.0'), + array('from'=>'3.8.0', 'to'=>'3.9.0') ); $count=0; From fe609275030d29d65c2a226a110fb26ff446a98d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 13:30:02 +0200 Subject: [PATCH 39/43] Fix button must appears if box selected --- htdocs/ftp/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 5e4dd33faed..4a42c6978ba 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -145,7 +145,7 @@ if ($action == 'add' && $user->rights->ftp->setup) { //TODO: Translate setEventMessage('Error '.$langs->trans($ecmdir->error)); - $_GET["action"] = "create"; + $action = "create"; } } @@ -376,9 +376,11 @@ jQuery(document).ready(function() { $("#checkall").click(function() { $(".checkboxfordelete").prop('checked', true); + jQuery("#delconst").show(); }); $("#checknone").click(function() { $(".checkboxfordelete").prop('checked', false); + jQuery("#delconst").hide(); }); }); From 2de690259a61bb03cfc0eeb39cb2c9b952993f72 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 14:01:05 +0200 Subject: [PATCH 40/43] Add migration script for 3.9 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5bc5f49b2e5..98c63e3c366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ php: - 5.5 - 5.6 - 7.0 - + matrix: allow_failures: - php: 7.0 @@ -130,6 +130,7 @@ script: - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log + - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log # - cat upgrade370380-2.log - cd ../.. - date From fc35c4e3f09bd07fecc9f59b27c7bce56bb2afe2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 14:01:59 +0200 Subject: [PATCH 41/43] Add migration script for 3.9 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 98c63e3c366..54d937625ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -130,6 +130,7 @@ script: - php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log + - php upgrade.php 3.8.0 3.9.0 ignoredbversion > upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log # - cat upgrade370380-2.log - cd ../.. From 53a9c93b90c0c7f1b6bc5c4e807c598a1d869613 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 15:16:43 +0200 Subject: [PATCH 42/43] Fix PHPCS --- htdocs/ftp/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 4a42c6978ba..9b0c2a36e0e 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -495,7 +495,7 @@ else // List content of directory ($newsection = '/', '/home', ...) if (! empty($conf->global->FTP_CONNECT_WITH_SFTP)) { - if ($newsection == '/') $newsection='/./'; # workaround for bug https://bugs.php.net/bug.php?id=64169 + if ($newsection == '/') $newsection='/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 //$dirHandle = opendir("ssh2.sftp://$conn_id".$newsection); //var_dump($dirHandle); $contents = scandir('ssh2.sftp://' . $conn_id . $newsection); From 0a6451d72c5d9447d7fe574542c30ed388c6a29f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Sep 2015 20:17:05 +0200 Subject: [PATCH 43/43] Fix memcached effect was lost because init was done each time. --- htdocs/core/class/translate.class.php | 3 +- htdocs/core/lib/memory.lib.php | 54 +++++++++++++++++++-------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 100af13af5d..5d06586fb16 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -234,7 +234,8 @@ class Translate if ($usecachekey) { //dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey); - + //global $aaa; $aaa+=1; + //print $aaa." ".$usecachekey."\n"; require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php'; $tmparray=dol_getcache($usecachekey); if (is_array($tmparray) && count($tmparray)) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index b68016c3a46..7df56b6283c 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -47,10 +47,16 @@ function dol_setcache($memoryid,$data) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Add memoryid=".$memoryid; $m->add($memoryid,$data); // This fails if key already exists @@ -66,10 +72,16 @@ function dol_setcache($memoryid,$data) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $result=$m->add($memoryid,$data); // This fails if key already exists if ($result) @@ -103,10 +115,16 @@ function dol_getcache($memoryid) // Using a memcached server if (! empty($conf->memcached->enabled) && class_exists('Memcached')) { + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcached(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + $memoryid=session_name().'_'.$memoryid; - $m=new Memcached(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); //$m->setOption(Memcached::OPT_COMPRESSION, false); //print "Get memoryid=".$memoryid; $data=$m->get($memoryid); @@ -124,10 +142,16 @@ function dol_getcache($memoryid) } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) { - $memoryid=session_name().'_'.$memoryid; - $m=new Memcache(); - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + global $m; + if (empty($m) || ! is_object($m)) + { + $m=new Memcache(); + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); + if (! $result) return -1; + } + + $memoryid=session_name().'_'.$memoryid; //$m->setOption(Memcached::OPT_COMPRESSION, false); $data=$m->get($memoryid); //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n
";