diff --git a/.scrutinizer.yml b/.scrutinizer.yml
new file mode 100644
index 00000000000..016129c7629
--- /dev/null
+++ b/.scrutinizer.yml
@@ -0,0 +1,85 @@
+# .scrutinizer.yml
+imports:
+ - javascript
+ - php
+
+filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+
+tools:
+ # Similar code detection
+ php_sim:
+ enabled: true
+ min_mass: 16
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+
+ # php_depend
+ php_pdepend:
+ enabled: true
+ configuration_file: null
+ suffixes:
+ - php
+ excluded_dirs: { }
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+
+ # php_analyzer
+ php_analyzer:
+ enabled: true
+ extensions:
+ - php
+ dependency_paths: { }
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+ path_configs: { }
+
+ # change tracking
+ php_changetracking:
+ enabled: true
+ bug_patterns:
+ - '\bfix(?:es|ed)?\b'
+ feature_patterns:
+ - '\badd(?:s|ed)?\b'
+ - '\bimplement(?:s|ed)?\b'
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+
+ # Coding-Style / Bug Detection
+ js_hint: true
+
+
+before_commands: { }
+after_commands: { }
+artifacts: { }
+build_failure_conditions: { }
diff --git a/ChangeLog b/ChangeLog
index 0b70cbe719f..c81af41cfa2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,8 @@ For users:
- Fix: Project Task numbering customs rule works.
- Fix: Add actions events not implemented.
- Fix: Price min of composition is not supplier price min by quantity
+- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers
+- New: Add categories translation
TODO
- New: Predefined product and free product use same form.
@@ -73,6 +75,9 @@ For developers:
- New: Normalize code for barcode generation to match other modules.
- New: Uniformize code for contacts forms.
- New: Add some hooks for financial reports.
+- New: A module can add its own ECM view.
+- New: A module can disable a standard ECM view.
+- New: Add multilang support into product webservice.
WARNING: Following change may create regression for some external modules, but was necessary to make
Dolibarr better:
@@ -91,6 +96,10 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
***** ChangeLog for 3.5.3 compared to 3.5.2 *****
Fix: Error on field accountancy code for export profile of invoices.
+Fix: [ bug #1351 ] VIES verification link broken.
+Fix: [ bug #1352 ] Removing a shipping does not remove the delivery.
+Fix: Option MAIN_INVERT_SENDER_RECIPIENT broken with typhon template.
+
***** ChangeLog for 3.5.2 compared to 3.5.1 *****
Fix: Can't add user for a task.
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index 25a977692b9..c5b3a6a991a 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -369,6 +369,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/.git*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.project`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.settings`;
+ $ret=`rm -fr $BUILDROOT/$PROJECT/.scrutinizer.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.travis.yml`;
$ret=`rm -fr $BUILDROOT/$PROJECT/.tx`;
$ret=`rm -f $BUILDROOT/$PROJECT/build.xml`;
diff --git a/doc/images/dolibarr_screenshot10.png b/doc/images/dolibarr_screenshot10.png
deleted file mode 100644
index 125af3135fa..00000000000
Binary files a/doc/images/dolibarr_screenshot10.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot10_1280x800.png b/doc/images/dolibarr_screenshot10_1280x800.png
new file mode 100644
index 00000000000..9a81f4c7f20
Binary files /dev/null and b/doc/images/dolibarr_screenshot10_1280x800.png differ
diff --git a/doc/images/dolibarr_screenshot11.png b/doc/images/dolibarr_screenshot11.png
deleted file mode 100755
index 26b417f0823..00000000000
Binary files a/doc/images/dolibarr_screenshot11.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot12.png b/doc/images/dolibarr_screenshot12.png
deleted file mode 100755
index a71fb9bcaf6..00000000000
Binary files a/doc/images/dolibarr_screenshot12.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot5.png b/doc/images/dolibarr_screenshot5.png
deleted file mode 100644
index 94e578a06a6..00000000000
Binary files a/doc/images/dolibarr_screenshot5.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot5_1280x800.png b/doc/images/dolibarr_screenshot5_1280x800.png
new file mode 100644
index 00000000000..faa34e9589b
Binary files /dev/null and b/doc/images/dolibarr_screenshot5_1280x800.png differ
diff --git a/doc/images/dolibarr_screenshot7.png b/doc/images/dolibarr_screenshot7.png
deleted file mode 100644
index f8620ce6d5a..00000000000
Binary files a/doc/images/dolibarr_screenshot7.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot7_1280x800.png b/doc/images/dolibarr_screenshot7_1280x800.png
new file mode 100644
index 00000000000..8690afa6acf
Binary files /dev/null and b/doc/images/dolibarr_screenshot7_1280x800.png differ
diff --git a/doc/images/dolibarr_screenshot8.png b/doc/images/dolibarr_screenshot8.png
deleted file mode 100644
index cb76e9650b7..00000000000
Binary files a/doc/images/dolibarr_screenshot8.png and /dev/null differ
diff --git a/doc/images/dolibarr_screenshot8_1280x800.png b/doc/images/dolibarr_screenshot8_1280x800.png
new file mode 100644
index 00000000000..ef2cc40e5ab
Binary files /dev/null and b/doc/images/dolibarr_screenshot8_1280x800.png differ
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index fc250cfe07a..37d8a6c04f8 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -107,6 +107,9 @@ class Categorie extends CommonObject
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($resql);
+
+ // multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
return 1;
}
@@ -767,14 +770,21 @@ class Categorie extends CommonObject
*/
function get_full_arbo($type,$markafterid=0)
{
+ global $langs;
+
$this->cats = array();
// Init this->motherof that is array(id_son=>id_parent, ...)
$this->load_motherof();
+ $current_lang = $langs->getDefaultLang();
// Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates
+ if (! empty($conf->global->MAIN_MULTILANGS))
+ $sql.= ", t.label as label_trans, t.description as description_trans";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
+ if (! empty($conf->global->MAIN_MULTILANGS))
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
$sql.= " WHERE c.entity IN (".getEntity('category',1).")";
$sql.= " AND c.type = ".$type;
@@ -788,8 +798,8 @@ class Categorie extends CommonObject
$this->cats[$obj->rowid]['rowid'] = $obj->rowid;
$this->cats[$obj->rowid]['id'] = $obj->rowid;
$this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent;
- $this->cats[$obj->rowid]['label'] = $obj->label;
- $this->cats[$obj->rowid]['description'] = $obj->description;
+ $this->cats[$obj->rowid]['label'] = ! empty($obj->label_trans) ? $obj->label_trans : $obj->label;
+ $this->cats[$obj->rowid]['description'] = ! empty($obj->description_trans) ? $obj->description_trans : $obj->description;
$i++;
}
}
@@ -1458,6 +1468,118 @@ class Categorie extends CommonObject
$this->imgHeight = $infoImg[1]; // Hauteur de l'image
}
+ /**
+ * Update ou cree les traductions des infos produits
+ *
+ * @return int <0 if KO, >0 if OK
+ */
+ function setMultiLangs()
+ {
+ global $langs;
+
+ $langs_available = $langs->get_available_languages();
+ $current_lang = $langs->getDefaultLang();
+
+ foreach ($langs_available as $key => $value)
+ {
+ $sql = "SELECT rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
+ $sql.= " WHERE fk_category=".$this->id;
+ $sql.= " AND lang='".$key."'";
+
+ $result = $this->db->query($sql);
+
+ if ($key == $current_lang)
+ {
+ if ($this->db->num_rows($result)) // si aucune ligne dans la base
+ {
+ $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
+ $sql2.= " SET label='".$this->db->escape($this->label)."',";
+ $sql2.= " description='".$this->db->escape($this->description)."'";
+ $sql2.= " WHERE fk_category=".$this->id." AND lang='".$key."'";
+ }
+ else
+ {
+ $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
+ $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label);
+ $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
+ }
+ dol_syslog(get_class($this).'::setMultiLangs sql='.$sql2);
+ if (! $this->db->query($sql2))
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this).'::setMultiLangs error='.$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+ else if (isset($this->multilangs["$key"]))
+ {
+ if ($this->db->num_rows($result)) // si aucune ligne dans la base
+ {
+ $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
+ $sql2.= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
+ $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
+ $sql2.= " WHERE fk_category=".$this->id." AND lang='".$key."'";
+ }
+ else
+ {
+ $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
+ $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]);
+ $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
+ }
+
+ // on ne sauvegarde pas des champs vides
+ if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] )
+ dol_syslog(get_class($this).'::setMultiLangs sql='.$sql2);
+ if (! $this->db->query($sql2))
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this).'::setMultiLangs error='.$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+ }
+ return 1;
+ }
+
+ /**
+ * Load array this->multilangs
+ *
+ * @return int <0 if KO, >0 if OK
+ */
+ function getMultiLangs()
+ {
+ global $langs;
+
+ $current_lang = $langs->getDefaultLang();
+
+ $sql = "SELECT lang, label, description";
+ $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
+ $sql.= " WHERE fk_category=".$this->id;
+
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ while ( $obj = $this->db->fetch_object($result) )
+ {
+ //print 'lang='.$obj->lang.' current='.$current_lang.' ';
+ if( $obj->lang == $current_lang ) // si on a les traduct. dans la langue courante on les charge en infos principales.
+ {
+ $this->label = $obj->label;
+ $this->description = $obj->description;
+
+ }
+ $this->multilangs["$obj->lang"]["label"] = $obj->label;
+ $this->multilangs["$obj->lang"]["description"] = $obj->description;
+ }
+ return 1;
+ }
+ else
+ {
+ $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
+ return -1;
+ }
+ }
/**
* Initialise an instance with random values.
diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php
index 64f526bcb3c..12eaa7e98f0 100644
--- a/htdocs/categories/fiche.php
+++ b/htdocs/categories/fiche.php
@@ -31,9 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("categories");
-$extrafields = new ExtraFields($db);
-$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
-
// Security check
$socid=GETPOST('socid','int');
if (!$user->rights->categorie->lire) accessforbidden();
@@ -64,6 +61,9 @@ if ($catorigin && $type == 0) $idCatOrigin = $catorigin;
$object = new Categorie($db);
+$extrafields = new ExtraFields($db);
+$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
+
/*
* Actions
*/
@@ -244,7 +244,7 @@ if ($user->rights->categorie->creer)
print '
'.$langs->trans("AddIn").' ';
print $form->select_all_categories($type, $catorigin);
print ' ';
-
+
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
new file mode 100644
index 00000000000..a6dadeb0e1c
--- /dev/null
+++ b/htdocs/categories/traduction.php
@@ -0,0 +1,284 @@
+
+ * Copyright (C) 2007 Rodolphe Quiedeville
+ * Copyright (C) 2010-2012 Destailleur Laurent
+ *
+ * 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/product/traduction.php
+ * \ingroup product
+ * \brief Page de traduction des produits
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
+
+$langs->load("categories");
+$langs->load("languages");
+
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action=GETPOST('action','alpha');
+$cancel=GETPOST('cancel','alpha');
+$type=GETPOST('type');
+
+// Security check
+$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
+$fieldtype = (! empty($ref) ? 'ref' : 'rowid');
+
+if ($id == "")
+{
+ dol_print_error('','Missing parameter id');
+ exit();
+}
+
+// Security check
+$result = restrictedArea($user, 'categorie', $id, '&category');
+
+$object = new Categorie($db);
+
+
+/*
+ * Actions
+ */
+
+// retour a l'affichage des traduction si annulation
+if ($cancel == $langs->trans("Cancel"))
+{
+ $action = '';
+}
+
+
+// Validation de l'ajout
+if ($action == 'vadd' &&
+$cancel != $langs->trans("Cancel") &&
+($user->rights->categorie->creer ))
+{
+ $object->fetch($id);
+ $current_lang = $langs->getDefaultLang();
+
+ // update de l'objet
+ if ( $_POST["forcelangprod"] == $current_lang )
+ {
+ $object->label = $_POST["libelle"];
+ $object->description = dol_htmlcleanlastbr($_POST["desc"]);
+ }
+ else
+ {
+ $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"];
+ $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
+ }
+
+ // sauvegarde en base
+ if ( $object->setMultiLangs() > 0 )
+ {
+ $action = '';
+ }
+ else
+ {
+ $action = 'add';
+ $mesg = ''.$object->error.'
';
+ }
+}
+
+// Validation de l'edition
+if ($action == 'vedit' &&
+$cancel != $langs->trans("Cancel") &&
+($user->rights->categorie->creer))
+{
+ $object->fetch($id);
+ $current_lang = $langs->getDefaultLang();
+
+ foreach ( $object->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet
+ {
+ if ( $key == $current_lang )
+ {
+ $object->label = $_POST["libelle-".$key];
+ $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
+ }
+ else
+ {
+ $object->multilangs[$key]["label"] = $_POST["libelle-".$key];
+ $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
+ }
+ }
+
+ if ( $object->setMultiLangs() > 0 )
+ {
+ $action = '';
+ }
+ else
+ {
+ $action = 'edit';
+ $mesg = ''.$object->error.'
';
+ }
+}
+
+$result = $object->fetch($id,$ref);
+
+
+/*
+ * View
+ */
+
+llxHeader("","",$langs->trans("Translation"));
+
+$form = new Form($db);
+$formadmin=new FormAdmin($db);
+
+if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
+elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
+elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
+elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
+elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
+else $title=$langs->trans("Category");
+
+$head = categories_prepare_head($object,$type);
+dol_fiche_head($head, 'translation', $title, 0, 'category');
+
+if (! empty($mesg)) {
+ dol_htmloutput_mesg($mesg);
+}
+
+print '';
+
+// Reference
+print '';
+print ''.$langs->trans("Ref").' ';
+print $object->label;
+print ' ';
+print ' ';
+print '
';
+
+if ($action == 'edit')
+{
+ //WYSIWYG Editor
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+
+ print '';
+
+}
+else
+{
+ $cnt_trans = 0;
+ if (! empty($object->multilangs))
+ {
+ foreach ($object->multilangs as $key => $value)
+ {
+ $cnt_trans++;
+ $s=picto_from_langcode($key);
+ print " ".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ";
+ print '';
+ print ''.$langs->trans('Label').' '.$object->multilangs[$key]["label"].' ';
+ print ''.$langs->trans('Description').' '.$object->multilangs[$key]["description"].' ';
+ print ''.$langs->trans('Note').' '.$object->multilangs[$key]["note"].' ';
+ print '
';
+ }
+ }
+ if (! $cnt_trans) print ' '. $langs->trans('NoTranslation');
+}
+
+print "\n";
+
+
+/* ************************************************************************** */
+/* */
+/* Barre d'action */
+/* */
+/* ************************************************************************** */
+
+print "\n\n";
+
+
+/*
+ * Form to add a new translation
+ */
+
+if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
+{
+ //WYSIWYG Editor
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+
+ print ' ';
+ print '';
+
+ print ' ';
+}
+
+llxFooter();
+$db->close();
+?>
\ No newline at end of file
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index a367dadeb7d..990a10c2500 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -179,8 +179,8 @@ $dolibarr_main_authentication='dolibarr';
// Parameters used to setup LDAP authentication.
// Uncomment them if dolibarr_main_authentication = 'ldap'
//
-// $dolibarr_main_auth_ldap_host='127.0.0.1';
-// $dolibarr_main_auth_ldap_port='389';
+// $dolibarr_main_auth_ldap_host='127.0.0.1'; // You can define several servers here separated with a comma.
+// $dolibarr_main_auth_ldap_port='389'; // Port
// $dolibarr_main_auth_ldap_version='3';
// $dolibarr_main_auth_ldap_servertype='openldap'; // openldap, activedirectory or egroupware
// $dolibarr_main_auth_ldap_login_attribute='loginfield'; // Ex: uid or samaccountname for active directory
diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php
index e51e3d3288f..26ecd1247e8 100644
--- a/htdocs/core/boxes/box_factures_fourn.php
+++ b/htdocs/core/boxes/box_factures_fourn.php
@@ -64,7 +64,7 @@ class box_factures_fourn extends ModeleBoxes
if ($user->rights->fournisseur->facture->lire)
{
$sql = "SELECT s.nom, s.rowid as socid,";
- $sql.= " f.rowid as facid, f.ref_supplier, f.amount,";
+ $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.amount,";
$sql.= " f.paye, f.fk_statut,";
$sql.= ' f.datef as df,';
$sql.= ' f.datec as datec,';
@@ -102,25 +102,29 @@ class box_factures_fourn extends ModeleBoxes
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
- 'text' => $objp->ref_supplier,
+ 'text' => ($objp->ref?$objp->ref:$objp->facid),
'text2'=> $late,
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
- $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
+ $this->info_box_contents[$i][2] = array('td' => 'align="left"',
+ 'text' => $objp->ref_supplier,
+ 'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
+
+ $this->info_box_contents[$i][3] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid);
- $this->info_box_contents[$i][3] = array('td' => 'align="left"',
+ $this->info_box_contents[$i][4] = array('td' => 'align="left"',
'text' => $objp->nom,
'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid);
- $this->info_box_contents[$i][4] = array('td' => 'align="right"',
+ $this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($datec,'day'));
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid=$fac->getSommePaiement();
- $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"',
+ $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type));
$i++;
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index ebe2f897b77..316ee7b086a 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -61,7 +61,7 @@ class box_factures_fourn_imp extends ModeleBoxes
if ($user->rights->fournisseur->facture->lire)
{
$sql = "SELECT s.nom, s.rowid as socid,";
- $sql.= " f.rowid as facid, f.ref_supplier, f.date_lim_reglement as datelimite,";
+ $sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,";
$sql.= " f.amount, f.datef as df,";
$sql.= " f.paye, f.fk_statut, f.type";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
@@ -98,25 +98,29 @@ class box_factures_fourn_imp extends ModeleBoxes
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
- 'text' => $objp->ref_supplier,
+ 'text' => ($objp->ref?$objp->ref:$objp->facid),
'text2'=> $late,
'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
- $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
+ $this->info_box_contents[$i][2] = array('td' => 'align="left"',
+ 'text' => $objp->ref_supplier,
+ 'url' => DOL_URL_ROOT."/fourn/facture/fiche.php?facid=".$objp->facid);
+
+ $this->info_box_contents[$i][3] = array('td' => 'align="left" width="16"',
'logo' => 'company',
'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid);
- $this->info_box_contents[$i][3] = array('td' => 'align="left"',
+ $this->info_box_contents[$i][4] = array('td' => 'align="left"',
'text' => $objp->nom,
'url' => DOL_URL_ROOT."/fourn/fiche.php?socid=".$objp->socid);
- $this->info_box_contents[$i][4] = array('td' => 'align="right"',
+ $this->info_box_contents[$i][5] = array('td' => 'align="right"',
'text' => dol_print_date($datelimite,'day'));
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid=$fac->getSommePaiement();
- $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"',
+ $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"',
'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type));
$i++;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 004153e2fdc..b32c5d4cb75 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -47,8 +47,8 @@ abstract class CommonObject
public $array_options=array();
- public $linkedObjectsIds;
- public $linkedObjects;
+ public $linkedObjectsIds; // Loaded by ->fetchObjectLinked
+ public $linkedObjects; // Loaded by ->fetchObjectLinked
// No constructor as it is an abstract class
@@ -1718,7 +1718,7 @@ abstract class CommonObject
* @param string $sourcetype Object source type
* @param int $targetid Object target id
* @param string $targettype Object target type
- * @param string $clause OR, AND clause
+ * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided
* @return void
*/
function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
@@ -2392,7 +2392,8 @@ abstract class CommonObject
/**
- * Function to check if an object is used by others
+ * Function to check if an object is used by others.
+ * Check is done into this->childtables. There is no check into llx_element_element.
*
* @param int $id Id of object
* @return int <0 if KO, 0 if not used, >0 if already used
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index a79cb494bd4..d8dc5a65e66 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -225,22 +225,6 @@ class Conf
if ($ret) $mc = new ActionsMulticompany($db);
}
- // Second or others levels object
- $this->propal->cloture = new stdClass();
- $this->propal->facturation = new stdClass();
- $this->commande->client = new stdClass();
- $this->commande->fournisseur = new stdClass();
- $this->facture->client = new stdClass();
- $this->facture->fournisseur = new stdClass();
- $this->fournisseur->commande = new stdClass();
- $this->fournisseur->facture = new stdClass();
- $this->contrat->services = new stdClass();
- $this->contrat->services->inactifs = new stdClass();
- $this->contrat->services->expires = new stdClass();
- $this->adherent->cotisation = new stdClass();
- $this->bank->rappro = new stdClass();
- $this->bank->cheque = new stdClass();
-
// Clean some variables
if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD="eldy_menu.php";
if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD="eldy_menu.php";
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 3ac6ce0eba1..416ee790282 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -424,16 +424,17 @@ class FormOther
/**
* Return list of project and tasks
*
- * @param int $selectedtask Pre-selected task
- * @param int $projectid Project id
- * @param string $htmlname Name of html select
- * @param int $modeproject 1 to restrict on projects owned by user
- * @param int $modetask 1 to restrict on tasks associated to user
- * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
- * @param int $useempty 0=Allow empty values
+ * @param int $selectedtask Pre-selected task
+ * @param int $projectid Project id
+ * @param string $htmlname Name of html select
+ * @param int $modeproject 1 to restrict on projects owned by user
+ * @param int $modetask 1 to restrict on tasks associated to user
+ * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
+ * @param int $useempty 0=Allow empty values
+ * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id
* @return void
*/
- function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0)
+ function selectProjectTasks($selectedtask='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0, $useempty=0, $disablechildoftaskid=0)
{
global $user, $langs;
@@ -448,7 +449,7 @@ class FormOther
if ($useempty) print ' ';
$j=0;
$level=0;
- $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid);
+ $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
print '';
}
else
@@ -458,17 +459,18 @@ class FormOther
}
/**
- * Write all lines of a project (if parent = 0)
+ * Write lines of a project (all lines of a project if parent = 0)
*
* @param int &$inc Cursor counter
- * @param int $parent Id parent
- * @param Object $lines Line object
+ * @param int $parent Id of parent task we want to see
+ * @param array $lines Array of task lines
* @param int $level Level
* @param int $selectedtask Id selected task
* @param int $selectedproject Id selected project
+ * @param int $disablechildoftaskid 1=Disable task that are child of the provided task id
* @return void
*/
- private function _pLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0)
+ private function _pLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selectedproject=0, $disablechildoftaskid=0)
{
global $langs, $user, $conf;
@@ -481,12 +483,12 @@ class FormOther
{
$var = !$var;
- //var_dump($selectedtask."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
+ //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);
// Break on a new project
- if ($parent == 0)
+ if ($parent == 0) // We are on a task at first level
{
- if ($lines[$i]->fk_project != $lastprojectid)
+ if ($lines[$i]->fk_project != $lastprojectid) // Break found on project
{
if ($i > 0 && $conf->browser->firefox) print '---------- ';
print 'id >= 0)
{
+ // Check if we must disable entry
+ $disabled=0;
+ if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid)))
+ {
+ $disabled++;
+ if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too
+ }
+
print ' id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected="selected"';
+ if ($disabled) print ' disabled="disabled"';
print '>';
print $langs->trans("Project").' '.$lines[$i]->projectref;
if (empty($lines[$i]->public))
@@ -534,7 +547,7 @@ class FormOther
}
$level++;
- if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject);
+ if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
$level--;
}
}
@@ -1042,7 +1055,7 @@ class FormOther
$emptybox->showBox(array(),array());
}
print "\n";
- print "\n";
+ print "\n";
print '';
@@ -1073,7 +1086,7 @@ class FormOther
$emptybox->showBox(array(),array());
}
print "
\n";
- print "\n";
+ print "\n";
print '
';
print "\n";
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index 5a6c2e8b6de..0f7d4a00482 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -128,7 +128,7 @@ class Ldap
$this->attr_firstname = $conf->global->LDAP_FIELD_FIRSTNAME;
$this->attr_mail = $conf->global->LDAP_FIELD_MAIL;
$this->attr_phone = $conf->global->LDAP_FIELD_PHONE;
- $this->attr_skype = $conf->global->LDAP_FIELD_SKYPE;
+ $this->attr_skype = $conf->global->LDAP_FIELD_SKYPE;
$this->attr_fax = $conf->global->LDAP_FIELD_FAX;
$this->attr_mobile = $conf->global->LDAP_FIELD_MOBILE;
}
@@ -151,9 +151,19 @@ class Ldap
$connected=0;
$this->bind=0;
+ // Check parameters
+ if (count($this->server) == 0 || empty($this->server[0]))
+ {
+ $this->error='LDAP setup (file conf.php) is not complete';
+ $return=-1;
+ dol_syslog(get_class($this)."::connect_bind ".$this->error, LOG_WARNING);
+ }
+
+ // Loop on each ldap server
foreach ($this->server as $key => $host)
{
if ($connected) break;
+ if (empty($host)) continue;
if (preg_match('/^ldap/',$host))
{
@@ -171,7 +181,7 @@ class Ldap
if ($this->serverType == "activedirectory")
{
$result=$this->setReferrals();
- dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser,LOG_DEBUG);
+ dol_syslog(get_class($this)."::connect_bind try bindauth for activedirectory on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
if ($this->result)
{
@@ -189,7 +199,7 @@ class Ldap
// Try in auth mode
if ($this->searchUser && $this->searchPassword)
{
- dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser,LOG_DEBUG);
+ dol_syslog(get_class($this)."::connect_bind try bindauth on ".$host." user=".$this->searchUser." password=".preg_replace('/./','*',$this->searchPassword),LOG_DEBUG);
$this->result=$this->bindauth($this->searchUser,$this->searchPassword);
if ($this->result)
{
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index cddd5cc557e..0fd1b1b8423 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -59,7 +59,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
$("#'.$htmlname.'").trigger("change");
});
// Check when keyup
- $("input#search_'.$htmlname.'").onDelayedKeyup({ handler: function() {
+ $("input#search_'.$htmlname.'").keyup(function() {
//console.log(\'keyup\');
if ($(this).val().length == 0)
{
@@ -93,7 +93,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
});
}
}
- }
});
$("input#search_'.$htmlname.'").autocomplete({
source: function( request, response ) {
@@ -366,7 +365,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0)
$("select#" + htmlname).html(response.value);
});
}
-
+
});'."\n";
$msg.= "\n";
diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php
index 293644be5dc..0e04c7e6b01 100644
--- a/htdocs/core/lib/categories.lib.php
+++ b/htdocs/core/lib/categories.lib.php
@@ -47,6 +47,11 @@ function categories_prepare_head($object,$type)
$head[$h][1] = $langs->trans("Photos");
$head[$h][2] = 'photos';
$h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type;
+ $head[$h][1] = $langs->trans("Translation");
+ $head[$h][2] = 'translation';
+ $h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php
index 6050c39da74..0652573ca37 100644
--- a/htdocs/core/lib/ecm.lib.php
+++ b/htdocs/core/lib/ecm.lib.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2008-2014 Laurent Destailleur
*
* 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
@@ -23,6 +23,43 @@
*/
+/**
+ * Prepare array with list of different ecm main dashboard
+ *
+ * @param object $object Object related to tabs
+ * @return array Array of tabs to shoc
+ */
+function ecm_prepare_dasboard_head($object)
+{
+ global $langs, $conf, $user;
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php';
+ $head[$h][1] = $langs->trans("ECMSectionsManual").img_help(1,$helptext1);
+ $head[$h][2] = 'index';
+ $h++;
+
+ if (! empty($conf->global->ECM_AUTO_TREE_ENABLED))
+ {
+ $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php';
+ $head[$h][1] = $langs->trans("ECMSectionsAuto").img_help(1,$helptext2);
+ $head[$h][2] = 'index_auto';
+ $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
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm');
+
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm','remove');
+
+ return $head;
+}
+
+
/**
* Prepare array with list of tabs
*
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index ff9710ae6fd..fd562fc8d15 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -581,7 +581,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
* @param array $links Array of tabs
* @param string $active Active tab name (document', 'info', 'ldap', ....)
* @param string $title Title
- * @param int $notab 0=Add tab header, 1=no tab header
+ * @param int $notab 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
* @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @return void
@@ -597,7 +597,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
* @param array $links Array of tabs
* @param int $active Active tab name
* @param string $title Title
- * @param int $notab 0=Add tab header, 1=no tab header
+ * @param int $notab 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
* @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @return void
@@ -4333,6 +4333,7 @@ function picto_from_langcode($codelang)
* 'group' to add a tab in group view
* 'member' to add a tab in fundation member view
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
+ * 'ecm' to add a tab for another ecm view
* @param string $mode 'add' to complete head, 'remove' to remove entries
* @return void
*/
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 20af2917fa4..4ef5ad707b1 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1532,3 +1532,126 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
}
return $ret;
}
+
+
+/**
+ * Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop
+ *
+ * @param DoliDB $db Database handler
+ * @param string $tabletocleantree Table to clean
+ * @param string $fieldfkparent Field name that contains id of parent
+ * @return int Nb of records fixed/deleted
+ */
+function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
+{
+ $totalnb=0;
+ $listofid=array();
+ $listofparentid=array();
+
+ // Get list of all id in array listofid and all parents in array listofparentid
+ $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $listofid[]=$obj->rowid;
+ if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id;
+ $i++;
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+
+ if (count($listofid))
+ {
+ print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'." \n";
+
+ // Check loops on each other
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself
+ dol_syslog("sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $nb=$db->affected_rows($sql);
+ if ($nb > 0)
+ {
+ print ' Some record that were parent of themself were cleaned.';
+ }
+
+ $totalnb+=$nb;
+ }
+ //else dol_print_error($db);
+
+ // Check other loops
+ $listofidtoclean=array();
+ foreach($listofparentid as $id => $pid)
+ {
+ // Check depth
+ //print 'Analyse record id='.$id.' with parent '.$pid.' ';
+
+ $cursor=$id; $arrayidparsed=array(); // We start from child $id
+ while ($cursor > 0)
+ {
+ $arrayidparsed[$cursor]=1;
+ if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child
+ {
+ print 'Found a loop between id '.$id.' - '.$cursor.' ';
+ unset($arrayidparsed);
+ $listofidtoclean[$cursor]=$id;
+ break;
+ }
+ $cursor=$listofparentid[$cursor];
+ }
+
+ if (count($listofidtoclean)) break;
+ }
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree;
+ $sql.= " SET ".$fieldfkparent." = 0";
+ $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong
+ dol_syslog("sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $nb=$db->affected_rows($sql);
+ if ($nb > 0)
+ {
+ // Removed orphelins records
+ print ' Some records were detected to have parent that is a child, we set them as root record for id: ';
+ print join(',',$listofidtoclean);
+ }
+
+ $totalnb+=$nb;
+ }
+ //else dol_print_error($db);
+
+ // Check and clean orphelins
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree;
+ $sql.= " SET ".$fieldfkparent." = 0";
+ $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent
+ dol_syslog("sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $nb=$db->affected_rows($sql);
+ if ($nb > 0)
+ {
+ // Removed orphelins records
+ print ' Some orphelins were found and modified to be parent so records are visible again for id: ';
+ print join(',',$listofid);
+ }
+
+ $totalnb+=$nb;
+ }
+ //else dol_print_error($db);
+
+ print ' We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.';
+ return $totalnb;
+ }
+}
diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index 07c568d41fc..1806d9f2970 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -73,7 +73,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
$ldap=new Ldap();
- $ldap->server=array($ldaphost);
+ $ldap->server=explode(',',$ldaphost);
$ldap->serverPort=$ldapport;
$ldap->ldapProtocolVersion=$ldapversion;
$ldap->serverType=$ldapservertype;
@@ -140,7 +140,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
$result=$ldap->connect_bind();
if ($result > 0)
{
- if ($result == 2)
+ if ($result == 2) // Connection is ok for user/pass into LDAP
{
dol_syslog("functions_ldap::check_user_password_ldap Authentification ok");
$login=$usertotest;
@@ -168,22 +168,22 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
{
dol_syslog("functions_ldap::check_user_password_ldap Sync user found id=".$user->id);
// On verifie si le login a change et on met a jour les attributs dolibarr
-
+
if ($conf->multicompany->enabled) {
- global $mc;
-
+ global $mc;
+
$ret=$mc->checkRight($user->id, $entitytotest);
if ($ret < 0) $login=false; // provoque l'echec de l'identification
}
-
-
+
+
if ($user->login != $ldap->login && $ldap->login)
{
$user->login = $ldap->login;
$user->update($user);
// TODO Que faire si update echoue car on update avec un login deja existant.
}
-
+
//$resultUpdate = $user->update_ldap2dolibarr($ldap);
}
}
@@ -212,12 +212,13 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
{
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
$ldap->ldapErrorText = ldap_error($ldap->connection);
- dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorText);
+ dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
}
sleep(1);
$langs->load('main');
$langs->load('other');
- $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
+ $langs->load('errors');
+ $_SESSION["dol_loginmesg"]=($ldap->error?$ldap->error:$langs->trans("ErrorBadLoginPassword"));
}
$ldap->close();
diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
index e9004283085..497663bf1d5 100644
--- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
@@ -780,9 +780,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Client destinataire
$posy=42;
+ $posx=102;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY(102,$posy-5);
+ $pdf->SetXY($posx,$posy-5);
$pdf->MultiCell(80,5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L');
// If SHIPPING contact defined on order, we use it
@@ -814,7 +816,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=42;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- //if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0,0,0);
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index 2cfe6bcb19e..33dba7e6ee3 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -63,7 +63,7 @@ class modCategorie extends DolibarrModules
$this->depends = array();
// Config pages
- $this->config_page_url = array('/categories/admin/categorie.php');
+ $this->config_page_url = array('categorie.php@categories');
$this->langfiles = array("products","companies","categories");
// Constantes
diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php
index 4822479e95f..3e365ba06e1 100644
--- a/htdocs/core/modules/modECM.class.php
+++ b/htdocs/core/modules/modECM.class.php
@@ -74,13 +74,13 @@ class modECM extends DolibarrModules
// Constants
$this->const = array(); // List of parameters
$r=0;
-
+
$this->const[$r][0] = "ECM_AUTO_TREE_ENABLED";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "1";
$this->const[$r][3] = 'Auto tree is enabled by default';
$this->const[$r][4] = 0;
-
+
// Boxes
$this->boxes = array(); // List of boxes
$r=0;
@@ -138,11 +138,12 @@ class modECM extends DolibarrModules
$r++;
// Left menu linked to top menu
- $this->menu[$r]=array('fk_menu'=>'r=0',
+ $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm',
'type'=>'left',
'titre'=>'ECMArea',
'mainmenu'=>'ecm',
- 'url'=>'/ecm/index.php',
+ 'leftmenu'=>'ecm',
+ 'url'=>'/ecm/index.php?mainmenu=ecm&leftmenu=ecm',
'langs'=>'ecm',
'position'=>101,
'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
@@ -151,24 +152,12 @@ class modECM extends DolibarrModules
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=1',
+ $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
'type'=>'left',
- 'titre'=>'ECMNewSection',
+ 'titre'=>'ECMSectionsManual',
'mainmenu'=>'ecm',
- 'url'=>'/ecm/docdir.php?action=create',
- 'langs'=>'ecm',
- 'position'=>100,
- 'perms'=>'$user->rights->ecm->setup',
- 'enabled'=>'$user->rights->ecm->setup',
- 'target'=>'',
- 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
- $r++;
-
- $this->menu[$r]=array('fk_menu'=>'r=1',
- 'type'=>'left',
- 'titre'=>'ECMFileManager',
- 'mainmenu'=>'ecm',
- 'url'=>'/ecm/index.php?action=file_manager',
+ 'leftmenu'=>'ecm_manual',
+ 'url'=>'/ecm/index.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
'langs'=>'ecm',
'position'=>102,
'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
@@ -177,21 +166,18 @@ class modECM extends DolibarrModules
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
- /*
- $this->menu[$r]=array('fk_menu'=>'r=1',
+ $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=ecm,fk_leftmenu=ecm',
'type'=>'left',
- 'titre'=>'Search',
+ 'titre'=>'ECMSectionsAuto',
'mainmenu'=>'ecm',
- 'url'=>'/ecm/search.php',
+ 'url'=>'/ecm/index_auto.php?action=file_manager&mainmenu=ecm&leftmenu=ecm',
'langs'=>'ecm',
'position'=>103,
- 'perms'=>'$user->rights->ecm->read',
- 'enabled'=>'$user->rights->ecm->read',
+ 'perms'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
+ 'enabled'=>'$user->rights->ecm->read || $user->rights->ecm->upload',
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
-
- $r++;*/
-
+ $r++;
}
/**
diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php
index 731084c0926..bb67e863667 100644
--- a/htdocs/core/tpl/login.tpl.php
+++ b/htdocs/core/tpl/login.tpl.php
@@ -61,7 +61,7 @@ $(document).ready(function () {
-
+
@@ -72,7 +72,7 @@ $(document).ready(function () {
-
+
trans('Login'); ?>
@@ -190,9 +190,9 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file
-
@@ -200,9 +200,9 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file
-
diff --git a/htdocs/core/tpl/objectline_add.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php
index d27268be121..e26b684d405 100644
--- a/htdocs/core/tpl/objectline_add.tpl.php
+++ b/htdocs/core/tpl/objectline_add.tpl.php
@@ -521,8 +521,7 @@ $(document).ready(function() {
});
});
- $('#product_desc').onDelayedKeyup({
- 'handler': function() {
+ $('#product_desc').keyup(function() {
var addline=false;
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
var content = $('#product_desc').val();
@@ -537,7 +536,6 @@ $(document).ready(function() {
} else {
$('#addlinebutton').attr('disabled','disabled');
}
- }
});
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index d48abbc0aa1..c9e8ded2e9e 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -348,8 +348,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 1) // TODO A virer
});
});
- $('#product_desc').onDelayedKeyup({
- 'handler': function() {
+ $('#product_desc').keyup(function() {
var addline=false;
if ($('#product_id').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
var content = $('#product_desc').val();
@@ -364,7 +363,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 1) // TODO A virer
} else {
$('#savelinebutton').attr('disabled','disabled');
}
- }
});
diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php
index 414c12bb462..5e002653922 100644
--- a/htdocs/core/tpl/passwordforgotten.tpl.php
+++ b/htdocs/core/tpl/passwordforgotten.tpl.php
@@ -46,7 +46,7 @@ $(document).ready(function () {
-
+
@@ -57,7 +57,7 @@ $(document).ready(function () {
-
+
@@ -129,7 +129,7 @@ if (! empty($hookmanager->resArray['options'])) {
-
+
trans('SendNewPasswordDesc'); ?>
@@ -139,15 +139,15 @@ if (! empty($hookmanager->resArray['options'])) {
trans('AuthenticationDoesNotAllowSendNewPassword', $mode); ?>
-
+
-
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 8cdcc3c2000..0ca94ef6df2 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -346,8 +346,10 @@ if ($action == 'refreshmanual')
* View
*/
-//print "xx".$_SESSION["dol_screenheight"];
-$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-166):660;
+// Define height of file area (depends on $_SESSION["dol_screenheight"])
+//print $_SESSION["dol_screenheight"];
+$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-186):660; // Also into index_auto.php file
+
$morejs=array();
if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js");
$moreheadcss="
@@ -417,11 +419,19 @@ if (! empty($conf->global->ECM_AUTO_TREE_ENABLED))
print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"));
+$helptext1=''; $helptext2='';
+$helptext1.=$langs->trans("ECMAreaDesc");
+$helptext1.=$langs->trans("ECMAreaDesc2");
+$helptext2.=$langs->trans("ECMAreaDesc");
+$helptext2.=$langs->trans("ECMAreaDesc2");
+
+/*
print '';
print $langs->trans("ECMAreaDesc")." ";
print $langs->trans("ECMAreaDesc2")." ";
print " \n";
print '
';
+*/
// Confirm remove file (for non javascript users)
if ($action == 'delete' && empty($conf->use_javascript_ajax))
@@ -436,6 +446,13 @@ dol_htmloutput_mesg($mesg);
if (! empty($conf->use_javascript_ajax)) $classviewhide='hidden';
else $classviewhide='visible';
+
+if (empty($conf->dol_use_jmobile))
+{
+$head = ecm_prepare_dasboard_head('');
+dol_fiche_head($head, 'index', '', 1, '');
+}
+
// Start container of all panels
?>
@@ -492,75 +509,6 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
print '
';
$showonrightsize='';
- // Auto section
- if (count($sectionauto))
- {
- $htmltooltip=$langs->trans("ECMAreaDesc2");
-
- // Root title line (Automatic section)
- print '';
- print '';
- print '';
- print '';
- print img_picto_common('','treemenu/base.gif');
- print ' ';
- $txt=$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsAuto").')';
- print $form->textwithpicto($txt, $htmltooltip, 1, 0);
- print ' ';
- print '
';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- print '';
- print ' ';
- print ' ';
-
- $sectionauto=dol_sort_array($sectionauto,'label','ASC',true,false);
-
- print '';
- print '';
- print '';
-
- $nbofentries=0;
- $oldvallevel=0;
- foreach ($sectionauto as $key => $val)
- {
- if (empty($val['test'])) continue; // If condition to show is ok
-
- $var=false;
-
- print '';
- if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
- {
- print '';
- print $val['label'];
- print ' ';
- }
- else
- {
- print '';
- print $val['label'];
- print ' ';
- }
-
- print '';
- // Info
- $htmltooltip=''.$langs->trans("ECMSection").' : '.$val['label'].' ';
- $htmltooltip=''.$langs->trans("Type").' : '.$langs->trans("ECMSectionAuto").' ';
- $htmltooltip.=''.$langs->trans("ECMCreationUser").' : '.$langs->trans("ECMTypeAuto").' ';
- $htmltooltip.=''.$langs->trans("Description").' : '.$val['desc'];
- print $form->textwithpicto('', $htmltooltip, 1, 'info');
- print '
';
- print ' ';
-
- $nbofentries++;
- }
-
- print ' ';
- }
-
// Manual section
$htmltooltip=$langs->trans("ECMAreaDesc2");
@@ -768,7 +716,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
}
-// End left banner
+// End left panel
?>
@@ -806,7 +754,7 @@ if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABL
}
$formfile=new FormFile($db);
- $formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile');
+ $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile');
}
else print ' ';
@@ -821,9 +769,11 @@ else print ' ';
// End of page
+//dol_fiche_end();
+
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
- include 'tpl/builddatabase.tpl.php';
+ include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
}
diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php
new file mode 100644
index 00000000000..b2d1b7eabee
--- /dev/null
+++ b/htdocs/ecm/index_auto.php
@@ -0,0 +1,605 @@
+
+ * Copyright (C) 2008-2010 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 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/ecm/index_auto.php
+ * \ingroup ecm
+ * \brief Main page for ECM section area
+ * \author Laurent Destailleur
+ */
+
+if (! defined('REQUIRE_JQUERY_LAYOUT')) define('REQUIRE_JQUERY_LAYOUT','1');
+if (! defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
+
+// Load traductions files
+$langs->load("ecm");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("users");
+$langs->load("orders");
+$langs->load("propal");
+$langs->load("bills");
+$langs->load("contracts");
+
+// Security check
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'ecm', 0);
+
+// Get parameters
+$socid=GETPOST('socid','int');
+$action=GETPOST("action");
+$section=GETPOST("section")?GETPOST("section","int"):GETPOST("section_id","int");
+$module=GETPOST("module");
+if (! $section) $section=0;
+$section_dir=GETPOST('section_dir');
+
+$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="fullname";
+if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield="level1name";
+
+$ecmdir = new EcmDirectory($db);
+if ($section)
+{
+ $result=$ecmdir->fetch($section);
+ if (! $result > 0)
+ {
+ dol_print_error($db,$ecmdir->error);
+ exit;
+ }
+}
+
+$form=new Form($db);
+$ecmdirstatic = new EcmDirectory($db);
+$userstatic = new User($db);
+
+$error=0;
+
+
+/*
+ * Actions
+ */
+
+// Upload file
+if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ // Define relativepath and upload_dir
+ $relativepath='';
+ if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath();
+ else $relativepath=$section_dir;
+ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+
+ if (empty($_FILES['userfile']['tmp_name']))
+ {
+ $error++;
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("File")), 'errors');
+ }
+
+ if (! $error)
+ {
+ 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)
+ {
+ //$mesg = ''.$langs->trans("FileTransferComplete").'
';
+ //print_r($_FILES);
+ $result=$ecmdir->changeNbOfFiles('+');
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($resupload < 0) // Unknown error
+ {
+ setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors');
+ }
+ else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
+ {
+ setEventMessage($langs->trans("ErrorFileIsInfectedWithAVirus"), 'errors');
+ }
+ else // Known error
+ {
+ setEventMessage($langs->trans($resupload), 'errors');
+ }
+ }
+ }
+ else
+ {
+ $langs->load("errors");
+ $mesg = ''.$langs->trans("ErrorFailToCreateDir",$upload_dir).'
';
+ }
+ }
+}
+
+
+
+// Add directory
+if ($action == 'add' && $user->rights->ecm->setup)
+{
+ $ecmdir->ref = 'NOTUSEDYET';
+ $ecmdir->label = GETPOST("label");
+ $ecmdir->description = GETPOST("desc");
+
+ $id = $ecmdir->create($user);
+ if ($id > 0)
+ {
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $mesg='Error '.$langs->trans($ecmdir->error).'
';
+ $action = "create";
+ }
+
+ clearstatcache();
+}
+
+// Remove file
+if ($action == 'confirm_deletefile')
+{
+ if (GETPOST('confirm') == 'yes')
+ {
+ $langs->load("other");
+ if ($section)
+ {
+ $result=$ecmdir->fetch($section);
+ if (! ($result > 0))
+ {
+ dol_print_error($db,$ecmdir->error);
+ exit;
+ }
+ $relativepath=$ecmdir->getRelativePath();
+ }
+ else $relativepath='';
+ $upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
+ $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
+
+ $ret=dol_delete_file($file);
+ if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
+ else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+
+ $result=$ecmdir->changeNbOfFiles('-');
+
+ clearstatcache();
+ }
+ $action='file_manager';
+}
+
+// Remove directory
+if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
+{
+ $result=$ecmdir->delete($user);
+ $mesg = ''.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'
';
+
+ clearstatcache();
+}
+
+// Refresh directory view
+if ($action == 'refreshmanual')
+{
+ $ecmdirtmp = new EcmDirectory($db);
+
+ // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
+ clearstatcache();
+
+ $diroutputslash=str_replace('\\','/',$conf->ecm->dir_output);
+ $diroutputslash.='/';
+
+ // Scan directory tree on disk
+ $disktree=dol_dir_list($conf->ecm->dir_output,'directories',1,'','^temp$','','',0);
+
+ // Scan directory tree in database
+ $sqltree=$ecmdirstatic->get_full_arbo(0);
+
+ $adirwascreated=0;
+
+ // Now we compare both trees to complete missing trees into database
+ //var_dump($disktree);
+ //var_dump($sqltree);
+ foreach($disktree as $dirdesc) // Loop on tree onto disk
+ {
+ $dirisindatabase=0;
+ foreach($sqltree as $dirsqldesc)
+ {
+ if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
+ {
+ $dirisindatabase=1;
+ break;
+ }
+ }
+
+ if (! $dirisindatabase)
+ {
+ $txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
+ dol_syslog($txt);
+ //print $txt." \n";
+
+ // We must first find the fk_parent of directory to create $dirdesc['fullname']
+ $fk_parent=-1;
+ $relativepathmissing=str_replace($diroutputslash,'',$dirdesc['fullname']);
+ $relativepathtosearchparent=$relativepathmissing;
+ //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
+ if (preg_match('/\//',$relativepathtosearchparent))
+ //while (preg_match('/\//',$relativepathtosearchparent))
+ {
+ $relativepathtosearchparent=preg_replace('/\/[^\/]*$/','',$relativepathtosearchparent);
+ $txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
+ dol_syslog($txt);
+ //print $txt." -> ";
+ $parentdirisindatabase=0;
+ foreach($sqltree as $dirsqldesc)
+ {
+ if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
+ {
+ $parentdirisindatabase=$dirsqldesc['id'];
+ break;
+ }
+ }
+ if ($parentdirisindatabase > 0)
+ {
+ dol_syslog("Yes with id ".$parentdirisindatabase);
+ //print "Yes with id ".$parentdirisindatabase." \n";
+ $fk_parent=$parentdirisindatabase;
+ //break; // We found parent, we can stop the while loop
+ }
+ else
+ {
+ dol_syslog("No");
+ //print "No \n";
+ }
+ }
+ else
+ {
+ dol_syslog("Parent is root");
+ $fk_parent=0; // Parent is root
+ }
+
+ if ($fk_parent >= 0)
+ {
+ $ecmdirtmp->ref = 'NOTUSEDYET';
+ $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
+ $ecmdirtmp->description = '';
+ $ecmdirtmp->fk_parent = $fk_parent;
+
+ $txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
+ dol_syslog($txt);
+ //print $ecmdirtmp->cachenbofdoc." \n";exit;
+ $id = $ecmdirtmp->create($user);
+ if ($id > 0)
+ {
+ $newdirsql=array('id'=>$id,
+ 'id_mere'=>$ecmdirtmp->fk_parent,
+ 'label'=>$ecmdirtmp->label,
+ 'description'=>$ecmdirtmp->description,
+ 'fullrelativename'=>$relativepathmissing);
+ $sqltree[]=$newdirsql; // We complete fulltree for following loops
+ //var_dump($sqltree);
+ $adirwascreated=1;
+ }
+ else
+ {
+ dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
+ }
+ }
+ else {
+ $txt="Parent of ".$dirdesc['fullname']." not found";
+ dol_syslog($txt);
+ //print $txt." \n";
+ }
+ }
+ }
+
+ // Loop now on each sql tree to check if dir exists
+ foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk
+ {
+ $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
+ if (! dol_is_dir($dirtotest))
+ {
+ $mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']." \n";
+ $ecmdirtmp->id=$dirdesc['id'];
+ $ecmdirtmp->delete($user,'databaseonly');
+ //exit;
+ }
+ }
+
+ $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown"
+ dol_syslog("sql = ".$sql);
+ $db->query($sql);
+
+ // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
+ // it to be sure that fulltree array is not used without reloading it.
+ if ($adirwascreated) $sqltree=null;
+}
+
+
+
+/*
+ * View
+ */
+
+// Define height of file area (depends on $_SESSION["dol_screenheight"])
+//print $_SESSION["dol_screenheight"];
+$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-186):660; // Also into index.php file
+
+$morejs=array();
+if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js");
+$moreheadcss="
+
+";
+$moreheadjs=empty($conf->use_javascript_ajax)?"":"
+";
+
+llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0);
+
+
+// Add sections to manage
+$rowspan=0;
+$sectionauto=array();
+if (! empty($conf->global->ECM_AUTO_TREE_ENABLED))
+{
+ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
+ if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
+ if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
+ if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
+ if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
+ if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
+ if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
+ if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
+ if (! empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); }
+ if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); }
+}
+
+print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"));
+
+$helptext1=''; $helptext2='';
+$helptext1.=$langs->trans("ECMAreaDesc");
+$helptext1.=$langs->trans("ECMAreaDesc2");
+$helptext2.=$langs->trans("ECMAreaDesc");
+$helptext2.=$langs->trans("ECMAreaDesc2");
+
+/*
+print '';
+print $langs->trans("ECMAreaDesc")." ";
+print $langs->trans("ECMAreaDesc2")." ";
+print " \n";
+print '
';
+*/
+
+// Confirm remove file (for non javascript users)
+if ($action == 'delete' && empty($conf->use_javascript_ajax))
+{
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
+
+}
+
+dol_htmloutput_mesg($mesg);
+
+
+if (! empty($conf->use_javascript_ajax)) $classviewhide='hidden';
+else $classviewhide='visible';
+
+
+if (empty($conf->dol_use_jmobile))
+{
+$head = ecm_prepare_dasboard_head('');
+dol_fiche_head($head, 'index_auto', '', 1, '');
+}
+
+// Start container of all panels
+?>
+
+
';
+// End top panel, toolbar
+
+?>
+
+
+formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
+}
+// End confirm
+
+
+if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
+{
+ print '
';
+
+ print '';
+ print '';
+ print ' '.$langs->trans("ECMSections");
+ print ' ';
+
+ $showonrightsize='';
+ // Auto section
+ if (count($sectionauto))
+ {
+ $htmltooltip=$langs->trans("ECMAreaDesc2");
+
+ // Root title line (Automatic section)
+ print '';
+ print '';
+ print '';
+ print '';
+ print img_picto_common('','treemenu/base.gif');
+ print ' ';
+ $txt=$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsAuto").')';
+ print $form->textwithpicto($txt, $htmltooltip, 1, 0);
+ print ' ';
+ print '
';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print '';
+ print ' ';
+ print ' ';
+
+ $sectionauto=dol_sort_array($sectionauto,'label','ASC',true,false);
+
+ print '';
+ print '';
+ print '';
+
+ $nbofentries=0;
+ $oldvallevel=0;
+ foreach ($sectionauto as $key => $val)
+ {
+ if (empty($val['test'])) continue; // If condition to show is ok
+
+ $var=false;
+
+ print '';
+ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
+ {
+ print '';
+ print $val['label'];
+ print ' ';
+ }
+ else
+ {
+ print '';
+ print $val['label'];
+ print ' ';
+ }
+
+ print '';
+ // Info
+ $htmltooltip=''.$langs->trans("ECMSection").' : '.$val['label'].' ';
+ $htmltooltip=''.$langs->trans("Type").' : '.$langs->trans("ECMSectionAuto").' ';
+ $htmltooltip.=''.$langs->trans("ECMCreationUser").' : '.$langs->trans("ECMTypeAuto").' ';
+ $htmltooltip.=''.$langs->trans("Description").' : '.$val['desc'];
+ print $form->textwithpicto('', $htmltooltip, 1, 'info');
+ print '
';
+ print ' ';
+
+ $nbofentries++;
+ }
+
+ print ' ';
+ }
+
+ print "
";
+}
+
+
+// End left banner
+?>
+
+
+
+use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
+ include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
+}
+
+
+
+llxFooter();
+
+$db->close();
+?>
diff --git a/htdocs/ecm/tpl/builddatabase.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php
similarity index 96%
rename from htdocs/ecm/tpl/builddatabase.tpl.php
rename to htdocs/ecm/tpl/enablefiletreeajax.tpl.php
index 1b34027142f..301fa5f955b 100644
--- a/htdocs/ecm/tpl/builddatabase.tpl.php
+++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php
@@ -13,12 +13,12 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* Output javascript for interactions code of ecm module
*/
?>
-
+