';
if ($conf->societe->enabled)
{
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 905b562ab5d..6e4e3fb941b 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -120,7 +120,7 @@ class ActionComm extends CommonObject
* Object user that create action
* @var User
* @deprecated
- * @see authorid
+ * @see $authorid
*/
public $author;
@@ -128,7 +128,7 @@ class ActionComm extends CommonObject
* Object user that modified action
* @var User
* @deprecated
- * @see usermodid
+ * @see $usermodid
*/
public $usermod;
@@ -1010,7 +1010,7 @@ class ActionComm extends CommonObject
/**
* Load all objects with filters.
- * WARNING: This make a fetch on all records instead of making one request with a join.
+ * @TODO WARNING: This make a fetch on all records instead of making one request with a join.
*
* @param DoliDb $db Database handler
* @param int $socid Filter by thirdparty
@@ -1020,7 +1020,7 @@ class ActionComm extends CommonObject
* @param string $sortfield Sort on this field
* @param string $sortorder ASC or DESC
* @param string $limit Limit number of answers
- * @return array or string Error string if KO, array with actions if OK
+ * @return array|string Error string if KO, array with actions if OK
*/
public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
{
@@ -1028,6 +1028,8 @@ class ActionComm extends CommonObject
$resarray=array();
+ dol_syslog(get_class()."::getActions", LOG_DEBUG);
+
$sql = "SELECT a.id";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE a.entity IN (".getEntity('agenda').")";
@@ -1041,7 +1043,6 @@ class ActionComm extends CommonObject
if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($limit, 0);
- dol_syslog(get_class()."::getActions", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
@@ -1285,7 +1286,7 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
- if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id))
+ if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id))
$option = 'nolink';
$label = $this->label;
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index ec899d72ae1..833f97b3b6b 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -356,7 +356,7 @@ class AgendaEvents extends DolibarrApi
unset($object->total_localtax2);
unset($object->total_ttc);
unset($object->fk_incoterms);
- unset($object->libelle_incoterms);
+ unset($object->label_incoterms);
unset($object->location_incoterms);
unset($object->name);
unset($object->lastname);
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 28670604b9e..bd57005b7bf 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -43,7 +43,7 @@ $action=GETPOST('action', 'alpha');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'actioncommlist'; // To manage different context of search
$resourceid=GETPOST("search_resourceid", "int")?GETPOST("search_resourceid", "int"):GETPOST("resourceid", "int");
$pid=GETPOST("search_projectid", 'int', 3)?GETPOST("search_projectid", 'int', 3):GETPOST("projectid", 'int', 3);
-$status=GETPOST("search_status", 'alpha')?GETPOST("search_status", 'alpha'):GETPOST("status", 'alpha');
+$status=(GETPOST("search_status", 'alpha') != '')?GETPOST("search_status", 'alpha'):GETPOST("status", 'alpha');
$type=GETPOST('search_type', 'alphanohtml')?GETPOST('search_type', 'alphanohtml'):GETPOST('type', 'alphanohtml');
$optioncss = GETPOST('optioncss', 'alpha');
$year=GETPOST("year", 'int');
@@ -97,15 +97,13 @@ if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $limit * $page ;
if (! $sortorder)
{
- $sortorder="DESC";
- if ($status == 'todo') $sortorder="DESC";
- //if ($status == 'done') $sortorder="DESC";
+ $sortorder="DESC,DESC";
+ if ($status == 'todo') $sortorder="DESC,DESC";
}
if (! $sortfield)
{
- $sortfield="a.datep";
- if ($status == 'todo') $sortfield="a.datep";
- //if ($status == 'done') $sortfield="a.datep2";
+ $sortfield="a.datep,a.id";
+ if ($status == 'todo') $sortfield="a.datep,a.id";
}
// Security check
@@ -500,7 +498,7 @@ if ($resql)
if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
- if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep", $param, '', 'align="center"', $sortfield, $sortorder);
+ if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "a.fk_contact", $param, "", "", $sortfield, $sortorder);
@@ -528,6 +526,7 @@ if ($resql)
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
$caction=new CActionComm($db);
$arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1);
+ $contactListCache = array();
while ($i < min($num, $limit))
{
@@ -647,7 +646,34 @@ if ($resql)
// Contact
if (! empty($arrayfields['a.fk_contact']['checked'])) {
print '';
- if ($obj->fk_contact > 0)
+
+
+ $actionstatic->fetchResources();
+ if(!empty($actionstatic->socpeopleassigned))
+ {
+ $contactList = array();
+ foreach ($actionstatic->socpeopleassigned as $socpeopleId => $socpeopleassigned)
+ {
+ if(!isset($contactListCache[$socpeopleassigned['id']]))
+ {
+ // if no cache found we fetch it
+ $contact = new Contact($db);
+ if($contact->fetch($socpeopleassigned['id'])>0)
+ {
+ $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 28);
+ $contactList[] = $contact->getNomUrl(1, '', 28);
+ }
+ }
+ else{
+ // use cache
+ $contactList[] = $contactListCache[$socpeopleassigned['id']];
+ }
+ }
+ if(!empty($contactList)){
+ print implode(', ', $contactList);
+ }
+ }
+ elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event
{
$contactstatic->id=$obj->fk_contact;
$contactstatic->email=$obj->email;
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 754cb736bc9..d4020f4df92 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -1186,33 +1186,34 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
}
}
- $ids1='';$ids2='';
- if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',', array_keys($cases1[$h]));
- if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',', array_keys($cases2[$h]));
+ $ids1='';
+ $ids2='';
+ if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1=join(',', array_keys($cases1[$h]));
+ if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2=join(',', array_keys($cases2[$h]));
if ($h == $begin_h) echo ' ';
else echo ' ';
- if (count($cases1[$h]) == 1) // only 1 event
+ if (is_array($cases1[$h]) && count($cases1[$h]) == 1) // only 1 event
{
$output = array_slice($cases1[$h], 0, 1);
$title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
if ($output[0]['string']) $title1.=($title1?' - ':'').$output[0]['string'];
if ($output[0]['color']) $color1 = $output[0]['color'];
}
- elseif (count($cases1[$h]) > 1)
+ elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1)
{
$title1=$langs->trans("Ref").' '.$ids1.($title1?' - '.$title1:'');
$color1='222222';
}
- if (count($cases2[$h]) == 1) // only 1 event
+ if (is_array($cases2[$h]) && count($cases2[$h]) == 1) // only 1 event
{
$output = array_slice($cases2[$h], 0, 1);
$title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
if ($output[0]['string']) $title2.=($title2?' - ':'').$output[0]['string'];
if ($output[0]['color']) $color2 = $output[0]['color'];
}
- elseif (count($cases2[$h]) > 1)
+ elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1)
{
$title2=$langs->trans("Ref").' '.$ids2.($title2?' - '.$title2:'');
$color2='222222';
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 721aba20de8..285ed03e7c3 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -694,7 +694,7 @@ if ($object->id > 0)
if ($num > 0)
{
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastPropals", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllPropals").' '.$num.' ';
@@ -779,7 +779,7 @@ if ($object->id > 0)
$db->free($resql2);
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastCustomerOrders", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllOrders").' '.$num.' ';
@@ -855,7 +855,7 @@ if ($object->id > 0)
$num = $db->num_rows($resql);
if ($num > 0) {
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastSendings", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllSendings").' '.$num.' ';
@@ -919,7 +919,7 @@ if ($object->id > 0)
if ($num >0)
{
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastContracts", ($num<=$MAXLIST?"":$MAXLIST)).' ';
@@ -989,7 +989,7 @@ if ($object->id > 0)
if ($num > 0)
{
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastInterventions", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllInterventions").' '.$num.' ';
@@ -1062,7 +1062,7 @@ if ($object->id > 0)
if ($num > 0)
{
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LatestCustomerTemplateInvoices", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllCustomerTemplateInvoices").' '.$num.' ';
@@ -1167,7 +1167,7 @@ if ($object->id > 0)
if ($num > 0)
{
print '';
- print '
';
+ print '';
print '';
print ''.$langs->trans("LastCustomersBills", ($num<=$MAXLIST?"":$MAXLIST)).' '.$langs->trans("AllBills").' '.$num.' ';
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 651d2c54ec7..15e4e226587 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -37,6 +38,11 @@ if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn
if (! $user->rights->societe->lire) accessforbidden();
+$hookmanager = new HookManager($db);
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('commercialindex'));
+
// Load translation files required by the page
$langs->loadLangs(array("commercial", "propal"));
@@ -897,6 +903,9 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php
index c5d8bc47232..a835ca241a3 100644
--- a/htdocs/comm/mailing/index.php
+++ b/htdocs/comm/mailing/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2005 Rodolphe Quiedeville
* Copyright (C) 2005-2009 Laurent Destailleur
* Copyright (C) 2010 Regis Houssin
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -27,6 +28,11 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+$hookmanager = new HookManager($db);
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('mailingindex'));
+
// Load translation files required by the page
$langs->loadLangs(array('commercial', 'orders'));
@@ -207,6 +213,9 @@ if ($langs->file_exists("html/spam.html", 0)) {
print ' ';
}
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 7331d7a86e9..8b52aedcaad 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1688,7 +1688,7 @@ if ($action == 'create')
if (!empty($conf->incoterm->enabled))
{
print '';
- print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).' ';
+ print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->label_incoterms, 1).' ';
print '';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print ' ';
@@ -2305,7 +2305,7 @@ $formquestion = array_merge($formquestion, array(
print '';
if ($action != 'editincoterm')
{
- print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
+ print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
}
else
{
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 0b9863f287b..598d34f7093 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -415,7 +415,7 @@ class Propal extends CommonObject
* @param float $remise_percent Pourcentage de remise de la ligne
* @param string $price_base_type HT or TTC
* @param float $pu_ttc Prix unitaire TTC
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits for type of lines
* @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
* @param int $rang Position of line
* @param int $special_code Special code (also used by externals modules!)
@@ -530,11 +530,11 @@ class Propal extends CommonObject
$pu_ht_devise = $tabprice[19];
// Rang to use
- $rangtouse = $rang;
- if ($rangtouse == -1)
+ $ranktouse = $rang;
+ if ($ranktouse == -1)
{
$rangmax = $this->line_max($fk_parent_line);
- $rangtouse = $rangmax + 1;
+ $ranktouse = $rangmax + 1;
}
// TODO A virer
@@ -568,7 +568,7 @@ class Propal extends CommonObject
$this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht;
- $this->line->rang=$rangtouse;
+ $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
@@ -1330,9 +1330,9 @@ class Propal extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
- $parameters=array('objFrom'=>$this,'clonedObj'=>$clonedObj);
+ $parameters=array('objFrom'=>$this,'clonedObj'=>$object);
$action='';
- $reshook=$hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
}
@@ -1383,7 +1383,7 @@ class Propal extends CommonObject
$sql.= ", p.fk_incoterms, p.location_incoterms";
$sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
$sql.= ", p.tms as date_modification";
- $sql.= ", i.libelle as libelle_incoterms";
+ $sql.= ", i.libelle as label_incoterms";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
$sql.= ", dr.code as demand_reason_code, dr.label as demand_reason";
@@ -1471,7 +1471,7 @@ class Propal extends CommonObject
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
- $this->libelle_incoterms = $obj->libelle_incoterms;
+ $this->label_incoterms = $obj->label_incoterms;
// Multicurrency
$this->fk_multicurrency = $obj->fk_multicurrency;
@@ -1615,11 +1615,14 @@ class Propal extends CommonObject
/**
* Load array lines
*
- * @param int $only_product Return only physical products
+ * @param int $only_product Return only physical products
+ * @param int $loadalsotranslation Return translation for products
+ *
* @return int <0 if KO, >0 if OK
*/
- public function fetch_lines($only_product = 0)
+ public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
+ global $langs, $conf;
// phpcs:enable
$this->lines=array();
@@ -1713,6 +1716,13 @@ class Propal extends CommonObject
$line->fetch_optionals();
+ // multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) {
+ $line = new Product($this->db);
+ $line->fetch($objp->fk_product);
+ $line->getMultiLangs();
+ }
+
$this->lines[$i] = $line;
//dol_syslog("1 ".$line->fk_product);
//print "xx $i ".$this->lines[$i]->fk_product;
@@ -1739,10 +1749,10 @@ class Propal extends CommonObject
*/
public function valid($user, $notrigger = 0)
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
global $conf;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
$error=0;
// Protection
@@ -1808,14 +1818,18 @@ class Propal extends CommonObject
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
- // Rename of propal directory ($this->ref = old ref, $num = new ref)
- // to not lose the linked files
+ // Now we rename also files into index
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'propale/".$this->db->escape($this->newref)."'";
+ $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'propale/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
+
+ // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->propal->multidir_output[$this->entity].'/'.$oldref;
$dirdest = $conf->propal->multidir_output[$this->entity].'/'.$newref;
-
- if (file_exists($dirsource))
+ if (! $error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest))
@@ -3502,7 +3516,7 @@ class Propal extends CommonObject
else
{
$langs->load("errors");
- print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Proposal"));
return "";
}
}
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index e69dbbc8b6c..309712ae76b 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville
* Copyright (C) 2004-2017 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -27,6 +28,11 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php';
+$hookmanager = new HookManager($db);
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('proposalindex'));
+
// Load translation files required by the page
$langs->loadLangs(array('propal', 'companies'));
@@ -540,6 +546,9 @@ if (! empty($conf->propal->enabled))
//print '
';
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardPropals', $parameters, $object); // Note that $action and $object may have been modified by hook
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index ff01690660a..c6af61acab9 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -162,10 +162,13 @@ $arrayfields=array(
'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
+ 'p.total_ht_invoiced'=>array('label'=>$langs->trans("AmountInvoicedHT"), 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT),
+ 'p.total_invoiced'=>array('label'=>$langs->trans("AmountInvoicedTTC"), 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'p.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
// Extra fields
@@ -267,10 +270,10 @@ $sql.= " typent.code as typent_code,";
$sql.= " ava.rowid as availability,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,';
-$sql.= ' p.datec as date_creation, p.tms as date_update,';
+$sql.= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,';
$sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,";
$sql.= ' u.login';
-if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user,";
+if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
@@ -444,7 +447,7 @@ if ($resql)
$newcardbutton.= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create');
}
- // Lignes des champs de filtre
+ // Fields title search
print ' ';
}
+ if (! empty($arrayfields['p.total_ht_invoiced']['checked']))
+ {
+ // Amount invoiced
+ print '';
+ print ' ';
+ }
+ if (! empty($arrayfields['p.total_invoiced']['checked']))
+ {
+ // Amount invoiced
+ print '';
+ print ' ';
+ }
if (! empty($arrayfields['u.login']['checked']))
{
// Author
@@ -674,6 +689,12 @@ if ($resql)
print '';
print ' ';
}
+ // Date cloture
+ if (! empty($arrayfields['p.date_cloture']['checked']))
+ {
+ print '';
+ print ' ';
+ }
// Status
if (! empty($arrayfields['p.fk_statut']['checked']))
{
@@ -709,6 +730,8 @@ if ($resql)
if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (! empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (! empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder);
// Extra fields
@@ -719,6 +742,7 @@ if ($resql)
print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
+ if (! empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print ' '."\n";
@@ -933,6 +957,48 @@ if ($resql)
if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
$totalarray['totalttc'] += $obj->total_ttc;
}
+ // Amount invoiced
+ if(! empty($arrayfields['p.total_ht_invoiced']['checked'])) {
+ $totalInvoiced = 0;
+ $p = new Propal($db);
+ $TInvoiceData = $p->InvoiceArrayList($obj->rowid);
+
+ if(! empty($TInvoiceData)) {
+ foreach($TInvoiceData as $invoiceData) {
+ $invoice = new Facture($db);
+ $invoice->fetch($invoiceData->facid);
+
+ if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
+ $totalInvoiced += $invoice->total_ht;
+ }
+ }
+
+ print ''.price($totalInvoiced)." \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalhtinvoicedfield']=$totalarray['nbfield'];
+ $totalarray['totalhtinvoiced'] += $totalInvoiced;
+ }
+ // Amount invoiced
+ if(! empty($arrayfields['p.total_invoiced']['checked'])) {
+ $totalInvoiced = 0;
+ $p = new Propal($db);
+ $TInvoiceData = $p->InvoiceArrayList($obj->rowid);
+
+ if(! empty($TInvoiceData)) {
+ foreach($TInvoiceData as $invoiceData) {
+ $invoice = new Facture($db);
+ $invoice->fetch($invoiceData->facid);
+
+ if(! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue;
+ $totalInvoiced += $invoice->total_ttc;
+ }
+ }
+
+ print ''.price($totalInvoiced)." \n";
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalinvoicedfield']=$totalarray['nbfield'];
+ $totalarray['totalinvoiced'] += $totalInvoiced;
+ }
$userstatic->id=$obj->fk_user_author;
$userstatic->login=$obj->login;
@@ -1015,6 +1081,14 @@ if ($resql)
print '';
if (! $i) $totalarray['nbfield']++;
}
+ // Date cloture
+ if (! empty($arrayfields['p.date_cloture']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Status
if (! empty($arrayfields['p.fk_statut']['checked']))
{
@@ -1059,6 +1133,8 @@ if ($resql)
elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
+ elseif ($totalarray['totalhtinvoicedfield'] == $i) print ''.price($totalarray['totalhtinvoiced']).' ';
+ elseif ($totalarray['totalinvoicedfield'] == $i) print ''.price($totalarray['totalinvoiced']).' ';
elseif ($totalarray['totalizable']) {
$printed = false;
foreach ($totalarray['totalizable'] as $totalizable) {
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index aa47f1c226d..13b7b5fa2d2 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -110,7 +110,6 @@ $mesg = $px1->isGraphKo();
if (! $mesg)
{
$px1->SetData($data);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
@@ -125,7 +124,6 @@ if (! $mesg)
$px1->SetYLabel($langs->trans("NbOfProposals"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfProposalsByMonth"));
@@ -152,7 +150,6 @@ $mesg = $px2->isGraphKo();
if (! $mesg)
{
$px2->SetData($data);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
@@ -167,7 +164,6 @@ if (! $mesg)
$px2->SetYLabel($langs->trans("AmountOfProposals"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
@@ -209,7 +205,6 @@ if (! $mesg)
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
- $px3->SetPrecisionY(0);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
index 1b78370048a..910772d87ca 100644
--- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
@@ -43,6 +43,8 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
// Load translation files required by the page
$langs->load("propal");
+$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
+
$total=0; $ilink=0;
foreach($linkedObjectBlock as $key => $objectlink)
{
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index eabb217fb99..bd143b551ae 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -734,7 +734,7 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
}
- // Remises liees a lignes de factures
+ // Discount linked to invoice lines
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql.= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
$sql.= " rc.fk_facture_source,";
@@ -904,7 +904,7 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("SupplierDiscounts"), '', '');
}
- // Remises liees a lignes de factures
+ // Discount linked to invoice lines
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql.= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,";
$sql.= " rc.fk_invoice_supplier_source,";
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 8ceadce89e5..0f875b68f22 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1519,11 +1519,11 @@ if ($action == 'create' && $user->rights->commande->creer)
if ($element == 'order' || $element == 'commande') {
$element = $subelement = 'commande';
}
- if ($element == 'propal') {
+ elseif ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
- if ($element == 'contract') {
+ elseif ($element == 'contract') {
$element = $subelement = 'contrat';
}
@@ -1737,7 +1737,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (!empty($conf->incoterm->enabled))
{
print '';
- print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).' ';
+ print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).' ';
print '';
$incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms');
@@ -2116,7 +2116,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
print '
';
- print '
';
+ print '';
if ($soc->outstanding_limit)
{
@@ -2361,7 +2361,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
if ($action != 'editincoterm')
{
- print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
+ print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
}
else
{
@@ -2454,7 +2454,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print '';
print '';
- print '';
+ print ''; // Close fichecenter
print '
';
@@ -2591,7 +2591,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
} else {
$langs->load("errors");
- print '';
+ print '';
}
}
}
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index 27b55f9e57f..36df0c0eacb 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -415,21 +415,16 @@ class Orders extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
- if(!DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
-
- $result = $this->commande->fetch($id);
-
- if(!$result) {
- throw new RestException(404, 'Order not found');
+ if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
}
- if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
- throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
+ $result = $this->commande->fetch($id);
+ if (! $result) {
+ throw new RestException(404, 'Order not found');
}
- if(!DolibarrApi::_checkAccessToResource('order', $this->commande->id)) {
+ if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -457,17 +452,16 @@ class Orders extends DolibarrApi
*/
public function deleteContact($id, $rowid)
{
- if(!DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
-
- $result = $this->commande->fetch($id);
-
- if(!$result) {
- throw new RestException(404, 'Order not found');
+ if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
}
- if(!DolibarrApi::_checkAccessToResource('order', $this->commande->id)) {
+ $result = $this->commande->fetch($id);
+ if (! $result) {
+ throw new RestException(404, 'Order not found');
+ }
+
+ if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index fd7832f868f..23d9db8f246 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -321,6 +321,7 @@ class Commande extends CommonOrder
public function valid($user, $idwarehouse = 0, $notrigger = 0)
{
global $conf,$langs;
+
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0;
@@ -423,13 +424,18 @@ class Commande extends CommonOrder
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
- // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
- // in order not to lose the attachments
+ // Now we rename also files into index
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->db->escape($this->newref)."'";
+ $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
+
+ // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->commande->dir_output.'/'.$oldref;
$dirdest = $conf->commande->dir_output.'/'.$newref;
- if (file_exists($dirsource))
+ if (! $error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
@@ -1312,7 +1318,7 @@ class Commande extends CommonOrder
* @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
* @param int $fk_product Id of product
* @param float $remise_percent Percentage discount of the line
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits of type of lines
* @param int $fk_remise_except Id remise
* @param string $price_base_type HT or TTC
* @param float $pu_ttc Prix unitaire TTC
@@ -1451,11 +1457,11 @@ class Commande extends CommonOrder
$pu_ht_devise = $tabprice[19];
// Rang to use
- $rangtouse = $rang;
- if ($rangtouse == -1)
+ $ranktouse = $rang;
+ if ($ranktouse == -1)
{
$rangmax = $this->line_max($fk_parent_line);
- $rangtouse = $rangmax + 1;
+ $ranktouse = $rangmax + 1;
}
// TODO A virer
@@ -1489,7 +1495,7 @@ class Commande extends CommonOrder
$this->line->fk_remise_except=$fk_remise_except;
$this->line->remise_percent=$remise_percent;
$this->line->subprice=$pu_ht;
- $this->line->rang=$rangtouse;
+ $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
@@ -1676,7 +1682,7 @@ class Commande extends CommonOrder
$sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
$sql.= ", c.module_source, c.pos_source";
- $sql.= ", i.libelle as libelle_incoterms";
+ $sql.= ", i.libelle as label_incoterms";
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', ca.code as availability_code, ca.label as availability_label';
@@ -1758,7 +1764,7 @@ class Commande extends CommonOrder
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
- $this->libelle_incoterms = $obj->libelle_incoterms;
+ $this->label_incoterms = $obj->label_incoterms;
// Multicurrency
$this->fk_multicurrency = $obj->fk_multicurrency;
@@ -1888,10 +1894,12 @@ class Commande extends CommonOrder
* Load array lines
*
* @param int $only_product Return only physical products
+ * @param int $loadalsotranslation Return translation for products
* @return int <0 if KO, >0 if OK
*/
- public function fetch_lines($only_product = 0)
+ public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
+ global $langs, $conf;
// phpcs:enable
$this->lines=array();
@@ -1984,6 +1992,13 @@ class Commande extends CommonOrder
$line->fetch_optionals();
+ // multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) {
+ $line = new Product($this->db);
+ $line->fetch($objp->fk_product);
+ $line->getMultiLangs();
+ }
+
$this->lines[$i] = $line;
$i++;
diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php
index 8b7fef878ed..3fa3f90774f 100644
--- a/htdocs/commande/customer.php
+++ b/htdocs/commande/customer.php
@@ -133,7 +133,7 @@ if ($resql)
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'class="right"', $sortfield, $sortorder);
print "\n";
- // Lignes des champs de filtre
+ // Fields title search
print ' ';
print '';
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index c0091b43af0..a0e87bf63a3 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville
* Copyright (C) 2004-2011 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -31,6 +32,11 @@ require_once DOL_DOCUMENT_ROOT .'/commande/class/commande.class.php';
if (!$user->rights->commande->lire) accessforbidden();
+$hookmanager = new HookManager($db);
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('ordersindex'));
+
// Load translation files required by the page
$langs->loadLangs(array('orders', 'bills'));
@@ -478,6 +484,8 @@ if (! empty($conf->commande->enabled))
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardOrders', $parameters, $object); // Note that $action and $object may have been modified by hook
// End of page
llxFooter();
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index f64aadf0e53..a25d863176e 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -143,6 +143,7 @@ $arrayfields=array(
'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)))
);
@@ -247,7 +248,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,';
-$sql.= ' c.date_creation as date_creation, c.tms as date_update,';
+$sql.= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,';
$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label";
if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
// Add fields from extrafields
@@ -693,6 +694,12 @@ if ($resql)
print '';
print ' ';
}
+ // Date cloture
+ if (! empty($arrayfields['c.date_cloture']['checked']))
+ {
+ print '';
+ print ' ';
+ }
// Status
if (! empty($arrayfields['c.fk_statut']['checked']))
{
@@ -748,7 +755,8 @@ if ($resql)
print $hookmanager->resPrint;
if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
+ if (! empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ');
print ' '."\n";
@@ -1092,6 +1100,14 @@ if ($resql)
print '';
if (! $i) $totalarray['nbfield']++;
}
+ // Date cloture
+ if (! empty($arrayfields['c.date_cloture']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Status
if (! empty($arrayfields['c.fk_statut']['checked']))
{
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 0d0b202a8c3..33acc2b4969 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -615,7 +615,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print_liste_field_titre('GenerateBill', '', '', '', '', 'align="center"');
print '';
- // Lignes des champs de filtre
+ // Fields title search
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardSpecialBills', $parameters, $object); // Note that $action and $object may have been modified by hook
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php
index 36cc40c851c..58631937955 100644
--- a/htdocs/compta/clients.php
+++ b/htdocs/compta/clients.php
@@ -151,7 +151,7 @@ if ($resql)
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", '', $sortfield, $sortorder, 'right ');
print "\n";
- // Lignes des champs de filtre
+ // Fields title search
print '';
print '';
diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php
deleted file mode 100644
index 87efafd3405..00000000000
--- a/htdocs/compta/compta-files.php
+++ /dev/null
@@ -1,454 +0,0 @@
-
- * Copyright (C) 2004-2018 Laurent Destailleur
- * Copyright (C) 2017 Pierre-Henry Favre
- *
- * 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/compta/compta-files.php
- * \ingroup compta
- * \brief Page to show portoflio and files of a thirdparty and download it
- */
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
-require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
-require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
-require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
-
-$langs->loadLangs(array("accountancy", "bills", "companies"));
-
-$date_start =GETPOST('date_start', 'alpha');
-$date_startDay= GETPOST('date_startday', 'int');
-$date_startMonth= GETPOST('date_startmonth', 'int');
-$date_startYear= GETPOST('date_startyear', 'int');
-$date_start=($date_startDay)?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear):strtotime($date_start);
-$date_stop =GETPOST('date_stop', 'alpha');
-$date_stopDay= GETPOST('date_stopday', 'int');
-$date_stopMonth= GETPOST('date_stopmonth', 'int');
-$date_stopYear= GETPOST('date_stopyear', 'int');
-//FIXME doldate
-$date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop);
-$action =GETPOST('action', 'alpha');
-
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('comptafileslist', 'globallist'));
-
-// Load variable for pagination
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'alpha');
-$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
-$offset = $limit * $page;
-$pageprev = $page - 1;
-$pagenext = $page + 1;
-if (! $sortfield) $sortfield="date,item"; // Set here default search field
-if (! $sortorder) $sortorder="DESC";
-
-
-$arrayfields=array(
- 'date'=>array('label'=>"Date", 'checked'=>1),
- //...
-);
-
-// Security check
-if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) {
- accessforbidden();
-}
-if ($user->societe_id > 0)
- accessforbidden();
-
-
-
-/*
- * Actions
- */
-
-$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity;
-
-//$parameters = array('socid' => $id);
-//$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks
-//if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
-$filesarray=array();
-$result=false;
-if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) {
- $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'";
- $sql="SELECT rowid as id, ref as ref, paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture";
- $sql.=" WHERE datef between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT;
- $sql.=" UNION ALL";
- $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn";
- $sql.=" WHERE datef between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
- $sql.=" UNION ALL";
- $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport";
- $sql.=" WHERE date_fin between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT;
- $sql.=" UNION ALL";
- $sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don";
- $sql.=" WHERE datedon between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT;
- $sql.=" UNION ALL";
- $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary";
- $sql.=" WHERE datep between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
- $sql.=" UNION ALL";
- $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales";
- $sql.=" WHERE date_creation between ".$wheretail;
- $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
- //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
- $sql.= $db->order($sortfield, $sortorder);
-
- $resd = $db->query($sql);
- $files=array();
- $link='';
-
- if ($resd)
- {
- $numd = $db->num_rows($resd);
-
- $tmpinvoice=new Facture($db);
- $tmpinvoicesupplier=new FactureFournisseur($db);
- $tmpdonation=new Don($db);
-
- $upload_dir ='';
- $i=0;
- while ($i < $numd)
- {
- $objd = $db->fetch_object($resd);
-
- switch($objd->item)
- {
- case "Invoice":
- $subdir=dol_sanitizeFileName($objd->ref);
- $upload_dir = $conf->facture->dir_output.'/'.$subdir;
- $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- case "SupplierInvoice":
- $tmpinvoicesupplier->fetch($objd->id);
- $subdir=get_exdir($tmpinvoicesupplier->id, 2, 0, 0, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref);
- $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
- $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- case "ExpenseReport":
- $subdir=dol_sanitizeFileName($objd->ref);
- $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
- $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- case "SalaryPayment":
- $subdir=dol_sanitizeFileName($objd->id);
- $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
- $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- case "Donation":
- $tmpdonation->fetch($objp->id);
- $subdir=get_exdir(0, 0, 0, 1, $tmpdonation, 'donation'). '/'. dol_sanitizeFileName($objd->id);
- $upload_dir = $conf->don->dir_output . '/' . $subdir;
- $link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- case "SocialContributions":
- $subdir=dol_sanitizeFileName($objd->id);
- $upload_dir = $conf->tax->dir_output . '/' . $subdir;
- $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F';
- break;
- default:
- $subdir='';
- $upload_dir='';
- $link='';
- break;
- }
-
- if (!empty($upload_dir))
- {
- $result=true;
- $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
- //var_dump($upload_dir);
- if (count($files) < 1)
- {
- $nofile['id']=$objd->id;
- $nofile['date']=$db->idate($objd->date);
- $nofile['paid']=$objd->paid;
- $nofile['amount']=$objd->total_ttc;
- $nofile['ref']=$objd->ref;
- $nofile['fk']=$objd->fk_soc;
- $nofile['item']=$objd->item;
-
- $filesarray[]=$nofile;
- }
- else
- {
- foreach ($files as $key => $file)
- {
- $file['id']=$objd->id;
- $file['date']=$db->idate($objd->date);
- $file['paid']=$objd->paid;
- $file['amount']=$objd->total_ttc;
- $file['ref']=$objd->ref;
- $file['fk']=$objd->fk_soc;
- $file['item']=$objd->item;
- $file['link']=$link.$file['name'];
- $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name'];
-
- $filesarray[]=$file;
- }
- }
- }
- $i++;
- }
- }
- else
- {
- dol_print_error($db);
- }
-
- $db->free($resd);
-}
-
-/*
- * cleanup of old ZIP
- */
-//FIXME
-/*
- *ZIP creation
- */
-
-if ($result && $action == "dl")
-{
- if (! extension_loaded('zip'))
- {
- setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors');
- exit;
- }
-
- $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp);
-
- dol_mkdir($dirfortmpfile);
-
- $log='date,type,ref,total,paid,filename,item_id'."\n";
- $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
-
- dol_delete_file($zipname);
-
- $zip = new ZipArchive;
- $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE);
- if ($res)
- {
- foreach ($filesarray as $key=> $file)
- {
- if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
- $log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n";
- }
- $zip->addFromString('transactions.csv', $log);
- $zip->close();
-
- ///Then download the zipped file.
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename='.basename($zipname));
- header('Content-Length: ' . filesize($zipname));
- readfile($zipname);
-
- dol_delete_file($zipname);
-
- exit();
- }
-}
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-$userstatic=new User($db);
-
-$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
-
-llxHeader('', $title, $help_url);
-
-$h=0;
-$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
-$head[$h][1] = $langs->trans("AccountantFiles");
-$head[$h][2] = 'AccountancyFiles';
-
-dol_fiche_head($head, 'AccountancyFiles');
-
-
-print ''."\n";
-print ' ';
-print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0);
-print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n";
-// Multicompany
-/*if (! empty($conf->multicompany->enabled) && is_object($mc))
- {
- print ' ';
- // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
- if (method_exists($mc, 'formObjectOptions'))
- {
- if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode
- {
- print "".''.$langs->trans("Entity").' ';
- print "".$mc->select_entities($entity);
- print " \n";
- }
- else
- {
- print ' ';
- }
- }
-
- $object = new stdClass();
- // Other attributes
- $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"');
- $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- if (empty($reshook))
- {
- print $object->showOptionals($extrafields, 'edit');
- }
- }*/
-if (! empty($conf->multicompany->enabled) && is_object($mc))
-{
- print ' - '.$langs->trans("Entity").' : ';
- $mc->dao->getEntities();
- $mc->dao->fetch($conf->entity);
- print $mc->dao->label;
- print " \n";
-}
-
-print ' '."\n";
-
-dol_fiche_end();
-
-if (!empty($date_start) && !empty($date_stop))
-{
- $param='action=searchfiles';
- $param.='&date_startday='.GETPOST('date_startday', 'int');
- $param.='&date_startmonth='.GETPOST('date_startmonth', 'int');
- $param.='&date_startyear='.GETPOST('date_startyear', 'int');
- $param.='&date_stopday='.GETPOST('date_stopday', 'int');
- $param.='&date_stopmonth='.GETPOST('date_stopmonth', 'int');
- $param.='&date_stopyear='.GETPOST('date_stopyear', 'int');
-
- print ''."\n";
- print ' ';
-
- echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day');
-
- print ' ';
- print ' ';
-
- //print ' ';
- //print ' ';
- //print ' ';
-
- //print ' ';
- //print ' ';
- //print ' ';
-
- print ' ';
- print ' '."\n";
-
- print ' ';
-
- print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
- print '
';
- print '';
- print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
- print ''.$langs->trans("Type").' ';
- print ''.$langs->trans("Ref").' ';
- print ''.$langs->trans("Link").' ';
- print ''.$langs->trans("Paid").' ';
- print ''.$langs->trans("Debit").' ';
- print ''.$langs->trans("Credit").' ';
- print ''.$langs->trans("Balance").' ';
- print ' ';
- if ($result)
- {
- $TData = dol_sort_array($filesarray, 'date', 'ASC');
-
- if (empty($TData))
- {
- print ''.$langs->trans("NoItem").' ';
- }
- else
- {
- // Sort array by date ASC to calculate balance
-
- $totalDebit = 0;
- $totalCredit = 0;
- // Balance calculation
- $balance = 0;
- foreach($TData as &$data1) {
- if ($data1['item']!='Invoice'&& $data1['item']!='Donation' ){
- $data1['amount']=-$data1['amount'];
- }
- if ($data1['amount']>0){
- }else{
- }
- $balance += $data1['amount'];
- $data1['balance'] = $balance;
- }
-
- // Display array
- foreach($TData as $data)
- {
- $html_class = '';
- //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
- //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
- print '';
- print "";
- print dol_print_date($data['date'], 'day');
- print " \n";
- print ''.$langs->trans($data['item']).' ';
- print ''.$data['ref'].' ';
-
- // File link
- print '".$data['name']." \n";
-
- print ''.$data['paid'].' ';
- print ''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')." \n";
- $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
- print ''.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))." \n";
- $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
- // Balance
- print ''.price($data['balance'])." \n";
- print " \n";
- }
-
- print '';
- print ' ';
- print ''.price($totalDebit).' ';
- print ''.price($totalCredit).' ';
- print ''.price(price2num($totalDebit - $totalCredit, 'MT')).' ';
- print " \n";
- }
- }
- print "
";
- print '
';
-}
-
-llxFooter();
-$db->close();
diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php
index 33bec241d48..830a1bc7e4c 100644
--- a/htdocs/compta/deplacement/stats/index.php
+++ b/htdocs/compta/deplacement/stats/index.php
@@ -107,7 +107,6 @@ $mesg = $px1->isGraphKo();
if (! $mesg)
{
$px1->SetData($data);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
@@ -121,7 +120,6 @@ if (! $mesg)
$px1->SetYLabel($langs->trans("Number"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberByMonth"));
@@ -155,7 +153,6 @@ if (! $mesg)
$px2->SetYLabel($langs->trans("Amount"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountTotal"));
@@ -197,7 +194,6 @@ if (! $mesg)
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
- $px3->SetPrecisionY(0);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 0f2669014a8..bfa21a9c759 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -181,7 +181,8 @@ if (empty($reshook))
// Change status of invoice
elseif ($action == 'reopen' && $usercancreate) {
$result = $object->fetch($id);
- if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced') || ($object->statut == 1 && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
+
+ if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
$result = $object->set_unpaid($user);
if ($result > 0) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
@@ -308,6 +309,38 @@ if (empty($reshook))
dol_print_error($db, $object->error);
}
+ elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ $object->retained_warranty_fk_cond_reglement = 0; // To clean property
+ $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int'));
+ if ($result < 0) dol_print_error($db, $object->error);
+
+ $old_rw_date_lim_reglement = $object->retained_warranty_date_limit;
+ $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement);
+ if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement;
+ if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date;
+ $result = $object->update($user);
+ if ($result < 0) dol_print_error($db, $object->error);
+ }
+
+ elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float'));
+ if ($result < 0)
+ dol_print_error($db, $object->error);
+ }
+
+ elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float'));
+ if ($result < 0)
+ dol_print_error($db, $object->error);
+ }
+
+
// Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
@@ -637,7 +670,7 @@ if (empty($reshook))
$resteapayer = $object->total_ttc - $totalpaye;
- // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
+ // We check that invlice lines are transferred into accountancy
$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
@@ -1208,6 +1241,16 @@ if (empty($reshook))
$object->situation_counter = 1;
$object->situation_final = 0;
$object->situation_cycle_ref = $object->newCycle();
+
+
+ $object->retained_warranty = GETPOST('retained_warranty', 'int');
+ $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
+
+ $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit');
+ if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){
+ $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit);
+ }
+ $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement);
}
$object->fetch_thirdparty();
@@ -1295,7 +1338,6 @@ if (empty($reshook))
$TTotalByTva[$line->tva_tx] += $line->total_ttc ;
}
- $amount_to_diff = 0;
foreach ($TTotalByTva as $tva => &$total)
{
$coef = $total / $srcobject->total_ttc; // Calc coef
@@ -2773,7 +2815,7 @@ if ($action == 'create')
$note_public = $invoice_predefined->note_public;
$note_private = $invoice_predefined->note_private;
- $sql = 'SELECT r.rowid, r.titre, r.total_ttc';
+ $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r';
$sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid;
@@ -2797,7 +2839,7 @@ if ($action == 'create')
print ' selected';
$exampletemplateinvoice->fetch(GETPOST('fac_rec'));
}
- print '>' . $objp->titre . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')';
+ print '>' . $objp->title . ' (' . price($objp->total_ttc) . ' ' . $langs->trans("TTC") . ')';
$i ++;
}
print '';
@@ -2973,21 +3015,24 @@ if ($action == 'create')
}
else
{
- print '';
+ if (! empty($conf->global->INVOICE_USE_SITUATION))
+ {
+ print '';
- print '';
+ print '';
+ }
print ' ';
+ if (! empty($conf->global->INVOICE_USE_SITUATION))
+ {
+ if($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY){
+
+ $rwStyle = 'display:none;';
+ if(GETPOST('type', 'int') == Facture::TYPE_SITUATION){
+ $rwStyle = '';
+ }
+
+
+ $retained_warranty = GETPOST('retained_warranty', 'int');
+ $retained_warranty = !empty($retained_warranty)?$retained_warranty:$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT;
+ print '' . $langs->trans('RetainedWarranty') . ' ';
+ print ' %';
+
+ // Retained warranty payment term
+ print ' ' . $langs->trans('PaymentConditionsShortRetainedWarranty') . ' ';
+ $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
+ $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
+ $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
+ print ' ';
+
+ print '';
+ }
+ }
+
// Payment mode
print '' . $langs->trans('PaymentMode') . ' ';
$form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT');
@@ -3172,7 +3255,7 @@ if ($action == 'create')
if (!empty($conf->incoterm->enabled))
{
print ' ';
- print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).' ';
+ print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).' ';
print '';
$incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms');
@@ -3444,6 +3527,7 @@ elseif ($id > 0 || ! empty($ref))
elseif($object->type == Facture::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote';
elseif($object->type == Facture::TYPE_DEPOSIT) $type_fac = 'Deposit';
$text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac)));
+ $text.=' '.$langs->trans('ConfirmConvertToReduc2');
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2);
}
@@ -4007,7 +4091,7 @@ elseif ($id > 0 || ! empty($ref))
print ' ';
if ($action != 'editincoterm')
{
- print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
+ print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
}
else
{
@@ -4016,6 +4100,126 @@ elseif ($id > 0 || ! empty($ref))
print ' ';
}
+ $displayWarranty = false;
+ if( ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)) ) )
+ {
+ // Check if this situation invoice is 100% for real
+ if(!empty($object->situation_final) && !empty($object->lines)){
+ $displayWarranty = true;
+ foreach($object->lines as $i => $line){
+ if($line->product_type < 2 && $line->situation_percent < 100){
+ $displayWarranty = false;
+ break;
+ }
+ }
+ }
+
+
+
+ // Retained Warranty
+ print '';
+ print '';
+ print ' ';
+ if ($action == 'editretainedwarranty')
+ {
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ print price($object->retained_warranty).'%';
+ }
+ print ' ';
+
+ // Retained warranty payment term
+ print '';
+ print '';
+ print ' ';
+ $defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement);
+ if($object->date > $defaultDate){
+ $defaultDate = $object->date;
+ }
+
+ if ($action == 'editretainedwarrantypaymentterms')
+ {
+ //date('Y-m-d',$object->date_lim_reglement)
+ print '';
+ print ' ';
+ print ' ';
+ $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
+ $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement;
+ $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
+ $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ print $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->retained_warranty_fk_cond_reglement, 'none');
+ if(!$displayWarranty){
+ print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" ');
+ }
+ }
+ print ' ';
+
+
+
+
+ if($displayWarranty)
+ {
+ // Retained Warranty payment date limit
+ print '';
+ print '';
+ print ' ';
+ $defaultDate = !empty($object->retained_warranty_date_limit)?$object->retained_warranty_date_limit:strtotime('-1 years', $object->date_lim_reglement);
+ if($object->date > $defaultDate){
+ $defaultDate = $object->date;
+ }
+
+ if ($action == 'editretainedwarrantydatelimit')
+ {
+ //date('Y-m-d',$object->date_lim_reglement)
+ print '';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ print dol_print_date($object->retained_warranty_date_limit, 'day');
+ }
+ print ' ';
+ }
+ }
+
+
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
@@ -4460,6 +4664,31 @@ elseif ($id > 0 || ! empty($ref))
print ' :';
print '' . price($resteapayeraffiche) . ' ';
print ' ';
+
+ // Retained warranty : usualy use on construction industry
+ if(!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty){
+
+ // Billed - retained warranty
+ if($object->type == Facture::TYPE_SITUATION)
+ {
+ $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100;
+ }
+ else
+ {
+ // Because one day retained warranty could be used on standard invoices
+ $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
+ }
+
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
+
+ print '' . $langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')) . ' : ' . price($billedWithRetainedWarranty) . ' ';
+
+ // retained warranty
+ print '';
+ print $langs->trans("RetainedWarranty") . ' ('.$object->retained_warranty.'%)';
+ print !empty($object->retained_warranty_date_limit)?' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
+ print ' : ' . price($retainedWarranty) . ' ';
+ }
}
else // Credit note
{
@@ -4612,7 +4841,7 @@ elseif ($id > 0 || ! empty($ref))
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
if ($object->statut == Facture::STATUS_VALIDATED)
{
- // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
+ // We check that invlice lines are transferred into accountancy
$ventilExportCompta = $object->getVentilExportCompta();
if ($ventilExportCompta == 0)
@@ -4650,7 +4879,7 @@ elseif ($id > 0 || ! empty($ref))
&& ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
{
- if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
+ if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted
{
print '';
} else {
@@ -4746,7 +4975,7 @@ elseif ($id > 0 || ! empty($ref))
}
// For credit note
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) {
- print '';
+ print '';
}
// For deposit invoice
if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id))
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index c1cc9df9e5c..37a031198bc 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -123,7 +123,8 @@ class FactureRec extends CommonInvoice
$now=dol_now();
// Clean parameters
- $this->titre=trim($this->titre);
+ $this->titre=trim($this->titre); // deprecated
+ $this->title=trim($this->title);
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
if (empty($this->suspended)) $this->suspended=0;
@@ -180,7 +181,7 @@ class FactureRec extends CommonInvoice
$sql.= ", multicurrency_tx";
$sql.= ", suspended";
$sql.= ") VALUES (";
- $sql.= "'".$this->db->escape($this->titre)."'";
+ $sql.= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
$sql.= ", ".$facsrc->socid;
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'";
@@ -376,7 +377,7 @@ class FactureRec extends CommonInvoice
*/
public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '')
{
- $sql = 'SELECT f.rowid, f.entity, f.titre, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc';
+ $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc';
$sql.= ', f.remise_percent, f.remise_absolue, f.remise';
$sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.note_private, f.note_public, f.fk_user_author';
@@ -410,8 +411,9 @@ class FactureRec extends CommonInvoice
$this->id = $obj->rowid;
$this->entity = $obj->entity;
- $this->titre = $obj->titre;
- $this->ref = $obj->titre;
+ $this->titre = $obj->title; // deprecated
+ $this->title = $obj->title;
+ $this->ref = $obj->title;
$this->ref_client = $obj->ref_client;
$this->suspended = $obj->suspended;
$this->type = $obj->type;
@@ -510,7 +512,7 @@ class FactureRec extends CommonInvoice
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Recupere les lignes de factures predefinies dans this->lines
+ * Get lines of template invoices into this->lines
*
* @return int 1 if OK, < 0 if KO
*/
@@ -876,7 +878,7 @@ class FactureRec extends CommonInvoice
* @param int $fk_product Product/Service ID predefined
* @param double $remise_percent Percentage discount of the line
* @param string $price_base_type HT or TTC
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits of type of lines
* @param int $fk_remise_except Id remise
* @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note)
* @param int $type Type of line (0=product, 1=service)
@@ -1807,7 +1809,7 @@ class FactureLigneRec extends CommonInvoiceLine
/**
- * Recupere les lignes de factures predefinies dans this->lines
+ * Get line of template invoice
*
* @param int $rowid Id of invoice
* @return int 1 if OK, < 0 if KO
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index e5041217cb3..7f5dde15c59 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -206,6 +206,21 @@ class Facture extends CommonInvoice
public $oldcopy;
+ /**
+ * @var double percentage of retainage
+ */
+ public $retained_warranty;
+
+ /**
+ * @var int timestamp of date limit of retainage
+ */
+ public $retained_warranty_date_limit;
+
+ /**
+ * @var int Code in llx_c_paiement
+ */
+ public $retained_warranty_fk_cond_reglement;
+
/**
* Standard invoice
*/
@@ -472,6 +487,9 @@ class Facture extends CommonInvoice
$sql.= ", fk_multicurrency";
$sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx";
+ $sql.= ", retained_warranty";
+ $sql.= ", retained_warranty_date_limit";
+ $sql.= ", retained_warranty_fk_cond_reglement";
$sql.= ")";
$sql.= " VALUES (";
$sql.= "'(PROV)'";
@@ -506,6 +524,10 @@ class Facture extends CommonInvoice
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx;
+ $sql.= ", ".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty));
+ $sql.= ", ".(!empty($this->retained_warranty_date_limit)?"'".$this->db->idate($this->retained_warranty_date_limit)."'":'NULL');
+ $sql.= ", ".(int) $this->retained_warranty_fk_cond_reglement;
+
$sql.=")";
$resql=$this->db->query($sql);
@@ -917,7 +939,7 @@ class Facture extends CommonInvoice
$facture->origin = $this->origin;
$facture->origin_id = $this->origin_id;
- $facture->lines = $this->lines; // Tableau des lignes de factures
+ $facture->lines = $this->lines; // Array of lines of invoice
$facture->products = $this->lines; // Tant que products encore utilise
$facture->situation_counter = $this->situation_counter;
$facture->situation_cycle_ref=$this->situation_cycle_ref;
@@ -1335,7 +1357,8 @@ class Facture extends CommonInvoice
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', f.fk_incoterms, f.location_incoterms';
$sql.= ', f.module_source, f.pos_source';
- $sql.= ", i.libelle as libelle_incoterms";
+ $sql.= ", i.libelle as label_incoterms";
+ $sql.= ", f.retained_warranty as retained_warranty, f.retained_warranty_date_limit as retained_warranty_date_limit, f.retained_warranty_fk_cond_reglement as retained_warranty_fk_cond_reglement";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
@@ -1405,12 +1428,16 @@ class Facture extends CommonInvoice
$this->situation_cycle_ref = $obj->situation_cycle_ref;
$this->situation_counter = $obj->situation_counter;
$this->situation_final = $obj->situation_final;
+ $this->retained_warranty = $obj->retained_warranty;
+ $this->retained_warranty_date_limit = $this->db->jdate($obj->retained_warranty_date_limit);
+ $this->retained_warranty_fk_cond_reglement = $obj->retained_warranty_fk_cond_reglement;
+
$this->extraparams = (array) json_decode($obj->extraparams, true);
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
$this->location_incoterms = $obj->location_incoterms;
- $this->libelle_incoterms = $obj->libelle_incoterms;
+ $this->label_incoterms = $obj->label_incoterms;
$this->module_source = $obj->module_source;
$this->pos_source = $obj->pos_source;
@@ -1467,10 +1494,14 @@ class Facture extends CommonInvoice
/**
* Load all detailed lines into this->lines
*
+ * @param int $only_product Return only physical products
+ * @param int $loadalsotranslation Return translation for products
+ *
* @return int 1 if OK, < 0 if KO
*/
- public function fetch_lines()
+ public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
+ global $langs, $conf;
// phpcs:enable
$this->lines=array();
@@ -1560,6 +1591,13 @@ class Facture extends CommonInvoice
$line->fetch_optionals();
+ // multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) {
+ $line = new Product($this->db);
+ $line->fetch($objp->fk_product);
+ $line->getMultiLangs();
+ }
+
$this->lines[$i] = $line;
$i++;
@@ -1637,6 +1675,8 @@ class Facture extends CommonInvoice
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->modelpdf)) $this->modelpdf=trim($this->modelpdf);
if (isset($this->import_key)) $this->import_key=trim($this->import_key);
+ if (isset($this->retained_warranty)) $this->retained_warranty = floatval($this->retained_warranty);
+
// Check parameters
// Put here code to add control on parameters values
@@ -1677,7 +1717,10 @@ class Facture extends CommonInvoice
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").",";
$sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).",";
$sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).",";
- $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final));
+ $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final)).",";
+ $sql.= " retained_warranty=".(empty($this->retained_warranty)?"0":$this->db->escape($this->retained_warranty)).",";
+ $sql.= " retained_warranty_date_limit=".(strval($this->retained_warranty_date_limit)!='' ? "'".$this->db->idate($this->retained_warranty_date_limit)."'" : 'null').",";
+ $sql.= " retained_warranty_fk_cond_reglement=".(isset($this->retained_warranty_fk_cond_reglement)?intval($this->retained_warranty_fk_cond_reglement):"null");
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@@ -2418,13 +2461,18 @@ class Facture extends CommonInvoice
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
- // Rename of object directory ($this->ref = old ref, $num = new ref)
- // to not lose the linked files
+ // Now we rename also files into index
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'facture/".$this->db->escape($this->newref)."'";
+ $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
+
+ // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output.'/'.$oldref;
$dirdest = $conf->facture->dir_output.'/'.$newref;
- if (file_exists($dirsource))
+ if (! $error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
@@ -2650,7 +2698,7 @@ class Facture extends CommonInvoice
* @param int $date_start Date start of service
* @param int $date_end Date end of service
* @param int $ventil Code of dispatching into accountancy
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits of type of lines
* @param int $fk_remise_except Id discount used
* @param string $price_base_type 'HT' or 'TTC'
* @param double $pu_ttc Unit price with tax (> 0 even for credit note)
@@ -2777,11 +2825,11 @@ class Facture extends CommonInvoice
$pu_ht_devise = $tabprice[19];
// Rank to use
- $rangtouse = $rang;
- if ($rangtouse == -1)
+ $ranktouse = $rang;
+ if ($ranktouse == -1)
{
$rangmax = $this->line_max($fk_parent_line);
- $rangtouse = $rangmax + 1;
+ $ranktouse = $rangmax + 1;
}
// Insert line
@@ -2815,7 +2863,7 @@ class Facture extends CommonInvoice
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
$this->line->ventil=$ventil;
- $this->line->rang=$rangtouse;
+ $this->line->rang=$ranktouse;
$this->line->info_bits=$info_bits;
$this->line->fk_remise_except=$fk_remise_except;
@@ -3447,7 +3495,7 @@ class Facture extends CommonInvoice
else
{
$langs->load("errors");
- print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return "";
}
}
@@ -4141,7 +4189,7 @@ class Facture extends CommonInvoice
/**
* 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 string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example.
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
@@ -4358,6 +4406,137 @@ class Facture extends CommonInvoice
return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
}
+
+
+ /**
+ * @return number or -1 if not available
+ */
+ public function getRetainedWarrantyAmount()
+ {
+ if(empty($this->retained_warranty) ){
+ return -1;
+ }
+
+ $retainedWarrantyAmount = 0;
+
+ // Billed - retained warranty
+ if($this->type == Facture::TYPE_SITUATION)
+ {
+ $displayWarranty = true;
+ // Check if this situation invoice is 100% for real
+ if(!empty($this->lines)){
+ foreach($this->lines as $i => $line){
+ if($line->product_type < 2 && $line->situation_percent < 100){
+ $displayWarranty = false;
+ break;
+ }
+ }
+ }
+
+ if($displayWarranty && !empty($this->situation_final))
+ {
+ $this->fetchPreviousNextSituationInvoice();
+ $TPreviousIncoice = $this->tab_previous_situation_invoice;
+
+ $total2BillWT = 0;
+ foreach ($TPreviousIncoice as &$fac){
+ $total2BillWT += $fac->total_ttc;
+ }
+ $total2BillWT += $this->total_ttc;
+
+ $retainedWarrantyAmount = $total2BillWT * $this->retained_warranty / 100;
+ }
+ else{
+ return -1;
+ }
+ }
+ else
+ {
+ // Because one day retained warranty could be used on standard invoices
+ $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
+ }
+
+ return $retainedWarrantyAmount;
+ }
+
+ /**
+ * Change the retained warranty
+ *
+ * @param float $value value of retained warranty
+ * @return int >0 if OK, <0 if KO
+ */
+ public function setRetainedWarranty($value)
+ {
+ dol_syslog(get_class($this).'::setRetainedWarranty('.$value.')');
+ if ($this->statut >= 0)
+ {
+ $fieldname = 'retained_warranty';
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET '.$fieldname.' = '.floatval($value);
+ $sql .= ' WHERE rowid='.$this->id;
+
+ if ($this->db->query($sql))
+ {
+ $this->retained_warranty = floatval($value);
+ return 1;
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarranty Erreur '.$sql.' - '.$this->db->error());
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarranty, status of the object is incompatible');
+ $this->error='Status of the object is incompatible '.$this->statut;
+ return -2;
+ }
+ }
+
+
+ /**
+ * Change the retained_warranty_date_limit
+ *
+ * @param int $timestamp date limit of retained warranty in timestamp format
+ * @param string $dateYmd date limit of retained warranty in Y m d format
+ * @return int >0 if OK, <0 if KO
+ */
+ public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false)
+ {
+ if(!$timestamp && $dateYmd){
+ $timestamp = $this->db->jdate($dateYmd);
+ }
+
+
+ dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit('.$timestamp.')');
+ if ($this->statut >= 0)
+ {
+ $fieldname = 'retained_warranty_date_limit';
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET '.$fieldname.' = '.(strval($timestamp)!='' ? '\'' .$this->db->idate($timestamp).'\'' : 'null' );
+ $sql .= ' WHERE rowid='.$this->id;
+
+ if ($this->db->query($sql))
+ {
+ $this->retained_warranty_date_limit = $timestamp;
+ return 1;
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit Erreur '.$sql.' - '.$this->db->error());
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarrantyDateLimit, status of the object is incompatible');
+ $this->error='Status of the object is incompatible '.$this->statut;
+ return -2;
+ }
+ }
}
/**
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 5eedb9b5740..25cf3f45fb1 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -187,7 +187,8 @@ if (empty($reshook))
if (! $error)
{
- $object->titre = GETPOST('titre', 'alpha');
+ $object->titre = GETPOST('titre', 'alpha'); // deprecated
+ $object->title = GETPOST('titre', 'alpha');
$object->note_private = GETPOST('note_private', 'none');
$object->note_public = GETPOST('note_public', 'none');
$object->modelpdf = GETPOST('modelpdf', 'alpha');
@@ -295,8 +296,9 @@ if (empty($reshook))
$result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY');
if ($result > 0)
{
- $object->titre = GETPOST('ref', 'alpha');
- $object->ref = $object->titre;
+ $object->titre = GETPOST('ref', 'alpha'); // deprecated
+ $object->title = GETPOST('ref', 'alpha');
+ $object->ref = $object->title;
}
else dol_print_error($db, $object->error, $object->errors);
}
@@ -774,7 +776,7 @@ if (empty($reshook))
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$objectline = new FactureLigneRec($db);
- if ($objectline->fetch(GETPOST('lineid')))
+ if ($objectline->fetch(GETPOST('lineid', 'int')))
{
$objectline->array_options=$array_options;
$result=$objectline->insertExtraFields();
@@ -784,6 +786,8 @@ if (empty($reshook))
}
}
+ $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
+
// Unset extrafield
if (is_array($extralabelsline))
{
@@ -795,8 +799,8 @@ if (empty($reshook))
}
// Define special_code for special lines
- $special_code=GETPOST('special_code');
- if (! GETPOST('qty')) $special_code=3;
+ $special_code=GETPOST('special_code', 'int');
+ if (! GETPOST('qty', 'alpha')) $special_code=3;
/*$line = new FactureLigne($db);
$line->fetch(GETPOST('lineid'));
@@ -832,11 +836,11 @@ if (empty($reshook))
$error ++;
}
} else {
- $type = GETPOST('type');
+ $type = GETPOST('type', 'int');
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
// Check parameters
- if (GETPOST('type') < 0) {
+ if (GETPOST('type', 'int') < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error ++;
}
@@ -868,7 +872,7 @@ if (empty($reshook))
0,
0,
$type,
- 0,
+ $position,
$special_code,
$label,
GETPOST('units'),
@@ -1423,8 +1427,8 @@ else
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
$list = array();
$models = ModelePDFFactures::liste_modeles($db);
- foreach ($models as $model) {
- $list[] = $model . ':' . $model;
+ foreach ($models as $k => $model) {
+ $list[] = str_replace(':', '|', $k) . ':' . $model;
}
$select = 'select;'.implode(',', $list);
print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select);
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 9f9e3276542..1226f7c8a79 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -213,7 +213,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['
/*
* List mode
*/
-$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
+$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql.= " f.datec, f.tms,";
$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
@@ -261,7 +261,7 @@ if ($search_month_date_when > 0)
if ($search_year_date_when > 0 && empty($search_day_date_when))
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when, $search_month_date_when, false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when, $search_month_date_when, false))."'";
elseif ($search_year_date_when > 0 && ! empty($search_day_date_when))
- $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'";
+ $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'";
else
$sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'";
}
@@ -514,7 +514,7 @@ if ($resql)
$invoicerectmp->unit_frequency=$objp->unit_frequency;
$invoicerectmp->nb_gen_max=$objp->nb_gen_max;
$invoicerectmp->nb_gen_done=$objp->nb_gen_done;
- $invoicerectmp->ref=$objp->titre;
+ $invoicerectmp->ref=$objp->title;
print '';
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index d12fc90fd77..eca39ade98c 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -182,6 +182,12 @@ $arrayfields=array(
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
+
+if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
+{
+ $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0);
+}
+
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@@ -373,6 +379,10 @@ $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
$sql.= ' f.paye as paye, f.fk_statut,';
$sql.= ' f.datec as date_creation, f.tms as date_update,';
+if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
+{
+ $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,';
+}
$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
$sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,";
@@ -834,6 +844,13 @@ if ($resql)
print ' ';
print '';
}
+
+ if(! empty($arrayfields['f.retained_warranty']['checked']))
+ {
+ print '';
+ print ' ';
+ }
+
if (! empty($arrayfields['dynamount_payed']['checked']))
{
print '';
@@ -899,6 +916,7 @@ if ($resql)
if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
+ if (! empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder);
if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder);
// Extra fields
@@ -939,7 +957,15 @@ if ($resql)
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->note_public=$obj->note_public;
$facturestatic->note_private=$obj->note_private;
-
+ if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
+ {
+ $facturestatic->retained_warranty=$obj->retained_warranty;
+ $facturestatic->retained_warranty_date_limit=$obj->retained_warranty_date_limit;
+ $facturestatic->situation_final=$obj->retained_warranty_date_limit;
+ $facturestatic->situation_final=$obj->retained_warranty_date_limit;
+ $facturestatic->situation_cycle_ref=$obj->situation_cycle_ref;
+ $facturestatic->situation_counter=$obj->situation_counter;
+ }
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
$thirdpartystatic->client=$obj->client;
@@ -959,11 +985,11 @@ if ($resql)
$totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
$totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
- $remaintopay = $facturestatic->total_ttc - $totalpay;
+ $remaintopay = price2num($facturestatic->total_ttc - $totalpay);
if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) {
$remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id);
$remaintopay = -$remaincreditnote;
- $totalpay = $facturestatic->total_ttc - $remaintopay;
+ $totalpay = price2num($facturestatic->total_ttc - $remaintopay);
}
print ' ';
+ print '';
print $obj->town;
print ' ';
if (! $i) $totalarray['nbfield']++;
@@ -1083,7 +1109,7 @@ if ($resql)
// Zip
if (! empty($arrayfields['s.zip']['checked']))
{
- print '';
+ print ' ';
print $obj->zip;
print ' ';
if (! $i) $totalarray['nbfield']++;
@@ -1143,7 +1169,7 @@ if ($resql)
// Amount HT
if (! empty($arrayfields['f.total_ht']['checked']))
{
- print ''.price($obj->total_ht)." \n";
+ print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
$totalarray['totalht'] += $obj->total_ht;
@@ -1151,7 +1177,7 @@ if ($resql)
// Amount VAT
if (! empty($arrayfields['f.total_vat']['checked']))
{
- print ''.price($obj->total_vat)." \n";
+ print ''.price($obj->total_vat)." \n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
$totalarray['totalvat'] += $obj->total_vat;
@@ -1159,7 +1185,7 @@ if ($resql)
// Amount LocalTax1
if (! empty($arrayfields['f.total_localtax1']['checked']))
{
- print ''.price($obj->total_localtax1)." \n";
+ print ''.price($obj->total_localtax1)." \n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield'];
$totalarray['totallocaltax1'] += $obj->total_localtax1;
@@ -1167,7 +1193,7 @@ if ($resql)
// Amount LocalTax2
if (! empty($arrayfields['f.total_localtax2']['checked']))
{
- print ''.price($obj->total_localtax2)." \n";
+ print ''.price($obj->total_localtax2)." \n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield'];
$totalarray['totallocaltax2'] += $obj->total_localtax2;
@@ -1175,15 +1201,20 @@ if ($resql)
// Amount TTC
if (! empty($arrayfields['f.total_ttc']['checked']))
{
- print ''.price($obj->total_ttc)." \n";
+ print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
$totalarray['totalttc'] += $obj->total_ttc;
}
+ if(! empty($arrayfields['f.retained_warranty']['checked']))
+ {
+ print ''.(! empty($obj->retained_warranty)?price($obj->retained_warranty).'%':' ').' ';
+ }
+
if (! empty($arrayfields['dynamount_payed']['checked']))
{
- print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').' '; // TODO Use a denormalized field
+ print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
$totalarray['totalam'] += $totalpay;
@@ -1191,7 +1222,7 @@ if ($resql)
if (! empty($arrayfields['rtp']['checked']))
{
- print ''.(! empty($remaintopay)?price($remaintopay, 0, $langs):' ').' '; // TODO Use a denormalized field
+ print ''.(! empty($remaintopay)?price($remaintopay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
$totalarray['totalrtp'] += $remaintopay;
@@ -1298,6 +1329,7 @@ if ($resql)
$filedir=$diroutputmassaction;
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->creer;
+ $title = '';
print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index ccc3b305447..db022259e35 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -62,42 +62,52 @@ if ($id > 0 || ! empty($ref))
}
}
+$hookmanager->initHooks(array('directdebitcard','globalcard'));
+
+
/*
* Actions
*/
-if ($action == "new")
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
{
- if ($object->id > 0)
+ if ($action == "new")
{
- $db->begin();
-
- $result = $object->demande_prelevement($user, GETPOST('withdraw_request_amount'));
- if ($result > 0)
+ if ($object->id > 0)
{
- $db->commit();
+ $db->begin();
- setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
- }
- else
- {
- $db->rollback();
- setEventMessages($object->error, $object->errors, 'errors');
+ $result = $object->demande_prelevement($user, GETPOST('withdraw_request_amount'));
+ if ($result > 0)
+ {
+ $db->commit();
+
+ setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
+ }
+ else
+ {
+ $db->rollback();
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
}
+ $action='';
}
- $action='';
-}
-if ($action == "delete")
-{
- if ($object->id > 0)
+ if ($action == "delete")
{
- $result = $object->demande_prelevement_delete($user, GETPOST('did'));
- if ($result == 0)
+ if ($object->id > 0)
{
- header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
- exit;
+ $result = $object->demande_prelevement_delete($user, GETPOST('did'));
+ if ($result == 0)
+ {
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
}
}
}
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 5d8fee98676..99abd48cb49 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -103,7 +103,6 @@ $mesg = $px1->isGraphKo();
if (! $mesg)
{
$px1->SetData($data);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
@@ -117,7 +116,6 @@ if (! $mesg)
$px1->SetYLabel($langs->trans("NumberOfBills"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
@@ -152,7 +150,6 @@ if (! $mesg)
$px2->SetYLabel($langs->trans("AmountOfBills"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
@@ -194,7 +191,6 @@ if (! $mesg)
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
- $px3->SetPrecisionY(0);
$px3->mode='depth';
$px3->SetTitle($langs->trans("AmountAverage"));
diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
index 97f0b876abc..bef705a21ab 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
@@ -38,6 +38,8 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("bills");
+$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
+
$total=0; $ilink=0;
foreach($linkedObjectBlock as $key => $objectlink)
{
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index ae84340333e..e2c0180dc3b 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -2,10 +2,11 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2005-2015 Regis Houssin
- * Copyright (C) 2015-2016 Juanjo Menent
+ * Copyright (C) 2015-2016 Juanjo Menent
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2016 Marcos García
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -63,6 +64,7 @@ if ($user->societe_id > 0)
$max=3;
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('invoiceindex'));
/*
@@ -351,6 +353,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$num = $db->num_rows($resql);
$i = 0;
+ print '';
print '
';
print ''.$langs->trans("BoxTitleLastCustomerBills", $max).' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.$langs->trans("AmountHT").' ';
@@ -409,8 +412,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
print '';
print $thirdpartystatic->getNomUrl(1, 'customer', 44);
print ' ';
- if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
- print ''.price($obj->total_ttc).' ';
+ if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
+ print ''.price($obj->total_ttc).' ';
print ''.dol_print_date($db->jdate($obj->tms), 'day').' ';
print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).' ';
print ' ';
@@ -428,7 +431,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
print ''.$langs->trans("NoInvoice").' ';
}
- print '
';
+ print '
';
$db->free($resql);
}
else
@@ -472,6 +475,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
{
$num = $db->num_rows($resql);
+ print '';
print '
';
print ''.$langs->trans("BoxTitleLastSupplierBills", $max).' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.$langs->trans("AmountHT").' ';
@@ -508,7 +512,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
print $thirdpartystatic->getNomUrl(1, 'supplier', 44);
print '';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
- print ''.price($obj->total_ttc).' ';
+ print ''.price($obj->total_ttc).' ';
print ''.dol_print_date($db->jdate($obj->tms), 'day').' ';
print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).' ';
print ' ';
@@ -524,7 +528,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++;
print ''.$langs->trans("NoInvoice").' ';
}
- print '
';
+ print '
';
}
else
{
@@ -561,6 +565,7 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire)
$i = 0;
+ print '';
print '
';
print '';
print ''.$langs->trans("BoxTitleLastModifiedDonations", $max).' ';
@@ -588,7 +593,7 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire)
print ' ';
print ''.$donationstatic->getNomUrl(1).' ';
print ''.$label.' ';
- print ''.price($objp->amount).' ';
+ print ''.price($objp->amount).' ';
print ''.dol_print_date($db->jdate($objp->dm), 'day').' ';
print ''.$donationstatic->LibStatut($objp->fk_statut, 3).' ';
print ' ';
@@ -600,7 +605,7 @@ if (! empty($conf->don->enabled) && $user->rights->societe->lire)
{
print ''.$langs->trans("None").' ';
}
- print '
';
+ print '
';
}
else dol_print_error($db);
}
@@ -634,6 +639,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
{
$num = $db->num_rows($resql);
+ print '';
print '
';
print '';
print ''.$langs->trans("ContributionsToPay").($num?' '.$num.' ':'').' ';
@@ -658,8 +664,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print ' ';
print ''.$chargestatic->getNomUrl(1).' ';
print ''.dol_print_date($db->jdate($obj->date_ech), 'day').' ';
- print ''.price($obj->amount).' ';
- print ''.price($obj->sumpaid).' ';
+ print ''.price($obj->amount).' ';
+ print ''.price($obj->sumpaid).' ';
print ''.$chargestatic->getLibStatut(3).' ';
print ' ';
$tot_ttc+=$obj->amount;
@@ -667,7 +673,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
}
print ''.$langs->trans("Total").' ';
- print ''.price($tot_ttc).' ';
+ print ''.price($tot_ttc).' ';
print ' ';
print ' ';
print ' ';
@@ -676,7 +682,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
{
print ''.$langs->trans("None").' ';
}
- print "
";
+ print "
";
$db->free($resql);
}
else
@@ -726,6 +732,8 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
if ($num)
{
$i = 0;
+
+ print '';
print '
';
print "";
print ''.$langs->trans("OrdersDeliveredToBill").' '.$num.' ';
@@ -778,8 +786,8 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
print $societestatic->getNomUrl(1, 'customer', 44);
print '';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
- print ''.price($obj->total_ttc).' ';
- print ''.price($obj->total_ttc-$obj->tot_fttc).' ';
+ print ''.price($obj->total_ttc).' ';
+ print ''.price($obj->total_ttc-$obj->tot_fttc).' ';
print ''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).' ';
print ' ';
$tot_ht += $obj->total_ht;
@@ -791,11 +799,11 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
print ''.$langs->trans("Total").' ('.$langs->trans("RemainderToBill").': '.price($tot_tobill).') ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($tot_ht).' ';
- print ''.price($tot_ttc).' ';
- print ''.price($tot_tobill).' ';
+ print ''.price($tot_ttc).' ';
+ print ''.price($tot_tobill).' ';
print ' ';
print ' ';
- print '
';
+ print '
';
}
$db->free($resql);
}
@@ -903,8 +911,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
print ' ';
print ''.dol_print_date($db->jdate($obj->datelimite), 'day').' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
- print ''.price($obj->total_ttc).' ';
- print ''.price($obj->am).' ';
+ print ''.price($obj->total_ttc).' ';
+ print ''.price($obj->am).' ';
print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).' ';
print ' ';
@@ -918,8 +926,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
print ''.$langs->trans("Total").' ('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).') ';
print ' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($total).' ';
- print ''.price($total_ttc).' ';
- print ''.price($totalam).' ';
+ print ''.price($total_ttc).' ';
+ print ''.price($totalam).' ';
print ' ';
print ' ';
}
@@ -1015,8 +1023,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
print ''.$societestatic->getNomUrl(1, 'supplier', 44).' ';
print ''.dol_print_date($db->jdate($obj->date_lim_reglement), 'day').' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($obj->total_ht).' ';
- print ''.price($obj->total_ttc).' ';
- print ''.price($obj->am).' ';
+ print ''.price($obj->total_ttc).' ';
+ print ''.price($obj->am).' ';
print ''.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).' ';
print '';
$total += $obj->total_ht;
@@ -1028,8 +1036,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
print ''.$langs->trans("Total").' ('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).') ';
print ' ';
if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print ''.price($total).' ';
- print ''.price($total_ttc).' ';
- print ''.price($totalam).' ';
+ print ''.price($total_ttc).' ';
+ print ''.price($totalam).' ';
print ' ';
print ' ';
}
@@ -1053,6 +1061,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$resql = 0;
if ($resql)
{
+ print '';
print '
';
print ''.$langs->trans("TasksToDo").'';
print " \n";
@@ -1067,12 +1076,15 @@ if ($resql)
$i++;
}
$db->free($resql);
- print "
";
+ print "
";
}
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardAccountancy', $parameters, $object); // Note that $action and $object may have been modified by hook
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index cd3bf06f43a..5b4e54fd807 100644
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -123,7 +123,7 @@ if ($result)
{
$num = $db->num_rows($result);
// les variables
- $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)?$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef"));
+ $cptfour = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "")?$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)?$conf->global->ACCOUNTING_VAT_BUY_ACCOUNT:$langs->trans("CodeNotDef"));
$tabfac = array();
@@ -139,7 +139,7 @@ if ($result)
{
$obj = $db->fetch_object($result);
// contrôles
- $compta_soc = (! empty($obj->code_compta_fournisseur)?$obj->code_compta_fournisseur:$cptfour);
+ $compta_soc = (($obj->code_compta_fournisseur != "")?$obj->code_compta_fournisseur:$cptfour);
$compta_prod = $obj->accountancy_code_buy;
if (empty($compta_prod))
{
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index fe51665163e..da85e28c612 100644
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -87,7 +87,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_start=dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end=dol_get_last_day($pastmonthyear, $pastmonth, false);
}
-$nom=$langs->trans("SellsJournal");
+$name=$langs->trans("SellsJournal");
$periodlink='';
$exportlink='';
$builddate=dol_now();
@@ -146,7 +146,7 @@ if ($result)
{
$obj = $db->fetch_object($result);
// les variables
- $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)?$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"));
+ $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")?$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"));
$compta_soc = (! empty($obj->code_compta)?$obj->code_compta:$cptcli);
$compta_prod = $obj->accountancy_code_sell;
if (empty($compta_prod))
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index f84a805caef..3107cf29742 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -472,14 +472,14 @@ if ($action == 'new')
print ''."\n";
print '';
- print ''.$langs->trans("DateChequeReceived").' '."\n";
- print ''.$langs->trans("ChequeNumber")." \n";
- print ''.$langs->trans("CheckTransmitter")." \n";
- print ''.$langs->trans("Bank")." \n";
- print ''.$langs->trans("Amount")." \n";
- print ''.$langs->trans("Payment")." \n";
- print ''.$langs->trans("LineRecord")." \n";
- print ''.$langs->trans("Select")." ";
+ print ' '.$langs->trans("DateChequeReceived").' '."\n";
+ print ''.$langs->trans("ChequeNumber")." \n";
+ print ''.$langs->trans("CheckTransmitter")." \n";
+ print ''.$langs->trans("Bank")." \n";
+ print ''.$langs->trans("Amount")." \n";
+ print ''.$langs->trans("Payment")." \n";
+ print ''.$langs->trans("LineRecord")." \n";
+ print ''.$langs->trans("Select")." ";
if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").' ';
print ' ';
print " \n";
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index d9a912ea50b..26e3f2792d6 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -489,7 +489,7 @@ class RemiseCheque extends CommonObject
else
{
$langs->load("errors");
- print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Bank"));
return "";
}
}
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 11de8aa48a2..64ae1dea1f2 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -157,7 +157,7 @@ if ($resql)
print '';
print '
'."\n";
- // Lignes des champs de filtre
+ // Fields title search
print '';
print '';
print ' ';
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 28417a6d4f1..614782c519b 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -991,16 +991,16 @@ class Paiement extends CommonObject
}
/**
- * Retourne la liste des factures sur lesquels porte le paiement
+ * Return list of invoices the payment is related to.
*
- * @param string $filter Critere de filtre
- * @return array Tableau des id de factures
+ * @param string $filter Filter
+ * @return int|array <0 if KO or array of invoice id
*/
public function getBillsArray($filter = '')
{
- $sql = 'SELECT fk_facture';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f';
- $sql.= ' WHERE pf.fk_facture = f.rowid AND fk_paiement = '.$this->id;
+ $sql = 'SELECT pf.fk_facture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice
+ $sql.= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
if ($filter) $sql.= ' AND '.$filter;
$resql = $this->db->query($sql);
if ($resql)
@@ -1026,6 +1026,40 @@ class Paiement extends CommonObject
}
}
+ /**
+ * Return list of amounts of payments.
+ *
+ * @return int|array Array of amount of payments
+ */
+ public function getAmountsArray()
+ {
+ $sql = 'SELECT pf.fk_facture, pf.amount';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
+ $sql.= ' WHERE pf.fk_paiement = '.$this->id;
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $i=0;
+ $num=$this->db->num_rows($resql);
+ $amounts = array();
+
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $amounts[$obj->fk_facture]=$obj->amount;
+ $i++;
+ }
+
+ return $amounts;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG);
+ return -1;
+ }
+ }
+
/**
* Return next reference of customer invoice not already used (or last reference)
* according to numbering module defined into constant FACTURE_ADDON
@@ -1107,7 +1141,7 @@ class Paiement extends CommonObject
else
{
$langs->load("errors");
- print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice"));
return "";
}
}
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index d31efcc9df8..301f2f532b1 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -63,78 +63,86 @@ $object = new BonPrelevement($db, "");
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+$hookmanager->initHooks(array('directdebitprevcard','globalcard'));
/*
* Actions
*/
-if ( $action == 'confirm_delete' )
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
{
- $res=$object->delete($user);
- if ($res > 0)
+ if ( $action == 'confirm_delete' )
+ {
+ $res=$object->delete($user);
+ if ($res > 0)
+ {
+ header("Location: index.php");
+ exit;
+ }
+ }
+
+ // Seems to no be used and replaced with $action == 'infocredit'
+ if ( $action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
+ {
+ $res=$object->set_credite();
+ if ($res >= 0)
+ {
+ header("Location: card.php?id=".$id);
+ exit;
+ }
+ }
+
+ if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+
+ /*
+ if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
+ {
+ $dir = $conf->prelevement->dir_output.'/receipts';
+
+ if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
+ {
+ $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
+ }
+
+ header("Location: card.php?id=".$id);
+ exit;
+ }
+ else
+ {
+ dol_syslog("Fichier invalide",LOG_WARNING);
+ $mesg='BadFile';
+ }*/
+
+ $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
+
+ if ($error)
+ {
+ header("Location: card.php?id=".$id."&error=$error");
+ exit;
+ }
+ }
+
+ // Set direct debit order to credited, create payment and close invoices
+ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
{
- header("Location: index.php");
- exit;
- }
-}
+ $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-// Seems to no be used and replaced with $action == 'infocredit
-if ( $action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
-{
- $res=$object->set_credite();
- if ($res >= 0)
- {
- header("Location: card.php?id=".$id);
- exit;
- }
-}
+ $error = $object->set_infocredit($user, $dt);
-if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
-{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-
- /*
- if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
- {
- $dir = $conf->prelevement->dir_output.'/receipts';
-
- if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
- {
- $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
- }
-
- header("Location: card.php?id=".$id);
- exit;
- }
- else
- {
- dol_syslog("Fichier invalide",LOG_WARNING);
- $mesg='BadFile';
- }*/
-
- $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
-
- if ($error)
- {
- header("Location: card.php?id=".$id."&error=$error");
- exit;
- }
-}
-
-// Set direct debit order to credited, create payment and close invoices
-if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
-{
- $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-
- $error = $object->set_infocredit($user, $dt);
-
- if ($error)
- {
- header("Location: card.php?id=".$id."&error=$error");
- exit;
- }
+ if ($error)
+ {
+ header("Location: card.php?id=".$id."&error=$error");
+ exit;
+ }
+ }
}
@@ -362,7 +370,7 @@ if ($id > 0 || $ref)
print " ";
print $ligne->LibStatut($obj->statut, 2);
print " ";
- print '';
+ print ' ';
print sprintf("%06s", $obj->rowid);
print ' ';
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index b462095278d..a60330270d4 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -1133,32 +1133,56 @@ class BonPrelevement extends CommonObject
/**
- * Get object and lines from database
+ * Get object and lines from database
*
* @param User $user Object user that delete
- * @return int >0 if OK, <0 if KO
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int >0 if OK, <0 if KO
*/
- public function delete($user = null)
+ public function delete($user = null, $notrigger = 0)
{
$this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id.")";
- $resql1=$this->db->query($sql);
- if (! $resql1) dol_print_error($this->db);
+ $error = 0;
+ $resql1 = $resql2 = $resql3 = $resql4 = 0;
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id;
- $resql2=$this->db->query($sql);
- if (! $resql2) dol_print_error($this->db);
+ if (! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('BON_PRELEVEMENT_DELETE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = ".$this->id;
- $resql3=$this->db->query($sql);
- if (! $resql3) dol_print_error($this->db);
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id.")";
+ $resql1=$this->db->query($sql);
+ if (! $resql1) dol_print_error($this->db);
+ }
- $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".$this->id;
- $resql4=$this->db->query($sql);
- if (! $resql4) dol_print_error($this->db);
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id;
+ $resql2=$this->db->query($sql);
+ if (! $resql2) dol_print_error($this->db);
+ }
- if ($resql1 && $resql2 && $resql3)
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = ".$this->id;
+ $resql3=$this->db->query($sql);
+ if (! $resql3) dol_print_error($this->db);
+ }
+
+ if (! $error)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".$this->id;
+ $resql4=$this->db->query($sql);
+ if (! $resql4) dol_print_error($this->db);
+ }
+
+ if ($resql1 && $resql2 && $resql3 && $resql4 && ! $error)
{
$this->db->commit();
return 1;
@@ -1174,28 +1198,72 @@ class BonPrelevement extends CommonObject
/**
* Returns clickable name (with picto)
*
- * @param int $withpicto link with picto
- * @param string $option link target
- * @return string URL of target
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string URL of target
*/
- public function getNomUrl($withpicto = 0, $option = '')
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{
- global $langs;
+ global $conf, $langs, $hookmanager;
+
+ if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result='';
- $label = $langs->trans("ShowWithdraw").': '.$this->ref;
- $link = '';
- $linkend=' ';
+ $label = '' . $langs->trans("ShowWithdraw") . ' ';
+ $label.= ' ';
+ $label.= '' . $langs->trans('Ref') . ': ' . $this->ref;
- if ($option == 'xxx')
+ $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
+
+ if ($option != 'nolink')
{
- $link = '';
- $linkend=' ';
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
+ if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
- if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
- $result.=$link.$this->ref.$linkend;
+ $linkclose='';
+ if (empty($notooltip))
+ {
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label=$langs->trans("ShowMyObject");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
+
+ /*
+ $hookmanager->initHooks(array('myobjectdao'));
+ $parameters=array('id'=>$this->id);
+ $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $linkclose = $hookmanager->resPrint;
+ */
+ }
+ else $linkclose = ($morecss?' class="'.$morecss.'"':'');
+
+ $linkstart = '';
+ $linkend=' ';
+
+ $result .= $linkstart;
+ if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
+ if ($withpicto != 2) $result.= $this->ref;
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
+ global $action,$hookmanager;
+ $hookmanager->initHooks(array('myobjectdao'));
+ $parameters=array('id'=>$this->id, 'getnomurl'=>$result);
+ $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $result = $hookmanager->resPrint;
+ else $result .= $hookmanager->resPrint;
+
return $result;
}
@@ -1349,7 +1417,7 @@ class BonPrelevement extends CommonObject
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
- $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
+ $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql.= " FROM";
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql.= " ".MAIN_DB_PREFIX."facture as f,";
@@ -1375,7 +1443,8 @@ class BonPrelevement extends CommonObject
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
- $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum);
+ $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
+ $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme;
$i++;
}
@@ -1580,15 +1649,16 @@ class BonPrelevement extends CommonObject
* @param string $row_cg pl.code_guichet AS cg, Not used for SEPA
* @param string $row_cc pl.number AS cc, Not used for SEPA
* @param string $row_somme pl.amount AS somme,
- * @param string $row_ref f.ref
+ * @param string $row_ref f.ref
* @param string $row_idfac pf.fk_facture AS idfac,
* @param string $row_iban rib.iban_prefix AS iban,
* @param string $row_bic rib.bic AS bic,
* @param string $row_datec rib.datec,
* @param string $row_drum rib.rowid used to generate rum
+ * @param string $row_rum rib.rum Rum defined on company bank account
* @return string Return string with SEPA part DrctDbtTxInf
*/
- public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
+ public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum)
{
// phpcs:enable
global $conf;
@@ -1600,7 +1670,7 @@ class BonPrelevement extends CommonObject
// Define value for RUM
// Example: RUMCustomerCode-CustomerBankAccountId-01424448606 (note: Date is date of creation of CustomerBankAccountId)
- $Rum = $this->buildRumNumber($row_code_client, $row_datec, $row_drum);
+ $Rum = empty($row_rum) ? $this->buildRumNumber($row_code_client, $row_datec, $row_drum) : $row_rum;
// Define date of RUM signature
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index e76cc9d184d..c0e6921c95d 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/compta/prelevement/class/ligneprelevement.class.php
* \ingroup prelevement
- * \brief Fichier de la classe des lignes de prelevements
+ * \brief File of class to manage lines of Direct Debit orders
*/
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index d9298c9f607..eaef92a1abc 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -52,42 +52,52 @@ $page = GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
+$hookmanager->initHooks(array('directdebitcreatecard','globalcard'));
+
+
/*
* Actions
*/
-// Change customer bank information to withdraw
-if ($action == 'modify')
-{
- for ($i = 1 ; $i < 9 ; $i++)
- {
- dolibarr_set_const($db, GETPOST("nom$i"), GETPOST("value$i"), 'chaine', 0, '', $conf->entity);
- }
-}
-if ($action == 'create')
-{
- // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
- $bprev = new BonPrelevement($db);
- $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear'));
+$parameters = array('mode' => $mode, 'format' => $format, 'limit' => $limit, 'page' => $page, 'offset' => $offset);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate);
- if ($result < 0)
+if (empty($reshook))
+{
+ // Change customer bank information to withdraw
+ if ($action == 'modify')
{
- setEventMessages($bprev->error, $bprev->errors, 'errors');
- }
- elseif ($result == 0)
- {
- $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed", $format);
- setEventMessages($mesg, null, 'errors');
- $mesg.=' '."\n";
- foreach($bprev->invoice_in_error as $key => $val)
+ for ($i = 1 ; $i < 9 ; $i++)
{
- $mesg.=''.$val." \n";
+ dolibarr_set_const($db, GETPOST("nom$i"), GETPOST("value$i"), 'chaine', 0, '', $conf->entity);
}
}
- else
+ if ($action == 'create')
{
- setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+ // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
+ $bprev = new BonPrelevement($db);
+ $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear'));
+
+ $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate);
+ if ($result < 0)
+ {
+ setEventMessages($bprev->error, $bprev->errors, 'errors');
+ }
+ elseif ($result == 0)
+ {
+ $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed", $format);
+ setEventMessages($mesg, null, 'errors');
+ $mesg.=' '."\n";
+ foreach($bprev->invoice_in_error as $key => $val)
+ {
+ $mesg.=''.$val." \n";
+ }
+ }
+ else
+ {
+ setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+ }
}
}
@@ -106,7 +116,7 @@ llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config() < 0)
{
$langs->load("errors");
- setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
+ setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
}
/*$h=0;
@@ -181,6 +191,7 @@ else
print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")." \n";
}
+print "\n";
print "\n";
print ' ';
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 83ac9a3483b..6d087ea477e 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -156,7 +156,7 @@ $sql.= " AND pl.fk_prelevement_bons = p.rowid";
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.entity IN (".getEntity('invoice').")";
-if ($prev_id) $sql.= " AND p.rowid=".$prev_id;
+if ($object->id > 0) $sql.= " AND p.rowid=".$object->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= $db->order($sortfield, $sortorder);
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index c930db99012..0e4d28fde2f 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -203,7 +203,7 @@ if ($resql)
print ' ';
- print '';
+ print ' ';
print img_picto('', 'statut'.$obj->statut).' ';
print substr('000000'.$obj->rowid, -6);
print ' ';
diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php
index 4e2c4e2d3a5..1be716f8f61 100644
--- a/htdocs/compta/prelevement/index.php
+++ b/htdocs/compta/prelevement/index.php
@@ -58,7 +58,7 @@ llxHeader('', $langs->trans("CustomersStandingOrdersArea"));
if (prelevement_check_config() < 0)
{
$langs->load("errors");
- setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
+ setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
}
print load_fiche_titre($langs->trans("CustomersStandingOrdersArea"));
diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/line.php
similarity index 95%
rename from htdocs/compta/prelevement/ligne.php
rename to htdocs/compta/prelevement/line.php
index 8b11716bf6f..c9004c04d26 100644
--- a/htdocs/compta/prelevement/ligne.php
+++ b/htdocs/compta/prelevement/line.php
@@ -20,7 +20,7 @@
*/
/**
- * \file htdocs/compta/prelevement/ligne.php
+ * \file htdocs/compta/prelevement/line.php
* \ingroup prelevement
* \brief card of withdraw line
*/
@@ -86,7 +86,7 @@ if ($action == 'confirm_rejet')
$rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int'));
- header("Location: ligne.php?id=".$id);
+ header("Location: line.php?id=".$id);
exit;
}
}
@@ -97,7 +97,7 @@ if ($action == 'confirm_rejet')
}
else
{
- header("Location: ligne.php?id=".$id);
+ header("Location: line.php?id=".$id);
exit;
}
}
@@ -112,7 +112,7 @@ $invoicestatic=new Facture($db);
llxHeader('', $langs->trans("StandingOrder"));
$h = 0;
-$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$id;
+$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id;
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
@@ -179,7 +179,7 @@ if ($id)
$rej = new RejetPrelevement($db, $user);
- print '';
+ print ' ';
print ' ';
print ' ';
print '';
@@ -231,7 +231,7 @@ if ($id)
{
if ($user->rights->prelevement->bons->credit)
{
- print "id\">".$langs->trans("StandingOrderReject")." ";
+ print "id\">".$langs->trans("StandingOrderReject")." ";
}
else
{
diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php
index 81e58e19cca..dd53988d2ec 100644
--- a/htdocs/compta/prelevement/list.php
+++ b/htdocs/compta/prelevement/list.php
@@ -172,7 +172,7 @@ if ($result)
print $ligne->LibStatut($obj->statut_ligne, 2);
print " ";
- print '';
+ print ' ';
print substr('000000'.$obj->rowid_ligne, -6);
print ' ';
diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php
index 333d07a4617..5d48cec2a75 100644
--- a/htdocs/compta/prelevement/rejets.php
+++ b/htdocs/compta/prelevement/rejets.php
@@ -100,7 +100,7 @@ if ($result)
print '';
print $ligne->LibStatut($obj->statut, 2).' ';
- print '';
+ print ' ';
print substr('000000'.$obj->rowid, -6)." ";
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index f0a01d1ae04..2182375ff1a 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -773,7 +773,7 @@ else
print ' ';
- print "".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname." \n";
+ print "".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname." \n";
if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).' ';
print ''.price(-$obj->amount).' ';
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index addc56a240b..70129e80403 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -943,7 +943,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
}
print "";
- print ' ';
+ print ' ';
if ($modecompta == 'BOOKKEEPING')
{
if (isset($encaiss[$case]))
@@ -978,8 +978,8 @@ print ' ';
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$nbcols+=2;
- print ''.(isset($totsorties[$annee])?price(price2num($totsorties[$annee], 'MT')):' ').' ';
- print ''.(isset($totentrees[$annee])?price(price2num($totentrees[$annee], 'MT')):' ').' ';
+ print ''.(isset($totsorties[$annee])?price(price2num($totsorties[$annee], 'MT')):' ').' ';
+ print ''.(isset($totentrees[$annee])?price(price2num($totentrees[$annee], 'MT')):' ').' ';
}
print " \n";
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 3ac50a65e9a..0318efb7e1a 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -655,7 +655,7 @@ if ($id > 0)
else
{
- print ''.$langs->trans("None").' ';
+ print ''.$langs->trans("None").' ';
print ' ';
print ' ';
}
diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php
index 7e25d8c3423..5f7f7d0fc0a 100644
--- a/htdocs/compta/sociales/list.php
+++ b/htdocs/compta/sociales/list.php
@@ -187,7 +187,7 @@ if ($resql)
if ($year)
{
- $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()." ":"");
+ $center=($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()." ":"");
print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy.png', 0, $newcardbutton, '', $limit);
}
else
@@ -281,7 +281,7 @@ if ($resql)
print '';
if ($obj->periode)
{
- print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').' ';
+ print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').' ';
}
else
{
diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php
index 384601ca989..af215902d0e 100644
--- a/htdocs/compta/sociales/payments.php
+++ b/htdocs/compta/sociales/payments.php
@@ -30,7 +30,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
+require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
@@ -90,7 +90,7 @@ print ' ';
if ($mode != 'sconly')
{
- $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')." ":"");
+ $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')." ":"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1);
}
else
@@ -181,7 +181,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
print $socialcontrib->getNomUrl(1, '20');
print ' ';
// Type
- print ''.$obj->lib.' ';
+ print ''.$obj->lib.' ';
// Date
$date=$obj->periode;
if (empty($date)) $date=$obj->date_ech;
diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php
index c69547740dc..fe6e2a9d150 100644
--- a/htdocs/compta/stats/byratecountry.php
+++ b/htdocs/compta/stats/byratecountry.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.
// Load translation files required by the page
$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy"));
-$modecompta = GETPOST('modecompta', 'alpha');
+$modecompta = (GETPOST('modecompta', 'alpha') ? GETPOST('modecompta', 'alpha') : $conf->global->ACCOUNTING_MODE);
// Date range
$year=GETPOST("year", 'int');
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index 8b58bde4199..c48bc385c53 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -5,6 +5,7 @@
* Copyright (C) 2006-2015 Yannick Warnier
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2019 Eric Seigne
*
* 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
@@ -116,7 +117,8 @@ foreach ($listofparams as $param)
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
}
-llxHeader('', $langs->trans("VATReport"), '', '', 0, 0, '', '', $morequerystring);
+$title = $langs->trans("VATReport") . " " . dol_print_date($date_start) . " -> " . dol_print_date($date_end);
+llxHeader('', $title, '', '', 0, 0, '', '', $morequerystring);
//print load_fiche_titre($langs->trans("VAT"),"");
@@ -184,8 +186,10 @@ if ($mysoc->tva_assuj) {
$vatsup.=' ('.$langs->trans("ToGetBack").')';
}
-
-report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
+$optioncss = GETPOST('optioncss');
+if($optioncss != "print") {
+ report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
+}
$vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid");
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 97dd835bda0..76d0e3911b5 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -179,7 +179,7 @@ if (empty($reshook))
$object->socid = GETPOST("socid", 'int');
$object->lastname = GETPOST("lastname", 'alpha');
$object->firstname = GETPOST("firstname", 'alpha');
- $object->civility_id = GETPOST("civility_id", 'alpha');
+ $object->civility_id = GETPOST("civility_id", 'alpha');
$object->poste = GETPOST("poste", 'alpha');
$object->address = GETPOST("address", 'alpha');
$object->zip = GETPOST("zipcode", 'alpha');
@@ -573,7 +573,7 @@ else
// Civility
print ''.$langs->trans("UserTitle").' ';
- print $formcompany->select_civility(GETPOST("civility_id", 'alpha')?GETPOST("civility_id", 'alpha'):$object->civility_id);
+ print $formcompany->select_civility(GETPOST("civility", 'alpha')?GETPOST("civility", 'alpha'):$object->civility_code);
print ' ';
print ''.$langs->trans("PostOrFunction").' ';
@@ -872,7 +872,7 @@ else
// Civility
print ''.$langs->trans("UserTitle").' ';
- print $formcompany->select_civility(isset($_POST["civility_id"])?GETPOST("civility_id"):$object->civility_id);
+ print $formcompany->select_civility(isset($_POST["civility"])?GETPOST("civility"):$object->civility_code);
print ' ';
print ''.$langs->trans("PostOrFunction").' ';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index dfefb8060fe..19437fe1aee 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -9,6 +9,7 @@
* Copyright (C) 2013 Alexandre Spangaro
* Copyright (C) 2013 Juanjo Menent
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -498,6 +499,7 @@ class Contact extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
@@ -507,7 +509,7 @@ class Contact extends CommonObject
* 2=Return key only (uid=qqq)
* @return string DN
*/
- private function _load_ldap_dn($info, $mode = 0)
+ public function _load_ldap_dn($info, $mode = 0)
{
// phpcs:enable
global $conf;
@@ -520,12 +522,13 @@ class Contact extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Initialise tableau info (tableau des attributs LDAP)
*
* @return array Tableau info des attributs
*/
- private function _load_ldap_info()
+ public function _load_ldap_info()
{
// phpcs:enable
global $conf, $langs;
@@ -1216,7 +1219,7 @@ class Contact extends CommonObject
global $langs;
$langs->load("dict");
- $code=(! empty($this->civility_id)?$this->civility_id:(! empty($this->civilite_id)?$this->civilite_id:''));
+ $code=(! empty($this->civility_id)?$this->civility:(! empty($this->civilite)?$this->civilite:''));
if (empty($code)) return '';
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
}
diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php
index 3f0d0313ee0..9cde6e2df4e 100644
--- a/htdocs/contact/consumption.php
+++ b/htdocs/contact/consumption.php
@@ -38,7 +38,7 @@ $id = GETPOST('id', 'int');
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$object = new Contact($db);
if ($id > 0) $object->fetch($id);
-if(empty($object->thirdparty)) $object->fetch_thirdparty();
+if (empty($object->thirdparty)) $object->fetch_thirdparty();
$socid = $object->thirdparty->id;
// Sort & Order fields
@@ -69,7 +69,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
}
// Customer or supplier selected in drop box
$thirdTypeSelect = GETPOST("third_select_id");
-$type_element = GETPOST('type_element')?GETPOST('type_element'):'';
+$type_element = GETPOSTISSET('type_element')?GETPOST('type_element'):'';
// Load translation files required by the page
$langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products"));
@@ -173,13 +173,13 @@ if ($type_element == 'fichinter')
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle, ';
$tables_from = MAIN_DB_PREFIX.'fichinterdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity('ficheinter').')';
$dateprint = 'f.datec';
$doc_number='f.ref';
}
-if ($type_element == 'invoice')
+elseif ($type_element == 'invoice')
{ // Customer : show products from invoices
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$documentstatic=new Facture($db);
@@ -187,14 +187,14 @@ if ($type_element == 'invoice')
$tables_from = MAIN_DB_PREFIX.'facturedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)";
$where = " WHERE f.entity IN (".getEntity('invoice').")";
$dateprint = 'f.datef';
$doc_number='f.ref';
$thirdTypeSelect='customer';
}
-if ($type_element == 'propal')
+elseif ($type_element == 'propal')
{
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$documentstatic=new Propal($db);
@@ -202,14 +202,14 @@ if ($type_element == 'propal')
$tables_from = MAIN_DB_PREFIX.'propaldet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('propal').')';
$datePrint = 'c.datep';
$doc_number='c.ref';
$thirdTypeSelect='customer';
}
-if ($type_element == 'order')
+elseif ($type_element == 'order')
{
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$documentstatic=new Commande($db);
@@ -217,14 +217,14 @@ if ($type_element == 'order')
$tables_from = MAIN_DB_PREFIX.'commandedet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('order').')';
$dateprint = 'c.date_commande';
$doc_number='c.ref';
$thirdTypeSelect='customer';
}
-if ($type_element == 'supplier_invoice')
+elseif ($type_element == 'supplier_invoice')
{ // Supplier : Show products from invoices.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$documentstatic=new FactureFournisseur($db);
@@ -232,14 +232,14 @@ if ($type_element == 'supplier_invoice')
$tables_from = MAIN_DB_PREFIX.'facture_fourn_det d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'f.datef';
$doc_number='f.ref';
$thirdTypeSelect='supplier';
}
-//if ($type_element == 'supplier_proposal')
+//elseif ($type_element == 'supplier_proposal')
//{
// require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
// $documentstatic=new SupplierProposal($db);
@@ -252,7 +252,7 @@ if ($type_element == 'supplier_invoice')
// $doc_number='c.ref';
// $thirdTypeSelect='supplier';
//}
-if ($type_element == 'supplier_order')
+elseif ($type_element == 'supplier_order')
{ // Supplier : Show products from orders.
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$documentstatic=new CommandeFournisseur($db);
@@ -260,14 +260,14 @@ if ($type_element == 'supplier_order')
$tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')';
$dateprint = 'c.date_valid';
$doc_number='c.ref';
$thirdTypeSelect='supplier';
}
-if ($type_element == 'contract')
+elseif ($type_element == 'contract')
{ // Order
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$documentstatic=new Contrat($db);
@@ -276,7 +276,7 @@ if ($type_element == 'contract')
$tables_from = MAIN_DB_PREFIX.'contratdet d';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid';
$tables_from.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid';
- $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid';
+ $tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id;
$tables_from.= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('contrat').')';
$dateprint = 'c.date_valid';
diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php
new file mode 100644
index 00000000000..622d195d8cd
--- /dev/null
+++ b/htdocs/contrat/agenda.php
@@ -0,0 +1,261 @@
+
+ * Copyright (C) 2017 Ferran Marcet
+ *
+ * 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/contrat/agenda.php
+ * \ingroup contrat
+ * \brief Page of contract events
+ */
+
+require "../main.inc.php";
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+if (! empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
+
+// Load translation files required by the page
+$langs->loadLangs(array("companies", "contracts"));
+
+if (GETPOST('actioncode', 'array'))
+{
+ $actioncode=GETPOST('actioncode', 'array', 3);
+ if (! count($actioncode)) $actioncode='0';
+}
+else
+{
+ $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+}
+$search_agenda_label=GETPOST('search_agenda_label');
+
+$action = GETPOST('action', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+
+// Security check
+if ($user->societe_id) $socid=$user->societe_id;
+$result = restrictedArea($user, 'contrat', $id, '');
+
+$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+$page = GETPOST("page", 'int');
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortfield) $sortfield='a.datep,a.id';
+if (! $sortorder) $sortorder='DESC,DESC';
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('agendacontract','globalcard'));
+
+
+/*
+ * Actions
+ */
+
+$parameters=array('id'=>$id);
+$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+ // Cancel
+ if (GETPOST('cancel', 'alpha') && ! empty($backtopage))
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
+ {
+ $actioncode='';
+ $search_agenda_label='';
+ }
+}
+
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formfile = new FormFile($db);
+if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
+
+if ($id > 0)
+{
+ // Load object modContract
+ $module=(! empty($conf->global->CONTRACT_ADDON)?$conf->global->CONTRACT_ADDON:'mod_contract_serpis');
+ if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php')
+ {
+ $module = substr($module, 0, dol_strlen($module)-4);
+ }
+ $result=dol_include_once('/core/modules/contract/'.$module.'.php');
+ if ($result > 0)
+ {
+ $modCodeContract = new $module();
+ }
+
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
+
+ $object = new Contrat($db);
+ $result = $object->fetch($id);
+ $object->fetch_thirdparty();
+
+ $title=$langs->trans("Agenda");
+ if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) $title=$object->ref." - ".$title;
+ llxHeader('', $title);
+
+ if (! empty($conf->notification->enabled)) $langs->load("mails");
+ $head = contract_prepare_head($object);
+
+ dol_fiche_head($head, 'agenda', $langs->trans("Contract"), -1, 'contract');
+
+ $linkback = ''.$langs->trans("BackToList").' ';
+
+ $morehtmlref='';
+ if (! empty($modCodeContract->code_auto)) {
+ $morehtmlref.=$object->ref;
+ } else {
+ $morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3);
+ $morehtmlref.=$form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
+ }
+
+ $morehtmlref.='';
+ // Ref customer
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
+ // Ref supplier
+ $morehtmlref.='
';
+ $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
+ // Thirdparty
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+ if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (
'.$langs->trans("OtherContracts").' )';
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($user->rights->contrat->creer)
+ {
+ if ($action != 'classify')
+ $morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='
';
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.=' ';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.='
';
+ $morehtmlref.=$proj->ref;
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.='';
+ }
+ }
+ }
+ $morehtmlref.='
';
+
+ dol_banner_tab($object, 'id', $linkback, 1, 'ref', 'none', $morehtmlref);
+
+ print '';
+
+ print '
';
+
+ $object->info($id);
+ dol_print_object_info($object, 1);
+
+ print '
';
+
+ dol_fiche_end();
+
+
+
+ // Actions buttons
+
+ /*$objthirdparty=$object;
+ $objcon=new stdClass();
+
+ $out='';
+ $permok=$user->rights->agenda->myactions->create;
+ if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
+ {
+ //$out.='trans("AddAnAction"),'filenew');
+ //$out.=" ";
+ }*/
+
+
+ //print '';
+ //print '
';
+
+
+ $newcardbutton='';
+ if (! empty($conf->agenda->enabled))
+ {
+ if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
+ {
+ $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
+ }
+ }
+
+ if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
+ {
+ print ' ';
+
+ $param='&id='.$id;
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
+
+ print load_fiche_titre($langs->trans("ActionsOnContract"), $newcardbutton, '');
+ //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
+
+ // List of all actions
+ $filters=array();
+ $filters['search_agenda_label']=$search_agenda_label;
+
+ // TODO Replace this with same code than into list.php
+ show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
+ }
+}
+
+llxFooter();
+$db->close();
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 5c9ac3375dd..430aad5e7e7 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1096,8 +1096,6 @@ $form = new Form($db);
$formfile = new FormFile($db);
if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
-$objectlignestatic=new ContratLigne($db);
-
// Load object modContract
$module=(! empty($conf->global->CONTRACT_ADDON)?$conf->global->CONTRACT_ADDON:'mod_contract_serpis');
if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php')
@@ -2211,10 +2209,14 @@ else
print '';
+ $MAXEVENT = 10;
+
+ $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt', DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id);
+
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
- $somethingshown = $formactions->showactions($object, 'contract', $socid, 1);
+ $somethingshown = $formactions->showactions($object, 'contract', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlright);
print '
';
@@ -2239,14 +2241,18 @@ $db->close();
margin->enabled) && $action == 'editline')
{
+ // TODO Why this ? To manage margin on contracts ?
?>
-
-
load("errors");
- print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
+ print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Contract"));
return "";
}
}
@@ -486,13 +486,18 @@ class Contrat extends CommonObject
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
- // Rename of object directory ($this->ref = old ref, $num = new ref)
- // to not lose the linked files
+ // Now we rename also files into index
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'";
+ $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
+
+ // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->contract->dir_output.'/'.$oldref;
$dirdest = $conf->contract->dir_output.'/'.$newref;
- if (file_exists($dirsource))
+ if (! $error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
@@ -716,10 +721,14 @@ class Contrat extends CommonObject
* Load lines array into this->lines.
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
*
+ * @param int $only_product Return only physical products
+ * @param int $loadalsotranslation Return translation for products
+ *
* @return ContratLigne[] Return array of contract lines
*/
- public function fetch_lines()
+ public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
+ global $langs, $conf;
// phpcs:enable
$this->nbofserviceswait=0;
$this->nbofservicesopened=0;
@@ -829,6 +838,13 @@ class Contrat extends CommonObject
// fetch optionals attributes and labels
$line->fetch_optionals();
+ // multilangs
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) {
+ $line = new Product($this->db);
+ $line->fetch($objp->fk_product);
+ $line->getMultiLangs();
+ }
+
$this->lines[$pos] = $line;
$this->lines_id_index_mapper[$line->id] = $pos;
@@ -851,7 +867,7 @@ class Contrat extends CommonObject
}
else
{
- dol_syslog(get_class($this)."::Fetch Erreur lecture des lignes de contrats liees aux produits");
+ dol_syslog(get_class($this)."::Fetch Error when reading lines of contracts linked to products");
return -3;
}
@@ -1350,7 +1366,7 @@ class Contrat extends CommonObject
* @param int $date_end Date de fin prevue
* @param string $price_base_type HT or TTC
* @param float $pu_ttc Prix unitaire TTC
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits of type of lines
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
@@ -1568,7 +1584,7 @@ class Contrat extends CommonObject
* @param int|string $date_debut_reel Date de debut reelle
* @param int|string $date_fin_reel Date de fin reelle
* @param string $price_base_type HT or TTC
- * @param int $info_bits Bits de type de lignes
+ * @param int $info_bits Bits of type of lines
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
@@ -1647,7 +1663,7 @@ class Contrat extends CommonObject
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
- if (($result = $this->defineBuyPrice($pu_ht, $remise_percent)) < 0)
+ if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0)
{
return $result;
}
@@ -1920,7 +1936,7 @@ class Contrat extends CommonObject
*/
public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1)
{
- global $conf, $langs, $user;
+ global $conf, $langs, $user, $hookmanager;
$result='';
@@ -1973,6 +1989,16 @@ class Contrat extends CommonObject
if ($withpicto != 2) $result.= ($this->ref?$this->ref:$this->id);
$result .= $linkend;
+ global $action;
+ $hookmanager->initHooks(array('contractdao'));
+ $parameters=array('id'=>$this->id, 'getnomurl'=>$result);
+ $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
+
return $result;
}
@@ -2521,7 +2547,7 @@ class Contrat extends CommonObject
/**
- * Classe permettant la gestion des lignes de contrats
+ * Class to manage lines of contracts
*/
class ContratLigne extends CommonObjectLine
{
diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php
index 10c2e2915b9..85538fe9ea8 100644
--- a/htdocs/contrat/index.php
+++ b/htdocs/contrat/index.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2011 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2019 Nicolas ZABOURI
*
* 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
@@ -28,6 +29,11 @@ require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
+$hookmanager = new HookManager($db);
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('contractindex'));
+
// Load translation files required by the page
$langs->loadLangs(array('products', 'companies', 'contracts'));
@@ -511,7 +517,7 @@ if ($resql)
$staticcompany->name=$obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '';
- print '';
+ print ' ';
print $staticcontratligne->LibStatut($obj->statut, 3);
print ' ';
print " \n";
@@ -590,7 +596,7 @@ if ($resql)
$staticcompany->name=$obj->name;
print $staticcompany->getNomUrl(1, '', 20);
print '';
- print '';
+ print ' ';
print $staticcontratligne->LibStatut($obj->statut, 3, 1);
print ' ';
print "\n";
@@ -609,6 +615,8 @@ else
//print '
';
print '';
+$parameters = array('user' => $user);
+$reshook = $hookmanager->executeHooks('dashboardContracts', $parameters, $object); // Note that $action and $object may have been modified by hook
llxFooter();
diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php
deleted file mode 100644
index 7d2b897f761..00000000000
--- a/htdocs/contrat/info.php
+++ /dev/null
@@ -1,156 +0,0 @@
-
- * Copyright (C) 2017 Ferran Marcet
- *
- * 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/contrat/info.php
- * \ingroup contrat
- * \brief Page des informations d'un contrat
- */
-
-require "../main.inc.php";
-require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
-}
-
-// Load translation files required by the page
-$langs->load("contracts");
-
-$action = GETPOST('action', 'alpha');
-$confirm = GETPOST('confirm', 'alpha');
-$id = GETPOST('id', 'int');
-$ref = GETPOST('ref', 'alpha');
-
-// Security check
-if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'contrat', $id, '');
-
-// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('contractcard','globalcard'));
-
-
-/*
- * Actions
- */
-
-// None
-
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-llxHeader('', $langs->trans("Contract"), "");
-
-$object = new Contrat($db);
-$object->fetch($id, $ref);
-if ($object->id > 0)
-{
- $object->fetch_thirdparty();
-}
-
-$object->info($object->id);
-
-$head = contract_prepare_head($object);
-
-dol_fiche_head($head, 'info', $langs->trans("Contract"), -1, 'contract');
-
-
-// Contract card
-
-$linkback = ''.$langs->trans("BackToList").' ';
-
-
-$morehtmlref='';
-//if (! empty($modCodeContract->code_auto)) {
-$morehtmlref.=$object->ref;
-/*} else {
- $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
-$morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
-}*/
-
-$morehtmlref.='';
-// Ref customer
-$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
-$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
-// Ref supplier
-$morehtmlref.='
';
-$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
-$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
-// Thirdparty
-$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
-// Project
-if (! empty($conf->projet->enabled))
-{
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($user->rights->contrat->creer)
- {
- if ($action != 'classify')
- //$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='
';
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
- $morehtmlref.=' ';
- $morehtmlref.=' ';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref.='
';
- $morehtmlref.=$proj->ref;
- $morehtmlref.=' ';
- } else {
- $morehtmlref.='';
- }
- }
-}
-$morehtmlref.='
';
-
-
-dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
-
-
-print '';
-print '
';
-
-print '
';
-
-print '
';
-dol_print_object_info($object);
-print '
';
-
-print '
';
-
-dol_fiche_end();
-
-
-llxFooter();
-$db->close();
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 28c4702a5c2..01cc12dd34a 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -592,7 +592,7 @@ if (! empty($arrayfields['c.tms']['checked'])){
print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (! empty($arrayfields['lower_planned_end_date']['checked'])) {
- print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
+ print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (! empty($arrayfields['status']['checked'])) {
print_liste_field_titre($staticcontratligne->LibStatut(0, 3), '', '', '', '', 'width="16"');
diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php
index b5eb5257ecc..0900c8c3ffe 100644
--- a/htdocs/core/actions_extrafields.inc.php
+++ b/htdocs/core/actions_extrafields.inc.php
@@ -27,7 +27,7 @@ $maxsizestring=255;
$maxsizeint=10;
$mesg=array();
-$extrasize=GETPOST('size', 'int');
+$extrasize=GETPOST('size', 'intcomma');
$type=GETPOST('type', 'alpha');
$param=GETPOST('param', 'alpha');
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index f7ec3beccc4..f474b1b05f8 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2018 Nicolas ZABOURI
- * Copyright (C) 2018 Juanjo Menent
- * Copyright (C) 2019 Ferran Marcet
+/* Copyright (C) 2015-2017 Laurent Destailleur
+ * Copyright (C) 2018 Nicolas ZABOURI
+ * Copyright (C) 2018 Juanjo Menent
+ * Copyright (C) 2019 Ferran Marcet
* Copyright (C) 2019 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
@@ -33,13 +33,14 @@
// $permtoread, $permtocreate and $permtodelete may be defined
// $uploaddir may be defined (example to $conf->projet->dir_output."/";)
// $toselect may be defined
+// $diroutputmassaction may be defined
// Protection
if (empty($objectclass) || empty($uploaddir))
{
- dol_print_error(null, 'include of actions_massactions.inc.php is done but var $massaction or $objectclass or $uploaddir was not defined');
- exit;
+ dol_print_error(null, 'include of actions_massactions.inc.php is done but var $massaction or $objectclass or $uploaddir was not defined');
+ exit;
}
@@ -47,1063 +48,1098 @@ if (empty($objectclass) || empty($uploaddir))
$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
if (! empty($massaction) && is_array($toselect) && count($toselect) < 1)
{
- $error++;
- setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
+ $error++;
+ setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
}
if (! $error && is_array($toselect) && count($toselect) > $maxformassaction)
{
- setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
- $error++;
+ setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
+ $error++;
}
if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
{
- $massaction='presend';
+ $massaction='presend';
}
if (! $error && $massaction == 'confirm_presend')
{
- $resaction = '';
- $nbsent = 0;
- $nbignored = 0;
- $langs->load("mails");
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $resaction = '';
+ $nbsent = 0;
+ $nbignored = 0;
+ $langs->load("mails");
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $listofobjectid=array();
- $listofobjectthirdparties=array();
- $listofobjectref=array();
+ $listofobjectid=array();
+ $listofobjectthirdparties=array();
+ $listofobjectref=array();
+ $attachedfilesThirdpartyObj=array();
+ $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0);
- if (! $error)
- {
- $thirdparty=new Societe($db);
+ if (! $error)
+ {
+ $thirdparty=new Societe($db);
- $objecttmp=new $objectclass($db);
- if ($objecttmp->element == 'expensereport') $thirdparty=new User($db);
- if ($objecttmp->element == 'holiday') $thirdparty=new User($db);
+ $objecttmp=new $objectclass($db);
+ if ($objecttmp->element == 'expensereport') $thirdparty=new User($db);
+ if ($objecttmp->element == 'holiday') $thirdparty=new User($db);
- foreach($toselect as $toselectid)
- {
- $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use
- $result=$objecttmp->fetch($toselectid);
- if ($result > 0)
- {
- $listofobjectid[$toselectid]=$toselectid;
+ foreach($toselect as $toselectid)
+ {
+ $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use
+ $result=$objecttmp->fetch($toselectid);
+ if ($result > 0)
+ {
+ $listofobjectid[$toselectid]=$toselectid;
- $thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid);
- if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id;
- if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author;
- if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user;
- if (empty($thirdpartyid)) $thirdpartyid=0;
+ $thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid);
+ if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id;
+ if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author;
+ if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user;
+ if (empty($thirdpartyid)) $thirdpartyid=0;
- $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
- $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
- }
- }
- }
+ $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
+ $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp;
+ }
+ }
+ }
- // Check mandatory parameters
- if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email))
- {
- $error++;
- setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
- $massaction='presend';
- }
+ // Check mandatory parameters
+ if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email))
+ {
+ $error++;
+ setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
+ $massaction='presend';
+ }
- $receiver=$_POST['receiver'];
- if (! is_array($receiver))
- {
- if (empty($receiver) || $receiver == '-1') $receiver=array();
- else $receiver=array($receiver);
- }
- if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory
- {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
- $massaction='presend';
- }
+ $receiver=$_POST['receiver'];
+ if (! is_array($receiver))
+ {
+ if (empty($receiver) || $receiver == '-1') $receiver=array();
+ else $receiver=array($receiver);
+ }
+ if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory
+ {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
+ $massaction='presend';
+ }
- if (! GETPOST('subject', 'none'))
- {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings');
- $massaction='presend';
- }
+ if (! GETPOST('subject', 'none'))
+ {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings');
+ $massaction='presend';
+ }
- // Loop on each recipient/thirdparty
- if (! $error)
- {
- foreach ($listofobjectthirdparties as $thirdpartyid)
- {
- $result = $thirdparty->fetch($thirdpartyid);
- if ($result < 0)
- {
- dol_print_error($db);
- exit;
- }
+ // Loop on each recipient/thirdparty
+ if (! $error)
+ {
+ foreach ($listofobjectthirdparties as $thirdpartyid)
+ {
+ $result = $thirdparty->fetch($thirdpartyid);
+ if ($result < 0)
+ {
+ dol_print_error($db);
+ exit;
+ }
- $sendto='';
- $sendtocc='';
- $sendtobcc='';
- $sendtoid = array();
+ $sendto='';
+ $sendtocc='';
+ $sendtobcc='';
+ $sendtoid = array();
- // Define $sendto
- $tmparray=array();
- if (trim($_POST['sendto']))
- {
- // Recipients are provided into free text
- $tmparray[] = trim($_POST['sendto']);
- }
- if (count($receiver)>0)
- {
- foreach($receiver as $key=>$val)
- {
- // Recipient was provided from combo list
- if ($val == 'thirdparty') // Id of third party or user
- {
- $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
- }
- elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact
- {
- $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
- $sendtoid[] = $val;
- }
- }
- }
- $sendto=implode(',', $tmparray);
+ // Define $sendto
+ $tmparray=array();
+ if (trim($_POST['sendto']))
+ {
+ // Recipients are provided into free text
+ $tmparray[] = trim($_POST['sendto']);
+ }
+ if (count($receiver)>0)
+ {
+ foreach($receiver as $key=>$val)
+ {
+ // Recipient was provided from combo list
+ if ($val == 'thirdparty') // Id of third party or user
+ {
+ $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
+ }
+ elseif ($val && method_exists($thirdparty, 'contact_get_property')) // Id of contact
+ {
+ $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
+ $sendtoid[] = $val;
+ }
+ }
+ }
+ $sendto=implode(',', $tmparray);
- // Define $sendtocc
- $receivercc=$_POST['receivercc'];
- if (! is_array($receivercc))
- {
- if ($receivercc == '-1') $receivercc=array();
- else $receivercc=array($receivercc);
- }
- $tmparray=array();
- if (trim($_POST['sendtocc']))
- {
- $tmparray[] = trim($_POST['sendtocc']);
- }
- if (count($receivercc) > 0)
- {
- foreach($receivercc as $key=>$val)
- {
- // Recipient was provided from combo list
- if ($val == 'thirdparty') // Id of third party
- {
- $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
- }
- elseif ($val) // Id du contact
- {
- $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
- //$sendtoid[] = $val; TODO Add also id of contact in CC ?
- }
- }
- }
- $sendtocc=implode(',', $tmparray);
+ // Define $sendtocc
+ $receivercc=$_POST['receivercc'];
+ if (! is_array($receivercc))
+ {
+ if ($receivercc == '-1') $receivercc=array();
+ else $receivercc=array($receivercc);
+ }
+ $tmparray=array();
+ if (trim($_POST['sendtocc']))
+ {
+ $tmparray[] = trim($_POST['sendtocc']);
+ }
+ if (count($receivercc) > 0)
+ {
+ foreach($receivercc as $key=>$val)
+ {
+ // Recipient was provided from combo list
+ if ($val == 'thirdparty') // Id of third party
+ {
+ $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
+ }
+ elseif ($val) // Id du contact
+ {
+ $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
+ //$sendtoid[] = $val; TODO Add also id of contact in CC ?
+ }
+ }
+ }
+ $sendtocc=implode(',', $tmparray);
- //var_dump($listofobjectref);exit;
- $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
- $listofqualifiedobj=array();
- $listofqualifiedref=array();
- $thirdpartywithoutemail=array();
+ //var_dump($listofobjectref);exit;
+ $listofqualifiedobj=array();
+ $listofqualifiedref=array();
+ $thirdpartywithoutemail=array();
- foreach($listofobjectref[$thirdpartyid] as $objectid => $objectobj)
- {
- //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut);
- if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT)
- {
- $langs->load("errors");
- $nbignored++;
- $resaction.=''.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'
';
- continue; // Payment done or started or canceled
- }
- if ($objectclass == 'Commande' && $objectojb->statut == Commande::STATUS_DRAFT)
- {
- $langs->load("errors");
- $nbignored++;
- $resaction.=''.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'
';
- continue;
- }
- if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT)
- {
- $langs->load("errors");
- $nbignored++;
- $resaction.=''.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'
';
- continue; // Payment done or started or canceled
- }
+ foreach($listofobjectref[$thirdpartyid] as $objectid => $objectobj)
+ {
+ //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut);
+ if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT)
+ {
+ $langs->load("errors");
+ $nbignored++;
+ $resaction.=''.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'
';
+ continue; // Payment done or started or canceled
+ }
+ if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT)
+ {
+ $langs->load("errors");
+ $nbignored++;
+ $resaction.=''.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'
';
+ continue;
+ }
+ if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT)
+ {
+ $langs->load("errors");
+ $nbignored++;
+ $resaction.=''.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'
';
+ continue; // Payment done or started or canceled
+ }
- // Test recipient
- if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
- {
- if ($objectobj->element == 'expensereport')
- {
- $fuser = new User($db);
- $fuser->fetch($objectobj->fk_user_author);
- $sendto = $fuser->email;
- }
- elseif ($objectobj->element == 'holiday')
- {
- $fuser = new User($db);
- $fuser->fetch($objectobj->fk_user);
- $sendto = $fuser->email;
- }
- else
- {
- $objectobj->fetch_thirdparty();
- $sendto = $objectobj->thirdparty->email;
- }
- }
+ // Test recipient
+ if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send)
+ {
+ if ($objectobj->element == 'expensereport')
+ {
+ $fuser = new User($db);
+ $fuser->fetch($objectobj->fk_user_author);
+ $sendto = $fuser->email;
+ }
+ elseif ($objectobj->element == 'holiday')
+ {
+ $fuser = new User($db);
+ $fuser->fetch($objectobj->fk_user);
+ $sendto = $fuser->email;
+ }
+ else
+ {
+ $objectobj->fetch_thirdparty();
+ $sendto = $objectobj->thirdparty->email;
+ }
+ }
- if (empty($sendto))
- {
- //print "No recipient for thirdparty ".$objectobj->thirdparty->name;
- $nbignored++;
- if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id]))
- {
- $resaction.=''.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'
';
- }
- dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
- $thirdpartywithoutemail[$objectobj->thirdparty->id]=1;
- continue;
- }
+ if (empty($sendto))
+ {
+ //print "No recipient for thirdparty ".$objectobj->thirdparty->name;
+ $nbignored++;
+ if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id]))
+ {
+ $resaction.=''.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'
';
+ }
+ dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING);
+ $thirdpartywithoutemail[$objectobj->thirdparty->id]=1;
+ continue;
+ }
- if ($_POST['addmaindocfile'])
- {
- // TODO Use future field $objectobj->fullpathdoc to know where is stored default file
- // TODO If not defined, use $objectobj->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
- $filename=dol_sanitizeFileName($objectobj->ref).'.pdf';
- $filedir=$uploaddir . '/' . dol_sanitizeFileName($objectobj->ref);
- $file = $filedir . '/' . $filename;
- $mime = dol_mimetype($file);
+ if ($_POST['addmaindocfile'])
+ {
+ // TODO Use future field $objectobj->fullpathdoc to know where is stored default file
+ // TODO If not defined, use $objectobj->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
+ $filename = dol_sanitizeFileName($objectobj->ref).'.pdf';
+ $subdir = '';
+ // TODO Set subdir to be compatible with multi levels dir trees
+ // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element)
+ $filedir = $uploaddir . '/' . $subdir . dol_sanitizeFileName($objectobj->ref);
+ $file = $filedir . '/' . $filename;
- if (dol_is_file($file))
- {
- // Create form object
- $attachedfiles=array(
- 'paths'=>array_merge($attachedfiles['paths'], array($file)),
- 'names'=>array_merge($attachedfiles['names'], array($filename)),
- 'mimes'=>array_merge($attachedfiles['mimes'], array($mime))
- );
- }
- else
- {
- $nbignored++;
- $langs->load("errors");
- $resaction.=''.$langs->trans('ErrorCantReadFile', $file).'
';
- dol_syslog('Failed to read file: '.$file, LOG_WARNING);
- continue;
- }
- }
+ // For supplier invoices, we use the file provided by supplier, not the one we generate
+ if ($objectobj->element == 'invoice_supplier')
+ {
+ $fileparams = dol_most_recent_file($uploaddir . '/' . get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+');
+ $file = $fileparams['fullname'];
+ }
- // Object of thirdparty qualified, we add it
- $listofqualifiedobj[$objectid]=$objectobj;
- $listofqualifiedref[$objectid]=$objectobj->ref;
+ $mime = dol_mimetype($file);
- //var_dump($listofqualifiedref);
- }
+ if (dol_is_file($file))
+ {
+ // Create form object
+ $attachedfilesThirdpartyObj[$thirdpartyid][$objectid]=array(
+ 'paths'=>array($file),
+ 'names'=>array($filename),
+ 'mimes'=>array($mime)
+ );
+ }
+ else
+ {
+ $nbignored++;
+ $langs->load("errors");
+ $resaction.=''.$langs->trans('ErrorCantReadFile', $file).'
';
+ dol_syslog('Failed to read file: '.$file, LOG_WARNING);
+ continue;
+ }
+ }
- // Send email if there is at least one qualified object for current thirdparty
- if (count($listofqualifiedobj) > 0)
- {
- $langs->load("commercial");
+ // Object of thirdparty qualified, we add it
+ $listofqualifiedobj[$objectid]=$objectobj;
+ $listofqualifiedref[$objectid]=$objectobj->ref;
- $fromtype = GETPOST('fromtype');
- if ($fromtype === 'user') {
- $from = $user->getFullName($langs) .' <'.$user->email.'>';
- }
- elseif ($fromtype === 'company') {
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
- }
- elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
- $tmp=explode(',', $user->email_aliases);
- $from = trim($tmp[($reg[1] - 1)]);
- }
- elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
- $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
- $from = trim($tmp[($reg[1] - 1)]);
- }
- elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
- $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
- $resql = $db->query($sql);
- $obj = $db->fetch_object($resql);
- if ($obj)
- {
- $from = $obj->label.' <'.$obj->email.'>';
- }
- }
- else {
- $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
- }
- $replyto = $from;
- $subject = GETPOST('subject', 'none');
- $message = GETPOST('message', 'none');
+ //var_dump($listofqualifiedref);
+ }
- $sendtobcc = GETPOST('sendtoccc');
- if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
- if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
- if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
- if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
- if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
- if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
- if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
+ // Send email if there is at least one qualified object for current thirdparty
+ if (count($listofqualifiedobj) > 0)
+ {
+ $langs->load("commercial");
- // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
- // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty)
- $oneemailperrecipient=(GETPOST('oneemailperrecipient', 'alpha')=='on'?1:0);
- $looparray=array();
- if (! $oneemailperrecipient)
- {
- $looparray = $listofqualifiedobj;
- foreach ($looparray as $key => $objecttmp)
- {
- $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object
- }
- }
- else
- {
- $objectforloop=new $objectclass($db);
- $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded)
- $looparray[0]=$objectforloop;
- }
- //var_dump($looparray);exit;
+ $fromtype = GETPOST('fromtype');
+ if ($fromtype === 'user') {
+ $from = $user->getFullName($langs) .' <'.$user->email.'>';
+ }
+ elseif ($fromtype === 'company') {
+ $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+ }
+ elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
+ $tmp=explode(',', $user->email_aliases);
+ $from = trim($tmp[($reg[1] - 1)]);
+ }
+ elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
+ $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
+ $from = trim($tmp[($reg[1] - 1)]);
+ }
+ elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
+ $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
+ $resql = $db->query($sql);
+ $obj = $db->fetch_object($resql);
+ if ($obj)
+ {
+ $from = $obj->label.' <'.$obj->email.'>';
+ }
+ }
+ else {
+ $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
+ }
+
+ $replyto = $from;
+ $subject = GETPOST('subject', 'none');
+ $message = GETPOST('message', 'none');
+
+ $sendtobcc = GETPOST('sendtoccc');
+ if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
+ if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
+ if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
+ if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
+ if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
+ if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
+ if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
+
+ // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
+ // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty)
+ $looparray=array();
+ if (! $oneemailperrecipient)
+ {
+ $looparray = $listofqualifiedobj;
+ foreach ($looparray as $key => $objecttmp)
+ {
+ $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object
+ }
+ }
+ else
+ {
+ $objectforloop=new $objectclass($db);
+ $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded)
+ $looparray[0]=$objectforloop;
+ }
+ //var_dump($looparray);exit;
dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient);
//var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref);
foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object
- {
- // Make substitution in email content
- $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
- $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
- $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref);
- $substitutionarray['__EMAIL__'] = $thirdparty->email;
- $substitutionarray['__CHECK_READ__'] = ' ';
+ {
+ // Make substitution in email content
+ $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp);
+ $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
+ $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref);
+ $substitutionarray['__EMAIL__'] = $thirdparty->email;
+ $substitutionarray['__CHECK_READ__'] = ' ';
- $parameters=array('mode'=>'formemail');
+ $parameters=array('mode'=>'formemail');
- if ( ! empty($listofobjectthirdparties) ) {
- $parameters['listofobjectthirdparties'] = $listofobjectthirdparties;
- }
- if ( ! empty($listofobjectref) ) {
- $parameters['listofobjectref'] = $listofobjectref;
- }
+ if (! empty($listofobjectthirdparties)) {
+ $parameters['listofobjectthirdparties'] = $listofobjectthirdparties;
+ }
+ if (! empty($listofobjectref)) {
+ $parameters['listofobjectref'] = $listofobjectref;
+ }
- complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
+ complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters);
$subjectreplaced=make_substitutions($subject, $substitutionarray);
$messagereplaced=make_substitutions($message, $substitutionarray);
- $filepath = $attachedfiles['paths'];
- $filename = $attachedfiles['names'];
- $mimetype = $attachedfiles['mimes'];
+ $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array());
+ if ($oneemailperrecipient)
+ {
+ // if "one email per recipient" is check we must collate $attachedfiles by thirdparty
+ if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id]))
+ {
+ foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){
+ // Create form object
+ $attachedfiles=array(
+ 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']),
+ 'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']),
+ 'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes'])
+ );
+ }
+ }
+ }
+ elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){
+ // Create form object
+ // if "one email per recipient" isn't check we must separate $attachedfiles by object
+ $attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid];
+ }
- // Define the trackid when emails sent from the mass action
- if ($oneemailperrecipient)
- {
- $trackid='thi'.$thirdparty->id;
- if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id;
- if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id;
- }
- else
- {
- $trackid=strtolower(get_class($objecttmp));
- if (get_class($objecttmp)=='Contrat') $trackid='con';
- if (get_class($objecttmp)=='Propal') $trackid='pro';
- if (get_class($objecttmp)=='Commande') $trackid='ord';
- if (get_class($objecttmp)=='Facture') $trackid='inv';
- if (get_class($objecttmp)=='Supplier_Proposal') $trackid='spr';
- if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor';
- if (get_class($objecttmp)=='FactureFournisseur') $trackid='sin';
+ $filepath = $attachedfiles['paths'];
+ $filename = $attachedfiles['names'];
+ $mimetype = $attachedfiles['mimes'];
- $trackid.=$objecttmp->id;
- }
- //var_dump($filepath);
- //var_dump($trackid);exit;
- //var_dump($subjectreplaced);
+ // Define the trackid when emails sent from the mass action
+ if ($oneemailperrecipient)
+ {
+ $trackid='thi'.$thirdparty->id;
+ if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id;
+ if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id;
+ }
+ else
+ {
+ $trackid=strtolower(get_class($objecttmp));
+ if (get_class($objecttmp)=='Contrat') $trackid='con';
+ if (get_class($objecttmp)=='Propal') $trackid='pro';
+ if (get_class($objecttmp)=='Commande') $trackid='ord';
+ if (get_class($objecttmp)=='Facture') $trackid='inv';
+ if (get_class($objecttmp)=='Supplier_Proposal') $trackid='spr';
+ if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor';
+ if (get_class($objecttmp)=='FactureFournisseur') $trackid='sin';
- // Send mail (substitutionarray must be done just before this)
+ $trackid.=$objecttmp->id;
+ }
+ //var_dump($filepath);
+ //var_dump($trackid);exit;
+ //var_dump($subjectreplaced);
+
+ // Send mail (substitutionarray must be done just before this)
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid);
- if ($mailfile->error)
- {
- $resaction.=''.$mailfile->error.'
';
- }
- else
- {
- $result=$mailfile->sendfile();
- if ($result)
- {
- $resaction.=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).' '; // Must not contain "
+ if ($mailfile->error)
+ {
+ $resaction.=''.$mailfile->error.'
';
+ }
+ else
+ {
+ $result=$mailfile->sendfile();
+ if ($result)
+ {
+ $resaction.=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).' '; // Must not contain "
- $error=0;
+ $error=0;
- // Insert logs into agenda
+ // Insert logs into agenda
foreach($listofqualifiedobj as $objid2 => $objectobj2)
- {
+ {
if ((! $oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level
dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2));
- /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
- if ($objectclass == 'Commande') $actiontypecode='AC_COM';
- if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
- if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
- if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
- if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
+ /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP';
+ if ($objectclass == 'Commande') $actiontypecode='AC_COM';
+ if ($objectclass == 'Facture') $actiontypecode='AC_FAC';
+ if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO';
+ if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD';
+ if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/
- $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
- if ($message)
- {
- if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
+ $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
+ if ($message)
+ {
+ if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subjectreplaced);
- $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
+ $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $messagereplaced);
- }
- $actionmsg2='';
+ }
+ $actionmsg2='';
- // Initialisation donnees
+ // Initialisation donnees
$objectobj2->sendtoid = 0;
$objectobj2->actionmsg = $actionmsg; // Long text
$objectobj2->actionmsg2 = $actionmsg2; // Short text
$objectobj2->fk_element = $objid2;
$objectobj2->elementtype = $objectobj2->element;
- $triggername = strtoupper(get_class($objectobj2)) .'_SENTBYMAIL';
- if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL';
- if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL';
- if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL';
- if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL';
- if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL';
- if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
- if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL';
- if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL';
+ $triggername = strtoupper(get_class($objectobj2)) .'_SENTBYMAIL';
+ if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL';
+ if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL';
+ if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL';
+ if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL';
+ if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL';
+ if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
+ if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL';
+ if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL';
- if (! empty($triggername))
- {
- // Appel des triggers
+ if (! empty($triggername))
+ {
+ // Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
- $interface=new Interfaces($db);
+ $interface=new Interfaces($db);
$result=$interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf);
- if ($result < 0) { $error++; $errors=$interface->errors; }
- // Fin appel triggers
+ if ($result < 0) { $error++; $errors=$interface->errors; }
+ // Fin appel triggers
- if ($error)
- {
- setEventMessages($db->lasterror(), $errors, 'errors');
- dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR);
- }
- }
- }
+ if ($error)
+ {
+ setEventMessages($db->lasterror(), $errors, 'errors');
+ dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR);
+ }
+ }
- $nbsent++; // Nb of email sent (may be lower than number of record selected if we group thirdparties)
- }
- else
- {
- $langs->load("other");
- if ($mailfile->error)
- {
- $resaction.=$langs->trans('ErrorFailedToSendMail', $from, $sendto);
- $resaction.=''.$mailfile->error.'
';
- }
- else
- {
- $resaction.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
';
- }
- }
- }
- }
- }
- }
+ $nbsent++; // Nb of object sent
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ if ($mailfile->error)
+ {
+ $resaction.=$langs->trans('ErrorFailedToSendMail', $from, $sendto);
+ $resaction.=''.$mailfile->error.'
';
+ }
+ else
+ {
+ $resaction.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
';
+ }
+ }
+ }
+ }
+ }
+ }
- $resaction.=($resaction?' ':$resaction);
- $resaction.=''.$langs->trans("ResultOfMailSending").': '."\n";
- $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n ";
- $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n ";
- $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n ";
+ $resaction.=($resaction?' ':$resaction);
+ $resaction.=''.$langs->trans("ResultOfMailSending").': '."\n";
+ $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n ";
+ $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n ";
+ $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n ";
- if ($nbsent)
- {
- $action=''; // Do not show form post if there was at least one successfull sent
- //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs');
- setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs');
- setEventMessages($resaction, null, 'mesgs');
- }
- else
- {
- //setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file
- setEventMessages($resaction, null, 'warnings');
- }
+ if ($nbsent)
+ {
+ $action=''; // Do not show form post if there was at least one successfull sent
+ //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs');
+ setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs');
+ setEventMessages($resaction, null, 'mesgs');
+ }
+ else
+ {
+ //setEventMessages($langs->trans("EMailSentToNRecipients", 0), null, 'warnings'); // May be object has no generated PDF file
+ setEventMessages($resaction, null, 'warnings');
+ }
- $action='list';
- $massaction='';
- }
+ $action='list';
+ $massaction='';
+ }
}
if ($massaction == 'confirm_createbills') // Create bills from orders
{
- $orders = GETPOST('toselect', 'array');
- $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
- $validate_invoices = GETPOST('validate_invoices', 'int');
+ $orders = GETPOST('toselect', 'array');
+ $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
+ $validate_invoices = GETPOST('validate_invoices', 'int');
- $TFact = array();
- $TFactThird = array();
+ $TFact = array();
+ $TFactThird = array();
- $nb_bills_created = 0;
+ $nb_bills_created = 0;
- $db->begin();
+ $db->begin();
- foreach($orders as $id_order)
- {
- $cmd = new Commande($db);
- if ($cmd->fetch($id_order) <= 0) continue;
+ foreach($orders as $id_order)
+ {
+ $cmd = new Commande($db);
+ if ($cmd->fetch($id_order) <= 0) continue;
- $objecttmp = new Facture($db);
- if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
- else {
- // Load extrafields of order
- $cmd->fetch_optionals();
+ $objecttmp = new Facture($db);
+ if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
+ else {
+ // Load extrafields of order
+ $cmd->fetch_optionals();
- $objecttmp->socid = $cmd->socid;
- $objecttmp->type = Facture::TYPE_STANDARD;
- $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
- $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
- $objecttmp->fk_project = $cmd->fk_project;
+ $objecttmp->socid = $cmd->socid;
+ $objecttmp->type = Facture::TYPE_STANDARD;
+ $objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
+ $objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
+ $objecttmp->fk_project = $cmd->fk_project;
$objecttmp->multicurrency_code = $cmd->multicurrency_code;
if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client;
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($datefacture))
- {
- $datefacture = dol_now();
- }
+ {
+ $datefacture = dol_now();
+ }
- $objecttmp->date = $datefacture;
- $objecttmp->origin = 'commande';
- $objecttmp->origin_id = $id_order;
+ $objecttmp->date = $datefacture;
+ $objecttmp->origin = 'commande';
+ $objecttmp->origin_id = $id_order;
- $objecttmp->array_options = $cmd->array_options; // Copy extrafields
+ $objecttmp->array_options = $cmd->array_options; // Copy extrafields
- $res = $objecttmp->create($user);
+ $res = $objecttmp->create($user);
- if($res > 0) $nb_bills_created++;
- }
+ if($res > 0) $nb_bills_created++;
+ }
- if ($objecttmp->id > 0)
- {
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
- $sql.= "fk_source";
- $sql.= ", sourcetype";
- $sql.= ", fk_target";
- $sql.= ", targettype";
- $sql.= ") VALUES (";
- $sql.= $id_order;
- $sql.= ", '".$objecttmp->origin."'";
- $sql.= ", ".$objecttmp->id;
- $sql.= ", '".$objecttmp->element."'";
- $sql.= ")";
+ if ($objecttmp->id > 0)
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
+ $sql.= "fk_source";
+ $sql.= ", sourcetype";
+ $sql.= ", fk_target";
+ $sql.= ", targettype";
+ $sql.= ") VALUES (";
+ $sql.= $id_order;
+ $sql.= ", '".$objecttmp->origin."'";
+ $sql.= ", ".$objecttmp->id;
+ $sql.= ", '".$objecttmp->element."'";
+ $sql.= ")";
- if (! $db->query($sql))
- {
- $error++;
- }
+ if (! $db->query($sql))
+ {
+ $error++;
+ }
- if (! $error)
- {
- $lines = $cmd->lines;
- if (empty($lines) && method_exists($cmd, 'fetch_lines'))
- {
- $cmd->fetch_lines();
- $lines = $cmd->lines;
- }
+ if (! $error)
+ {
+ $lines = $cmd->lines;
+ if (empty($lines) && method_exists($cmd, 'fetch_lines'))
+ {
+ $cmd->fetch_lines();
+ $lines = $cmd->lines;
+ }
- $fk_parent_line=0;
- $num=count($lines);
+ $fk_parent_line=0;
+ $num=count($lines);
- for ($i=0;$i<$num;$i++)
- {
- $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
- // If we build one invoice for several order, we must put the invoice of order on the line
- if (! empty($createbills_onebythird))
- {
- $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs));
- }
+ for ($i=0;$i<$num;$i++)
+ {
+ $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
+ // If we build one invoice for several order, we must put the invoice of order on the line
+ if (! empty($createbills_onebythird))
+ {
+ $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs));
+ }
- if ($lines[$i]->subprice < 0)
- {
- // Negative line, we create a discount line
- $discount = new DiscountAbsolute($db);
- $discount->fk_soc=$objecttmp->socid;
- $discount->amount_ht=abs($lines[$i]->total_ht);
- $discount->amount_tva=abs($lines[$i]->total_tva);
- $discount->amount_ttc=abs($lines[$i]->total_ttc);
- $discount->tva_tx=$lines[$i]->tva_tx;
- $discount->fk_user=$user->id;
- $discount->description=$desc;
- $discountid=$discount->create($user);
- if ($discountid > 0)
- {
- $result=$objecttmp->insert_discount($discountid);
- //$result=$discount->link_to_invoice($lineid,$id);
- }
- else
- {
- setEventMessages($discount->error, $discount->errors, 'errors');
- $error++;
- break;
- }
- }
- else
- {
- // Positive line
- $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
- // Date start
- $date_start=false;
- if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
- if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
- if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
- //Date end
- $date_end=false;
- if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
- if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
- if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
- // Reset fk_parent_line for no child products and special product
- if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
- {
- $fk_parent_line = 0;
- }
+ if ($lines[$i]->subprice < 0)
+ {
+ // Negative line, we create a discount line
+ $discount = new DiscountAbsolute($db);
+ $discount->fk_soc=$objecttmp->socid;
+ $discount->amount_ht=abs($lines[$i]->total_ht);
+ $discount->amount_tva=abs($lines[$i]->total_tva);
+ $discount->amount_ttc=abs($lines[$i]->total_ttc);
+ $discount->tva_tx=$lines[$i]->tva_tx;
+ $discount->fk_user=$user->id;
+ $discount->description=$desc;
+ $discountid=$discount->create($user);
+ if ($discountid > 0)
+ {
+ $result=$objecttmp->insert_discount($discountid);
+ //$result=$discount->link_to_invoice($lineid,$id);
+ }
+ else
+ {
+ setEventMessages($discount->error, $discount->errors, 'errors');
+ $error++;
+ break;
+ }
+ }
+ else
+ {
+ // Positive line
+ $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
+ // Date start
+ $date_start=false;
+ if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
+ if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
+ if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
+ //Date end
+ $date_end=false;
+ if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
+ if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
+ if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
+ // Reset fk_parent_line for no child products and special product
+ if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
+ {
+ $fk_parent_line = 0;
+ }
- // Extrafields
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
- $lines[$i]->fetch_optionals($lines[$i]->rowid);
- $array_options = $lines[$i]->array_options;
- }
+ // Extrafields
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
+ $lines[$i]->fetch_optionals($lines[$i]->rowid);
+ $array_options = $lines[$i]->array_options;
+ }
- $result = $objecttmp->addline(
- $desc,
- $lines[$i]->subprice,
- $lines[$i]->qty,
- $lines[$i]->tva_tx,
- $lines[$i]->localtax1_tx,
- $lines[$i]->localtax2_tx,
- $lines[$i]->fk_product,
- $lines[$i]->remise_percent,
- $date_start,
- $date_end,
- 0,
- $lines[$i]->info_bits,
- $lines[$i]->fk_remise_except,
- 'HT',
- 0,
- $product_type,
- $ii,
- $lines[$i]->special_code,
- $objecttmp->origin,
- $lines[$i]->rowid,
- $fk_parent_line,
- $lines[$i]->fk_fournprice,
- $lines[$i]->pa_ht,
- $lines[$i]->label,
- $array_options
- );
- if ($result > 0)
- {
- $lineid=$result;
- }
- else
- {
- $lineid=0;
- $error++;
- break;
- }
- // Defined the new fk_parent_line
- if ($result > 0 && $lines[$i]->product_type == 9)
- {
- $fk_parent_line = $result;
- }
- }
- }
- }
- }
+ $result = $objecttmp->addline(
+ $desc,
+ $lines[$i]->subprice,
+ $lines[$i]->qty,
+ $lines[$i]->tva_tx,
+ $lines[$i]->localtax1_tx,
+ $lines[$i]->localtax2_tx,
+ $lines[$i]->fk_product,
+ $lines[$i]->remise_percent,
+ $date_start,
+ $date_end,
+ 0,
+ $lines[$i]->info_bits,
+ $lines[$i]->fk_remise_except,
+ 'HT',
+ 0,
+ $product_type,
+ $ii,
+ $lines[$i]->special_code,
+ $objecttmp->origin,
+ $lines[$i]->rowid,
+ $fk_parent_line,
+ $lines[$i]->fk_fournprice,
+ $lines[$i]->pa_ht,
+ $lines[$i]->label,
+ $array_options
+ );
+ if ($result > 0)
+ {
+ $lineid=$result;
+ }
+ else
+ {
+ $lineid=0;
+ $error++;
+ break;
+ }
+ // Defined the new fk_parent_line
+ if ($result > 0 && $lines[$i]->product_type == 9)
+ {
+ $fk_parent_line = $result;
+ }
+ }
+ }
+ }
+ }
- //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
+ //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
- if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
- else $TFact[$objecttmp->id] = $objecttmp;
- }
+ if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
+ else $TFact[$objecttmp->id] = $objecttmp;
+ }
- // Build doc with all invoices
- $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
- $toselect = array();
+ // Build doc with all invoices
+ $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
+ $toselect = array();
- if (! $error && $validate_invoices)
- {
- $massaction = $action = 'builddoc';
+ if (! $error && $validate_invoices)
+ {
+ $massaction = $action = 'builddoc';
- foreach($TAllFact as &$objecttmp)
- {
- $result = $objecttmp->validate($user);
- if ($result <= 0)
- {
- $error++;
- setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
- break;
- }
+ foreach($TAllFact as &$objecttmp)
+ {
+ $result = $objecttmp->validate($user);
+ if ($result <= 0)
+ {
+ $error++;
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ break;
+ }
- $id = $objecttmp->id; // For builddoc action
- $object = $objecttmp;
+ $id = $objecttmp->id; // For builddoc action
+ $object = $objecttmp;
- // Builddoc
- $donotredirect = 1;
- $upload_dir = $conf->facture->dir_output;
- $permissioncreate=$user->rights->facture->creer;
+ // Builddoc
+ $donotredirect = 1;
+ $upload_dir = $conf->facture->dir_output;
+ $permissioncreate=$user->rights->facture->creer;
- // Call action to build doc
- $savobject = $object;
- $object = $objecttmp;
- include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- $object = $savobject;
- }
+ // Call action to build doc
+ $savobject = $object;
+ $object = $objecttmp;
+ include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
+ $object = $savobject;
+ }
- $massaction = $action = 'confirm_createbills';
- }
+ $massaction = $action = 'confirm_createbills';
+ }
- if (! $error)
- {
- $db->commit();
+ if (! $error)
+ {
+ $db->commit();
setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
- // Make a redirect to avoid to bill twice if we make a refresh or back
- $param='';
- if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
- if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
- if ($sall) $param.='&sall='.urlencode($sall);
- if ($socid > 0) $param.='&socid='.urlencode($socid);
- if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut);
- if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday);
- if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth);
- if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear);
- if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday);
- if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth);
- if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear);
- if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
- if ($search_company) $param.='&search_company='.urlencode($search_company);
- if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer);
- if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
- if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
- if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht);
- if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat);
- if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc);
- if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref);
- if ($show_files) $param.='&show_files=' .urlencode($show_files);
- if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
- if ($billed != '') $param.='&billed='.urlencode($billed);
+ // Make a redirect to avoid to bill twice if we make a refresh or back
+ $param='';
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+ if ($sall) $param.='&sall='.urlencode($sall);
+ if ($socid > 0) $param.='&socid='.urlencode($socid);
+ if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut);
+ if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday);
+ if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth);
+ if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear);
+ if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday);
+ if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth);
+ if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear);
+ if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
+ if ($search_company) $param.='&search_company='.urlencode($search_company);
+ if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer);
+ if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
+ if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
+ if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht);
+ if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat);
+ if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc);
+ if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref);
+ if ($show_files) $param.='&show_files=' .urlencode($show_files);
+ if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
+ if ($billed != '') $param.='&billed='.urlencode($billed);
- header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
- exit;
- }
- else
- {
- $db->rollback();
- $action='create';
- $_GET["origin"]=$_POST["origin"];
- $_GET["originid"]=$_POST["originid"];
- setEventMessages("Error", null, 'errors');
- $error++;
- }
+ header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
+ exit;
+ }
+ else
+ {
+ $db->rollback();
+ $action='create';
+ $_GET["origin"]=$_POST["origin"];
+ $_GET["originid"]=$_POST["originid"];
+ setEventMessages("Error", null, 'errors');
+ $error++;
+ }
}
if (!$error && $massaction == 'cancelorders')
{
- $db->begin();
- $nbok = 0;
+ $db->begin();
+
+ $nbok = 0;
- $orders = GETPOST('toselect', 'array');
- foreach ($orders as $id_order)
- {
+ $orders = GETPOST('toselect', 'array');
+ foreach ($orders as $id_order)
+ {
- $cmd = new Commande($db);
- if ($cmd->fetch($id_order) <= 0)
- continue;
+ $cmd = new Commande($db);
+ if ($cmd->fetch($id_order) <= 0)
+ continue;
- if ($cmd->statut != Commande::STATUS_VALIDATED)
- {
- $langs->load('errors');
- setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors');
- $error++;
- break;
- }
- else
- $result = $cmd->cancel();
+ if ($cmd->statut != Commande::STATUS_VALIDATED)
+ {
+ $langs->load('errors');
+ setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors');
+ $error++;
+ break;
+ }
+ else
+ $result = $cmd->cancel();
- if ($result < 0)
- {
- setEventMessages($cmd->error, $cmd->errors, 'errors');
- $error++;
- break;
- }
- else
- $nbok++;
- }
- if (!$error)
- {
- if ($nbok > 1)
- setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- else
- setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
+ if ($result < 0)
+ {
+ setEventMessages($cmd->error, $cmd->errors, 'errors');
+ $error++;
+ break;
+ }
+ else
+ $nbok++;
+ }
+ if (!$error)
+ {
+ if ($nbok > 1)
+ setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
+ else
+ setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
}
if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search'))
{
- if (empty($diroutputmassaction))
- {
- dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
- exit;
- }
+ if (empty($diroutputmassaction))
+ {
+ dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined');
+ exit;
+ }
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
- $objecttmp=new $objectclass($db);
- $listofobjectid=array();
- $listofobjectthirdparties=array();
- $listofobjectref=array();
- foreach($toselect as $toselectid)
- {
- $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use
- $result=$objecttmp->fetch($toselectid);
- if ($result > 0)
- {
- $listofobjectid[$toselectid]=$toselectid;
- $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
- $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
- $listofobjectref[$toselectid]=$objecttmp->ref;
- }
- }
+ $objecttmp=new $objectclass($db);
+ $listofobjectid=array();
+ $listofobjectthirdparties=array();
+ $listofobjectref=array();
+ foreach($toselect as $toselectid)
+ {
+ $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use
+ $result=$objecttmp->fetch($toselectid);
+ if ($result > 0)
+ {
+ $listofobjectid[$toselectid]=$toselectid;
+ $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
+ $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
+ $listofobjectref[$toselectid]=$objecttmp->ref;
+ }
+ }
- $arrayofinclusion=array();
- foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$';
- foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files
- $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true);
+ $arrayofinclusion=array();
+ foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$';
+ foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files
+ $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true);
- // build list of files with full path
- $files = array();
- foreach($listofobjectref as $basename)
- {
- $basename = dol_sanitizeFileName($basename);
- foreach($listoffiles as $filefound)
- {
- if (strstr($filefound["name"], $basename))
- {
- $files[] = $uploaddir.'/'.$basename.'/'.$filefound["name"];
- break;
- }
- }
- }
+ // build list of files with full path
+ $files = array();
+ foreach($listofobjectref as $basename)
+ {
+ $basename = dol_sanitizeFileName($basename);
+ foreach($listoffiles as $filefound)
+ {
+ if (strstr($filefound["name"], $basename))
+ {
+ $files[] = $uploaddir.'/'.$basename.'/'.$filefound["name"];
+ break;
+ }
+ }
+ }
- // Define output language (Here it is not used because we do only merging existing PDF)
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang;
- if (! empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ // Define output language (Here it is not used because we do only merging existing PDF)
+ $outputlangs = $langs;
+ $newlang='';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09');
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang;
+ if (! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
- if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT))
- {
- // Create output dir if not exists
- dol_mkdir($diroutputmassaction);
+ if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT))
+ {
+ // Create output dir if not exists
+ dol_mkdir($diroutputmassaction);
- // Defined name of merged file
- $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
- $filename=preg_replace('/\s/', '_', $filename);
+ // Defined name of merged file
+ $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
+ $filename=preg_replace('/\s/', '_', $filename);
- // Save merged file
- if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
- {
- if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
- else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
- }
- if ($year) $filename.='_'.$year;
- if ($month) $filename.='_'.$month;
+ // Save merged file
+ if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
+ {
+ if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
+ else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
+ }
+ if ($year) $filename.='_'.$year;
+ if ($month) $filename.='_'.$month;
- if (count($files)>0)
- {
- $now=dol_now();
- $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
+ if (count($files)>0)
+ {
+ $now=dol_now();
+ $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
- $input_files = '';
- foreach($files as $f) {
- $input_files.=' '.escapeshellarg($f);
- }
+ $input_files = '';
+ foreach($files as $f) {
+ $input_files.=' '.escapeshellarg($f);
+ }
- $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file);
- exec($cmd);
+ $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file);
+ exec($cmd);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
- $langs->load("exports");
- setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
- }
- else
- {
- setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
- }
- }
- else {
- // Create empty PDF
- $formatarray=pdf_getFormat();
- $page_largeur = $formatarray['width'];
- $page_hauteur = $formatarray['height'];
- $format = array($page_largeur,$page_hauteur);
+ $langs->load("exports");
+ setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
+ }
+ }
+ else {
+ // Create empty PDF
+ $formatarray=pdf_getFormat();
+ $page_largeur = $formatarray['width'];
+ $page_hauteur = $formatarray['height'];
+ $format = array($page_largeur, $page_hauteur);
- $pdf=pdf_getInstance($format);
+ $pdf=pdf_getInstance($format);
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- // Add all others
- foreach($files as $file)
- {
- // Charge un document PDF depuis un fichier.
- $pagecount = $pdf->setSourceFile($file);
- for ($i = 1; $i <= $pagecount; $i++)
- {
- $tplidx = $pdf->importPage($i);
- $s = $pdf->getTemplatesize($tplidx);
- $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
- $pdf->useTemplate($tplidx);
- }
- }
+ // Add all others
+ foreach($files as $file)
+ {
+ // Charge un document PDF depuis un fichier.
+ $pagecount = $pdf->setSourceFile($file);
+ for ($i = 1; $i <= $pagecount; $i++)
+ {
+ $tplidx = $pdf->importPage($i);
+ $s = $pdf->getTemplatesize($tplidx);
+ $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
+ $pdf->useTemplate($tplidx);
+ }
+ }
- // Create output dir if not exists
- dol_mkdir($diroutputmassaction);
+ // Create output dir if not exists
+ dol_mkdir($diroutputmassaction);
- // Defined name of merged file
- $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
- $filename=preg_replace('/\s/', '_', $filename);
+ // Defined name of merged file
+ $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
+ $filename=preg_replace('/\s/', '_', $filename);
- // Save merged file
- if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
- {
- if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
- else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
- }
- if ($year) $filename.='_'.$year;
- if ($month) $filename.='_'.$month;
- if ($pagecount)
- {
- $now=dol_now();
- $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
- $pdf->Output($file, 'F');
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
+ // Save merged file
+ if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
+ {
+ if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
+ else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
+ }
+ if ($year) $filename.='_'.$year;
+ if ($month) $filename.='_'.$month;
+ if ($pagecount)
+ {
+ $now=dol_now();
+ $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
+ $pdf->Output($file, 'F');
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
- $langs->load("exports");
- setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
- }
- else
- {
- setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
- }
- }
+ $langs->load("exports");
+ setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
+ }
+ }
}
// Remove a file from massaction area
if ($action == 'remove_file')
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $langs->load("other");
- $upload_dir = $diroutputmassaction;
- $file = $upload_dir . '/' . GETPOST('file');
- $ret=dol_delete_file($file);
- if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
- else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
- $action='';
+ $langs->load("other");
+ $upload_dir = $diroutputmassaction;
+ $file = $upload_dir . '/' . GETPOST('file');
+ $ret=dol_delete_file($file);
+ if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
+ else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
+ $action='';
}
// Validate records
if (! $error && $massaction == 'validate' && $permtocreate)
{
- $objecttmp=new $objectclass($db);
+ $objecttmp=new $objectclass($db);
- if ($objecttmp->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
- {
- $langs->load("errors");
- setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
- $error++;
- }
- if ($objecttmp->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL))
- {
- $langs->load("errors");
- setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
- $error++;
- }
- if (! $error)
- {
- $db->begin();
+ if ($objecttmp->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
+ $error++;
+ }
+ if ($objecttmp->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
+ $error++;
+ }
+ if (! $error)
+ {
+ $db->begin();
- $nbok = 0;
- foreach($toselect as $toselectid)
- {
- $result=$objecttmp->fetch($toselectid);
- if ($result > 0)
- {
- //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
- //else
- $result = $objecttmp->validate($user);
- if ($result == 0)
- {
- $langs->load("errors");
- setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
- $error++;
- break;
- }
- elseif ($result < 0)
- {
- setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
- $error++;
- break;
- }
- else $nbok++;
- }
- else
- {
- setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
- $error++;
- break;
- }
- }
+ $nbok = 0;
+ foreach($toselect as $toselectid)
+ {
+ $result=$objecttmp->fetch($toselectid);
+ if ($result > 0)
+ {
+ //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
+ //else
+ $result = $objecttmp->validate($user);
+ if ($result == 0)
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
+ $error++;
+ break;
+ }
+ elseif ($result < 0)
+ {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ break;
+ }
+ else $nbok++;
+ }
+ else
+ {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ break;
+ }
+ }
- if (! $error)
- {
- if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- //var_dump($listofobjectthirdparties);exit;
- }
+ if (! $error)
+ {
+ if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
+ else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ //var_dump($listofobjectthirdparties);exit;
+ }
}
// Closed records
if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permtoclose) {
@@ -1132,9 +1168,9 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permtoclo
if (!$error) {
if ($nbok > 1)
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- else
- setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
- $db->commit();
+ else
+ setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
+ $db->commit();
}
else {
$db->rollback();
@@ -1143,66 +1179,66 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permtoclo
// Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before)
if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permtodelete)
{
- $db->begin();
+ $db->begin();
- $objecttmp=new $objectclass($db);
- $nbok = 0;
- foreach($toselect as $toselectid)
- {
- $result=$objecttmp->fetch($toselectid);
- if ($result > 0)
- {
- // Refuse deletion for some objects/status
- if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)
- {
- $langs->load("errors");
- $nbignored++;
- $resaction.=''.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'
';
- continue;
- }
+ $objecttmp=new $objectclass($db);
+ $nbok = 0;
+ foreach($toselect as $toselectid)
+ {
+ $result=$objecttmp->fetch($toselectid);
+ if ($result > 0)
+ {
+ // Refuse deletion for some objects/status
+ if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)
+ {
+ $langs->load("errors");
+ $nbignored++;
+ $resaction.=''.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'
';
+ continue;
+ }
- if ($objectclass == "Task" && $objecttmp->hasChildren() > 0)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id;
- $res = $db->query($sql);
+ if ($objectclass == "Task" && $objecttmp->hasChildren() > 0)
+ {
+ $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id;
+ $res = $db->query($sql);
- if (!$res)
- {
- setEventMessage('ErrorRecordParentingNotModified', 'errors');
- $error++;
- }
- }
+ if (!$res)
+ {
+ setEventMessage('ErrorRecordParentingNotModified', 'errors');
+ $error++;
+ }
+ }
- if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
- else $result = $objecttmp->delete($user);
+ if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
+ else $result = $objecttmp->delete($user);
- if ($result <= 0)
- {
- setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
- $error++;
- break;
- }
- else $nbok++;
- }
- else
- {
- setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
- $error++;
- break;
- }
- }
+ if ($result <= 0)
+ {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ break;
+ }
+ else $nbok++;
+ }
+ else
+ {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ break;
+ }
+ }
- if (! $error)
- {
- if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
- else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
- $db->commit();
- }
- else
- {
- $db->rollback();
- }
- //var_dump($listofobjectthirdparties);exit;
+ if (! $error)
+ {
+ if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
+ else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ //var_dump($listofobjectthirdparties);exit;
}
// Generate document foreach object according to model linked to object
@@ -1268,6 +1304,8 @@ if (! $error && $massaction == 'generate_doc' && $permtoread)
$parameters['toselect']=$toselect;
$parameters['uploaddir']=$uploaddir;
+$parameters['massaction']=$massaction;
+$parameters['diroutputmassaction']=$diroutputmassaction;
$reshook=$hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php
index 7ef25e62b8b..e039529eef7 100644
--- a/htdocs/core/ajax/extraparams.php
+++ b/htdocs/core/ajax/extraparams.php
@@ -17,7 +17,7 @@
/**
* \file /htdocs/core/ajax/extraparams.php
- * \brief File to return Ajax response on set extra parameters of elements
+ * \brief File to make Ajax action on setting extra parameters of elements
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php
index 6b06cccd50c..987a59ec3fb 100644
--- a/htdocs/core/ajax/objectonoff.php
+++ b/htdocs/core/ajax/objectonoff.php
@@ -15,8 +15,9 @@
*/
/**
- * \file htdocs/core/ajax/productonoff.php
- * \brief File to set tosell and tobuy for product
+ * \file htdocs/core/ajax/objectonoff.php
+ * \brief File to set status for an object
+ * This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set.
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
@@ -36,6 +37,13 @@ $field=GETPOST('field', 'alpha');
$element=GETPOST('element', 'alpha');
$object = new GenericObject($db);
+
+// Security check
+if (! empty($user->societe_id))
+ $socid = $user->societe_id;
+
+
+
/*
* View
*/
@@ -44,6 +52,20 @@ top_httphead();
print ''."\n";
+if ($element == 'societe' && in_array($field, array('status')))
+{
+ $result = restrictedArea($user, 'societe', $id);
+}
+elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch')))
+{
+ $result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid');
+}
+else
+{
+ accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1);
+ exit;
+}
+
// Registering new values
if (($action == 'set') && ! empty($id))
$object->setValueFrom($field, $value, $element, $id);
diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php
new file mode 100644
index 00000000000..3055942f89a
--- /dev/null
+++ b/htdocs/core/ajax/pingresult.php
@@ -0,0 +1,71 @@
+
+ *
+ * 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/core/ajax/pingresult.php
+ * \brief File to save result of an anonymous ping into database (1 ping is done per installation)
+ */
+
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
+if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+
+$action=GETPOST('action', 'alpha');
+$hash_unique_id=GETPOST('hash_unique_id', 'alpha');
+$hash_algo=GETPOST('hash', 'alpha');
+
+
+// Security check
+if (! empty($user->societe_id))
+ $socid = $user->societe_id;
+
+$now = dol_now();
+
+
+/*
+ * View
+ */
+
+top_httphead();
+
+print ''."\n";
+
+// If ok
+if ($action == 'firstpingok')
+{
+ // Note: pings are by entities
+ dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
+ dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id);
+
+ print 'First ping OK saved for entity '.$conf->entity;
+}
+// If ko
+elseif ($action == 'firstpingko')
+{
+ // Note: pings are by entities
+ dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt');
+ print 'First ping KO saved for entity '.$conf->entity;
+}
+else {
+ print 'Error action='.$action.' not supported';
+}
diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php
index 9e7dea2ef95..faaddd31b23 100644
--- a/htdocs/core/ajax/security.php
+++ b/htdocs/core/ajax/security.php
@@ -17,7 +17,7 @@
/**
* \file htdocs/core/ajax/security.php
- * \brief This ajax component is used to generated has keys for security purposes
+ * \brief This ajax component is used to generated hash keys for security purposes
* like key to use into URL to protect them.
*/
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 300040639a8..995ba93fb64 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -422,7 +422,7 @@ class box_activity extends ModeleBoxes
);
$totalnb += $data[$j]->nb;
$this->info_box_contents[$line][3] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="nowrap right"',
'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
);
$this->info_box_contents[$line][4] = array(
diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php
index 8575e739946..956e73b4acf 100644
--- a/htdocs/core/boxes/box_commandes.php
+++ b/htdocs/core/boxes/box_commandes.php
@@ -146,7 +146,7 @@ class box_commandes extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="nowrap right"',
'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
);
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index 09de3b874e3..74f8cbc6b64 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -151,7 +151,7 @@ class box_factures_fourn_imp extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="nowrap right"',
'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
);
diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php
index fd85f136f96..a0692c791b2 100644
--- a/htdocs/core/boxes/box_factures_imp.php
+++ b/htdocs/core/boxes/box_factures_imp.php
@@ -161,7 +161,7 @@ class box_factures_imp extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="nowrap right"',
'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
);
diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php
index 4323661370c..6e5afe5df99 100644
--- a/htdocs/core/boxes/box_graph_invoices_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_permonth.php
@@ -74,6 +74,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
//$facturestatic=new Facture($db);
+ $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
+ if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
+
$text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
$this->info_box_head = array(
'text' => $text,
@@ -129,7 +132,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
- $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png';
@@ -143,11 +146,17 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px1->SetData($data1);
unset($data1);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px1->SetLegend($legend);
@@ -157,7 +166,6 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px1->SetYLabel($langs->trans("NumberOfBills"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
@@ -169,7 +177,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
- $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png';
@@ -183,11 +191,17 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px2->SetData($data2);
unset($data2);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px2->SetLegend($legend);
@@ -197,7 +211,6 @@ class box_graph_invoices_permonth extends ModeleBoxes
$px2->SetYLabel($langs->trans("AmountOfBillsHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
@@ -224,6 +237,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
index bba5185c94a..df4f4afc146 100644
--- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
@@ -73,6 +73,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
+ $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
+ if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
+
$text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
$this->info_box_head = array(
'text' => $text,
@@ -126,7 +129,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
- $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png';
@@ -140,11 +143,17 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px1->SetData($data1);
unset($data1);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px1->SetLegend($legend);
@@ -154,7 +163,6 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px1->SetYLabel($langs->trans("NumberOfBills"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
@@ -166,7 +174,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
- $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png';
@@ -180,11 +188,17 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px2->SetData($data2);
unset($data2);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px2->SetLegend($legend);
@@ -194,7 +208,6 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$px2->SetYLabel($langs->trans("AmountOfBillsHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfBillsByMonthHT"));
@@ -221,6 +234,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php
index b06558393aa..b530b4ea268 100644
--- a/htdocs/core/boxes/box_graph_orders_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_permonth.php
@@ -74,6 +74,9 @@ class box_graph_orders_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
//$commandestatic=new Commande($db);
+ $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
+ if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
+
$text = $langs->trans("BoxCustomersOrdersPerMonth", $max);
$this->info_box_head = array(
'text' => $text,
@@ -129,7 +132,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
- $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png';
@@ -141,11 +144,17 @@ class box_graph_orders_permonth extends ModeleBoxes
{
$px1->SetData($data1);
unset($data1);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px1->SetLegend($legend);
@@ -155,7 +164,6 @@ class box_graph_orders_permonth extends ModeleBoxes
$px1->SetYLabel($langs->trans("NumberOfOrders"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
@@ -167,7 +175,7 @@ class box_graph_orders_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
- $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png';
@@ -179,11 +187,17 @@ class box_graph_orders_permonth extends ModeleBoxes
{
$px2->SetData($data2);
unset($data2);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px2->SetLegend($legend);
@@ -193,7 +207,6 @@ class box_graph_orders_permonth extends ModeleBoxes
$px2->SetYLabel($langs->trans("AmountOfOrdersHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
@@ -220,6 +233,7 @@ class box_graph_orders_permonth extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
index 9cb11aed7c1..8359ddbe070 100644
--- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
@@ -73,6 +73,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+ $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
+ if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
+
$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
$this->info_box_head = array(
'text' => $text,
@@ -128,7 +131,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
- $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png';
@@ -140,11 +143,17 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
{
$px1->SetData($data1);
unset($data1);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px1->SetLegend($legend);
@@ -154,7 +163,6 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px1->SetYLabel($langs->trans("NumberOfOrders"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfOrdersByMonth"));
@@ -166,7 +174,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
- $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png';
@@ -178,11 +186,17 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
{
$px2->SetData($data2);
unset($data2);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px2->SetLegend($legend);
@@ -192,7 +206,6 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$px2->SetYLabel($langs->trans("AmountOfOrdersHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
@@ -219,6 +232,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php
index 0fe5c66d532..d32c9bb1918 100644
--- a/htdocs/core/boxes/box_graph_product_distribution.php
+++ b/htdocs/core/boxes/box_graph_product_distribution.php
@@ -171,7 +171,6 @@ class box_graph_product_distribution extends ModeleBoxes
unset($data1);
if ($nocolor) $px1->SetDataColor(array(array(220,220,220)));
- $px1->SetPrecisionY(0);
$px1->SetLegend($legend);
$px1->setShowLegend(0);
$px1->setShowPointValue($showpointvalue);
@@ -182,7 +181,6 @@ class box_graph_product_distribution extends ModeleBoxes
//$px1->SetYLabel($langs->trans("NumberOfBills"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
//$px1->mode='depth';
$px1->SetType(array('pie'));
@@ -231,7 +229,6 @@ class box_graph_product_distribution extends ModeleBoxes
unset($data2);
if ($nocolor) $px2->SetDataColor(array(array(220,220,220)));
- $px2->SetPrecisionY(0);
$px2->SetLegend($legend);
$px2->setShowLegend(0);
$px2->setShowPointValue($showpointvalue);
@@ -242,7 +239,6 @@ class box_graph_product_distribution extends ModeleBoxes
//$px2->SetYLabel($langs->trans("AmountOfBillsHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
//$px2->mode='depth';
$px2->SetType(array('pie'));
@@ -292,7 +288,6 @@ class box_graph_product_distribution extends ModeleBoxes
unset($data3);
if ($nocolor) $px3->SetDataColor(array(array(220,220,220)));
- $px3->SetPrecisionY(0);
$px3->SetLegend($legend);
$px3->setShowLegend(0);
$px3->setShowPointValue($showpointvalue);
@@ -303,7 +298,6 @@ class box_graph_product_distribution extends ModeleBoxes
//$px3->SetYLabel($langs->trans("AmountOfBillsHT"));
$px3->SetShading(3);
$px3->SetHorizTickIncrement(1);
- $px3->SetPrecisionY(0);
$px3->SetCssPrefix("cssboxes");
//$px3->mode='depth';
$px3->SetType(array('pie'));
@@ -338,6 +332,7 @@ class box_graph_product_distribution extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php
index b21381473c2..75673ee3fce 100644
--- a/htdocs/core/boxes/box_graph_propales_permonth.php
+++ b/htdocs/core/boxes/box_graph_propales_permonth.php
@@ -74,6 +74,9 @@ class box_graph_propales_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
//$propalstatic=new Propal($db);
+ $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
+ if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
+
$langs->load("propal");
$text = $langs->trans("BoxProposalsPerMonth", $max);
@@ -128,7 +131,7 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
- $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars');
$filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png";
@@ -141,11 +144,17 @@ class box_graph_propales_permonth extends ModeleBoxes
$px1->SetType($datatype1);
$px1->SetData($data1);
unset($data1);
- $px1->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px1->SetLegend($legend);
@@ -155,7 +164,6 @@ class box_graph_propales_permonth extends ModeleBoxes
$px1->SetYLabel($langs->trans("NumberOfProposals"));
$px1->SetShading(3);
$px1->SetHorizTickIncrement(1);
- $px1->SetPrecisionY(0);
$px1->SetCssPrefix("cssboxes");
$px1->mode='depth';
$px1->SetTitle($langs->trans("NumberOfProposalsByMonth"));
@@ -167,7 +175,7 @@ class box_graph_propales_permonth extends ModeleBoxes
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
- $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0));
+ $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth);
$datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars');
//$datatype2 = array('lines','bars');
@@ -182,11 +190,17 @@ class box_graph_propales_permonth extends ModeleBoxes
$px2->SetType($datatype2);
$px2->SetData($data2);
unset($data2);
- $px2->SetPrecisionY(0);
$i=$startyear;$legend=array();
while ($i <= $endyear)
{
- $legend[]=$i;
+ if ($startmonth != 1)
+ {
+ $legend[]=sprintf("%d/%d", $i-2001, $i-2000);
+ }
+ else
+ {
+ $legend[]=$i;
+ }
$i++;
}
$px2->SetLegend($legend);
@@ -196,7 +210,6 @@ class box_graph_propales_permonth extends ModeleBoxes
$px2->SetYLabel($langs->trans("AmountOfProposalsHT"));
$px2->SetShading(3);
$px2->SetHorizTickIncrement(1);
- $px2->SetPrecisionY(0);
$px2->SetCssPrefix("cssboxes");
$px2->mode='depth';
$px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT"));
@@ -223,6 +236,7 @@ class box_graph_propales_permonth extends ModeleBoxes
';
$stringtoshow.=''; // hideobject is to start hidden
$stringtoshow.='
';
+ $stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
$stringtoshow.=' ';
diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php
index b1330192a11..3fcd8001227 100644
--- a/htdocs/core/boxes/box_services_contracts.php
+++ b/htdocs/core/boxes/box_services_contracts.php
@@ -84,7 +84,7 @@ class box_services_contracts extends ModeleBoxes
if ($user->rights->service->lire && $user->rights->contrat->lire)
{
$contractstatic=new Contrat($db);
- $contratlignestatic=new ContratLigne($db);
+ $contractlinestatic=new ContratLigne($db);
$thirdpartytmp = new Societe($db);
$productstatic = new Product($db);
@@ -116,13 +116,13 @@ class box_services_contracts extends ModeleBoxes
$objp = $db->fetch_object($result);
$datem=$db->jdate($objp->datem);
- $contratlignestatic->id=$objp->cdid;
- $contratlignestatic->fk_contrat=$objp->rowid;
- $contratlignestatic->label=$objp->label;
- $contratlignestatic->description=$objp->description;
- $contratlignestatic->type=$objp->type;
- $contratlignestatic->product_id=$objp->product_id;
- $contratlignestatic->product_ref=$objp->product_ref;
+ $contractlinestatic->id=$objp->cdid;
+ $contractlinestatic->fk_contrat=$objp->rowid;
+ $contractlinestatic->label=$objp->label;
+ $contractlinestatic->description=$objp->description;
+ $contractlinestatic->type=$objp->type;
+ $contractlinestatic->product_id=$objp->product_id;
+ $contractlinestatic->product_ref=$objp->product_ref;
$contractstatic->statut=$objp->contract_status;
$contractstatic->id=$objp->rowid;
@@ -153,7 +153,7 @@ class box_services_contracts extends ModeleBoxes
if ($resultd)
{
$objtp = $db->fetch_object($resultd);
- if ($objtp->label != '') $contratlignestatic->label = $objtp->label;
+ if ($objtp->label != '') $contractlinestatic->label = $objtp->label;
}
}
@@ -215,7 +215,7 @@ class box_services_contracts extends ModeleBoxes
$this->info_box_contents[$i][] = array(
'td' => 'class="right" width="18"',
- 'text' => $contratlignestatic->LibStatut($objp->statut, 3)
+ 'text' => $contractlinestatic->LibStatut($objp->statut, 3)
);
$i++;
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index bf9b617693f..eabe0440dca 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -286,8 +286,7 @@ class CMailFile
// We now define $this->headers and $this->message
$this->headers = $smtp_headers . $mime_headers;
// On nettoie le header pour qu'il ne se termine pas par un retour chariot.
- // Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees
- // comme des injections mail par les serveurs de messagerie.
+ // This avoid also empty lines at end that can be interpreted as mail injection by email servers.
$this->headers = preg_replace("/([\r\n]+)$/i", "", $this->headers);
//$this->message = $this->eol.'This is a message with multiple parts in MIME format.'.$this->eol;
diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php
index a97d992bf89..a551857ded4 100644
--- a/htdocs/core/class/ccountry.class.php
+++ b/htdocs/core/class/ccountry.class.php
@@ -47,8 +47,8 @@ class Ccountry // extends CommonObject
*/
public $errors = array();
- //var $element='ccountry'; //!< Id that identify managed objects
- //var $table_element='ccountry'; //!< Name of table without prefix where object is stored
+ public $element='ccountry'; //!< Id that identify managed objects
+ public $table_element='c_country'; //!< Name of table without prefix where object is stored
/**
* @var int ID
@@ -65,7 +65,9 @@ class Ccountry // extends CommonObject
public $active;
-
+ public $fields=array(
+ 'label' => array('type'=>'varchar(250)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>15, 'notnull'=>-1, 'showoncombobox'=>'1')
+ );
/**
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index f989f0bb431..e6d47c53d5f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -10,8 +10,8 @@
* Copyright (C) 2015 Alexandre Spangaro
* Copyright (C) 2016 Bahfir abbes
* Copyright (C) 2017 ATM Consulting
- * Copyright (C) 2017 Nicolas ZABOURI
- * Copyright (C) 2017 Rui Strecht
+ * Copyright (C) 2017-2019 Nicolas ZABOURI
+ * Copyright (C) 2017 Rui Strecht
* Copyright (C) 2018 Frédéric France
* Copyright (C) 2018 Josep Lluís Amador
*
@@ -53,6 +53,7 @@ abstract class CommonObject
/**
* @var string Error string
+ * @see $errors
*/
public $error;
@@ -391,7 +392,7 @@ abstract class CommonObject
* @var string
* @see SetIncoterms()
*/
- public $libelle_incoterms;
+ public $label_incoterms;
/**
* @var string
@@ -2053,6 +2054,44 @@ abstract class CommonObject
}
}
+
+ /**
+ * Change the retained warranty payments terms
+ *
+ * @param int $id Id of new payment terms
+ * @return int >0 if OK, <0 if KO
+ */
+ public function setRetainedWarrantyPaymentTerms($id)
+ {
+ dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms('.$id.')');
+ if ($this->statut >= 0 || $this->element == 'societe')
+ {
+ $fieldname = 'retained_warranty_fk_cond_reglement';
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET '.$fieldname.' = '.$id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ if ($this->db->query($sql))
+ {
+ $this->retained_warranty_fk_cond_reglement = $id;
+ return 1;
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error());
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
+ else
+ {
+ dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible');
+ $this->error='Status of the object is incompatible '.$this->statut;
+ return -2;
+ }
+ }
+
/**
* Define delivery address
* @deprecated
@@ -2443,9 +2482,9 @@ abstract class CommonObject
*/
public function updateRangOfLine($rowid, $rang)
{
- $fieldposition = 'rang'; // @TODO Rename 'rang' and 'position' into 'rank'
+ $fieldposition = 'rang'; // @TODO Rename 'rang' into 'position'
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
- if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'rank';
+ if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'position';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
$sql.= ' WHERE rowid = '.$rowid;
@@ -2749,7 +2788,7 @@ abstract class CommonObject
$MODULE = "";
if ($this->element == 'propal')
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL";
- elseif ($this->element == 'order')
+ elseif ($this->element == 'commande' || $this->element == 'order')
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER";
elseif ($this->element == 'facture')
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE";
@@ -3762,7 +3801,7 @@ abstract class CommonObject
{
// phpcs:enable
$out = '';
- $this->libelle_incoterms = '';
+ $this->label_incoterms = '';
if (!empty($this->fk_incoterms))
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
@@ -3835,7 +3874,7 @@ abstract class CommonObject
if ($res)
{
$obj = $this->db->fetch_object($res);
- $this->libelle_incoterms = $obj->libelle;
+ $this->label_incoterms = $obj->libelle;
}
return 1;
}
@@ -4450,7 +4489,7 @@ abstract class CommonObject
* Common function for all objects extending CommonObject for generating documents
*
* @param string $modelspath Relative folder where generators are placed
- * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example.
+ * @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example.
* @param Translate $outputlangs Output language to use
* @param int $hidedetails 1 to hide details. 0 by default
* @param int $hidedesc 1 to hide product description. 0 by default
@@ -4465,6 +4504,8 @@ abstract class CommonObject
$srctemplatepath='';
+ dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null'));
+
// Increase limit for PDF build
$err=error_reporting();
error_reporting(0);
@@ -4505,7 +4546,7 @@ abstract class CommonObject
// If generator was found
if ($filefound)
{
- global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db
+ global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
require_once $file;
@@ -5006,6 +5047,8 @@ abstract class CommonObject
$attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey];
$attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey];
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey];
+ $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey];
+
if ($attributeRequired)
{
@@ -5023,6 +5066,21 @@ abstract class CommonObject
//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
+ if (!empty($attrfieldcomputed))
+ {
+ if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS))
+ {
+ $value = dol_eval($attrfieldcomputed, 1, 0);
+ dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
+ $new_array_options[$key] = $value;
+ }
+ else
+ {
+ $new_array_options[$key] = null;
+ }
+ }
+
+
switch ($attributeType)
{
case 'int':
@@ -6027,6 +6085,12 @@ abstract class CommonObject
$type='link';
$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
}
+ elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
+ $param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N');
+ $type = 'sellist';
+ }
+
+
$langfile=$val['langfile'];
$list=$val['list'];
$help=$val['help'];
@@ -6048,7 +6112,7 @@ abstract class CommonObject
{
$morecss = 'minwidth100imp';
}
- elseif ($type == 'datetime')
+ elseif ($type == 'datetime' || $type == 'timestamp')
{
$morecss = 'minwidth200imp';
}
@@ -6092,7 +6156,7 @@ abstract class CommonObject
$value='';
}
}
- elseif ($type == 'datetime')
+ elseif ($type == 'datetime' || $type == 'timestamp')
{
if(! empty($value)) {
$value=dol_print_date($value, 'dayhour');
@@ -6362,7 +6426,7 @@ abstract class CommonObject
* @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan)
* @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
- * @param string $onetrtd All fields in same tr td
+ * @param string $onetrtd All fields in same tr td (TODO field not used ?)
* @return string
*/
public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0)
@@ -6379,6 +6443,7 @@ abstract class CommonObject
$out .= ' ';
$out .= "\n";
+ $extrafields_collapse_num = '';
$e = 0;
foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
{
@@ -6438,6 +6503,20 @@ abstract class CommonObject
if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate')
{
+ $extrafields_collapse_num = '';
+ $extrafield_param = $extrafields->attributes[$this->table_element]['param'][$key];
+ if (!empty($extrafield_param) && is_array($extrafield_param)) {
+ $extrafield_param_list = array_keys($extrafield_param['options']);
+
+ if (count($extrafield_param_list)>0) {
+ $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
+
+ if ($extrafield_collapse_display_value==1 || $extrafield_collapse_display_value==2) {
+ $extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key];
+ }
+ }
+ }
+
$out .= $extrafields->showSeparator($key, $this);
}
else
@@ -6457,12 +6536,9 @@ abstract class CommonObject
$html_id = !empty($this->id) ? 'extrarow-'.$this->element.'_'.$key.'_'.$this->id : '';
- $out .= '
';
- if(!empty($compatibleImportElementsList))
+ if (!empty($compatibleImportElementsList))
{
$res=@include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php');
}
@@ -6628,7 +6641,7 @@ class Form
public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
{
global $conf, $langs, $hookmanager;
- global $bc;
+ global $bc, $action;
$linktoelem='';
$linktoelemlist='';
@@ -6659,12 +6672,11 @@ class Form
'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
- 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')')
+ 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled , 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')'),
+ 'ticket'=>array('enabled'=>$conf->ticket->enabled , 'perms'=>1, 'label'=>'LinkToTicket', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('ticket').')')
);
}
- global $action;
-
// Can complete the possiblelink array
$hookmanager->initHooks(array('commonobject'));
$parameters=array('listofidcompanytoscan' => $listofidcompanytoscan);
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 87b32902684..03c70f749d2 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/core/class/html.formaccounting.class.php
- * \ingroup Advanced accountancy
+ * \ingroup Accountancy (Double entries)
* \brief File of class with all html predefined components
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
@@ -392,7 +392,7 @@ class FormAccounting extends Form
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
- if (!empty($obj->code_compta_fournisseur)) {
+ if ($obj->code_compta_fournisseur != "") {
$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
}
}
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 31353ea3d10..bb1cf5fbfe7 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -213,24 +213,22 @@ class FormActions
$page=0; $param='';
- $total = 0;
-
print '
';
print '
';
print '';
- print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
- print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
- print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+ print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+ print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+ print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
- print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
- print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
+ print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
+ print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
print ' ';
print "\n";
- $userstatic = new User($this->db);
-
- if (count($listofactions))
+ if (is_array($listofactions) && count($listofactions))
{
+ $cacheusers=array();
+
$cursorevent = 0;
foreach($listofactions as $action)
{
@@ -246,8 +244,20 @@ class FormActions
print '';
if (! empty($action->userownerid))
{
- $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched
- print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
+ if (is_object($cacheusers[$action->userownerid]))
+ {
+ $tmpuser = $cacheusers[$action->userownerid];
+ }
+ else
+ {
+ $tmpuser = new User($this->db);
+ $tmpuser->fetch($action->userownerid);
+ $cacheusers[$action->userownerid] = $tmpuser;
+ }
+ if ($tmpuser->id > 0)
+ {
+ print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
+ }
}
print ' ';
// Type
@@ -284,10 +294,7 @@ class FormActions
}
print '';
print '';
- if (! empty($action->author->id))
- {
- print $action->getLibStatut(3);
- }
+ print $action->getLibStatut(3);
print ' ';
print '';
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index d2fb93000a9..2207ab8ab2b 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -211,13 +211,13 @@ class FormCompany
* The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
* Thus the links with the departments are done on a department independently of its name.
*
- * @param string $selected Code state preselected (mus be state id)
+ * @param int $selected Code state preselected (mus be state id)
* @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show
* @param string $htmlname Id of department. If '', we want only the string with
* @return string String with HTML select
* @see select_country()
*/
- public function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id')
+ public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id')
{
// phpcs:enable
global $conf,$langs,$user;
@@ -391,7 +391,7 @@ class FormCompany
/**
* Return combo list with people title
*
- * @param string $selected Title preselected
+ * @param string $selected Civility/Title code preselected
* @param string $htmlname Name of HTML select combo field
* @param string $morecss Add more css on SELECT element
* @return string String with HTML select
@@ -908,7 +908,7 @@ class FormCompany
$out = '';
if ($typeinput=='form') {
- if ($selected == '') $out .= ' ';
+ if ($selected == '' || $selected == '-1') $out .= ' ';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$out .= ''.$langs->trans('Prospect').' ';
}
@@ -920,7 +920,7 @@ class FormCompany
}
$out .= ''.$langs->trans('NorProspectNorCustomer').' ';
} elseif ($typeinput=='list') {
- $out .= ' ';
+ $out .= ' ';
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$out .= ''.$langs->trans('Customer').' ';
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index b729ad51fc5..5f63d4db66c 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -130,15 +130,35 @@ class FormFile
$out .= '';
- $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
- $maxphp=@ini_get('upload_max_filesize'); // En inconnu
+ $max=$conf->global->MAIN_UPLOAD_DOC; // In Kb
+ $maxphp=@ini_get('upload_max_filesize'); // In unknown
if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1;
if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024;
if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024;
- // Now $max and $maxphp are in Kb
+ $maxphp2=@ini_get('post_max_size'); // In unknown
+ if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1;
+ if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024;
+ if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024;
+ if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024;
+ // Now $max and $maxphp and $maxphp2 are in Kb
$maxmin = $max;
- if ($maxphp > 0) $maxmin=min($max, $maxphp);
+ $maxphptoshow = $maxphptoshowparam = '';
+ if ($maxphp > 0)
+ {
+ $maxmin=min($max, $maxphp);
+ $maxphptoshow = $maxphp;
+ $maxphptoshowparam = 'upload_max_filesize';
+ }
+ if ($maxphp2 > 0)
+ {
+ $maxmin=min($max, $maxphp2);
+ if ($maxphp2 < $maxphp)
+ {
+ $maxphptoshow = $maxphp2;
+ $maxphptoshowparam = 'post_max_size';
+ }
+ }
if ($maxmin > 0)
{
@@ -168,7 +188,7 @@ class FormFile
{
$langs->load('other');
$out .= ' ';
- $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphp), 1);
+ $out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1);
}
}
else
@@ -1040,9 +1060,9 @@ class FormFile
* @param string $relativepath Relative path of docs (autodefined if not provided), relative to module dir, not to MAIN_DATA_ROOT.
* @param int $permonobject Permission on object (so permission to delete or crop document)
* @param int $useinecm Change output for use in ecm module:
- * 0 or 6: Add a preview column. Show also a rename and crop button.
+ * 0 or 6: Add a preview column. Show also a rename button. Show also a crop button for some values of $modulepart (must be supported into hard coded list in this function + photos_resize.php + restrictedArea + checkUserAccessToObject)
* 1: Add link to edit ECM entry
- * 2: Add rename and crop file
+ * 2: Add rename and crop link
* 4: Add a preview column
* 5: Add link to edit ECM entry and Add a preview column
* @param string $textifempty Text to show if filearray is empty ('NoFileFound' if not defined)
@@ -1068,7 +1088,7 @@ class FormFile
global $form;
$disablecrop=1;
- if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0;
+ if (in_array($modulepart, array('bom','expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0;
// Define relative path used to store the file
if (empty($relativepath))
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index b39c3839c71..b0cdcd23a96 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -394,6 +394,7 @@ class FormMail extends Form
if ($this->param['models'] != 'none')
{
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
+
if ($result < 0)
{
setEventMessages($this->error, $this->errors, 'errors');
@@ -935,7 +936,6 @@ class FormMail extends Form
$defaultmessage=preg_replace("/^( )+/", "", $defaultmessage);
$defaultmessage=preg_replace("/^\n+/", "", $defaultmessage);
}
-
$out.= ' ';
$out.= '';
$out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody');
@@ -1154,6 +1154,12 @@ class FormMail extends Form
return -1;
}
+ $languagetosearch = (is_object($outputlangs) ? $outputlangs->defaultlang : '');
+ // Define $languagetosearchmain to fall back on main language (for example to get 'es_ES' for 'es_MX')
+ $tmparray = explode('_', $languagetosearch);
+ $languagetosearchmain = $tmparray[0].'_'.strtoupper($tmparray[0]);
+ if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = '';
+
$sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
@@ -1161,10 +1167,10 @@ class FormMail extends Form
$sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned
if ($active >= 0) $sql.=" AND active = ".$active;
if ($label) $sql.=" AND label ='".$db->escape($label)."'";
- if (! ($id > 0) && is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')";
+ if (! ($id > 0) && $languagetosearch) $sql.= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
if ($id > 0) $sql.= " AND rowid=".$id;
if ($id == -1) $sql.= " AND position=0";
- if (is_object($outputlangs)) $sql.= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
+ if ($languagetosearch) $sql.= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
else $sql.= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined
$sql.= $db->plimit(1);
//print $sql;
diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php
index f9b0a59280f..ea038fa8131 100644
--- a/htdocs/core/class/html.formmargin.class.php
+++ b/htdocs/core/class/html.formmargin.class.php
@@ -199,8 +199,6 @@ class FormMargin
if (! $user->rights->margins->liretous) return;
- $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
-
$marginInfo = $this->getMarginInfosArray($object, $force_price);
if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
@@ -240,13 +238,13 @@ class FormMargin
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
print ' ';
print ''.$langs->trans('MarginOnProducts').' ';
- print ''.price($marginInfo['pv_products'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['pa_products'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).' ';
+ print ''.price($marginInfo['pv_products']).' ';
+ print ''.price($marginInfo['pa_products']).' ';
+ print ''.price($marginInfo['margin_on_products']).' ';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
- print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').' ';
if (! empty($conf->global->DISPLAY_MARK_RATES))
- print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').' ';
print ' ';
}
@@ -254,13 +252,13 @@ class FormMargin
{
print '';
print ''.$langs->trans('MarginOnServices').' ';
- print ''.price($marginInfo['pv_services'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['pa_services'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).' ';
+ print ''.price($marginInfo['pv_services']).' ';
+ print ''.price($marginInfo['pa_services']).' ';
+ print ''.price($marginInfo['margin_on_services']).' ';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
- print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').' ';
if (! empty($conf->global->DISPLAY_MARK_RATES))
- print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').' ';
print ' ';
}
@@ -268,13 +266,13 @@ class FormMargin
{
print '';
print ''.$langs->trans('TotalMargin').' ';
- print ''.price($marginInfo['pv_total'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['pa_total'], null, null, null, null, $rounding).' ';
- print ''.price($marginInfo['total_margin'], null, null, null, null, $rounding).' ';
+ print ''.price($marginInfo['pv_total']).' ';
+ print ''.price($marginInfo['pa_total']).' ';
+ print ''.price($marginInfo['total_margin']).' ';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
- print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').' ';
if (! empty($conf->global->DISPLAY_MARK_RATES))
- print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').' ';
+ print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').' ';
print ' ';
}
print '
';
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 5b829f95f86..c6a138b2a02 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -393,7 +393,8 @@ class FormOther
public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '')
{
// phpcs:enable
- global $conf,$langs;
+ global $conf, $langs;
+
$langs->load('users');
$out = '';
@@ -415,17 +416,44 @@ class FormOther
// Get list of users allowed to be viewed
$sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u";
- $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")";
+
+ if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
+ {
+ if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
+ $sql_usr.= " WHERE u.entity IS NOT NULL"; // Show all users
+ } else {
+ $sql_usr.= " WHERE EXISTS (SELECT ug.fk_user FROM ".MAIN_DB_PREFIX."usergroup_user as ug WHERE u.rowid = ug.fk_user AND ug.entity IN (".getEntity('usergroup')."))";
+ $sql_usr.= " OR u.entity = 0"; // Show always superadmin
+ }
+ }
+ else
+ {
+ $sql_usr.= " WHERE u.entity IN (".getEntity('user').")";
+ }
+
if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.rowid = ".$user->id;
- if (! empty($user->societe_id)) $sql_usr.=" AND u.fk_soc = ".$user->societe_id;
+ if (! empty($user->socid)) $sql_usr.=" AND u.fk_soc = ".$user->socid;
// Add existing sales representatives of thirdparty of external user
- if (empty($user->rights->user->user->lire) && $user->societe_id)
+ if (empty($user->rights->user->user->lire) && $user->socid)
{
$sql_usr.=" UNION ";
$sql_usr.= "SELECT u2.rowid, u2.lastname, u2.firstname, u2.statut, u2.login";
$sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql_usr.= " WHERE u2.entity IN (0,".$conf->entity.")";
- $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->societe_id;
+
+ if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
+ {
+ if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
+ $sql_usr.= " WHERE u2.entity IS NOT NULL"; // Show all users
+ } else {
+ $sql_usr.= " WHERE EXISTS (SELECT ug2.fk_user FROM ".MAIN_DB_PREFIX."usergroup_user as ug2 WHERE u2.rowid = ug2.fk_user AND ug2.entity IN (".getEntity('usergroup')."))";
+ }
+ }
+ else
+ {
+ $sql_usr.= " WHERE u2.entity IN (".getEntity('user').")";
+ }
+
+ $sql_usr.= " AND u2.rowid = sc.fk_user AND sc.fk_soc=".$user->socid;
}
$sql_usr.= " ORDER BY statut DESC, lastname ASC"; // Do not use 'ORDER BY u.statut' here, not compatible with the UNION.
//print $sql_usr;exit;
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index b4c0c4295c9..8e01e93b66e 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -60,7 +60,7 @@ class FormProjets
* @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
- * @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable)
+ * @param int $discard_closed Discard closed projects (0=Keep, 1=hide completely, 2=Disable). Use a negative value to not show the "discarded" tooltip.
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @param int $mode 0 for HTML mode and 1 for JSON mode
@@ -100,13 +100,13 @@ class FormProjets
}
else
{
- $out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
+ $out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
}
- if ($discard_closed)
+ if ($discard_closed > 0)
{
if (class_exists('Form'))
{
- if (empty($form)) $form=new Form($this->db);
+ if (! is_object($form)) $form=new Form($this->db);
$out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
}
}
@@ -367,7 +367,7 @@ class FormProjets
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out.=$comboenhancement;
- $morecss='minwidth200 maxwidth500';
+ $morecss='minwidth200imp maxwidth500';
}
if (empty($option_only)) {
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index 1d681d2672b..a7797f91833 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -419,7 +419,7 @@ class FormTicket
if ($withdolfichehead) dol_fiche_end();
- print '
';
+ print '';
print ' ';
if ($this->withcancel) {
@@ -733,40 +733,97 @@ class FormTicket
print ajax_combobox('select'.$htmlname);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Clear list of attached files in send mail form (also stored in session)
+ *
+ * @return void
+ */
+ public function clear_attached_files()
+ {
+ // phpcs:enable
+ global $conf,$user;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ // Set tmp user directory
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
+ if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
+
+ $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
+ unset($_SESSION["listofpaths".$keytoavoidconflict]);
+ unset($_SESSION["listofnames".$keytoavoidconflict]);
+ unset($_SESSION["listofmimes".$keytoavoidconflict]);
+ }
+
/**
* Show the form to add message on ticket
*
- * @param string $width Width of form
- * @return void
+ * @param string $width Width of form
+ * @return void
*/
public function showMessageForm($width = '40%')
{
- global $conf, $langs, $user, $mysoc;
+ global $conf, $langs, $user, $hookmanager, $form, $mysoc;
+
+ $formmail = new FormMail($this->db);
+ $addfileaction = 'addfile';
+
+ if (! is_object($form)) $form=new Form($this->db);
// Load translation files required by the page
$langs->loadLangs(array('other', 'mails'));
- $addfileaction = 'addfile';
+ // Clear temp files. Must be done at beginning, before call of triggers
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
+ {
+ $this->clear_attached_files();
+ }
- $form = new Form($this->db);
- $formmail = new FormMail($this->db);
+ // Define output language
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->load('other');
+ }
+ // Get message template for $this->param["models"] into c_email_templates
+ $arraydefaultmessage = -1;
+ if ($this->param['models'] != 'none')
+ {
+ $model_id=0;
+ if (array_key_exists('models_id', $this->param))
+ {
+ $model_id=$this->param["models_id"];
+ }
+
+ $arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one
+ }
// Define list of attached files
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
- if (!empty($_SESSION["listofpaths"])) {
- $listofpaths = explode(';', $_SESSION["listofpaths"]);
+ $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
+
+ if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
+ {
+ if (! empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
+ {
+ foreach($this->param['fileinit'] as $file)
+ {
+ $this->add_attached_files($file, basename($file), dol_mimetype($file));
+ }
+ }
}
- if (!empty($_SESSION["listofnames"])) {
- $listofnames = explode(';', $_SESSION["listofnames"]);
- }
-
- if (!empty($_SESSION["listofmimes"])) {
- $listofmimes = explode(';', $_SESSION["listofmimes"]);
- }
+ if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
+ if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
+ if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
// Define output language
$outputlangs = $langs;
@@ -808,6 +865,7 @@ class FormTicket
print '';
print ' ';
print ' ';
+ print ' ';
foreach ($this->param as $key => $value) {
print ' ';
}
@@ -1000,7 +1058,7 @@ class FormTicket
$out .= '';
$out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key];
if (!$this->withfilereadonly) {
- $out .= ' ';
+ $out .= ' ';
}
$out .= '
';
}
diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php
index d1d7534af23..26f96b93ec5 100644
--- a/htdocs/core/class/menubase.class.php
+++ b/htdocs/core/class/menubase.class.php
@@ -422,7 +422,8 @@ class Menubase
$this->position='';
$this->url='http://dummy';
$this->target='';
- $this->titre='Specimen menu';
+ $this->titre='Specimen menu'; // deprecated
+ $this->title='Specimen menu';
$this->langs='';
$this->level='';
$this->leftmenu='';
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index 08025161a0d..8df81bd4495 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -39,10 +39,12 @@ abstract class Stats
* @param int $endyear Start year
* @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
- * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
- * @return array Array of values
+ * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
+ * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
+ * @return array Array of values
+
*/
- public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0)
+ public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{
global $conf,$user,$langs;
@@ -86,6 +88,8 @@ abstract class Stats
else
{
$year=$startyear;
+ $sm = $startmonth - 1;
+ if ($sm != 0) $year = $year - 1;
while ($year <= $endyear)
{
$datay[$year] = $this->getNbByMonth($year, $format);
@@ -96,11 +100,11 @@ abstract class Stats
for ($i = 0 ; $i < 12 ; $i++)
{
- $data[$i][]=$datay[$endyear][$i][0];
+ $data[$i][]=$datay[$endyear][($i+$sm)%12][0];
$year=$startyear;
while($year <= $endyear)
{
- $data[$i][]=$datay[$year][$i][1];
+ $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1];
$year++;
}
}
@@ -134,9 +138,10 @@ abstract class Stats
* @param int $startyear End year
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
+ * @param int $startmonth month of the fiscal year start min 1 max 12 ; if 1 = january
* @return array Array of values
*/
- public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0)
+ public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0, $startmonth = 1)
{
global $conf,$user,$langs;
@@ -181,6 +186,8 @@ abstract class Stats
else
{
$year=$startyear;
+ $sm = $startmonth - 1;
+ if ($sm != 0) $year = $year - 1;
while($year <= $endyear)
{
$datay[$year] = $this->getAmountByMonth($year, $format);
@@ -191,11 +198,11 @@ abstract class Stats
// $data = array('xval'=>array(0=>xlabel,1=>yval1,2=>yval2...),...)
for ($i = 0 ; $i < 12 ; $i++)
{
- $data[$i][]=$datay[$endyear][$i][0]; // set label
+ $data[$i][]=$datay[$endyear][($i+$sm)%12][0]; // set label
$year=$startyear;
while($year <= $endyear)
{
- $data[$i][]=$datay[$year][$i][1]; // set yval for x=i
+ $data[$i][]=$datay[$year - (1 - ((int) ($i+$sm)/12)) + ($sm == 0 ? 1 : 0)][($i+$sm)%12][1]; // set yval for x=i
$year++;
}
}
@@ -411,7 +418,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
- * Renvoie le nombre de proposition par mois pour une annee donnee
+ * Renvoie le nombre de documents par mois pour une annee donnee
+ * Return number of documents per month for a given year
*
* @param int $year Year
* @param string $sql SQL
@@ -470,7 +478,8 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
- * Renvoie le nombre d'element par mois pour une annee donnee
+ * Renvoie le montant totalise par mois pour une annee donnee
+ * Return the amount per month for a given year
*
* @param int $year Year
* @param string $sql SQL
@@ -527,6 +536,7 @@ abstract class Stats
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Renvoie le montant moyen par mois pour une annee donnee
+ * Return the amount average par month for a given year
*
* @param int $year Year
* @param string $sql SQL
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index 9e0063ac414..f86d6570e5c 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -50,33 +50,36 @@ class Utils
* Purge files into directory of data files.
* CAN BE A CRON TASK
*
- * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile')
- * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
+ * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than $nbsecondsold seconds, 'allfiles', 'logfile')
+ * @param int $nbsecondsold Nb of seconds old to accept deletion of a directory if $choice is 'tempfilesold'
+ * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
*/
- public function purgeFiles($choice = 'tempfilesold')
+ public function purgeFiles($choice = 'tempfilesold', $nbsecondsold = 86400)
{
global $conf, $langs, $dolibarr_main_data_root;
$langs->load("admin");
- dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG);
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$filesarray=array();
if (empty($choice)) $choice='tempfilesold';
+ dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG);
+
if ($choice=='tempfiles' || $choice=='tempfilesold')
{
// Delete temporary files
if ($dolibarr_main_data_root)
{
- $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks
- if ($choice == 'tempfilesold')
+ $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks
+
+ if ($choice == 'tempfilesold')
{
$now = dol_now();
foreach($filesarray as $key => $val)
{
- if ($val['date'] > ($now - (24 * 3600))) unset($filesarray[$key]); // Discard files not older than 24h
+ if ($val['date'] > ($now - ($nbsecondsold))) unset($filesarray[$key]); // Discard temp dir not older than $nbsecondsold
}
}
}
@@ -119,13 +122,14 @@ class Utils
$counterror=0;
if (count($filesarray))
{
- foreach($filesarray as $key => $value)
+ foreach($filesarray as $key => $value)
{
//print "x ".$filesarray[$key]['fullname']."-".$filesarray[$key]['type']." \n";
- if ($filesarray[$key]['type'] == 'dir')
+ if ($filesarray[$key]['type'] == 'dir')
{
$startcount=0;
$tmpcountdeleted=0;
+
$result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted);
$count+=$result;
$countdeleted+=$tmpcountdeleted;
@@ -165,6 +169,13 @@ class Utils
}
else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':'');
+ // Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them
+ if (! empty($conf->api->enabled))
+ {
+ dol_mkdir($conf->api->dir_temp);
+ }
+ dol_mkdir($conf->user->dir_temp);
+
//return $count;
return 0; // This function can be called by cron so must return 0 if OK
}
diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php
index 75a6fa14ec1..55e7fe27b0b 100644
--- a/htdocs/core/db/Database.interface.php
+++ b/htdocs/core/db/Database.interface.php
@@ -101,11 +101,11 @@ interface Database
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
+ * Return the number of lines in the result of a request INSERT, DELETE or UPDATE
*
* @param resource $resultset Curseur de la requete voulue
- * @return int Nombre de lignes
- * @see num_rows
+ * @return int Number of lines
+ * @see num_rows()
*/
public function affected_rows($resultset);
// phpcs:enable
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index b05f118b08b..3819e785f68 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -160,10 +160,10 @@ abstract class DoliDB implements Database
}
/**
- * Annulation d'une transaction et retour aux anciennes valeurs
+ * Cancel a transaction and go back to initial data values
*
* @param string $log Add more log to default log line
- * @return resource|int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
+ * @return resource|int 1 if cancelation is ok or transaction not open, 0 if error
*/
public function rollback($log = '')
{
diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php
index efffd5059c6..d8261b8034e 100644
--- a/htdocs/core/db/mssql.class.php
+++ b/htdocs/core/db/mssql.class.php
@@ -523,10 +523,10 @@ class DoliDBMssql extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
+ * Return the number of lines in the result of a request INSERT, DELETE or UPDATE
*
* @param resource $resultset Curseur de la requete voulue
- * @return int Nombre de lignes
+ * @return int Number of lines
* @see num_rows()
*/
public function affected_rows($resultset)
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index 98f2e5c5a1b..96763077e66 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -363,10 +363,10 @@ class DoliDBMysqli extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
+ * Return the number of lines in the result of a request INSERT, DELETE or UPDATE
*
* @param mysqli_result $resultset Curseur de la requete voulue
- * @return int Nombre de lignes
+ * @return int Number of lines
* @see num_rows()
*/
public function affected_rows($resultset)
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 2777f2d0365..250429ce422 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -617,11 +617,11 @@ class DoliDBPgsql extends DoliDB
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
+ * Return the number of lines in the result of a request INSERT, DELETE or UPDATE
*
* @param resource $resultset Result set of request
* @return int Nb of lines
- * @see num_rows
+ * @see num_rows()
*/
public function affected_rows($resultset)
{
diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php
index b7d06870ff5..360b72f80d9 100644
--- a/htdocs/core/db/sqlite3.class.php
+++ b/htdocs/core/db/sqlite3.class.php
@@ -403,9 +403,13 @@ class DoliDBSqlite3 extends DoliDB
*/
public function query($query, $usesavepoint = 0, $type = 'auto')
{
+ global $conf;
+
$ret=null;
+
$query = trim($query);
- $this->error = 0;
+
+ $this->error = '';
// Convert MySQL syntax to SQLite syntax
if (preg_match('/ALTER\s+TABLE\s*(.*)\s*ADD\s+CONSTRAINT\s+(.*)\s*FOREIGN\s+KEY\s*\(([\w,\s]+)\)\s*REFERENCES\s+(\w+)\s*\(([\w,\s]+)\)/i', $query, $reg)) {
@@ -449,7 +453,8 @@ class DoliDBSqlite3 extends DoliDB
}
//print "After convertSQLFromMysql:\n".$query." \n";
- dol_syslog('sql='.$query, LOG_DEBUG);
+ if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG);
+ if (empty($query)) return false; // Return false = error if empty request
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
try {
@@ -481,7 +486,8 @@ class DoliDBSqlite3 extends DoliDB
$errormsg .= ' ('.$this->lasterrno.')';
}
- dol_syslog($errormsg, LOG_ERR);
+ if ($conf->global->SYSLOG_LEVEL < LOG_DEBUG) dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); // Log of request was not yet done previously
+ dol_syslog(get_class($this)."::query SQL Error message: ".$errormsg, LOG_ERR);
}
$this->lastquery=$query;
$this->_results = $ret;
diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php
index 13b2d1ae520..78dbba9934e 100644
--- a/htdocs/core/extrafieldsinexport.inc.php
+++ b/htdocs/core/extrafieldsinexport.inc.php
@@ -34,6 +34,15 @@ if ($resql) // This can fail when class is used on old database (during migra
case 'boolean':
$typeFilter="Boolean";
break;
+ case 'select':
+ if (! empty($conf->global->EXPORT_LABEL_FOR_SELECT))
+ {
+ $tmpparam=unserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...)
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) {
+ $typeFilter="Select:".$obj->param;
+ }
+ }
+ break;
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php
index 14c69259b98..79ad6d19115 100644
--- a/htdocs/core/js/lib_foot.js.php
+++ b/htdocs/core/js/lib_foot.js.php
@@ -148,6 +148,7 @@ print '
/* Set handler to add page_y param on output (click on href links or submit button) */
jQuery(".reposition").click(function() {
var page_y = $(document).scrollTop();
+
if (page_y > 0)
{
if (this.href)
@@ -157,7 +158,7 @@ print '
}
else
{
- console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y);
+ console.log("We click on tag with .reposition class but element is not an html tag, so we try to update input form field page_y with value "+page_y);
jQuery("input[type=hidden][name=page_y]").val(page_y);
}
}
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index 889d9da8a2c..1de902d1f1d 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2017 Alexandre Spangaro
* Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2019 Eric Seigne
*
* 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
@@ -19,10 +20,28 @@
/**
* \file htdocs/core/lib/accounting.lib.php
- * \ingroup Advanced accountancy
+ * \ingroup Accountancy (Double entries)
* \brief Library of accountancy functions
*/
+
+/**
+ * Check if a value is empty with some options
+ *
+ * @author Michael - https://www.php.net/manual/fr/function.empty.php#90767
+ * @param mixed $var Value to test
+ * @param int|null $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default.
+ * @param int|null $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default.
+ * @return boolean True of False
+ */
+function is_empty($var, $allow_false = false, $allow_ws = false)
+{
+ if (!isset($var) || is_null($var) || ($allow_ws == false && trim($var) == "" && !is_bool($var)) || ($allow_false === false && is_bool($var) && $var === false) || (is_array($var) && empty($var))) {
+ return true;
+ }
+ return false;
+}
+
/**
* Prepare array with list of tabs
*
@@ -75,12 +94,12 @@ function length_accountg($account)
{
global $conf;
- if ($account < 0 || empty($account)) return '';
+ if ($account < 0 || is_empty($account)) return '';
- if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
+ if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
- if (! empty($g)) {
+ if (! is_empty($g)) {
// Clean parameters
$i = strlen($account);
@@ -110,12 +129,12 @@ function length_accounta($accounta)
{
global $conf;
- if ($accounta < 0 || empty($accounta)) return '';
+ if ($accounta < 0 || is_empty($accounta)) return '';
- if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
+ if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
- if (! empty($a)) {
+ if (! is_empty($a)) {
// Clean parameters
$i = strlen($accounta);
@@ -156,9 +175,9 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build
{
global $langs;
- print "\n\n\n";
+ print "\n\n\n";
- if(! empty($varlink)) $varlink = '?'.$varlink;
+ if(! is_empty($varlink)) $varlink = '?'.$varlink;
$head=array();
$h=0;
@@ -167,6 +186,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build
$head[$h][2] = 'journal';
print '';
+ print ' ';
dol_fiche_head($head, 'journal');
@@ -221,5 +241,5 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build
print ' ';
- print "\n\n\n";
+ print "\n\n\n";
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index a96e63a4f43..43f4723d695 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -538,11 +538,12 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
}
/**
- * On/off button for object
+ * On/off button to change status of an object
+ * This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php
*
* @param Object $object Object to set
* @param string $code Name of constant : status or status_buy for product by example
- * @param string $field Name of database field : tosell or tobuy for product by example
+ * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example
* @param string $text_on Text if on
* @param string $text_off Text if off
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 99344b12dc1..58e411a0bdf 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -649,6 +649,8 @@ function getFormeJuridiqueLabel($code)
*/
function getCountriesInEEC()
{
+ global $conf;
+
// List of all country codes that are in europe for european vat rules
// List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
$country_code_in_EEC=array(
@@ -687,6 +689,12 @@ function getCountriesInEEC()
//'CH', // Switzerland - No. Swizerland in not in EEC
);
+ if (! empty($conf->global->MAIN_COUNTRIES_IN_EEC))
+ {
+ // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK'
+ $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC);
+ }
+
return $country_code_in_EEC;
}
@@ -1188,7 +1196,8 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
}
/**
- * Show html area with actions (done or not, ignore the name of function)
+ * Show html area with actions (done or not, ignore the name of function).
+ * Note: Global parameter $param must be defined.
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
@@ -1208,7 +1217,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
global $user, $conf;
global $form;
- global $param;
+ global $param, $massactionbutton;
dol_include_once('/comm/action/class/actioncomm.class.php');
@@ -1251,6 +1260,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref";
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref";
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", o.ref";
+ elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", o.ref";
+ elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", o.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
@@ -1273,6 +1284,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o";
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o";
+ elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql.= ", ".MAIN_DB_PREFIX."bom_bom as o";
+ elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql.= ", ".MAIN_DB_PREFIX."contrat as o";
$sql.= " WHERE a.entity IN (".getEntity('agenda').")";
if ($force_filter_contact === false) {
@@ -1298,6 +1311,16 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
}
+ elseif (is_object($filterobj) && get_class($filterobj) == 'BOM')
+ {
+ $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
+ if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
+ }
+ elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat')
+ {
+ $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
+ if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
+ }
}
// Condition on actioncode
@@ -1352,6 +1375,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
} elseif (empty($sql) && !empty($sql2)) {
$sql = $sql2;
}
+
//TODO Add limit in nb of results
$sql.= $db->order($sortfield_new, $sortorder);
dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
@@ -1505,7 +1529,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
$out.=getTitleFieldOfList($langs->trans("Type"));
$out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder);
- $out.=getTitleFieldOfList('');
+ $out.=getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder);
$out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php
index 0583fa4f365..d1a4a07689e 100644
--- a/htdocs/core/lib/contract.lib.php
+++ b/htdocs/core/lib/contract.lib.php
@@ -30,8 +30,8 @@
*/
function contract_prepare_head(Contrat $object)
{
- global $db, $langs, $conf;
-
+ global $db, $langs, $conf, $user;
+
$h = 0;
$head = array();
@@ -79,9 +79,14 @@ function contract_prepare_head(Contrat $object)
$head[$h][2] = 'documents';
$h++;
- $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Info");
- $head[$h][2] = 'info';
+ $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id;
+ $head[$h][1].= $langs->trans("Events");
+ if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
+ {
+ $head[$h][1].= '/';
+ $head[$h][1].= $langs->trans("Agenda");
+ }
+ $head[$h][2] = 'agenda';
$h++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract', 'remove');
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index f4a25334e00..92b739b3190 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -555,6 +555,7 @@ function dol_count_nb_of_line($file)
*
* @param string $pathoffile Path of file
* @return integer File size
+ * @see dol_print_size()
*/
function dol_filesize($pathoffile)
{
@@ -1435,16 +1436,16 @@ function dol_meta_create($object)
if (is_dir($dir))
{
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$client = $object->thirdparty->name . " " . $object->thirdparty->address . " " . $object->thirdparty->zip . " " . $object->thirdparty->town;
$meta = "REFERENCE=\"" . $object->ref . "\"
DATE=\"" . dol_print_date($object->date, '') . "\"
- NB_ITEMS=\"" . $nblignes . "\"
+ NB_ITEMS=\"" . $nblines . "\"
CLIENT=\"" . $client . "\"
AMOUNT_EXCL_TAX=\"" . $object->total_ht . "\"
AMOUNT=\"" . $object->total_ttc . "\"\n";
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
//Pour les articles
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\"
@@ -1559,6 +1560,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
$info = pathinfo($destfile);
$destfile = dol_sanitizeFileName($info['filename'].($info['extension']!='' ? ('.'.strtolower($info['extension'])) : ''));
+
// We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because
// this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call).
$destfile = dol_string_nohtmltag($destfile);
@@ -2163,6 +2165,12 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file)));
$original_file=$dolibarr_main_data_root.'/'.$original_file;
}
+ // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log
+ elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root))
+ {
+ $accessallowed=($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file)));
+ $original_file=$dolibarr_main_data_root.'/doctemplates/websites/'.$original_file;
+ }
// Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip
elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root))
{
@@ -2568,7 +2576,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$accessallowed=1;
}
$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
- $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='".$db->escape($refname)."' AND entity=".$conf->entity;
+ $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
// Wrapping pour les rapport de paiements
elseif ($modulepart == 'supplier_payment')
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index a25fd098f9a..e34c3e3b7b5 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1330,10 +1330,10 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$nophoto='';
$morehtmlleft.='
';
}
- //elseif ($conf->browser->layout != 'phone') { // Show no photo link
+ else { // Show no photo link
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.=' ';
- //}
+ }
}
}
elseif ($object->element == 'ticket')
@@ -1349,10 +1349,10 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$nophoto='';
$morehtmlleft.='
';
}
- //elseif ($conf->browser->layout != 'phone') { // Show no photo link
- $nophoto='/public/theme/common/nophoto.png';
- $morehtmlleft.=' ';
- //}
+ else { // Show no photo link
+ $nophoto='/public/theme/common/nophoto.png';
+ $morehtmlleft.=' ';
+ }
}
}
else
@@ -2447,6 +2447,13 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
$newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
}
}
+ elseif (strtoupper($countrycode) == "JM")
+ {//Jamaïque
+ if(dol_strlen($newphone) == 12)
+ {//ex: +1867_ABC_DEFG
+ $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
+ }
+ }
elseif (strtoupper($countrycode) == "MG")
{//Madagascar
if(dol_strlen($phone) == 13)
@@ -2935,22 +2942,23 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
/**
* Show picto whatever it's its name (generic function)
*
- * @param string $titlealt Text on title tag for tooltip. Not used if param notitle is set to 1.
- * @param string $picto Name of image file to show ('filenew', ...)
- * If no extension provided, we use '.png'. Image must be stored into theme/xxx/img directory.
- * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img
- * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img
- * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
- * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"')
- * @param boolean|int $pictoisfullpath If true or 1, image path is a full path
- * @param int $srconly Return only content of the src attribute of img.
- * @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip.
- * @param string $alt Force alt for bind people
- * @param string $morecss Add more class css on img tag (For example 'myclascss'). Work only if $moreatt is empty.
- * @return string Return img tag
+ * @param string $titlealt Text on title tag for tooltip. Not used if param notitle is set to 1.
+ * @param string $picto Name of image file to show ('filenew', ...)
+ * If no extension provided, we use '.png'. Image must be stored into theme/xxx/img directory.
+ * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img
+ * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img
+ * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
+ * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"')
+ * @param boolean|int $pictoisfullpath If true or 1, image path is a full path
+ * @param int $srconly Return only content of the src attribute of img.
+ * @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip.
+ * @param string $alt Force alt for bind people
+ * @param string $morecss Add more class css on img tag (For example 'myclascss'). Work only if $moreatt is empty.
+ * @param string $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left maring on picto, 0 = No margin left. Works for fontawesome picto only.
+ * @return string Return img tag
* @see img_object(), img_picto_common()
*/
-function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '')
+function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '', $marginleftonlyshort = 2)
{
global $conf, $langs;
@@ -2986,7 +2994,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fa='fas';
$fakey = $pictowithoutext;
$facolor = ''; $fasize = '';
- $marginleftonlyshort = 2;
+
if ($pictowithoutext == 'setup') {
$fakey = 'fa-cog';
$fasize = '1.4em';
@@ -4399,7 +4407,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
{
if ($currency_code == 'auto') $currency_code=$conf->currency;
- $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY');
+ $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD');
$listoflanguagesbefore=array('nl_NL');
if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore))
{
@@ -5260,7 +5268,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
// Here, object->id, object->ref and modulepart are required.
//var_dump($modulepart);
if (in_array($modulepart, array('thirdparty','contact','member','propal','proposal','commande','order','facture','invoice',
- 'supplier_order','supplier_proposal','shipment','contract','expensereport')))
+ 'supplier_order','supplier_proposal','shipment','contract','expensereport','ficheinter')))
{
$path=($object->ref?$object->ref:$object->id);
}
@@ -6553,10 +6561,17 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o
$newmesgarray=array();
foreach($mesgarray as $val)
{
- $tmpmesgstring=preg_replace('/<\/div>/', '
', $val);
- $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring);
- $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring);
- $newmesgarray[]=$tmpmesgstring;
+ if (is_string($val))
+ {
+ $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val);
+ $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring);
+ $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring);
+ $newmesgarray[]=$tmpmesgstring;
+ }
+ else
+ {
+ dol_syslog("Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
+ }
}
$mesgarray=$newmesgarray;
}
@@ -7037,7 +7052,7 @@ function getLanguageCodeFromCountryCode($countrycode)
$buildprimarykeytotest = strtolower($countrycode).'-'.strtoupper($countrycode);
if (in_array($buildprimarykeytotest, $locales)) return strtolower($countrycode).'_'.strtoupper($countrycode);
- if (function_exists('locale_get_primary_language')) // Need extension php-intl
+ if (function_exists('locale_get_primary_language') && function_exists('locale_get_region')) // Need extension php-intl
{
foreach ($locales as $locale)
{
@@ -8123,14 +8138,22 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
$attr['href'] = '';
}
- if(empty($id)){
+ if(!empty($id)){
$attr['id'] = $id;
}
// Override attr
if(!empty($params['attr']) && is_array($params['attr'])){
foreach($params['attr'] as $key => $value){
- $attr[$key] = $value;
+ if($key == 'class'){
+ $attr['class'].= ' '.$value;
+ }
+ elseif($key == 'classOverride'){
+ $attr['class'] = $value;
+ }
+ else{
+ $attr[$key] = $value;
+ }
}
}
@@ -8202,10 +8225,10 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
$attr['href'] = '';
- if($status == -1){ // Not enough permissions
+ if($status == -1){ // disable
$attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("FeatureDisabled"));
}
- elseif($status == 0){ // disable
+ elseif($status == 0){ // Not enough permissions
$attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions"));
}
}
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index a315747b8f6..b4c8f6bf011 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -576,6 +576,7 @@ function isValidVATID($company)
{
$vatprefix = $company->country_code;
if ($vatprefix == 'GR') $vatprefix = '(EL|GR)';
+ elseif ($vatprefix == 'MC') $vatprefix = 'FR'; // Monaco is using french VAT numbers
else $vatprefix = preg_quote($vatprefix, '/');
if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,14}$/i', str_replace(' ', '', $company->tva_intra)))
{
@@ -739,8 +740,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
global $conf,$user;
if (! is_object($objsoc)) $valueforccc=$objsoc;
- elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur;
- else $valueforccc=$objsoc->code_client;
+ elseif ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=dol_string_unaccent($objsoc->code_fournisseur);
+ else $valueforccc=dol_string_unaccent($objsoc->code_client);
$sharetable = $table;
if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function
@@ -988,6 +989,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
// Define $maskLike
$maskLike = dol_string_nospecial($mask);
$maskLike = str_replace("%", "_", $maskLike);
+
// Replace protected special codes with matching number of _ as wild card caracter
$maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike);
$maskLike = preg_replace('/\{yy\}/i', '__', $maskLike);
@@ -1163,7 +1165,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
// Now we replace the refclient
if ($maskrefclient)
{
- //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n
";
+ //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode." maskrefclient_clientcode=".$maskrefclient_clientcode."\n
";exit;
$maskrefclient_maskbefore='{'.$maskrefclient.'}';
$maskrefclient_maskafter=$maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT);
$numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal);
diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php
index 714bc26b7da..83e483b3e97 100644
--- a/htdocs/core/lib/geturl.lib.php
+++ b/htdocs/core/lib/geturl.lib.php
@@ -172,14 +172,21 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
* For example: https://www.abc.mydomain.com/dir/page.html return 'mydomain'
*
* @param string $url Full URL.
- * @param int $mode 0=return 'mydomain', 1=return 'mydomain.com'
+ * @param int $mode 0=return 'mydomain', 1=return 'mydomain.com', 2=return 'abc.mydomain.com'
* @return string Returns domaine name
*/
function getDomainFromURL($url, $mode = 0)
{
$tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s)://
$tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain
- $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part www.abc before domain name
+ if ($mode == 2)
+ {
+ $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com'
+ }
+ else
+ {
+ $tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com'
+ }
if (empty($mode))
{
$tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...)
diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php
index 50723ee5249..f64054dde30 100644
--- a/htdocs/core/lib/hrm.lib.php
+++ b/htdocs/core/lib/hrm.lib.php
@@ -20,7 +20,6 @@
* \ingroup HRM
* \brief Library for hrm
*/
-$langs->load('hrm');
/**
* Return head table for establishment tabs screen
@@ -32,6 +31,8 @@ function establishment_prepare_head($object)
{
global $langs, $conf;
+ $langs->load('hrm');
+
$h = 0;
$head = array();
@@ -65,6 +66,8 @@ function hrm_admin_prepare_head()
{
global $langs, $conf, $user;
+ $langs->load('hrm');
+
$h = 0;
$head = array();
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 9495a13edde..b3d518eb088 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -136,7 +136,14 @@ function invoice_admin_prepare_head()
$head[$h][1] = $langs->trans("Payments");
$head[$h][2] = 'payment';
$h++;
-
+
+ if($conf->global->INVOICE_USE_SITUATION){
+ $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
+ $head[$h][1] = $langs->trans("InvoiceSituation");
+ $head[$h][2] = 'situation';
+ $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
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 14c0435b4ad..ba42ebd23d8 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -36,25 +36,31 @@
/**
* Return array with format properties of default PDF format
*
- * @param Translate $outputlangs Output lang to use to autodetect output format if setup not done
+ * @param Translate $outputlangs Output lang to use to autodetect output format if we need 'auto' detection
+ * @param string $mode 'setup' = Use setup, 'auto' = Force autodetection whatever is setup
* @return array Array('width'=>w,'height'=>h,'unit'=>u);
*/
-function pdf_getFormat(Translate $outputlangs = null)
+function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup')
{
- global $conf,$db;
+ global $conf, $db, $langs;
+
+ dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT)?'null':$conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null'));
// Default value if setup was not done and/or entry into c_paper_format not defined
$width=210; $height=297; $unit='mm';
- if (empty($conf->global->MAIN_PDF_FORMAT))
+ if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto')
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$pdfformat=dol_getDefaultFormat($outputlangs);
}
- else $pdfformat=$conf->global->MAIN_PDF_FORMAT;
+ else
+ {
+ $pdfformat=$conf->global->MAIN_PDF_FORMAT;
+ }
$sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
- $sql.=" WHERE code = '".$pdfformat."'";
+ $sql.=" WHERE code = '".$db->escape($pdfformat)."'";
$resql=$db->query($sql);
if ($resql)
{
@@ -175,18 +181,29 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P')
/**
* Return if pdf file is protected/encrypted
*
- * @param TCPDF $pdf PDF initialized object
* @param string $pathoffile Path of file
* @return boolean True or false
*/
-function pdf_getEncryption(&$pdf, $pathoffile)
+function pdf_getEncryption($pathoffile)
{
+ require_once TCPDF_PATH.'tcpdf_parser.php';
+
$isencrypted = false;
- $pdfparser = $pdf->_getPdfParser($pathoffile);
- $data = $pdfparser->getParsedData();
- if (isset($data[0]['trailer'][1]['/Encrypt'])) {
- $isencrypted = true;
+ $content = file_get_contents($pathoffile);
+
+ //ob_start();
+ @($parser = new \TCPDF_PARSER(ltrim($content)));
+ list($xref, $data) = $parser->getParsedData();
+ unset($parser);
+ //ob_end_clean();
+
+ if (isset($xref['trailer']['encrypt'])) {
+ $isencrypted = true; // Secured pdf file are currently not supported
+ }
+
+ if (empty($data)) {
+ $isencrypted = true; // Object list not found. Possible secured file
}
return $isencrypted;
@@ -2028,10 +2045,10 @@ function pdf_getTotalQty($object, $type, $outputlangs)
global $hookmanager;
$total=0;
- $nblignes=count($object->lines);
+ $nblines=count($object->lines);
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->special_code != 3)
{
@@ -2195,3 +2212,49 @@ function pdf_getSizeForImage($realpath)
}
return array('width'=>$width,'height'=>$height);
}
+
+/**
+ * Return line total amount discount
+ *
+ * @param Object $object Object
+ * @param int $i Current line number
+ * @param Translate $outputlangs Object langs for output
+ * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
+ * @return string Return total of line excl tax
+ */
+function pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails = 0)
+{
+ global $conf, $hookmanager;
+ $sign=1;
+ if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+ if ($object->lines[$i]->special_code == 3)
+ {
+ return $outputlangs->transnoentities("Option");
+ }
+ else
+ {
+
+ if (is_object($hookmanager))
+ {
+ $special_code = $object->lines[$i]->special_code;
+ if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
+
+ $parameters = array(
+ 'i'=>$i,
+ 'outputlangs'=>$outputlangs,
+ 'hidedetails'=>$hidedetails,
+ 'special_code'=>$special_code
+ );
+
+ $action='';
+
+ if( $hookmanager->executeHooks('getlinetotalremise', $parameters, $object, $action)>0)
+ {
+ return $hookmanager->resPrint; // Note that $action and $object may have been modified by some hooks
+ }
+ }
+
+ if (empty($hidedetails) || $hidedetails > 1) return $sign * ( ($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht );
+ }
+ return '';
+}
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index c8640f9928f..68a6d9082f2 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -127,7 +127,7 @@ function product_prepare_head($object)
$h++;
}
}
-
+
// Tab to link resources
if (!empty($conf->resource->enabled))
{
@@ -173,7 +173,7 @@ function product_prepare_head($object)
if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
$nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
}
@@ -483,7 +483,7 @@ function show_stats_for_company($product, $socid)
/**
* Return translation label of a unit key
*
- * @param int $unit Unit key (-3,0,3,98,99...)
+ * @param int $unit ID of unit (rowid in llx_c_units table)
* @param string $measuring_style Style of unit: weight, volume,...
* @return string Unit string
* @see formproduct->selectMeasuringUnits
@@ -494,7 +494,7 @@ function measuring_units_string($unit, $measuring_style = '')
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$measuringUnits= new CUnits($db);
$result = $measuringUnits->fetchAll('', '', 0, 0, array(
- 't.code' => $unit,
+ 't.rowid' => $unit,
't.unit_type' => $measuring_style,
't.active' => 1
));
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index efcfeca61dd..a1b93cb0280 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -371,12 +371,14 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$numlines=count($lines);
// We declare counter as global because we want to edit them into recursive call
- global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned,$total_projectlinesa_tobill,$total_projectlinesa_billed;
+ global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned, $total_projectlinesa_declared_if_planned, $total_projectlinesa_tobill, $total_projectlinesa_billed;
+
if ($level == 0)
{
$total_projectlinesa_spent=0;
$total_projectlinesa_planned=0;
$total_projectlinesa_spent_if_planned=0;
+ $total_projectlinesa_declared_if_planned=0;
$total_projectlinesa_tobill=0;
$total_projectlinesa_billed=0;
}
@@ -491,9 +493,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
//else print '
';
for ($k = 0 ; $k < $level ; $k++)
{
- print " ";
+ print '';
}
print $lines[$i]->label;
+ for ($k = 0 ; $k < $level ; $k++)
+ {
+ print '
';
+ }
if ($showlineingray) print '';
//else print ' ';
print "\n";
@@ -624,6 +630,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
$total_projectlinesa_spent += $lines[$i]->duration;
$total_projectlinesa_planned += $lines[$i]->planned_workload;
if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration;
+ if ($lines[$i]->planned_workload) $total_projectlinesa_declared_if_planned += $lines[$i]->planned_workload * $lines[$i]->progress / 100;
}
}
else
@@ -652,7 +659,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
print '
';
if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %';
print ' ';
- print '
';
+ print '
';
+ if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_declared_if_planned / $total_projectlinesa_planned, 2).' %';
+ print ' ';
if ($showbilltime)
{
print '
';
diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php
index 126063dce4d..cb632ab2bfd 100644
--- a/htdocs/core/lib/salaries.lib.php
+++ b/htdocs/core/lib/salaries.lib.php
@@ -1,6 +1,7 @@
+ * Copyright (C) 2015 Charlie BENKE
+ * Copyright (C) 2019 Alexandre Spangaro
*
* 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
@@ -27,15 +28,15 @@
function salaries_prepare_head($object)
{
- global $db, $langs, $conf;
+ global $db, $langs, $conf;
- $h = 0;
- $head = array();
+ $h = 0;
+ $head = array();
- $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Card");
- $head[$h][2] = 'card';
- $h++;
+ $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Card");
+ $head[$h][2] = 'card';
+ $h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
@@ -43,23 +44,56 @@ function salaries_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
- $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+ $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
- $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id;
- $head[$h][1] = $langs->trans('Documents');
- if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).' ';
- $head[$h][2] = 'documents';
- $h++;
+ $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
+ $head[$h][1] = $langs->trans('Documents');
+ if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).' ';
+ $head[$h][2] = 'documents';
+ $h++;
- $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Info");
- $head[$h][2] = 'info';
- $h++;
+ $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Info");
+ $head[$h][2] = 'info';
+ $h++;
- complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
- return $head;
+ return $head;
+}
+
+/**
+ * Return array head with list of tabs to view object informations
+ *
+ * @return array head
+ */
+function salaries_admin_prepare_head()
+{
+ global $langs, $conf, $user;
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
+ $head[$h][1] = $langs->trans("Miscellaneous");
+ $head[$h][2] = 'general';
+ $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, '', $head, $h, 'salaries_admin');
+
+ $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
+ $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
+ $head[$h][2] = 'attributes';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, '', $head, $h, 'salaries_admin', 'remove');
+
+ return $head;
}
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index dcdc70c3fe6..2ee5a45c010 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -247,7 +247,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
{
if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; }
}
- elseif (! empty($feature2)) // This should be used for future changes
+ elseif (! empty($feature2)) // This is for permissions on 2 levels
{
$tmpreadok=1;
foreach($feature2 as $subfeature)
@@ -263,7 +263,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
$nbko++;
}
}
- elseif (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions
+ elseif (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is permissions on 1 level
{
if (empty($user->rights->$feature->lire)
&& empty($user->rights->$feature->read)
@@ -279,7 +279,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
// Check write permission from module (we need to know write permission to create but also to delete drafts record)
$createok=1; $nbko=0;
- if (GETPOST('action', 'aZ09') == 'create' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'))
+ if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'))
{
foreach ($featuresarray as $feature)
{
@@ -307,7 +307,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
{
if (! $user->rights->banque->cheque) { $createok=0; $nbko++; }
}
- elseif (! empty($feature2)) // This should be used
+ elseif (! empty($feature2)) // This is for permissions on one level
{
foreach($feature2 as $subfeature)
{
@@ -317,7 +317,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
else { $createok=1; break; } // Break to bypass second test if the first is ok
}
}
- elseif (! empty($feature)) // This is for old permissions ('creer' or 'write')
+ elseif (! empty($feature)) // This is for permissions on 2 levels ('creer' or 'write')
{
//print ' feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
if (empty($user->rights->$feature->creer)
@@ -329,7 +329,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
// If a or and at least one ok
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
- if (GETPOST('action', 'aZ09') == 'create' && ! $createok) accessforbidden();
+ if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden();
//print "Write access is ok";
}
@@ -384,7 +384,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
{
if (! $user->rights->salaries->delete) $deleteok=0;
}
- elseif (! empty($feature2)) // This should be used for permissions on 2 levels
+ elseif (! empty($feature2)) // This is for permissions on 2 levels
{
foreach($feature2 as $subfeature)
{
@@ -392,7 +392,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
else { $deleteok=1; break; } // For bypass the second test if the first is ok
}
}
- elseif (! empty($feature)) // This is used for permissions on 1 level
+ elseif (! empty($feature)) // This is used for permissions on 1 level
{
//print ' feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
if (empty($user->rights->$feature->supprimer)
@@ -451,7 +451,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
if ($feature == 'project') $feature='projet';
if ($feature == 'task') $feature='projet_task';
- $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource','expensereport','holiday'); // Test on entity only (Objects with no link to company)
+ $check = array('adherent','banque','bom','don','user','usergroup','product','produit','service','produit|service','categorie','resource','expensereport','holiday'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object
$checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet','project'); // Test for project object
diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php
index 7b3ef796432..50a7611af82 100644
--- a/htdocs/core/lib/stock.lib.php
+++ b/htdocs/core/lib/stock.lib.php
@@ -78,3 +78,36 @@ function stock_prepare_head($object)
return $head;
}
+
+/**
+ * Return array head with list of tabs to view object informations.
+ *
+ * @return array head array with tabs
+ */
+function stock_admin_prepare_head()
+{
+ global $langs, $conf, $user;
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = DOL_URL_ROOT.'/admin/stock.php';
+ $head[$h][1] = $langs->trans("Miscellaneous");
+ $head[$h][2] = 'general';
+ $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, null, $head, $h, 'stock_admin');
+
+ $head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php';
+ $head[$h][1] = $langs->trans("ExtraFields");
+ $head[$h][2] = 'attributes';
+ $h++;
+
+ complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
+
+ return $head;
+}
diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php
index d5e2d3be854..07573db1a11 100644
--- a/htdocs/core/lib/takepos.lib.php
+++ b/htdocs/core/lib/takepos.lib.php
@@ -38,7 +38,8 @@ function takepos_prepare_head()
$head[$h][2] = 'setup';
$h++;
- for ($i = 1; $i <= $conf->global->TAKEPOS_NUM_TERMINALS; $i++)
+ $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
+ for ($i = 1; $i <= $numterminals; $i++)
{
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i;
$head[$h][1] = $langs->trans("Terminal"). " ".$i;
diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php
index c5791e5c89e..84be86f4a15 100644
--- a/htdocs/core/lib/ticket.lib.php
+++ b/htdocs/core/lib/ticket.lib.php
@@ -159,7 +159,7 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
- print '';
+ print '';
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
print '';
@@ -185,5 +185,5 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
print ' ';
}
- print '';
+ print '
';
}
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 7da112fa255..81e9c8dea73 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -295,10 +295,9 @@ function user_admin_prepare_head()
* @param boolean $foruserprofile Show for user profile view
* @return void
*/
-function show_theme($fuser, $edit = 0, $foruserprofile = false)
+function showSkins($fuser, $edit = 0, $foruserprofile = false)
{
global $conf,$langs,$db,$form;
- global $bc;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
@@ -351,9 +350,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
{
print '
'.$langs->trans("DefaultSkin").' ';
print '';
- $url='https://www.dolistore.com/lang-en/4-skins';
- if (preg_match('/fr/i', $langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
- //if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
+ $url='https://www.dolistore.com/4-skins';
print '';
print $langs->trans('DownloadMoreSkins');
print ' ';
@@ -432,7 +429,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print ' ';
print ''.$langs->trans("TopMenuDisableImages").' ';
print ''.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).' ';
- print 'conf->THEME_ELDY_TEXTLINK)?" checked":"");
+ print ' conf->THEME_ELDY_TEXTLINK)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").' ';
print '';
@@ -477,7 +474,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print ' ';
print ''.$langs->trans("TopMenuBackgroundColor").' ';
print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).' ';
- print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
+ print ' conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").' ';
print '';
@@ -524,7 +521,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print ' ';
print ''.$langs->trans("TopMenuBackgroundColor").' ';
print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).' ';
- print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
+ print ' conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").' ';
print '';
@@ -573,7 +570,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print ' ';
print ''.$langs->trans("TopMenuBackgroundColor").' ';
print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).' ';
- print 'conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
+ print ' conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").' ';
print '';
@@ -763,7 +760,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print ' ';
print ''.$langs->trans("TopMenuBackgroundColor").' ';
print ''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).' ';
- print ' conf->THEME_ELDY_TEXTLINK)?" checked":"");
+ print ' conf->THEME_ELDY_TEXTLINK)?" checked":"");
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
print '> '.$langs->trans("UsePersonalValue").' ';
print '';
@@ -813,9 +810,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
/* Must first change option to choose color of highlight instead of yes or no.
print ' ';
print ''.$langs->trans("HighlightLinesOnMouseHover").' ';
- print ' global->THEME_ELDY_USE_HOVER?" checked":"").'> ';
- print ' '.$langs->trans("UsePersonalValue").' ';
- print ' ';
+ print ' global->THEME_ELDY_USE_HOVER?" checked":"").'> ';
+ print ' '.$langs->trans("UsePersonalValue").' ';
+ print ' ';
print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print ' ';
print ' ';
@@ -825,7 +822,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '
';
print ''.$langs->trans("HighlightLinesColor").' ';
print '';
- //print ' ';
+ //print ' ';
//print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
if ($edit)
{
@@ -856,9 +853,9 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
/* Must first change option to choose color of highlight instead of yes or no.
print ' ';
print ''.$langs->trans("HighlightLinesOnMouseHover").' ';
- print ' global->THEME_ELDY_USE_HOVER?" checked":"").'> ';
- print ' '.$langs->trans("UsePersonalValue").' ';
- print ' ';
+ print ' global->THEME_ELDY_USE_HOVER?" checked":"").'> ';
+ print ' '.$langs->trans("UsePersonalValue").' ';
+ print ' ';
print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print ' ';
print ' ';
@@ -869,7 +866,7 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
print '
';
print ''.$langs->trans("HighlightLinesChecked").' ';
print '';
- //print ' ';
+ //print ' ';
//print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
if ($edit)
{
@@ -947,5 +944,44 @@ function show_theme($fuser, $edit = 0, $foruserprofile = false)
*/
}
+
+ // Use MAIN_OPTIMIZEFORTEXTBROWSER
+ if ($foruserprofile)
+ {
+ //$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
+ $default=$langs->trans('No');
+ print ' ';
+ print ''.$langs->trans("MAIN_OPTIMIZEFORCOLORBLIND").' ';
+ print '';
+
+ $colorBlindOptions = array(
+ 0 => $langs->trans('No'),
+ 'protanopia' => $langs->trans('Protanopia'),
+ 'deuteranopes' => $langs->trans('Deuteranopes'),
+ 'tritanopes' => $langs->trans('Tritanopes'),
+ );
+
+ if ($edit)
+ {
+ print $form->selectArray('MAIN_OPTIMIZEFORCOLORBLIND', $colorBlindOptions, $fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND, 0);
+ }
+ else
+ {
+ if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])){
+ print $colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND];
+ }
+ else{
+ print yn(0);
+ }
+ }
+ print ' ('.$langs->trans("Default").': '.$default.' ) ';
+ print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORCOLORBLINDDesc"));
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+
+ }
print '
';
}
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 198f91a4446..4d89210cd44 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -29,13 +29,16 @@
* @param Website $website Web site object
* @param string $content Content to replace
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
+ * @param string $contenttype Content type
* @return boolean True if OK
* @see dolWebsiteOutput() for function used to replace content in a web server context
*/
-function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0)
+function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype='html')
{
$nbrep = 0;
+ dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')', LOG_DEBUG);
+
// Replace php code. Note $content may come from database and does not contains body tags.
$replacewith='...php...';
if ($removephppart) $replacewith='';
@@ -90,6 +93,8 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0)
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
$content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
+ dol_syslog('dolWebsiteReplacementOfLinks end', LOG_DEBUG);
+
return $content;
}
@@ -176,16 +181,18 @@ function dolKeepOnlyPhpCode($str)
* Render a string of an HTML content and output it.
* Used to ouput the page when viewed from server (Dolibarr or Apache).
*
- * @param string $content Content string
+ * @param string $content Content string
+ * @param string $contenttype Content type
+ * @param int $containerid Contenair id
* @return void
* @see dolWebsiteReplacementOfLinks() for function used to replace content in the backoffice context when USEDOLIBARREDITOR is not on
*/
-function dolWebsiteOutput($content)
+function dolWebsiteOutput($content, $contenttype='html', $containerid='')
{
global $db, $langs, $conf, $user;
global $dolibarr_main_url_root, $dolibarr_main_data_root;
- dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
+ dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -195,9 +202,12 @@ function dolWebsiteOutput($content)
if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor
{
// We remove the part of content
- $content = preg_replace('/.*<\/head>/ims', '', $content);
- $content = preg_replace('/^.*]*)*>/ims', '', $content);
- $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
+ if ($contenttype == 'html')
+ {
+ $content = preg_replace('/.*<\/head>/ims', '', $content);
+ $content = preg_replace('/^.*]*)*>/ims', '', $content);
+ $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content);
+ }
}
elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server
{
@@ -285,7 +295,7 @@ function dolWebsiteOutput($content)
*
* @param string $content Content string
* @return void
- * @see dolWebsiteOutput
+ * @see dolWebsiteOutput()
*/
/*
function dolWebsiteSaveContent($content)
@@ -339,6 +349,14 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
}
}
+ if (defined('USEDOLIBARREDITOR'))
+ {
+ print '';
+ print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. Redirect has been canceled as it is not supported in edition mode.";
+ print '
';
+ return;
+ }
+
if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server
{
// Check new container exists
@@ -397,7 +415,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
*/
function includeContainer($containerref)
{
- global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
+ global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running included containers.
global $includehtmlcontentopened;
global $websitekey, $websitepagefile;
@@ -434,7 +452,224 @@ function includeContainer($containerref)
$includehtmlcontentopened--;
}
+/**
+ * Return HTML content to add structured data for an article, news or Blog Post.
+ *
+ * @param string $type 'blogpost', 'product', 'software'...
+ * @param array $data Array of data parameters for structured data
+ * @return string HTML content
+ */
+function getStructuredData($type, $data = array())
+{
+ global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
+ if ($type == 'software')
+ {
+ $ret = ''."\n";
+ $ret .= ''."\n";
+ }
+ elseif ($type == 'blogpost')
+ {
+ if ($websitepage->fk_user_creat > 0)
+ {
+ include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+ $tmpuser = new User($db);
+ $restmpuser = $tmpuser->fetch($websitepage->fk_user_creat);
+
+ if ($restmpuser > 0)
+ {
+ $ret = ''."\n";
+ $ret .= ''."\n";
+ }
+ }
+ }
+ elseif ($type == 'product')
+ {
+ $ret = ''."\n";
+ $ret.= ''."\n";
+ }
+ return $ret;
+}
+
+/**
+ * Return list of containers object that match a criteria
+ *
+ * @param string $type Type of container to search into (Example: 'page')
+ * @param string $algo Algorithm used for search (Example: 'meta' is searching into meta information like title and description, 'metacontent')
+ * @param string $searchstring Search string
+ * @param int $max Max number of answers
+ * @return string HTML content
+ */
+function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25)
+{
+ global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
+
+ $error = 0;
+ $arrayresult = array('code'=>'', 'list'=>array());
+
+ if (! is_object($weblangs)) $weblangs = $langs;
+
+ if (empty($searchstring))
+ {
+ $error++;
+ $arrayresult['code']='KO';
+ $arrayresult['message']=$weblangs->trans("EmptySearchString");
+ }
+ elseif (dol_strlen($searchstring) < 2)
+ {
+ $weblangs->load("errors");
+ $error++;
+ $arrayresult['code']='KO';
+ $arrayresult['message']=$weblangs->trans("ErrorSearchCriteriaTooSmall");
+ }
+ elseif (! in_array($type, array('', 'page')))
+ {
+ $error++;
+ $arrayresult['code']='KO';
+ $arrayresult['message']='Bad value for parameter $type';
+ }
+
+ $searchdone = 0;
+
+ if (! $error && in_array($algo, array('meta', 'metacontent', 'content')))
+ {
+ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page';
+ $sql.= " WHERE fk_website = ".$website->id;
+ if ($type) $sql.= " AND type_container = '".$db->escape($type)."'";
+ $sql.= " AND (";
+ $searchalgo = '';
+ if ($algo == 'meta' || $algo == 'metacontent')
+ {
+ $searchalgo.= ($searchalgo?' OR ':'')."title LIKE '%".$db->escape($searchstring)."%' OR description LIKE '%".$db->escape($searchstring)."%'";
+ $searchalgo.= ($searchalgo?' OR ':'')."keywords LIKE '".$db->escape($searchstring).",%' OR keywords LIKE '% ".$db->escape($searchstring)."%'"; // TODO Use a better way to scan keywords
+ }
+ if ($algo == 'metacontent' || $algo == 'content')
+ {
+ $searchalgo.= ($searchalgo?' OR ':'')."content LIKE '%".$db->escape($searchstring)."%'";
+ }
+ $sql.=$searchalgo;
+ $sql.= ")";
+ $sql.= $db->plimit($max);
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $i = 0;
+ while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0))
+ {
+ if ($obj->rowid > 0)
+ {
+ $tmpwebsitepage = new WebsitePage($db);
+ $tmpwebsitepage->fetch($obj->rowid);
+ if ($tmpwebsitepage->id > 0) $arrayresult['list'][]=$tmpwebsitepage;
+ }
+ $i++;
+ }
+
+ $arrayresult['code']='OK';
+ if (empty($arrayresult['list']))
+ {
+ $arrayresult['code']='KO';
+ $arrayresult['message']=$weblangs->trans("NoRecordFound");
+ }
+ }
+ else
+ {
+ $error++;
+ $arrayresult['code']=$db->lasterrno();
+ $arrayresult['message']=$db->lasterror();
+ }
+
+ $searchdone = 1;
+ }
+
+ if (! $searchdone)
+ {
+ $error++;
+ $arrayresult['code']='KO';
+ $arrayresult['message']='No supported algorithm found';
+ }
+
+ return $arrayresult;
+}
/**
* Download all images found into page content $tmp.
@@ -619,313 +854,3 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
}
}
}
-
-
-
-/**
- * Save content of a page on disk
- *
- * @param string $filemaster Full path of filename master.inc.php for website to generate
- * @return boolean True if OK
- */
-function dolSaveMasterFile($filemaster)
-{
- global $conf;
-
- // Now generate the master.inc.php page
- dol_syslog("We regenerate the master file");
- dol_delete_file($filemaster);
-
- $mastercontent = ''."\n";
- $result = file_put_contents($filemaster, $mastercontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filemaster, octdec($conf->global->MAIN_UMASK));
-
- return $result;
-}
-
-/**
- * Save content of a page on disk
- *
- * @param string $filealias Full path of filename to generate
- * @param Website $object Object website
- * @param WebsitePage $objectpage Object websitepage
- * @return boolean True if OK
- */
-function dolSavePageAlias($filealias, $object, $objectpage)
-{
- global $conf;
-
- // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
- dol_syslog("We regenerate the alias page filealias=".$filealias);
-
- $aliascontent = 'id.'.tpl.php\'; ';
- $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
- $aliascontent.= '?>'."\n";
- $result = file_put_contents($filealias, $aliascontent);
- if (! empty($conf->global->MAIN_UMASK)) {
- @chmod($filealias, octdec($conf->global->MAIN_UMASK));
- }
-
- return ($result?true:false);
-}
-
-
-/**
- * Save content of a page on disk
- *
- * @param string $filetpl Full path of filename to generate
- * @param Website $object Object website
- * @param WebsitePage $objectpage Object websitepage
- * @return boolean True if OK
- */
-function dolSavePageContent($filetpl, $object, $objectpage)
-{
- global $conf;
-
- // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
- dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
-
- dol_delete_file($filetpl);
-
- $shortlangcode = '';
- if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
-
- $tplcontent ='';
- $tplcontent.= "\n";
- if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
- {
- $tplcontent.= "\n";
- }
- $tplcontent.= ''."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= ' '."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
- $tplcontent.= ''."\n";
-
- $tplcontent.= ''."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= $objectpage->content."\n";
- $tplcontent.= ''."\n";
- $tplcontent.= ''."\n";
-
- $tplcontent.= '"."\n";
-
- //var_dump($filetpl);exit;
- $result = file_put_contents($filetpl, $tplcontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
-
- return $result;
-}
-
-
-/**
- * Save content of the index.php and wrapper.php page
- *
- * @param string $pathofwebsite Path of website root
- * @param string $fileindex Full path of file index.php
- * @param string $filetpl File tpl to index.php page redirect to
- * @param string $filewrapper Full path of file wrapper.php
- * @return boolean True if OK
- */
-function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
-{
- global $conf;
-
- $result1=false;
- $result2=false;
-
- dol_mkdir($pathofwebsite);
-
- dol_delete_file($fileindex);
- $indexcontent = ''."\n";
- $result1 = file_put_contents($fileindex, $indexcontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($fileindex, octdec($conf->global->MAIN_UMASK));
-
- dol_delete_file($filewrapper);
-
- $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
-
- $result2 = file_put_contents($filewrapper, $wrappercontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
-
- return ($result1 && $result2);
-}
-
-
-/**
- * Save content of a page on disk
- *
- * @param string $filehtmlheader Full path of filename to generate
- * @param string $htmlheadercontent Content of file
- * @return boolean True if OK
- */
-function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
-{
- global $conf, $pathofwebsite;
-
- dol_syslog("Save html header into ".$filehtmlheader);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filehtmlheader, $htmlheadercontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
- return false;
- }
-
- return true;
-}
-
-/**
- * Save content of a page on disk
- *
- * @param string $filecss Full path of filename to generate
- * @param string $csscontent Content of file
- * @return boolean True if OK
- */
-function dolSaveCssFile($filecss, $csscontent)
-{
- global $conf, $pathofwebsite;
-
- dol_syslog("Save css file into ".$filecss);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filecss, $csscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filecss, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- setEventMessages('Failed to write file '.$filecss, null, 'errors');
- return false;
- }
-
- return true;
-}
-
-/**
- * Save content of a page on disk
- *
- * @param string $filejs Full path of filename to generate
- * @param string $jscontent Content of file
- * @return boolean True if OK
- */
-function dolSaveJsFile($filejs, $jscontent)
-{
- global $conf, $pathofwebsite;
-
- dol_syslog("Save js file into ".$filejs);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filejs, $jscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filejs, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- setEventMessages('Failed to write file '.$filejs, null, 'errors');
- return false;
- }
-
- return true;
-}
-
-/**
- * Save content of a page on disk
- *
- * @param string $filerobot Full path of filename to generate
- * @param string $robotcontent Content of file
- * @return boolean True if OK
- */
-function dolSaveRobotFile($filerobot, $robotcontent)
-{
- global $conf, $pathofwebsite;
-
- dol_syslog("Save robot file into ".$filerobot);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filerobot, $robotcontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- setEventMessages('Failed to write file '.$filerobot, null, 'errors');
- return false;
- }
-
- return true;
-}
-
-/**
- * Save content of a page on disk
- *
- * @param string $filehtaccess Full path of filename to generate
- * @param string $htaccess Content of file
- * @return boolean True if OK
- */
-function dolSaveHtaccessFile($filehtaccess, $htaccess)
-{
- global $conf, $pathofwebsite;
-
- dol_syslog("Save htaccess file into ".$filehtaccess);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filehtaccess, $htaccess);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
- return false;
- }
-
- return true;
-}
diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php
new file mode 100644
index 00000000000..53f9e5f11c9
--- /dev/null
+++ b/htdocs/core/lib/website2.lib.php
@@ -0,0 +1,457 @@
+
+ *
+ * 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/core/lib/website2.lib.php
+ * \ingroup website
+ * \brief Library for website module (rare functions not required for execution of website)
+ */
+
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filemaster Full path of filename master.inc.php for website to generate
+ * @return boolean True if OK
+ */
+function dolSaveMasterFile($filemaster)
+{
+ global $conf;
+
+ // Now generate the master.inc.php page
+ dol_syslog("We regenerate the master file");
+ dol_delete_file($filemaster);
+
+ $mastercontent = ''."\n";
+ $result = file_put_contents($filemaster, $mastercontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filemaster, octdec($conf->global->MAIN_UMASK));
+
+ return $result;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filealias Full path of filename to generate
+ * @param Website $object Object website
+ * @param WebsitePage $objectpage Object websitepage
+ * @return boolean True if OK
+ */
+function dolSavePageAlias($filealias, $object, $objectpage)
+{
+ global $conf;
+
+ // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
+ dol_syslog("We regenerate the alias page filealias=".$filealias);
+
+ $aliascontent = 'id.'.tpl.php\'; ';
+ $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
+ $aliascontent.= '?>'."\n";
+ $result = file_put_contents($filealias, $aliascontent);
+ if (! empty($conf->global->MAIN_UMASK)) {
+ @chmod($filealias, octdec($conf->global->MAIN_UMASK));
+ }
+
+ return ($result?true:false);
+}
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filetpl Full path of filename to generate
+ * @param Website $object Object website
+ * @param WebsitePage $objectpage Object websitepage
+ * @return boolean True if OK
+ */
+function dolSavePageContent($filetpl, $object, $objectpage)
+{
+ global $conf;
+
+ // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
+ dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
+
+ dol_delete_file($filetpl);
+
+ $shortlangcode = '';
+ if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
+
+ $tplcontent ='';
+ $tplcontent.= "\n";
+ if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
+ {
+ $tplcontent.= "\n";
+ }
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ' '."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
+ $tplcontent.= ''."\n";
+
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= $objectpage->content."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+
+ $tplcontent.= 'id.');'."\n";
+ $tplcontent.= "// END PHP ?>"."\n";
+
+ //var_dump($filetpl);exit;
+ $result = file_put_contents($filetpl, $tplcontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
+
+ return $result;
+}
+
+
+/**
+ * Save content of the index.php and wrapper.php page
+ *
+ * @param string $pathofwebsite Path of website root
+ * @param string $fileindex Full path of file index.php
+ * @param string $filetpl File tpl to index.php page redirect to
+ * @param string $filewrapper Full path of file wrapper.php
+ * @return boolean True if OK
+ */
+function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
+{
+ global $conf;
+
+ $result1=false;
+ $result2=false;
+
+ dol_mkdir($pathofwebsite);
+
+ dol_delete_file($fileindex);
+ $indexcontent = ''."\n";
+ $result1 = file_put_contents($fileindex, $indexcontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($fileindex, octdec($conf->global->MAIN_UMASK));
+
+ dol_delete_file($filewrapper);
+
+ $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
+
+ $result2 = file_put_contents($filewrapper, $wrappercontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
+
+ return ($result1 && $result2);
+}
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filehtmlheader Full path of filename to generate
+ * @param string $htmlheadercontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save html header into ".$filehtmlheader);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filehtmlheader, $htmlheadercontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filecss Full path of filename to generate
+ * @param string $csscontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveCssFile($filecss, $csscontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save css file into ".$filecss);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filecss, $csscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filecss, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filecss, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filejs Full path of filename to generate
+ * @param string $jscontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveJsFile($filejs, $jscontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save js file into ".$filejs);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filejs, $jscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filejs, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filejs, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filerobot Full path of filename to generate
+ * @param string $robotcontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveRobotFile($filerobot, $robotcontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save robot file into ".$filerobot);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filerobot, $robotcontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filerobot, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filehtaccess Full path of filename to generate
+ * @param string $htaccess Content of file
+ * @return boolean True if OK
+ */
+function dolSaveHtaccessFile($filehtaccess, $htaccess)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save htaccess file into ".$filehtaccess);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filehtaccess, $htaccess);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $file Full path of filename to generate
+ * @param string $content Content of file
+ * @return boolean True if OK
+ */
+function dolSaveManifestJson($file, $content)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save manifest.js.php file into ".$file);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($file, $content);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$file, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+
+
+/**
+ * Show list of themes. Show all thumbs of themes
+ *
+ * @param Website $website Object website to load the tempalte into
+ * @return void
+ */
+function showWebsiteTemplates(Website $website)
+{
+ global $conf,$langs,$db,$form;
+ global $bc;
+
+ $dirthemes=array('/doctemplates/websites');
+ if (! empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application
+ {
+ foreach($conf->modules_parts['websitetemplates'] as $reldir)
+ {
+ $dirthemes=array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
+ }
+ }
+ $dirthemes=array_unique($dirthemes);
+ // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
+
+ $colspan=2;
+
+ $thumbsbyrow=6;
+ print '';
+
+ // Title
+ print ' ';
+ print '';
+ $url='https://www.dolistore.com/43-web-site-templates';
+ print '';
+ print $langs->trans('DownloadMoreSkins');
+ print ' ';
+ print ' ';
+
+ print '';
+ print ''.$langs->trans("ThemeDir").' ';
+ print '';
+ foreach($dirthemes as $dirtheme)
+ {
+ echo '"'.$dirtheme.'" ';
+ }
+ print ' ';
+ print ' ';
+
+ print '';
+
+ print '';
+
+ $i=0;
+ foreach($dirthemes as $dir)
+ {
+ //print $dirroot.$dir;exit;
+ $dirtheme=DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
+ if (is_dir($dirtheme))
+ {
+ $handle=opendir($dirtheme);
+ if (is_resource($handle))
+ {
+ while (($subdir = readdir($handle))!==false)
+ {
+ if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
+ && substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir))
+ {
+ $subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir);
+
+ // Disable not stable themes (dir ends with _exp or _dev)
+ if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
+ if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
+
+ print '
';
+
+ $file=$dirtheme."/".$subdirwithoutzip.".jpg";
+ $url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
+
+ if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
+ print '
';
+ print '
';
+ print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')';
+ print '
ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").' ';
+ print '
';
+
+ $i++;
+ }
+ }
+ }
+ }
+ }
+
+ print '
';
+
+ print ' ';
+ print '
';
+}
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index 3a4ec85ec58..dcd874bdf3d 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -218,10 +218,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'billing', '', 2000__+MAX_llx_menu__, '/don/stats/index.php?mainmenu=billing&leftmenu=donations', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__);
-- Special expenses
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled || $conf->loan->enabled || $conf->banque->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'billing', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?mainmenu=billing&leftmenu=tax', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)', '', 0, 6, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/list.php?mainmenu=billing&leftmenu=tax_salary', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?mainmenu=billing&leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/list.php?mainmenu=billing&leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2213__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/stats/index.php?mainmenu=billing&leftmenu=tax_salary', 'Statistics', 2, 'companies', '$user->rights->salaries->read', '', 0, 4, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/salaries/list.php?mainmenu=billing&leftmenu=tax_salary', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/salaries/card.php?mainmenu=billing&leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 0, 2, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/salaries/list.php?mainmenu=billing&leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2213__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/salaries/stats/index.php?mainmenu=billing&leftmenu=tax_salary', 'Statistics', 2, 'companies', '$user->rights->salaries->read', '', 0, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'billing', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/list.php?mainmenu=billing&leftmenu=tax_loan', 'Loans', 1, 'loan', '$user->rights->loan->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/card.php?mainmenu=billing&leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 0, 2, __ENTITY__);
--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?mainmenu=billing&leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__);
@@ -281,6 +281,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2430__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_bookeeping', 'Bookkeeping', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 15, __ENTITY__);
-- Balance
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__);
+ -- Export accounting documents
+ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2436__+MAX_llx_menu__, 'accountancy', 'accountancy_files', 2400__+MAX_llx_menu__, '/compta/compta-files.php?mainmenu=accountancy&leftmenu=accountancy_files', 'AccountantFiles', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 17, __ENTITY__);
-- Reports
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'MenuReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 3073ffe6032..4596afc0bcf 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1108,11 +1108,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (! empty($conf->salaries->enabled))
{
$langs->load("salaries");
- $newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
+ $newmenu->add("/salaries/list.php?leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
- $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write);
- $newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read);
- $newmenu->add("/compta/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 2, $user->rights->salaries->read);
+ $newmenu->add("/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write);
+ $newmenu->add("/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read);
+ $newmenu->add("/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 2, $user->rights->salaries->read);
}
}
@@ -1285,9 +1285,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
// Files
- if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2)
+ if ((! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 1) || ! empty($conf->global->ACCOUNTANCY_SHOW_EXPORT_FILES_MENU))
{
- $newmenu->add("/compta/compta-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
+ $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
}
// Reports
@@ -1329,6 +1329,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Accountancy (simple)
if (! empty($conf->comptabilite->enabled))
{
+ // Files
+ if (! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 1)
+ {
+ $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'files');
+ }
+
// Bilan, resultats
$newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca');
@@ -1573,7 +1579,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
{
$langs->load("mrp");
- $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
+ $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->bom->read, '', $mainmenu, 'bom');
$newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write);
$newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read);
}
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 9a695788b47..16d3969652d 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1297,7 +1297,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// For the moment, we manage this with hard coded exception
//print "Remove box ".$file.' ';
if ($file == 'box_graph_product_distribution.php') {
- if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled)) {
+ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
dol_syslog("We discard disabling of module ".$file." because another module still active require it.");
continue;
}
@@ -1938,7 +1938,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
$menu->type=$this->menu[$key]['type'];
$menu->mainmenu=isset($this->menu[$key]['mainmenu'])?$this->menu[$key]['mainmenu']:(isset($menu->fk_mainmenu)?$menu->fk_mainmenu:'');
$menu->leftmenu=isset($this->menu[$key]['leftmenu'])?$this->menu[$key]['leftmenu']:'';
- $menu->titre=$this->menu[$key]['titre'];
+ $menu->titre=$this->menu[$key]['titre']; // deprecated
+ $menu->title=$this->menu[$key]['titre'];
$menu->url=$this->menu[$key]['url'];
$menu->langs=$this->menu[$key]['langs'];
$menu->position=$this->menu[$key]['position'];
diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php
index 5deb40fc7ad..23fef1ef2c5 100644
--- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php
+++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php
@@ -111,7 +111,7 @@ class pdf_ban extends ModeleBankAccountDoc
if ($conf->bank->dir_output)
{
- //$nblignes = count($object->lines); // This is set later with array of tasks
+ //$nblines = count($object->lines); // This is set later with array of tasks
// Definition of $dir and $file
if ($object->specimen)
@@ -275,6 +275,7 @@ class pdf_ban extends ModeleBankAccountDoc
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show table for lines
*
@@ -287,13 +288,15 @@ class pdf_ban extends ModeleBankAccountDoc
* @param int $hidebottom Hide bottom bar of array
* @return void
*/
- private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{
+ // phpcs:enable
global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
@@ -303,9 +306,10 @@ class pdf_ban extends ModeleBankAccountDoc
* @param Translate $outputlangs Object lang for output
* @return void
*/
- private function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $langs,$conf,$mysoc;
+ // phpcs:enable
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -380,6 +384,7 @@ class pdf_ban extends ModeleBankAccountDoc
*/
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
*
@@ -389,9 +394,11 @@ class pdf_ban extends ModeleBankAccountDoc
* @param int $hidefreetext 1=Hide free text
* @return integer
*/
- private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
+ // phpcs:enable
global $conf;
+
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
//return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
}
diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
index 9783c4690b2..e3990bc8ccc 100644
--- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
+++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
@@ -114,7 +114,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
if (! empty($conf->bank->dir_output))
{
- //$nblignes = count($object->lines); // This is set later with array of tasks
+ //$nblines = count($object->lines); // This is set later with array of tasks
// Definition of $dir and $file
if ($object->specimen)
@@ -418,6 +418,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show table for lines
*
@@ -430,15 +431,17 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param int $hidebottom Hide bottom bar of array
* @return void
*/
- private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{
+ // phpcs:enable
global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show miscellaneous information (payment mode, payment term, ...)
*
@@ -448,7 +451,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param Translate $outputlangs Langs object
* @return void
*/
- private function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
global $conf, $mysoc;
@@ -475,7 +478,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show area for the customer to sign
*
@@ -485,7 +489,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
- private function _signature_area(&$pdf, $object, $posy, $outputlangs)
+ protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -517,6 +521,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
@@ -526,8 +531,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param Translate $outputlangs Object lang for output
* @return void
*/
- private function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
+ // phpcs:enable
global $langs,$conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -609,6 +615,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
*/
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
*
@@ -618,9 +625,11 @@ class pdf_sepamandate extends ModeleBankAccountDoc
* @param int $hidefreetext 1=Hide free text
* @return integer
*/
- private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
+ // phpcs:enable
global $conf;
+
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
index 1b39fe16095..3d2564591da 100644
--- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
+++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
@@ -116,7 +116,6 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["code"]=$code;
$_GET["type"]=$encoding;
- $_GET["height"]=$height;
$_GET["readable"]=$readable;
if ($code) {
@@ -166,7 +165,6 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["code"]=$code;
$_GET["type"]=$encoding;
- $_GET["height"]=$height;
$_GET["readable"]=$readable;
if ($code) {
diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php
index ba5c437f0a0..aa8eef7aa59 100644
--- a/htdocs/core/modules/bom/mod_bom_advanced.php
+++ b/htdocs/core/modules/bom/mod_bom_advanced.php
@@ -23,7 +23,7 @@
/**
* \file htdocs/core/modules/bom/mod_bom_advanced.php
* \ingroup bom
- * \brief Fichier contenant la classe du modele de numerotation de reference de bom advanced
+ * \brief File containing class for numbering model of bom advanced
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
@@ -52,7 +52,7 @@ class mod_bom_advanced extends ModeleNumRefboms
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
index 80876747d59..f2ef19ca19a 100644
--- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
+++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php
@@ -252,7 +252,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
$pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(32, 26);
- $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
+ $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
$pdf->SetFont('', '', $default_font_size);
$pdf->SetXY(10, 32);
diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
index 7ff3bc6f6cc..545222c8b03 100644
--- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
+++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
@@ -46,7 +46,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 5975da49fbe..1dff7d5050b 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -219,7 +219,7 @@ class pdf_einstein extends ModelePDFCommandes
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -228,7 +228,7 @@ class pdf_einstein extends ModelePDFCommandes
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
if ($conf->commande->dir_output)
{
@@ -308,7 +308,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -400,7 +400,7 @@ class pdf_einstein extends ModelePDFCommandes
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -429,7 +429,7 @@ class pdf_einstein extends ModelePDFCommandes
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -540,7 +540,7 @@ class pdf_einstein extends ModelePDFCommandes
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -549,7 +549,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -1217,6 +1217,8 @@ class pdf_einstein extends ModelePDFCommandes
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
@@ -1225,10 +1227,11 @@ class pdf_einstein extends ModelePDFCommandes
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param string $titlekey Translation key to show as title of document
- * @return void
+ * @return int Return topshift value
*/
- private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
{
+ // phpcs:enable
global $conf,$langs,$hookmanager;
// Load traductions files requiredby by page
@@ -1307,6 +1310,14 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+ if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && ! empty($object->thirdparty->code_client))
+ {
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ }
+
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
@@ -1429,6 +1440,8 @@ class pdf_einstein extends ModelePDFCommandes
return $top_shift;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
*
@@ -1438,8 +1451,9 @@ class pdf_einstein extends ModelePDFCommandes
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
- private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
+ // phpcs:enable
global $conf;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 1abc6c95e20..4ca0cf36391 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -7,7 +7,7 @@
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2015 Marcos García
* Copyright (C) 2017 Ferran Marcet
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Frédéric France
*
* 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
@@ -27,7 +27,7 @@
/**
* \file htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
* \ingroup commande
- * \brief Fichier de la classe permettant de generer les commandes au modele Eratosthène
+ * \brief File of Class to generate PDF orders with template Eratosthène
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/**
- * Classe to generate PDF orders with template Eratosthene
+ * Class to generate PDF orders with template Eratosthene
*/
class pdf_eratosthene extends ModelePDFCommandes
{
@@ -149,13 +149,13 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 0; // Affiche si il y a eu escompte
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
@@ -194,7 +194,7 @@ class pdf_eratosthene extends ModelePDFCommandes
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -203,7 +203,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Translations
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$hidetop=0;
if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
@@ -217,7 +217,7 @@ class pdf_eratosthene extends ModelePDFCommandes
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -541,7 +541,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -599,7 +599,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -738,7 +738,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -747,7 +747,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -1352,6 +1352,8 @@ class pdf_eratosthene extends ModelePDFCommandes
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
@@ -1362,8 +1364,9 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param string $titlekey Translation key to show as title of document
* @return void
*/
- private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
{
+ // phpcs:enable
global $conf,$langs,$hookmanager;
// Translations
@@ -1564,6 +1567,8 @@ class pdf_eratosthene extends ModelePDFCommandes
return $top_shift;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
*
@@ -1573,8 +1578,9 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
- private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
+ // phpcs:enable
global $conf;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
index f10f858544f..b6c7fe6d78f 100644
--- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
@@ -25,7 +25,7 @@
/**
* \file htdocs/core/modules/commande/doc/pdf_proforma.modules.php
* \ingroup commande
- * \brief Fichier de la classe permettant de generer les commandes au modele Proforma
+ * \brief File of Class to generate PDF orders with template Proforma
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/pdf_einstein.modules.php';
@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/**
- * Classe permettant de generer les commandes au modele Proforma
+ * Class to generate PDF orders with template Proforma
*/
class pdf_proforma extends pdf_einstein
{
@@ -57,6 +57,8 @@ class pdf_proforma extends pdf_einstein
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
@@ -65,12 +67,13 @@ class pdf_proforma extends pdf_einstein
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param string $titlekey Translation key to show as title of document
- * @return void
+ * @return int Return topshift value
*/
- private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma")
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma")
{
+ // phpcs:enable
global $conf,$langs,$hookmanager;
- parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
+ return parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
}
}
diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php
index 8c96c237a0f..892a279cbe8 100644
--- a/htdocs/core/modules/commande/mod_commande_saphir.php
+++ b/htdocs/core/modules/commande/mod_commande_saphir.php
@@ -52,7 +52,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index 97fedf45808..d358149d7cc 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -4,7 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand (Resultic)
* Copyright (C) 2011 Fabrice CHERRIER
- * Copyright (C) 2013-2018 Philippe Grand
+ * Copyright (C) 2013-2019 Philippe Grand
* Copyright (C) 2015 Marcos García
* Copyright (C) 2018 Frédéric France
*
@@ -144,13 +144,13 @@ class pdf_strato extends ModelePDFContract
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 0; // Affiche mode reglement
- $this->option_condreg = 0; // Affiche conditions reglement
- $this->option_codeproduitservice = 0; // Affiche code produit-service
- $this->option_multilang = 0; // Dispo en plusieurs langues
- $this->option_draft_watermark = 1; //Support add of a watermark on drafts
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 0; // Display payment mode
+ $this->option_condreg = 0; // Display payment terms
+ $this->option_codeproduitservice = 0; // Display product-service code
+ $this->option_multilang = 0; // Available in several languages
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
$this->emetteur=$mysoc;
diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
index 28e5addd2b2..9f94dd86867 100644
--- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
+++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
@@ -414,7 +414,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
}
}
// Make substitutions into odt of thirdparty
- $tmparray=$this->get_substitutionarray_thirdparty($socobject, $outputlangs);
+ if ($socobject->element == 'contact') {
+ $tmparray = $this->get_substitutionarray_contact($socobject, $outputlangs);
+ } else {
+ $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
+ }
foreach($tmparray as $key=>$value)
{
try {
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 87f04dca016..5bcd6d153d0 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -168,7 +168,7 @@ class pdf_espadon extends ModelePdfExpedition
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
@@ -176,7 +176,7 @@ class pdf_espadon extends ModelePdfExpedition
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -253,8 +253,8 @@ class pdf_espadon extends ModelePdfExpedition
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblignes with the new facture lines content after hook
- $nblignes = count($object->lines);
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -404,7 +404,7 @@ class pdf_espadon extends ModelePdfExpedition
$nexY = $tab_top + $this->tabTitleHeight + 2;
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -464,7 +464,7 @@ class pdf_espadon extends ModelePdfExpedition
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -548,7 +548,7 @@ class pdf_espadon extends ModelePdfExpedition
if ($weighttxt && $voltxt) $nexY+=2;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80)));
diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index 8696bc21a02..bd46fc5a75e 100644
--- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2015 Laurent Destailleur
* Copyright (C) 2005-2011 Regis Houssin
* Copyright (C) 2013 Florian Henry
- * Copyright (C) 2015 Marcos García
+ * Copyright (C) 2015 Marcos García
*
* 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,7 +23,7 @@
/**
* \file htdocs/core/modules/expedition/doc/pdf_merou.modules.php
* \ingroup expedition
- * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou
+ * \brief Class file used to generate the dispatch slips for the Merou model
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
@@ -134,7 +134,7 @@ class pdf_merou extends ModelePdfExpedition
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1;
+ $this->option_logo = 1; // Display logo
// Get source company
$this->emetteur=$mysoc;
@@ -222,7 +222,7 @@ class pdf_merou extends ModelePdfExpedition
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format, 'mm', 'l');
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -347,7 +347,7 @@ class pdf_merou extends ModelePdfExpedition
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -356,7 +356,7 @@ class pdf_merou extends ModelePdfExpedition
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index e8de6ffdb73..8929b86a938 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -23,12 +23,13 @@
/**
* \file htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
* \ingroup expedition
- * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
+ * \brief Class file used to generate the dispatch slips for the Rouget model
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
/**
@@ -133,7 +134,7 @@ class pdf_rouget extends ModelePdfExpedition
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1;
+ $this->option_logo = 1; // Display logo
// Get source company
$this->emetteur=$mysoc;
@@ -197,7 +198,7 @@ class pdf_rouget extends ModelePdfExpedition
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
@@ -205,7 +206,7 @@ class pdf_rouget extends ModelePdfExpedition
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -282,8 +283,8 @@ class pdf_rouget extends ModelePdfExpedition
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblignes with the new facture lines content after hook
- $nblignes = count($object->lines);
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -423,7 +424,7 @@ class pdf_rouget extends ModelePdfExpedition
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -481,7 +482,7 @@ class pdf_rouget extends ModelePdfExpedition
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -563,7 +564,7 @@ class pdf_rouget extends ModelePdfExpedition
if ($weighttxt && $voltxt) $nexY+=2;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index 8bb3eaa7804..b85ca573188 100644
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -117,13 +117,13 @@ class pdf_standard extends ModeleExpenseReport
public $emetteur;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
global $conf, $langs, $mysoc, $user;
// Translations
@@ -172,12 +172,12 @@ class pdf_standard extends ModeleExpenseReport
$this->posxup=145;
$this->posxqty=168;
$this->postotalttc=178;
- // if (empty($conf->projet->enabled)) {
- // $this->posxtva-=20;
- // $this->posxup-=20;
- // $this->posxqty-=20;
- // $this->postotalttc-=20;
- // }
+ // if (empty($conf->projet->enabled)) {
+ // $this->posxtva-=20;
+ // $this->posxup-=20;
+ // $this->posxqty-=20;
+ // $this->postotalttc-=20;
+ // }
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxdate-=20;
@@ -196,19 +196,19 @@ class pdf_standard extends ModeleExpenseReport
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Object $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
*/
- public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager;
@@ -220,7 +220,7 @@ class pdf_standard extends ModeleExpenseReport
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "trips", "projects", "dict", "bills", "banks"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
if ($conf->expensereport->dir_output) {
// Definition of $dir and $file
@@ -351,7 +351,7 @@ class pdf_standard extends ModeleExpenseReport
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++) {
+ for ($i = 0 ; $i < $nblines ; $i++) {
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
@@ -374,7 +374,7 @@ class pdf_standard extends ModeleExpenseReport
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
// There is no space left for total+free text
- if ($i == ($nblignes-1)) {
+ if ($i == ($nblines-1)) {
// No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -400,8 +400,8 @@ class pdf_standard extends ModeleExpenseReport
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
//$nblineFollowComment = 1;
- // Cherche nombre de lignes a venir pour savoir si place suffisante
- // if ($i < ($nblignes - 1)) // If it's not last line
+ // Search number of lines coming to know if there is enough room
+ // if ($i < ($nblines - 1)) // If it's not last line
// {
// //Fetch current description to know on which line the next one should be placed
// $follow_comment = $object->lines[$i]->comments;
@@ -414,8 +414,8 @@ class pdf_standard extends ModeleExpenseReport
// $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed);
// }
- //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Passe espace entre les lignes
- $nexY += ($pdf->getFontSize()*1.3); // Passe espace entre les lignes
+ //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines
+ $nexY += ($pdf->getFontSize()*1.3); // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -501,9 +501,9 @@ class pdf_standard extends ModeleExpenseReport
$posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs);
}
- // Pied de page
+ // Page footer
$this->_pagefoot($pdf, $object, $outputlangs);
- if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPage();
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
$pdf->Close();
@@ -540,17 +540,17 @@ class pdf_standard extends ModeleExpenseReport
}
}
- /**
- * @param TCPDF $pdf Object PDF
- * @param Object $object Object to show
- * @param int $linenumber line number
- * @param int $curY current y position
- * @param int $default_font_size default siez of font
- * @param Translate $outputlangs Object lang for output
- * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
- * @return void
- */
- private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
+ /**
+ * @param TCPDF $pdf Object PDF
+ * @param Object $object Object to show
+ * @param int $linenumber line number
+ * @param int $curY current y position
+ * @param int $default_font_size default siez of font
+ * @param Translate $outputlangs Object lang for output
+ * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
+ * @return void
+ */
+ private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
{
global $conf;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -618,7 +618,7 @@ class pdf_standard extends ModeleExpenseReport
}
$comment .= $object->lines[$linenumber]->comments;
$pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1);
- }
+ }
/**
* Show top header of page.
@@ -846,7 +846,7 @@ class pdf_standard extends ModeleExpenseReport
}
}
}
- }
+ }
/**
* Show table for lines
@@ -1024,6 +1024,7 @@ class pdf_standard extends ModeleExpenseReport
if ($resql)
{
$num = $this->db->num_rows($resql);
+ $totalpaid = 0;
$i=0;
while ($i < $num) {
$y+=$tab3_height;
diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
index c0a5aa0a031..5217e2dc1c3 100644
--- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php
+++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
@@ -55,7 +55,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php
index c3c8431962e..9d606aadc33 100644
--- a/htdocs/core/modules/export/export_csv.modules.php
+++ b/htdocs/core/modules/export/export_csv.modules.php
@@ -261,6 +261,9 @@ class ExportCsv extends ModeleExports
}
$this->col=0;
+
+ $reg=array();
+
foreach($array_selected_sorted as $code => $value)
{
if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code);
diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php
index ffb1fd83cce..0e7fd0f1169 100644
--- a/htdocs/core/modules/export/export_excel.modules.php
+++ b/htdocs/core/modules/export/export_excel.modules.php
@@ -345,6 +345,8 @@ class ExportExcel extends ModeleExports
// Define first row
$this->col=0;
+ $reg=array();
+
foreach($array_selected_sorted as $code => $value)
{
if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code);
diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php
index 266cedc1310..038446643a2 100644
--- a/htdocs/core/modules/export/export_excel2007new.modules.php
+++ b/htdocs/core/modules/export/export_excel2007new.modules.php
@@ -304,6 +304,8 @@ class ExportExcel2007new extends ModeleExports
// Define first row
$this->col=0;
+ $reg=array();
+
foreach($array_selected_sorted as $code => $value)
{
if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index de1ebc00a8b..acc88a1e96a 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -160,13 +160,13 @@ class pdf_crabe extends ModelePDFFactures
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 1; // Affiche si il y a eu escompte
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 1; // Displays if there has been a discount
$this->option_credit_note = 1; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
@@ -235,7 +235,9 @@ class pdf_crabe extends ModelePDFFactures
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
+
+ dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -244,13 +246,13 @@ class pdf_crabe extends ModelePDFFactures
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -316,8 +318,8 @@ class pdf_crabe extends ModelePDFFactures
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblignes with the new facture lines content after hook
- $nblignes = count($object->lines);
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
$nbpayments = count($object->getListOfPayments());
// Create pdf instance
@@ -358,7 +360,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -465,7 +467,7 @@ class pdf_crabe extends ModelePDFFactures
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -521,7 +523,7 @@ class pdf_crabe extends ModelePDFFactures
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -650,7 +652,7 @@ class pdf_crabe extends ModelePDFFactures
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -659,7 +661,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -1345,6 +1347,50 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+
+ // Retained warranty
+ if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) )
+ {
+ $displayWarranty = false;
+
+ // Check if this situation invoice is 100% for real
+ if(!empty($object->lines)){
+ $displayWarranty = true;
+ foreach($object->lines as $i => $line){
+ if($line->product_type < 2 && $line->situation_percent < 100){
+ $displayWarranty = false;
+ break;
+ }
+ }
+ }
+
+ if($displayWarranty){
+ $pdf->SetTextColor(40, 40, 40);
+ $pdf->SetFillColor(255, 255, 255);
+
+ $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
+
+ // Billed - retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
+
+ // retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty") . ' ('.$object->retained_warranty.'%)';
+ $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
+
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
+ }
+ }
}
}
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 9c7c7797841..26e2b1824d8 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -160,13 +160,13 @@ class pdf_sponge extends ModelePDFFactures
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 1; // Affiche si il y a eu escompte
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 1; // Displays if there has been a discount
$this->option_credit_note = 1; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
@@ -209,7 +209,7 @@ class pdf_sponge extends ModelePDFFactures
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -218,7 +218,7 @@ class pdf_sponge extends ModelePDFFactures
// Translations
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$hidetop=0;
if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
@@ -232,7 +232,7 @@ class pdf_sponge extends ModelePDFFactures
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -329,8 +329,8 @@ class pdf_sponge extends ModelePDFFactures
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblignes with the new facture lines content after hook
- $nblignes = count($object->lines);
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
$nbpayments = count($object->getListOfPayments());
// Create pdf instance
@@ -449,7 +449,7 @@ class pdf_sponge extends ModelePDFFactures
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$pdf->startTransaction();
$pdf->SetFont('', '', $default_font_size - 1);
@@ -572,7 +572,7 @@ class pdf_sponge extends ModelePDFFactures
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
@@ -630,7 +630,7 @@ class pdf_sponge extends ModelePDFFactures
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -782,7 +782,7 @@ class pdf_sponge extends ModelePDFFactures
$nexY = max($nexY, $posYAfterImage);
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -791,7 +791,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -1225,13 +1225,172 @@ class pdf_sponge extends ModelePDFFactures
$useborder=0;
$index = 0;
+
+
+ // pourcentage global d'avancement
+ $percent = 0;
+ $i=0;
+ foreach ($object->lines as $line)
+ {
+ if(!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)){
+ $percent += $line->situation_percent;
+ $i++;
+ }
+ }
+ if(!empty($i)){
+ $avancementGlobal = $percent/$i;
+ }
+ else{
+ $avancementGlobal = 0;
+ }
+
+ $object->fetchPreviousNextSituationInvoice();
+ $TPreviousIncoice = $object->tab_previous_situation_invoice;
+
+ $total_a_payer = 0;
+ $total_a_payer_ttc = 0;
+ foreach ($TPreviousIncoice as &$fac){
+ $total_a_payer += $fac->total_ht;
+ $total_a_payer_ttc += $fac->total_ttc;
+ }
+ $total_a_payer += $object->total_ht;
+ $total_a_payer_ttc += $object->total_ttc;
+
+ if(!empty($avancementGlobal)){
+ $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
+ $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
+ }
+ else{
+ $total_a_payer = 0;
+ $total_a_payer_ttc = 0;
+ }
+
+ $deja_paye = 0;
+ $i = 1;
+ if(!empty($TPreviousIncoice)){
+
+ $pdf->setY($tab2_top);
+ $posy = $pdf->GetY();
+
+
+
+
+ foreach ($TPreviousIncoice as &$fac){
+
+ if($posy > $this->page_hauteur - 4 ) {
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ // cumul TVA précédent
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+
+ $facSign = '';
+ if($i>1){
+ $facSign = $fac->total_ht>=0?'+':'';
+ }
+
+ $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
+
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $i++;
+ $deja_paye += $fac->total_ht;
+ $posy += $tab2_hl;
+
+ $pdf->setY($posy);
+ }
+
+ // Display curent total
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $facSign = '';
+ if($i>1){
+ $facSign = $object->total_ht>=0?'+':''; // gestion d'un cas particulier client
+ }
+
+ if($fac->type === facture::TYPE_CREDIT_NOTE){
+ $facSign = '-'; // les avoirs
+ }
+
+
+ $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $posy += $tab2_hl;
+
+ // Display all total
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer*$avancementGlobal/100, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ $posy += $tab2_hl;
+
+ if($posy > $this->page_hauteur - 4 ) {
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ $tab2_top = $posy;
+ $index=0;
+ }
+
+ $tab2_top += 3;
+
+ // Get Total HT
+ $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
+
+ // Total remise
+ $total_line_remise=0;
+ foreach($object->lines as $i => $line) {
+ $total_line_remise+= pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ // Gestion remise sous forme de ligne négative
+ if($line->total_ht < 0) $total_line_remise += -$line->total_ht;
+ }
+ if($total_line_remise > 0) {
+ if (! empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount"), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
+ // Show total NET before discount
+ if (! empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount"), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
+ }
+
// Total HT
$pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
- $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
@@ -1256,7 +1415,7 @@ class pdf_sponge extends ModelePDFFactures
//{
foreach($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
foreach($localtax_rate as $tvakey => $tvaval)
{
@@ -1330,7 +1489,14 @@ class pdf_sponge extends ModelePDFFactures
}
if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
- $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
+ if(!empty($sum_pdf_tva))
+ {
+ $coef_fix_tva = $object->total_tva / $sum_pdf_tva;
+ }
+ else {
+ $coef_fix_tva = 1;
+ }
+
foreach($this->tva as $tvakey => $tvaval) {
$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
@@ -1427,7 +1593,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
}
- //}
+
// Revenue stamp
if (price2num($object->revenuestamp) != 0)
@@ -1449,6 +1615,69 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+
+
+ /*if($object->type == Facture::TYPE_SITUATION)
+ {
+ // reste à payer total
+ $index++;
+
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetFillColor(255,255,255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('SituationTotalRayToRest'), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer_ttc-$deja_paye, 0, $outputlangs), 0, 'R', 1);
+ }*/
+
+
+ // Retained warranty
+ if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) )
+ {
+ $displayWarranty = false;
+
+ // Check if this situation invoice is 100% for real
+ if(!empty($object->situation_final)){
+ $displayWarranty = true;
+ }
+ elseif(!empty($object->lines) && $object->status == Facture::STATUS_DRAFT ){
+ // $object->situation_final need validation to be done so this test is need for draft
+ $displayWarranty = true;
+ foreach($object->lines as $i => $line){
+ if($line->product_type < 2 && $line->situation_percent < 100){
+ $displayWarranty = false;
+ break;
+ }
+ }
+ }
+
+ if($displayWarranty){
+ $pdf->SetTextColor(40, 40, 40);
+ $pdf->SetFillColor(255, 255, 255);
+
+ $retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100;
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
+
+ // Billed - retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
+
+ // retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty") . ' ('.$object->retained_warranty.'%)';
+ $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
+
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
+ }
+ }
}
}
@@ -1456,7 +1685,7 @@ class pdf_sponge extends ModelePDFFactures
$creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
- //print "x".$creditnoteamount."-".$depositsamount;exit;
+
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if ($object->paye) $resteapayer=0;
@@ -1509,6 +1738,20 @@ class pdf_sponge extends ModelePDFFactures
return ($tab2_top + ($tab2_hl * $index));
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return list of active generation modules
+ *
+ * @param DoliDB $db Database handler
+ * @param integer $maxfilenamelength Max length of value to show
+ * @return array List of templates
+ */
+ public static function liste_modeles($db, $maxfilenamelength = 0)
+ {
+ // phpcs:enable
+ return parent::liste_modeles($db, $maxfilenamelength); // TODO: Change the autogenerated stub
+ }
+
/**
* Show table for lines
*
diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php
index 752a80669c5..4c9d249d6c8 100644
--- a/htdocs/core/modules/facture/mod_facture_mars.php
+++ b/htdocs/core/modules/facture/mod_facture_mars.php
@@ -62,7 +62,7 @@ class mod_facture_mars extends ModeleNumRefFactures
}
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php
index 8c921d982bf..992a90b9731 100644
--- a/htdocs/core/modules/facture/mod_facture_mercure.php
+++ b/htdocs/core/modules/facture/mod_facture_mercure.php
@@ -46,7 +46,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php
index c01fa9d2e09..db9a3e2e046 100644
--- a/htdocs/core/modules/facture/mod_facture_terre.php
+++ b/htdocs/core/modules/facture/mod_facture_terre.php
@@ -72,7 +72,7 @@ class mod_facture_terre extends ModeleNumRefFactures
}
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
@@ -184,6 +184,8 @@ class mod_facture_terre extends ModeleNumRefFactures
{
global $db;
+ dol_syslog(get_class($this)."::getNextValue mode=".$mode, LOG_DEBUG);
+
if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
elseif ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
@@ -195,7 +197,6 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$resql=$db->query($sql);
- dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
if ($resql)
{
$obj = $db->fetch_object($resql);
@@ -219,7 +220,6 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$sql.= " ORDER BY ref DESC";
- dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 41edc6c0a1d..936eabeadda 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -136,12 +136,12 @@ class pdf_soleil extends ModelePDFFicheinter
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 0; // Affiche mode reglement
- $this->option_condreg = 0; // Affiche conditions reglement
- $this->option_codeproduitservice = 0; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 0; // Display payment mode
+ $this->option_condreg = 0; // Display payment terms
+ $this->option_codeproduitservice = 0; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
$this->option_draft_watermark = 1; //Support add of a watermark on drafts
// Get source company
@@ -216,7 +216,7 @@ class pdf_soleil extends ModelePDFFicheinter
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Create pdf instance
$pdf=pdf_getInstance($this->format);
@@ -274,7 +274,7 @@ class pdf_soleil extends ModelePDFFicheinter
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php
index 1902ffc70af..1d33cb7fc83 100644
--- a/htdocs/core/modules/fichinter/mod_arctic.php
+++ b/htdocs/core/modules/fichinter/mod_arctic.php
@@ -57,7 +57,7 @@ class mod_arctic extends ModeleNumRefFicheinter
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index f75e5035670..606b23e2767 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -581,8 +581,27 @@ class ImportCsv extends ModeleImports
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
$newval=$defaultref;
}
-
-
+ elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute')
+ {
+ $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
+ $class=$objimport->array_import_convertvalue[0][$val]['class'];
+ $method=$objimport->array_import_convertvalue[0][$val]['method'];
+ $resultload = dol_include_once($file);
+ if (empty($resultload))
+ {
+ dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method);
+ break;
+ }
+ $classinstance=new $class($this->db);
+ $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
+ if ($res<0) {
+ if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
+ else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
+ $this->errors[$error]['type']='FOREIGNKEY';
+ $errorforthistable++;
+ $error++;
+ }
+ }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric')
{
$newval = price2num($newval);
@@ -594,16 +613,25 @@ class ImportCsv extends ModeleImports
// Test regexp
if (! empty($objimport->array_import_regex[0][$val]) && ($newval != ''))
{
- // If test is "Must exist in a field@table"
- if (preg_match('/^(.*)@(.*)$/', $objimport->array_import_regex[0][$val], $reg))
+ // If test is "Must exist in a field@table or field@table:..."
+ if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg))
{
$field=$reg[1];
$table=$reg[2];
+ $filter=!empty($reg[3])?substr($reg[3], 1):'';
+
+ $cachekey = $field.'@'.$table;
+ if(! empty($filter)) $cachekey.= ':'.$filter;
// Load content of field@table into cache array
- if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache
+ if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache
{
$sql="SELECT ".$field." as aliasfield FROM ".$table;
+ if(! empty($filter))
+ {
+ $sql.= ' WHERE ' . $filter;
+ }
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -612,7 +640,7 @@ class ImportCsv extends ModeleImports
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
- if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield;
+ if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield;
$i++;
}
}
@@ -623,9 +651,11 @@ class ImportCsv extends ModeleImports
}
// Now we check cache is not empty (should not) and key is into cache
- if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval, $this->cachefieldtable[$field.'@'.$table]))
+ if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey]))
{
- $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table);
+ $tableforerror = $table;
+ if(! empty($filter)) $tableforerror.= ':'.$filter;
+ $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror);
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
@@ -669,18 +699,30 @@ class ImportCsv extends ModeleImports
if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table
if ($val == 'user->id')
{
- $listfields[] = preg_replace('/^'.preg_quote($alias).'\./', '', $key);
+ $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
$listvalues[] = $user->id;
}
elseif (preg_match('/^lastrowid-/', $val))
{
$tmp=explode('-', $val);
$lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0;
- $keyfield = preg_replace('/^'.preg_quote($alias).'\./', '', $key);
+ $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
$listfields[] = $keyfield;
$listvalues[] = $lastinsertid;
//print $key."-".$val."-".$listfields."-".$listvalues." ";exit;
}
+ elseif (preg_match('/^const-/', $val))
+ {
+ $tmp=explode('-', $val, 2);
+ $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
+ $listvalues[] = "'".$tmp[1]."'";
+ }
+ else
+ {
+ $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden';
+ $this->errors[$error]['type']='Import profile setup';
+ $error++;
+ }
}
}
//print 'listfields='.$listfields.' listvalues='.$listvalues.' ';
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index ae0290401cc..66670247a4c 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -608,8 +608,27 @@ class ImportXlsx extends ModeleImports
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
$newval=$defaultref;
}
-
-
+ elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='compute')
+ {
+ $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
+ $class=$objimport->array_import_convertvalue[0][$val]['class'];
+ $method=$objimport->array_import_convertvalue[0][$val]['method'];
+ $resultload = dol_include_once($file);
+ if (empty($resultload))
+ {
+ dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method);
+ break;
+ }
+ $classinstance=new $class($this->db);
+ $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord));
+ if ($res<0) {
+ if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
+ else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
+ $this->errors[$error]['type']='FOREIGNKEY';
+ $errorforthistable++;
+ $error++;
+ }
+ }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric')
{
$newval = price2num($newval);
@@ -621,16 +640,25 @@ class ImportXlsx extends ModeleImports
// Test regexp
if (! empty($objimport->array_import_regex[0][$val]) && ($newval != ''))
{
- // If test is "Must exist in a field@table"
- if (preg_match('/^(.*)@(.*)$/', $objimport->array_import_regex[0][$val], $reg))
+ // If test is "Must exist in a field@table or field@table:..."
+ if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg))
{
$field=$reg[1];
$table=$reg[2];
+ $filter=!empty($reg[3])?substr($reg[3], 1):'';
+
+ $cachekey = $field.'@'.$table;
+ if(! empty($filter)) $cachekey.= ':'.$filter;
// Load content of field@table into cache array
- if (! is_array($this->cachefieldtable[$field.'@'.$table])) // If content of field@table not already loaded into cache
+ if (! is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache
{
$sql="SELECT ".$field." as aliasfield FROM ".$table;
+ if(! empty($filter))
+ {
+ $sql.= ' WHERE ' . $filter;
+ }
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -639,7 +667,7 @@ class ImportXlsx extends ModeleImports
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
- if ($obj) $this->cachefieldtable[$field.'@'.$table][]=$obj->aliasfield;
+ if ($obj) $this->cachefieldtable[$cachekey][]=$obj->aliasfield;
$i++;
}
}
@@ -650,9 +678,11 @@ class ImportXlsx extends ModeleImports
}
// Now we check cache is not empty (should not) and key is into cache
- if (! is_array($this->cachefieldtable[$field.'@'.$table]) || ! in_array($newval, $this->cachefieldtable[$field.'@'.$table]))
+ if (! is_array($this->cachefieldtable[$cachekey]) || ! in_array($newval, $this->cachefieldtable[$cachekey]))
{
- $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $table);
+ $tableforerror = $table;
+ if(! empty($filter)) $tableforerror.= ':'.$filter;
+ $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror);
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
@@ -688,21 +718,33 @@ class ImportXlsx extends ModeleImports
// Loop on each hidden fields to add them into listfields/listvalues
foreach($objimport->array_import_fieldshidden[0] as $key => $val)
{
- if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table
+ if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table
if ($val == 'user->id')
{
- $listfields[] = preg_replace('/^'.preg_quote($alias).'\./', '', $key);
+ $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
$listvalues[] = $user->id;
}
elseif (preg_match('/^lastrowid-/', $val))
{
$tmp=explode('-', $val);
$lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0;
- $keyfield = preg_replace('/^'.preg_quote($alias).'\./', '', $key);
+ $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
$listfields[] = $keyfield;
$listvalues[] = $lastinsertid;
//print $key."-".$val."-".$listfields."-".$listvalues." ";exit;
}
+ elseif (preg_match('/^const-/', $val))
+ {
+ $tmp=explode('-', $val, 2);
+ $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);
+ $listvalues[] = "'".$tmp[1]."'";
+ }
+ else
+ {
+ $this->errors[$error]['lib']='Bad value of profile setup '.$val.' for array_import_fieldshidden';
+ $this->errors[$error]['type']='Import profile setup';
+ $error++;
+ }
}
}
//print 'listfields='.$listfields.' listvalues='.$listvalues.' ';
diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
index a2124b801a6..fcb5ef8433e 100644
--- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
@@ -139,9 +139,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
- $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_codeproduitservice = 1; // Affiche code produit-service
+ $this->option_logo = 1; // Display logo FAC_PDF_LOGO
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_codeproduitservice = 1; // Display product-service code
$this->franchise=!$mysoc->tva_assuj;
@@ -479,7 +479,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php
index 531ff26a354..5cae280f245 100644
--- a/htdocs/core/modules/livraison/mod_livraison_jade.php
+++ b/htdocs/core/modules/livraison/mod_livraison_jade.php
@@ -61,7 +61,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php
index f05900600c2..23af66b1913 100644
--- a/htdocs/core/modules/livraison/mod_livraison_saphir.php
+++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php
@@ -56,7 +56,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index b7ef8950fe1..12f95053dc0 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -170,15 +170,23 @@ class modAccounting extends DolibarrModules
$this->rights = array(); // Permission array used by this module
$r = 0;
- $this->rights[$r][0] = 50440;
- $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';
+ $this->rights[$r][0] = 50440;
+ $this->rights[$r][1] = 'Manage chart of accounts, setup of accountancy';
+ $this->rights[$r][2] = 'r';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'chartofaccount';
+ $this->rights[$r][5] = '';
+ $r++;
+
+ $this->rights[$r][0] = 50430;
+ $this->rights[$r][1] = 'Define and close a fiscal year';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'chartofaccount';
+ $this->rights[$r][4] = 'fiscalyear';
$this->rights[$r][5] = '';
$r++;
- $this->rights[$r][0] = 50401;
+ $this->rights[$r][0] = 50401;
$this->rights[$r][1] = 'Bind products and invoices with accounting accounts';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
@@ -212,6 +220,30 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'creer';
$r++;
+ $this->rights[$r][0] = 50414;
+ $this->rights[$r][1] = 'Delete operations in Ledger';
+ $this->rights[$r][2] = 'd';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'supprimer';
+ $r++;
+
+ $this->rights[$r][0] = 50415;
+ $this->rights[$r][1] = 'Delete all operations by year and journal in Ledger';
+ $this->rights[$r][2] = 'd';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'supprimer_tous';
+ $r++;
+
+ $this->rights[$r][0] = 50418;
+ $this->rights[$r][1] = 'Export operations of the Ledger';
+ $this->rights[$r][2] = 'r';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mouvements';
+ $this->rights[$r][5] = 'export';
+ $r++;
+
$this->rights[$r][0] = 50420;
$this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)';
$this->rights[$r][2] = 'r';
@@ -220,14 +252,6 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'lire';
$r++;
- $this->rights[$r][0] = 50430;
- $this->rights[$r][1] = 'Define and close a fiscal year';
- $this->rights[$r][2] = 'r';
- $this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'fiscalyear';
- $this->rights[$r][5] = '';
- $r++;
-
// Menus
//-------
@@ -240,7 +264,7 @@ class modAccounting extends DolibarrModules
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Chartofaccounts';
- $this->export_icon[$r]='Accounting';
+ $this->export_icon[$r]='accounting';
$this->export_permission[$r]=array(array("accounting","chartofaccount"));
$this->export_fields_array[$r]=array('ac.rowid'=>'ChartofaccountsId','ac.pcg_version'=>'Chartofaccounts','aa.rowid'=>'Id','aa.account_number'=>"AccountAccounting",'aa.label'=>"Label",'aa.account_parent'=>"Accountparent",'aa.pcg_type'=>"Pcgtype",'aa.pcg_subtype'=>'Pcgsubtype','aa.active'=>'Status');
$this->export_TypeFields_array[$r]=array('ac.rowid'=>'List:accounting_system:pcg_version','aa.account_number'=>"Text",'aa.label'=>"Text",'aa.account_parent'=>"Text",'aa.pcg_type'=>'Text','aa.pcg_subtype'=>'Text','aa.active'=>'Status');
@@ -264,32 +288,36 @@ class modAccounting extends DolibarrModules
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('b'=>MAIN_DB_PREFIX.'accounting_bookkeeping'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r]=array(
- 'b.doc_date'=>"Docdate",
- 'b.piece_num'=>"TransactionNumShort",
+ 'b.piece_num'=>"TransactionNumShort",
+ 'b.doc_date'=>"Docdate",
+ //'b.doc_type'=>'Doctype',
+ 'b.doc_ref'=>'Piece',
'b.code_journal'=>'Codejournal',
- 'b.journal_label'=>'JournalLabel',
+ //'b.journal_label'=>'JournalLabel',
'b.numero_compte'=>'AccountAccounting',
- 'b.label_compte'=>'LabelAccount',
+ //'b.label_compte'=>'LabelAccount',
'b.subledger_account'=>'SubledgerAccount',
'b.subledger_label'=>'SubledgerAccountLabel',
'b.label_operation'=>'LabelOperation',
'b.debit'=>"Debit",
'b.credit'=>"Credit"
);
- $this->import_fieldshidden_array[$r]=array('b.fk_user_author'=>'user->id'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
+ $this->import_fieldshidden_array[$r]=array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r]=array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r]=array(
- 'b.doc_date'=>'formatted as \'.dol_print_date(dol_now(),\'%Y-%m-%d\')',
- 'b.piece_num'=>'1',
+ 'b.piece_num'=>'123 (!!! use next value not already used)',
+ 'b.doc_date'=>dol_print_date(dol_now(), "%Y-%m-%d"),
+ //'b.doc_type'=>'import',
+ 'b.doc_ref'=>'My document ABC',
'b.code_journal'=>"VTE",
- 'b.journal_label'=>"Journal des ventes",
+ //'b.journal_label'=>"Sale journal",
'b.numero_compte'=>"707",
- 'b.label_compte'=>'Ventes',
+ //'b.label_compte'=>'Product account 707',
'b.subledger_account'=>'',
'b.subledger_label'=>'',
- 'b.label_operation'=>"Ventes services",
- 'b.debit'=>"0,00",
- 'b.credit'=>"100,00"
+ 'b.label_operation'=>"Sale of ABC",
+ 'b.debit'=>"0",
+ 'b.credit'=>"100"
);
// Chart of accounts
diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php
index b77acf288a3..827928af6b6 100644
--- a/htdocs/core/modules/modAdherent.class.php
+++ b/htdocs/core/modules/modAdherent.class.php
@@ -274,20 +274,22 @@ class modAdherent extends DolibarrModules
'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",
'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation',
'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel',
- 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount'
+ 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.datef'=>'DateEndSubscription','c.subscription'=>'Amount'
);
$this->export_TypeFields_array[$r]=array(
'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",
'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",
'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date',
- 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric'
+ 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text',
+ 'c.rowid'=>'Numeric','c.dateadh'=>'Date','c.datef'=>'Date','c.subscription'=>'Numeric'
);
$this->export_entities_array[$r]=array(
'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member',
'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",
'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",
'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member',
- 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription'
+ 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type',
+ 'c.rowid'=>'subscription','c.dateadh'=>'subscription','c.datef'=>'subscription','c.subscription'=>'subscription'
);
// Add extra fields
$keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php
index b860bf5b9bc..11de955fdbe 100644
--- a/htdocs/core/modules/modApi.class.php
+++ b/htdocs/core/modules/modApi.class.php
@@ -53,6 +53,7 @@ class modApi extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "interface";
+ $this->module_position = '24';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php
index fb2c818043e..21c33d35170 100644
--- a/htdocs/core/modules/modBanque.class.php
+++ b/htdocs/core/modules/modBanque.class.php
@@ -150,14 +150,15 @@ class modBanque extends DolibarrModules
$this->export_fields_array[$r]=array(
'b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label',
'b.num_chq'=>'ChequeOrTransferNumber','b.fk_bordereau'=>'ChequeBordereau','-b.amount'=>'Debit','b.amount'=>'Credit',
- 'b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty",
- "s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode"
+ 'b.num_releve'=>'AccountStatement','b.rappro'=>'Conciliated','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty",
+ "s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode"
);
- $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text");
+ $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','b.fk_bordereau'=>'Text','-b.amount'=>'Numeric','b.amount'=>'Numeric','b.num_releve'=>'Text','b.rappro'=>'Boolean','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text");
$this->export_entities_array[$r]=array(
'b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account',
- 'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account',
- 'b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company"
+ 'b.num_chq'=>'account','b.fk_bordereau'=>'account','-b.amount'=>'account','b.amount'=>'account',
+ 'b.num_releve'=>'account','b.rappro'=>'account','b.datec'=>"account","bu.url_id"=>"company",
+ "s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company"
);
$this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG');
if (empty($conf->fournisseur->enabled))
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index d8f8b6915f3..4b819a5bcae 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -230,7 +230,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r]='category_'.$r;
$this->export_label[$r]='CatProdList';
$this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->produit->enabled';
+ $this->export_enabled[$r]='$conf->product->enabled || $conf->service->enabled';
$this->export_permission[$r]=array(array("categorie","lire"),array("produit","lire"));
$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref');
$this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.ref'=>'Text');
@@ -425,8 +425,8 @@ class modCategorie extends DolibarrModules
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product');
- $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"
- );
+ $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*");
+ $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0');
$this->import_convertvalue_array[$r]=array(
'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
@@ -444,7 +444,10 @@ class modCategorie extends DolibarrModules
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
- $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"
+ $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*");
+ $this->import_regex_array[$r]=array(
+ 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2',
+ 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0'
);
$this->import_convertvalue_array[$r]=array(
@@ -463,7 +466,10 @@ class modCategorie extends DolibarrModules
$this->import_icon[$r]=$this->picto;
$this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
- $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"
+ $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*");
+ $this->import_regex_array[$r]=array(
+ 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1',
+ 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0'
);
$this->import_convertvalue_array[$r]=array(
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index 025bbf0a50c..ea70a9f4103 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -51,7 +51,7 @@ class modCommande extends DolibarrModules
$this->numero = 25;
$this->family = "crm";
- $this->module_position = '30';
+ $this->module_position = '23';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des commandes clients";
diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php
index 708f0fb86a7..92b79f3ffb8 100644
--- a/htdocs/core/modules/modDynamicPrices.class.php
+++ b/htdocs/core/modules/modDynamicPrices.class.php
@@ -42,6 +42,7 @@ class modDynamicPrices extends DolibarrModules
$this->numero = 2200;
$this->family = "products";
+ $this->module_position = '85';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable the usage of math expressions for prices";
diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php
index 6a2ba294b7e..0d8fa008c6b 100644
--- a/htdocs/core/modules/modExpenseReport.class.php
+++ b/htdocs/core/modules/modExpenseReport.class.php
@@ -44,7 +44,7 @@ class modExpenseReport extends DolibarrModules
$this->numero = 770;
$this->family = "hr";
- $this->module_position = '40';
+ $this->module_position = '42';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index 106de48e96d..88343d8df49 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -218,7 +218,7 @@ class modFacture extends DolibarrModules
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
- 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
+ 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',
'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
@@ -232,21 +232,31 @@ class modFacture extends DolibarrModules
$this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
+ if (! empty($conf->cashdesk->enabled) || ! empty($conf->takepos->enabled) || ! empty($conf->global->INVOICE_SHOW_POS_IN_EXPORT))
+ {
+ $this->export_fields_array[$r]['f.module_source']='POSModule';
+ $this->export_fields_array[$r]['f.pos_source']='POSTerminal';
+ }
$this->export_TypeFields_array[$r] = array(
's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'none.rest'=>"NumericCompute", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric',
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
- 'pj.ref'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
+ 'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
'p.accountancy_code_sell'=>'Text'
);
+ if (! empty($conf->cashdesk->enabled) || ! empty($conf->takepos->enabled) || ! empty($conf->global->INVOICE_SHOW_POS_IN_EXPORT))
+ {
+ $this->export_TypeFields_array[$r]['f.module_source']='Text';
+ $this->export_TypeFields_array[$r]['f.pos_source']='Text';
+ }
$this->export_entities_array[$r] = array(
- 's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
+ 's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
- 's.tva_intra'=>'company', 'pj.ref'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
+ 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_sell'=>'product',
@@ -292,7 +302,7 @@ class modFacture extends DolibarrModules
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus',
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
- 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef',
+ 'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef',
'p.amount'=>'AmountPayment', 'pf.amount'=>'AmountPaymentDistributedOnInvoice', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber',
'pt.code'=>'CodePaymentMode', 'pt.libelle'=>'LabelPaymentMode', 'p.note'=>'PaymentNote', 'p.fk_bank'=>'IdTransaction', 'ba.ref'=>'AccountRef'
);
@@ -304,19 +314,29 @@ class modFacture extends DolibarrModules
$this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
+ if (! empty($conf->cashdesk->enabled) || ! empty($conf->takepos->enabled) || ! empty($conf->global->INVOICE_SHOW_POS_IN_EXPORT))
+ {
+ $this->export_fields_array[$r]['f.module_source']='POSModule';
+ $this->export_fields_array[$r]['f.pos_source']='POSTerminal';
+ }
$this->export_TypeFields_array[$r] = array(
's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'none.rest'=>'NumericCompute', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status',
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
- 'pj.ref'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
+ 'pj.ref'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.title'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
'p.fk_bank'=>'Numeric', 'p.note'=>'Text', 'pt.code'=>'Text', 'pt.libelle'=>'text', 'ba.ref'=>'Text'
);
+ if (! empty($conf->cashdesk->enabled) || ! empty($conf->takepos->enabled) || ! empty($conf->global->INVOICE_SHOW_POS_IN_EXPORT))
+ {
+ $this->export_fields_array[$r]['f.module_source']='POSModule';
+ $this->export_fields_array[$r]['f.pos_source']='POSTerminal';
+ }
$this->export_entities_array[$r] = array(
- 's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
+ 's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
- 's.tva_intra'=>'company', 'pj.ref'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
+ 's.tva_intra'=>'company', 'pj.ref'=>'project', 'p.title'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
'p.num_paiement'=>'payment', 'pt.code'=>'payment', 'pt.libelle'=>'payment', 'p.note'=>'payment', 'f.fk_user_author'=>'user', 'uc.login'=>'user',
'f.fk_user_valid'=>'user', 'uv.login'=>'user', 'p.fk_bank'=>'account', 'ba.ref'=>'account'
);
diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php
index 8267000297b..5ebba6ff6ee 100644
--- a/htdocs/core/modules/modFicheinter.class.php
+++ b/htdocs/core/modules/modFicheinter.class.php
@@ -50,7 +50,7 @@ class modFicheinter extends DolibarrModules
$this->numero = 70;
$this->family = "crm";
- $this->module_position = '45';
+ $this->module_position = '41';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des fiches d'intervention";
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index 12193b630c8..8ba2f173ffd 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -49,7 +49,7 @@ class modFournisseur extends DolibarrModules
// Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "srm";
- $this->module_position = '10';
+ $this->module_position = '12';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des fournisseurs";
@@ -276,7 +276,7 @@ class modFournisseur extends DolibarrModules
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Factures fournisseurs et lignes de facture';
+ $this->export_label[$r]='Vendor invoices and lines of invoices';
$this->export_icon[$r]='bill';
$this->export_permission[$r]=array(array("fournisseur","facture","export"));
$this->export_fields_array[$r]=array(
@@ -484,7 +484,7 @@ class modFournisseur extends DolibarrModules
// Order
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
+ $this->export_label[$r]='Purchase Orders and lines of purchase orders';
$this->export_icon[$r]='order';
$this->export_permission[$r]=array(array("fournisseur","commande","export"));
$this->export_fields_array[$r]=array(
diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php
index 09a30e16914..8bb34a338e5 100644
--- a/htdocs/core/modules/modHoliday.class.php
+++ b/htdocs/core/modules/modHoliday.class.php
@@ -54,7 +54,7 @@ class modHoliday extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "hr";
- $this->module_position = '30';
+ $this->module_position = '42';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index 3a18749bcde..d425b07d01a 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -50,7 +50,7 @@ class modProduct extends DolibarrModules
$this->numero = 50;
$this->family = "products";
- $this->module_position = '20';
+ $this->module_position = '25';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Product management";
diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php
index f100e8629e7..deb5192efc6 100644
--- a/htdocs/core/modules/modProjet.class.php
+++ b/htdocs/core/modules/modProjet.class.php
@@ -49,7 +49,7 @@ class modProjet extends DolibarrModules
$this->numero = 400;
$this->family = "projects";
- $this->module_position = '10';
+ $this->module_position = '14';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des projets";
@@ -220,7 +220,7 @@ class modProjet extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
'p.rowid'=>"List:projet:ref::project",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
- 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
+ 'pt.rowid'=>'Numeric','pt.ref'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
@@ -247,8 +247,8 @@ class modProjet extends DolibarrModules
$keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// Add fields for tasks
- $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.label'=>'LabelTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
- $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.label'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
+ $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
+ $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
// Add extra fields for task
$keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index b28477f3719..745fec8ef96 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -49,7 +49,7 @@ class modPropale extends DolibarrModules
$this->numero = 20;
$this->family = "crm";
- $this->module_position = '20';
+ $this->module_position = '22';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des propositions commerciales";
diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php
index 9fc82dc9ad6..6594d7bb04a 100644
--- a/htdocs/core/modules/modReception.class.php
+++ b/htdocs/core/modules/modReception.class.php
@@ -41,10 +41,10 @@ class modReception extends DolibarrModules
global $conf, $user;
$this->db = $db;
- $this->numero = 104160;
+ $this->numero = 94160;
$this->family = "srm";
- $this->module_position = 40;
+ $this->module_position = '40';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des réceptions fournisseurs";
diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
index 5925998a2b2..cceacf3263c 100644
--- a/htdocs/core/modules/modResource.class.php
+++ b/htdocs/core/modules/modResource.class.php
@@ -55,7 +55,7 @@ class modResource extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "projects";
- $this->module_position = '20';
+ $this->module_position = '16';
// Module label (no space allowed)
// used if translation string 'ModuleXXXName' not found
// (where XXX is value of numeric property 'numero' of module)
diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php
index e111e81ef6b..71aff3a11a6 100644
--- a/htdocs/core/modules/modSalaries.class.php
+++ b/htdocs/core/modules/modSalaries.class.php
@@ -5,7 +5,7 @@
* Copyright (C) 2004 Benoit Mortier
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2014 Alexandre Spangaro
+ * Copyright (C) 2014-2019 Alexandre Spangaro
*
* 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
@@ -68,8 +68,7 @@ class modSalaries extends DolibarrModules
$this->dirs = array("/salaries/temp");
// Config pages
- //$this->config_page_url = array('salaries.php');
- $this->config_page_url = array();
+ $this->config_page_url = array('salaries.php@salaries');
// Dependencies
$this->hidden = false; // A condition to hide module
@@ -144,7 +143,7 @@ class modSalaries extends DolibarrModules
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Salaries and payments';
+ $this->export_label[$r]='SalariesAndPayments';
$this->export_permission[$r]=array(array("salaries","export"));
$this->export_fields_array[$r]=array('u.firstname'=>"Firstname",'u.lastname'=>"Lastname",'u.login'=>"Login",'u.salary'=>'CurrentSalary','p.datep'=>'DatePayment','p.datesp'=>'DateStartPeriod','p.dateep'=>'DateEndPeriod','p.amount'=>'AmountPayment','p.num_payment'=>'Numero','p.label'=>'Label','p.note'=>'Note');
$this->export_TypeFields_array[$r]=array('u.firstname'=>"Text",'u.lastname'=>"Text",'u.login'=>'Text','u.salary'=>"Numeric",'p.datep'=>'Date','p.datesp'=>'Date','p.dateep'=>'Date','p.amount'=>'Numeric','p.num_payment'=>'Numeric','p.label'=>'Text');
diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php
index 9db733e4bb2..605c48f0e6b 100644
--- a/htdocs/core/modules/modService.class.php
+++ b/htdocs/core/modules/modService.class.php
@@ -48,7 +48,7 @@ class modService extends DolibarrModules
$this->numero = 53;
$this->family = "products";
- $this->module_position = '30';
+ $this->module_position = '29';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Service management";
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index cb01019cc1b..e41e96c5add 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -49,7 +49,7 @@ class modSociete extends DolibarrModules
$this->numero = 1;
$this->family = "crm";
- $this->module_position = '10';
+ $this->module_position = '09';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des sociétés et contacts";
diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php
index 882b02b5fb4..18cddf2a143 100644
--- a/htdocs/core/modules/modSupplierProposal.class.php
+++ b/htdocs/core/modules/modSupplierProposal.class.php
@@ -50,6 +50,7 @@ class modSupplierProposal extends DolibarrModules
$this->numero = 1120;
$this->family = "srm";
+ $this->module_position = '35';
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "supplier_proposalDESC";
diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php
index 1ac6ead1087..b754eae2765 100644
--- a/htdocs/core/modules/modSyslog.class.php
+++ b/htdocs/core/modules/modSyslog.class.php
@@ -46,7 +46,7 @@ class modSyslog extends DolibarrModules
// It is used to group modules in module setup page
$this->family = "base";
// Module position in the family on 2 digits ('01', '10', '20', ...)
- $this->module_position = '50';
+ $this->module_position = '75';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php
index 9436bfa84e8..e16b6e87fd0 100644
--- a/htdocs/core/modules/modTicket.class.php
+++ b/htdocs/core/modules/modTicket.class.php
@@ -99,6 +99,7 @@ class modTicket extends DolibarrModules
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->langfiles = array("ticket");
+
// Constants
// List of particular constants to add when module is enabled
// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php
index bf7b0c49896..7e31400f1ab 100644
--- a/htdocs/core/modules/modUser.class.php
+++ b/htdocs/core/modules/modUser.class.php
@@ -46,7 +46,7 @@ class modUser extends DolibarrModules
$this->numero = 0;
$this->family = "hr"; // Family for module (or "base" if core module)
- $this->module_position = '10';
+ $this->module_position = '05';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des utilisateurs (requis)";
diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php
index 2aa98e80679..f031d3cc5ec 100644
--- a/htdocs/core/modules/modWebServices.class.php
+++ b/htdocs/core/modules/modWebServices.class.php
@@ -41,6 +41,7 @@ class modWebServices extends DolibarrModules
$this->numero = 2600;
$this->family = "interface";
+ $this->module_position = '25';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable the Dolibarr web services server";
diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php
index 33c7bae997a..8f2ba109bd7 100644
--- a/htdocs/core/modules/modWebServicesClient.class.php
+++ b/htdocs/core/modules/modWebServicesClient.class.php
@@ -41,6 +41,7 @@ class modWebServicesClient extends DolibarrModules
$this->numero = 2660;
$this->family = "interface";
+ $this->module_position = '26';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable the web service client to call external supplier web services";
diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php
index 21ad0d91b9e..a9cde1b86cb 100644
--- a/htdocs/core/modules/payment/mod_payment_ant.php
+++ b/htdocs/core/modules/payment/mod_payment_ant.php
@@ -55,7 +55,7 @@ class mod_payment_ant extends ModeleNumRefPayments
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php
index 7670a623c49..f6bb3bc46a7 100644
--- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php
+++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php
@@ -154,7 +154,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$widthtouse = $maxwidthtouse;
$heighttouse = $maxheighttouse;
$logoHeight = $heighttouse;
- $logoWidth = $heighttouse;
+ $logoWidth = $widthtouse;
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
@@ -175,9 +175,11 @@ class pdf_tcpdflabel extends CommonStickerGenerator
}
elseif ($textleft!='' && $textright!='') // left and right part
{
+ $logoHeight = $heighttouse/2;
+ $logoWidth = $widthtouse/2;
if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') ) // left part logo/barcode right part text
{
- if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
+ if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $logoWidth, 0);
elseif ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
@@ -187,7 +189,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
}
elseif (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
{
- if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
+ if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $logoWidth, 0);
elseif ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
@@ -203,7 +205,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else {
$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
- $pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
+ $pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
}
}
elseif ($textright == '%LOGO%') // right part logo left part text/barcode
diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
index 49dc1b7598c..f8861380b2f 100644
--- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
+++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
@@ -244,7 +244,7 @@ class doc_generic_product_odt extends ModelePDFProduct
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
- if ($conf->produit->dir_output)
+ if ($conf->product->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
@@ -262,7 +262,7 @@ class doc_generic_product_odt extends ModelePDFProduct
$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
- $dir = $conf->produit->dir_output;
+ $dir = $conf->product->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
@@ -302,9 +302,9 @@ class doc_generic_product_odt extends ModelePDFProduct
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
- //print "conf->produit->dir_temp=".$conf->produit->dir_temp;
+ //print "conf->product->dir_temp=".$conf->product->dir_temp;
- dol_mkdir($conf->produit->dir_temp);
+ dol_mkdir($conf->product->dir_temp);
// If CUSTOMER contact defined on product, we use it
@@ -357,10 +357,10 @@ class doc_generic_product_odt extends ModelePDFProduct
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
- $odfHandler = new odf(
+ $odfHandler = new odf(
$srctemplatepath,
array(
- 'PATH_TO_TMP' => $conf->produit->dir_temp,
+ 'PATH_TO_TMP' => $conf->product->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php
index 04d566248b9..a9bc06f1021 100644
--- a/htdocs/core/modules/product/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php
@@ -172,20 +172,20 @@ class pdf_standard extends ModelePDFProduct
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
- if ($conf->produit->dir_output)
+ if ($conf->product->dir_output)
{
// Definition of $dir and $file
if ($object->specimen)
{
- $dir = $conf->produit->dir_output;
+ $dir = $conf->product->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->produit->dir_output . "/" . $objectref;
+ $dir = $conf->product->dir_output . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
}
@@ -346,7 +346,7 @@ class pdf_standard extends ModelePDFProduct
// Loop on each lines
/*
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
@@ -375,7 +375,7 @@ class pdf_standard extends ModelePDFProduct
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -484,7 +484,7 @@ class pdf_standard extends ModelePDFProduct
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -493,7 +493,7 @@ class pdf_standard extends ModelePDFProduct
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
index c7005206fcc..257b477a8df 100644
--- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
@@ -188,7 +188,7 @@ class pdf_baleine extends ModelePDFProjects
if ($conf->projet->dir_output)
{
- //$nblignes = count($object->lines); // This is set later with array of tasks
+ //$nblines = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
@@ -250,7 +250,7 @@ class pdf_baleine extends ModelePDFProjects
}
$object->lines=$tasksarray;
- $nblignes=count($object->lines);
+ $nblines=count($object->lines);
$pdf->Open();
$pagenb=0;
@@ -287,7 +287,7 @@ class pdf_baleine extends ModelePDFProjects
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -313,7 +313,7 @@ class pdf_baleine extends ModelePDFProjects
$nexY = $tab_top + $heightoftitleline + 1;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -352,7 +352,7 @@ class pdf_baleine extends ModelePDFProjects
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -428,7 +428,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -437,7 +437,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index dfbe97c3fd5..381d68c16d2 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -160,7 +160,7 @@ class pdf_beluga extends ModelePDFProjects
if ($conf->projet->dir_output)
{
- //$nblignes = count($object->lines); // This is set later with array of tasks
+ //$nblines = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
@@ -223,7 +223,7 @@ class pdf_beluga extends ModelePDFProjects
}
$object->lines=$tasksarray;
- $nblignes=count($object->lines);
+ $nblines=count($object->lines);
$pdf->Open();
$pagenb=0;
@@ -260,7 +260,7 @@ class pdf_beluga extends ModelePDFProjects
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -438,7 +438,7 @@ class pdf_beluga extends ModelePDFProjects
$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
}
$pdf->SetXY($this->posxstatut, $curY);
- $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R');
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R');
if (is_array($elementarray) && count($elementarray) > 0)
{
@@ -642,7 +642,7 @@ class pdf_beluga extends ModelePDFProjects
}
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
index 2c69fbd6bab..14946ca5cf3 100644
--- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
@@ -120,7 +120,7 @@ class pdf_timespent extends ModelePDFProjects
if ($conf->projet->dir_output)
{
- //$nblignes = count($object->lines); // This is set later with array of tasks
+ //$nblines = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
@@ -181,7 +181,7 @@ class pdf_timespent extends ModelePDFProjects
}
$object->lines=$tasksarray;
- $nblignes=count($object->lines);
+ $nblines=count($object->lines);
$pdf->Open();
$pagenb=0;
@@ -218,7 +218,7 @@ class pdf_timespent extends ModelePDFProjects
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -244,7 +244,7 @@ class pdf_timespent extends ModelePDFProjects
$nexY = $tab_top + $heightoftitleline + 1;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -283,7 +283,7 @@ class pdf_timespent extends ModelePDFProjects
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -359,7 +359,7 @@ class pdf_timespent extends ModelePDFProjects
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -368,7 +368,7 @@ class pdf_timespent extends ModelePDFProjects
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php
index d9287109d6e..70394f92129 100644
--- a/htdocs/core/modules/project/mod_project_universal.php
+++ b/htdocs/core/modules/project/mod_project_universal.php
@@ -55,7 +55,7 @@ class mod_project_universal extends ModeleNumRefProjects
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php
index f08067541e8..760caaa366e 100644
--- a/htdocs/core/modules/project/task/mod_task_universal.php
+++ b/htdocs/core/modules/project/task/mod_task_universal.php
@@ -55,7 +55,7 @@ class mod_task_universal extends ModeleNumRefTask
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 54fe56421ea..4ad23a1704e 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -218,7 +218,7 @@ class pdf_azur extends ModelePDFPropales
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -227,7 +227,7 @@ class pdf_azur extends ModelePDFPropales
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "propal", "products"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
@@ -235,7 +235,7 @@ class pdf_azur extends ModelePDFPropales
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -362,7 +362,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -470,7 +470,7 @@ class pdf_azur extends ModelePDFPropales
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -527,7 +527,7 @@ class pdf_azur extends ModelePDFPropales
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -640,7 +640,7 @@ class pdf_azur extends ModelePDFPropales
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -649,7 +649,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index 14a2456157a..3ddc8a45a52 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -193,7 +193,7 @@ class pdf_cyan extends ModelePDFPropales
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -206,7 +206,7 @@ class pdf_cyan extends ModelePDFPropales
$outputlangs->load("propal");
$outputlangs->load("products");
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$hidetop=0;
if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
@@ -220,7 +220,7 @@ class pdf_cyan extends ModelePDFPropales
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -557,7 +557,7 @@ class pdf_cyan extends ModelePDFPropales
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -617,7 +617,7 @@ class pdf_cyan extends ModelePDFPropales
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -755,7 +755,7 @@ class pdf_cyan extends ModelePDFPropales
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -764,7 +764,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
index dec1f35e7b0..71e78368d9c 100644
--- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php
+++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
@@ -131,7 +131,7 @@ class pdf_squille extends ModelePdfReception
$outputlangs->load("receptions");
$outputlangs->load("productbatch");
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
@@ -139,7 +139,7 @@ class pdf_squille extends ModelePdfReception
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -216,8 +216,8 @@ class pdf_squille extends ModelePdfReception
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- // Set nblignes with the new facture lines content after hook
- $nblignes = count($object->lines);
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -357,7 +357,7 @@ class pdf_squille extends ModelePdfReception
$fk_commandefourndet=0;
$totalOrdered=0;
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -416,7 +416,7 @@ class pdf_squille extends ModelePdfReception
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -496,7 +496,7 @@ class pdf_squille extends ModelePdfReception
if ($weighttxt && $voltxt) $nexY+=2;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php
index 4c5ffcd66c5..f3106cef761 100644
--- a/htdocs/core/modules/societe/mod_codecompta_panicum.php
+++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php
@@ -96,8 +96,8 @@ class mod_codecompta_panicum extends ModeleAccountancyCode
$this->code='';
if (is_object($societe)) {
- if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
- else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
+ if ($type == 'supplier') $this->code = (($societe->code_compta_fournisseur != "")?$societe->code_compta_fournisseur:'');
+ else $this->code = (($societe->code_compta != "")?$societe->code_compta:'');
}
return 0; // return ok
diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php
index d185b4cfcf7..4a873847d8a 100644
--- a/htdocs/core/modules/societe/modules_societe.class.php
+++ b/htdocs/core/modules/societe/modules_societe.class.php
@@ -393,7 +393,7 @@ abstract class ModeleAccountancyCode
* @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
+ * @deprecated Use the new function generateDocument of Objects class
* @see Societe::generateDocument()
*/
function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
index 35c467c110c..ac9c0423694 100644
--- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
+++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
@@ -244,7 +244,7 @@ class doc_generic_stock_odt extends ModelePDFStock
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
- if ($conf->produit->dir_output)
+ if ($conf->product->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
@@ -262,7 +262,7 @@ class doc_generic_stock_odt extends ModelePDFStock
$supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
- $dir = $conf->produit->dir_output;
+ $dir = $conf->product->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
@@ -302,9 +302,9 @@ class doc_generic_stock_odt extends ModelePDFStock
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
- //print "conf->produit->dir_temp=".$conf->produit->dir_temp;
+ //print "conf->product->dir_temp=".$conf->product->dir_temp;
- dol_mkdir($conf->produit->dir_temp);
+ dol_mkdir($conf->product->dir_temp);
// If CUSTOMER contact defined on stock, we use it
@@ -360,7 +360,7 @@ class doc_generic_stock_odt extends ModelePDFStock
$odfHandler = new odf(
$srctemplatepath,
array(
- 'PATH_TO_TMP' => $conf->produit->dir_temp,
+ 'PATH_TO_TMP' => $conf->product->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
index e1181aa6fe2..6c222f96dca 100644
--- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
@@ -201,7 +201,7 @@ class pdf_standard extends ModelePDFStock
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
if ($conf->stock->dir_output)
{
@@ -323,8 +323,8 @@ class pdf_standard extends ModelePDFStock
{
$num = $db->num_rows($resql);
$i = 0;
- $nblignes = $num;
- for ($i = 0 ; $i < $nblignes ; $i++)
+ $nblines = $num;
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$objp = $db->fetch_object($resql);
@@ -372,7 +372,7 @@ class pdf_standard extends ModelePDFStock
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -452,7 +452,7 @@ class pdf_standard extends ModelePDFStock
$totalvaluesell+=price2num($pricemin*$objp->value, 'MT');
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -461,7 +461,7 @@ class pdf_standard extends ModelePDFStock
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -550,7 +550,7 @@ class pdf_standard extends ModelePDFStock
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -576,7 +576,7 @@ class pdf_standard extends ModelePDFStock
// Loop on each lines
/*
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
@@ -605,7 +605,7 @@ class pdf_standard extends ModelePDFStock
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -644,7 +644,7 @@ class pdf_standard extends ModelePDFStock
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -653,7 +653,7 @@ class pdf_standard extends ModelePDFStock
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
index 2a1819a3aa0..5efa1b0b312 100644
--- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
@@ -331,7 +331,7 @@ class pdf_stdmovement extends ModelePDFMovement
* END TODO
**/
- //$nblignes = count($object->lines);
+ //$nblines = count($object->lines);
if ($conf->stock->dir_output)
{
@@ -481,8 +481,8 @@ class pdf_stdmovement extends ModelePDFMovement
{
$num = $db->num_rows($resql);
$i = 0;
- $nblignes = $num;
- for ($i = 0 ; $i < $nblignes ; $i++)
+ $nblines = $num;
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$objp = $db->fetch_object($resql);
@@ -530,7 +530,7 @@ class pdf_stdmovement extends ModelePDFMovement
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -639,9 +639,9 @@ class pdf_stdmovement extends ModelePDFMovement
$totalvaluesell+=price2num($pricemin*$objp->value, 'MT');
- $nexY+=3.5; // Passe espace entre les lignes
+ $nexY+=3.5; // Add space between lines
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -650,7 +650,7 @@ class pdf_stdmovement extends ModelePDFMovement
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -724,7 +724,7 @@ class pdf_stdmovement extends ModelePDFMovement
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
+
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 5c0904baba8..4c4fe7106a7 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -199,7 +199,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$hookmanager,$nblines;
// Get source company
if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
@@ -259,7 +259,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
@@ -296,7 +296,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -370,7 +370,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -397,7 +397,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -495,7 +495,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->localtax2[$localtax2rate]+=$localtax2ligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -504,7 +504,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
index 6154ba5e1d9..c816953a298 100644
--- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
+++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
@@ -57,7 +57,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
index 612595b8c44..e96f5ef4eab 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
@@ -185,7 +185,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
+ global $user,$langs,$conf,$hookmanager,$mysoc,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -194,7 +194,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$hidetop=0;
if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
@@ -205,7 +205,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$realpatharray=array();
if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -284,7 +284,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
@@ -496,7 +496,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -553,7 +553,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -689,7 +689,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80)));
@@ -698,7 +698,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index 0c9e8e0967a..9f9f0cfad38 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -213,7 +213,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
+ global $user,$langs,$conf,$hookmanager,$mysoc,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -222,13 +222,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -307,7 +307,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
@@ -344,7 +344,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -418,7 +418,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -481,7 +481,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -591,7 +591,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -600,7 +600,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
index 79ad993ef81..e4b6b73fbc1 100644
--- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
@@ -264,7 +264,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
@@ -325,7 +325,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -354,7 +354,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -412,7 +412,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -421,7 +421,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
index e2407877a7b..d06a2ccfcf3 100644
--- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
+++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
@@ -55,7 +55,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
index d8d489c1bbf..e486474d1d5 100644
--- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
@@ -209,7 +209,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -218,13 +218,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Load traductions files requiredby by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
- $nblignes = count($object->lines);
+ $nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
@@ -333,7 +333,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -403,7 +403,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
+ for ($i = 0 ; $i < $nblines ; $i++)
{
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
@@ -469,7 +469,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -587,7 +587,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
@@ -596,7 +596,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $nexY+=2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php
index 361ecdd0c9d..007e0b318cd 100644
--- a/htdocs/core/modules/ticket/mod_ticket_universal.php
+++ b/htdocs/core/modules/ticket/mod_ticket_universal.php
@@ -53,7 +53,7 @@ class mod_ticket_universal extends ModeleNumRefTicket
public $name='Universal';
/**
- * Renvoi la description du modele de numerotation
+ * Returns the description of the numbering model
*
* @return string Texte descripif
*/
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 2ecb127f3b2..47be8cdf974 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -53,6 +53,12 @@ elseif ($modulepart == 'project')
if (! $user->rights->projet->lire) accessforbidden();
$accessallowed=1;
}
+elseif ($modulepart == 'bom')
+{
+ $result=restrictedArea($user, 'bom', $id, 'bom_bom');
+ if (! $user->rights->bom->read) accessforbidden();
+ $accessallowed=1;
+}
elseif ($modulepart == 'expensereport')
{
$result=restrictedArea($user, 'expensereport', $id, 'expensereport');
@@ -205,8 +211,19 @@ elseif ($modulepart == 'ticket')
$dir=$conf->ticket->dir_output; // By default
}
}
+elseif ($modulepart == 'bom')
+{
+ require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
+ $object = new BOM($db);
+ if ($id > 0)
+ {
+ $result = $object->fetch($id);
+ if ($result <= 0) dol_print_error($db, 'Failed to load object');
+ $dir=$conf->bom->dir_output; // By default
+ }
+}
else {
- print 'Action crop for module part '.$modulepart.' is not supported yet.';
+ print 'Action crop for modulepart = '.$modulepart.' is not supported yet.';
}
if (empty($backtourl))
@@ -220,6 +237,7 @@ if (empty($backtourl))
elseif (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
+ else $backtourl=DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
}
diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php
index 45c620db456..360db1e94b0 100644
--- a/htdocs/core/tpl/admin_extrafields_add.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -44,7 +44,7 @@ $langs->load("modulebuilder");
jQuery(document).ready(function() {
function init_typeoffields(type)
{
- console.log("We select a new type = "+type);
+ console.log("select a new type (add) = "+type);
var size = jQuery("#size");
var computed_value = jQuery("#computed_value");
var langfile = jQuery("#langfile");
@@ -68,7 +68,6 @@ $langs->load("modulebuilder");
?>
// Case of computed field
- console.log(type);
if (type == '' || type == 'varchar' || type == 'int' || type == 'double' || type == 'price') {
jQuery("tr.extra_computed_value").show();
} else {
@@ -96,18 +95,19 @@ $langs->load("modulebuilder");
else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'html') { size.val('2000').removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
- else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").show();}
+ else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
- else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();jQuery("#helppassword").hide();}
+ else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
+ else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpchkbxlst").show();}
+ else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helplink").show();}
else if (type == 'separate') {
langfile.val('').prop('disabled',true);size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true);
- jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();
+ jQuery("#value_choice").show();
+ jQuery(".spanforparamtooltip").hide(); jQuery("#helpseparate").show();
}
else { // type = string
size.val('').prop('disabled', true);
@@ -165,11 +165,12 @@ $langs->load("modulebuilder");
- textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelplink"), 1, 0, '', 0, 2, 'helpvalue4')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelplink"), 1, 0, '', 0, 2, 'helpvalue4')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?>
@@ -179,7 +180,11 @@ $langs->load("modulebuilder");
trans("LanguageFile"); ?>
-
+global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
+
+
+
+
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index 1ba83bc393f..1c4e91a50a5 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -43,7 +43,7 @@ $langs->load("modulebuilder");
jQuery(document).ready(function() {
function init_typeoffields(type)
{
- console.log("select new type "+type);
+ console.log("select a new type (edit) = "+type);
var size = jQuery("#size");
var computed_value = jQuery("#computed_value");
var langfile = jQuery("#langfile");
@@ -54,7 +54,7 @@ $langs->load("modulebuilder");
var list = jQuery("#list");
var totalizable = jQuery("#totalizable");
load("modulebuilder");
else if (type == 'text') { size.removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'html') { size.removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
else if (type == 'varchar') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
- else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").show();}
- else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
- else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
- else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
- else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();jQuery("#helppassword").hide();}
- else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();}
+ else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
+ else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
+ else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
+ else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
+ else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
+ else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpchkbxlst").show();}
+ else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helplink").show();}
+ else if (type == 'separate') {
+ size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true);
+ jQuery("#value_choice").show();
+ jQuery(".spanforparamtooltip").hide(); jQuery("#helpseparate").show();
+ }
else { // type = string
size.val('').prop('disabled', true);
unique.removeAttr('disabled');
@@ -173,7 +177,7 @@ if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_ar
}
}
}
-elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password'))
+elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password') || ($type == 'separate'))
{
$paramlist=array_keys($param['options']);
$param_chain = $paramlist[0];
@@ -229,11 +233,12 @@ else
- textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelplink"), 1, 0, '', 0, 2, 'helpvalue4')?>
- textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"), 1, 0, '', 0, 2, 'helpvalue1')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"), 1, 0, '', 0, 2, 'helpvalue2')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"), 1, 0, '', 0, 2, 'helpvalue3')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelplink"), 1, 0, '', 0, 2, 'helpvalue4')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"), 1, 0, '', 0, 2, 'helpvalue5')?>
+ textwithpicto('', $langs->trans("ExtrafieldParamHelpSeparator"), 1, 0, '', 0, 2, 'helpvalue6')?>
@@ -243,7 +248,11 @@ else
trans("LanguageFile"); ?>
-
+global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
+
+
+
+
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 8971dc2a919..0b92df1e519 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -66,13 +66,15 @@ $(document).ready(function(){
var fk_element = "";
var element_id = "";
var filepath = "";
+ var token = ""; // We use old 'token' and not 'newtoken' for Ajax call because the ajax page has the NOTOKENRENEWAL constant set.
$.post("/core/ajax/row.php",
{
roworder: roworder,
table_element_line: table_element_line,
fk_element: fk_element,
element_id: element_id,
- filepath: filepath
+ filepath: filepath,
+ token: token
},
function() {
console.log("tableDND end of ajax call");
diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
index 1dad8a6739d..35aefb9f719 100644
--- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
@@ -40,7 +40,17 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
{
$value = $obj->$tmpkey;
}
-
+ // If field is a computed field, we make computation to get value
+ if ($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])
+ {
+ //global $obj, $object;
+ //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
+ //var_dump($obj);
+ //var_dump($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]);
+ $value = dol_eval($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key], 1);
+ //var_dump($value);
+ }
+
print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
print '';
if (! $i) $totalarray['nbfield']++;
diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php
index a34308432e4..10aff5637c8 100644
--- a/htdocs/core/tpl/extrafields_view.tpl.php
+++ b/htdocs/core/tpl/extrafields_view.tpl.php
@@ -48,8 +48,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
//var_dump($extrafields->attributes[$object->table_element]);
if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label']))
-
{
+ $extrafields_collapse_num = '';
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
// Discard if extrafield is a hidden field on form
@@ -86,11 +86,25 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
}
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate')
{
+ $extrafields_collapse_num = '';
+ $extrafield_param = $extrafields->attributes[$object->table_element]['param'][$key];
+ if (!empty($extrafield_param) && is_array($extrafield_param)) {
+ $extrafield_param_list = array_keys($extrafield_param['options']);
+
+ if (count($extrafield_param_list)>0) {
+ $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
+
+ if ($extrafield_collapse_display_value==1 || $extrafield_collapse_display_value==2) {
+ $extrafields_collapse_num = $extrafields->attributes[$object->table_element]['pos'][$key];
+ }
+ }
+ }
+
print $extrafields->showSeparator($key, $object);
}
else
{
- print '';
+ print '