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

This commit is contained in:
Laurent Destailleur 2020-12-17 14:06:12 +01:00
commit 539afb88fe
10 changed files with 342 additions and 152 deletions

Binary file not shown.

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="INSTAT">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Envelope"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="envelopeId"/>
<xsd:element ref="DateTime"/>
<xsd:element ref="Party"/>
<xsd:element ref="softwareUsed" minOccurs="0"/>
<xsd:element ref="Declaration" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="envelopeId" type="xsd:string"/>
<xsd:element name="DateTime">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="date"/>
<xsd:element ref="time" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Party">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="partyId"/>
<xsd:element ref="partyName"/>
</xsd:sequence>
<xsd:attribute name="partyType" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="PSI"/>
<xsd:enumeration value="TDP"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="partyRole" use="required">
<xsd:simpleType>
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="sender"/>
<xsd:enumeration value="PSI"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="partyId" type="xsd:string"/>
<xsd:element name="partyName" type="xsd:string"/>
<xsd:element name="softwareUsed" type="xsd:string"/>
<xsd:element name="Declaration">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="declarationId"/>
<xsd:element ref="referencePeriod"/>
<xsd:element ref="PSIId"/>
<xsd:element ref="Function"/>
<xsd:element ref="declarationTypeCode"/>
<xsd:element ref="flowCode"/>
<xsd:element ref="currencyCode"/>
<xsd:element ref="Item" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="declarationId" type="xsd:string"/>
<xsd:element name="referencePeriod" type="xsd:string"/>
<xsd:element name="PSIId" type="xsd:string"/>
<xsd:element name="Function">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="functionCode"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="functionCode" type="xsd:string"/>
<xsd:element name="declarationTypeCode" type="xsd:string"/>
<xsd:element name="flowCode" type="xsd:string"/>
<xsd:element name="currencyCode" type="xsd:string"/>
<xsd:element name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="itemNumber"/>
<xsd:element ref="CN8" minOccurs="0"/>
<xsd:element ref="MSConsDestCode" minOccurs="0"/>
<xsd:element ref="countryOfOriginCode" minOccurs="0"/>
<xsd:element ref="netMass" minOccurs="0"/>
<xsd:element ref="quantityInSU" minOccurs="0"/>
<xsd:element ref="invoicedAmount"/>
<xsd:element ref="partnerId" minOccurs="0"/>
<xsd:element ref="invoicedNumber" minOccurs="0"/>
<xsd:element ref="statisticalProcedureCode" />
<xsd:element ref="NatureOfTransaction" minOccurs="0"/>
<xsd:element ref="modeOfTransportCode" minOccurs="0"/>
<xsd:element ref="regionCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="itemNumber" type="xsd:integer"/>
<xsd:element name="CN8">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="CN8Code" minOccurs="0"/>
<xsd:element ref="SUCode" minOccurs="0"/>
<xsd:element ref="additionalGoodsCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CN8Code" type="xsd:string"/>
<xsd:element name="SUCode" type="xsd:string"/>
<xsd:element name="additionalGoodsCode" type="xsd:string"/>
<xsd:element name="MSConsDestCode" type="xsd:string"/>
<xsd:element name="countryOfOriginCode" type="xsd:string"/>
<xsd:element name="netMass" type="xsd:integer"/>
<xsd:element name="quantityInSU" type="xsd:integer"/>
<xsd:element name="invoicedAmount" type="xsd:integer"/>
<xsd:element name="partnerId" type="xsd:string"/>
<xsd:element name="invoicedNumber" type="xsd:string"/>
<xsd:element name="statisticalProcedureCode" type="xsd:integer"/>
<xsd:element name="NatureOfTransaction">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="natureOfTransactionACode"/>
<xsd:element ref="natureOfTransactionBCode" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="natureOfTransactionACode" type="xsd:string"/>
<xsd:element name="natureOfTransactionBCode" type="xsd:string"/>
<xsd:element name="modeOfTransportCode" type="xsd:string"/>
<xsd:element name="regionCode" type="xsd:string"/>
<xsd:element name="date" type="xsd:date"/>
<xsd:element name="time" type="xsd:time"/>
</xsd:schema>

View File

@ -28,20 +28,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if ($action == 'setvalue') if ($action == 'setvalue') {
{
$showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha'); $showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha');
$res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU", $showmenu, 'chaine', 0, '', $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) {
$error++;
}
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {

View File

@ -38,20 +38,23 @@ function printDropdownBookmarksList()
$url = $_SERVER["PHP_SELF"]; $url = $_SERVER["PHP_SELF"];
if (!empty($_SERVER["QUERY_STRING"])) if (!empty($_SERVER["QUERY_STRING"])) {
{
$url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''); $url .= (dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '');
} else { } else {
global $sortfield, $sortorder; global $sortfield, $sortorder;
$tmpurl = ''; $tmpurl = '';
// No urlencode, all param $url will be urlencoded later // No urlencode, all param $url will be urlencoded later
if ($sortfield) $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield; if ($sortfield) {
if ($sortorder) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder; $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield;
if (is_array($_POST)) }
{ if ($sortorder) {
foreach ($_POST as $key => $val) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder;
{ }
if (preg_match('/^search_/', $key) && $val != '') $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val; if (is_array($_POST)) {
foreach ($_POST as $key => $val) {
if (preg_match('/^search_/', $key) && $val != '') {
$tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val;
}
} }
} }
$url .= ($tmpurl ? '?'.$tmpurl : ''); $url .= ($tmpurl ? '?'.$tmpurl : '');
@ -68,8 +71,7 @@ function printDropdownBookmarksList()
// Url to go on create new bookmark page // Url to go on create new bookmark page
$newbtn = ''; $newbtn = '';
if (!empty($user->rights->bookmark->creer)) if (!empty($user->rights->bookmark->creer)) {
{
//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url); //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url);
$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >'; $newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >';
@ -81,13 +83,11 @@ function printDropdownBookmarksList()
$sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
$sql .= " AND entity IN (".getEntity('bookmarks').")"; $sql .= " AND entity IN (".getEntity('bookmarks').")";
$sql .= " ORDER BY position"; $sql .= " ORDER BY position";
if ($resql = $db->query($sql)) if ($resql = $db->query($sql)) {
{
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$bookmarkList = '<div id="dropdown-bookmarks-list" >'; $bookmarkList = '<div id="dropdown-bookmarks-list" >';
$i = 0; $i = 0;
while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
{
$bookmarkList .= '<a class="dropdown-item bookmark-item'.(strpos($obj->url, 'http') === 0 ? ' bookmark-item-external' : '').'" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >'; $bookmarkList .= '<a class="dropdown-item bookmark-item'.(strpos($obj->url, 'http') === 0 ? ' bookmark-item-external' : '').'" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >';
$bookmarkList .= dol_escape_htmltag($obj->title); $bookmarkList .= dol_escape_htmltag($obj->title);
$bookmarkList .= '</a>'; $bookmarkList .= '</a>';
@ -104,15 +104,13 @@ function printDropdownBookmarksList()
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">'; $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">';
$searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>'; $searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
// Url to go on create new bookmark page // Url to go on create new bookmark page
if (!empty($user->rights->bookmark->creer)) if (!empty($user->rights->bookmark->creer)) {
{
$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"'; $searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>'; $searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
} }
$i = 0; $i = 0;
while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {
{
$searchForm .= '<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' rel="'.dol_escape_htmltag($obj->url).'" >'; $searchForm .= '<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' rel="'.dol_escape_htmltag($obj->url).'" >';
$searchForm .= dol_escape_htmltag($obj->title); $searchForm .= dol_escape_htmltag($obj->title);
$searchForm .= '</option>'; $searchForm .= '</option>';

View File

@ -83,8 +83,14 @@ class Bookmark extends CommonObject
*/ */
public $title; public $title;
/**
* @var int position of bookmark
*/
public $position; public $position;
/**
* @var string favicon
*/
public $favicon; public $favicon;
@ -116,8 +122,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::fetch", LOG_DEBUG); dol_syslog("Bookmark::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
@ -151,7 +156,9 @@ class Bookmark extends CommonObject
// Clean parameters // Clean parameters
$this->url = trim($this->url); $this->url = trim($this->url);
$this->title = trim($this->title); $this->title = trim($this->title);
if (empty($this->position)) $this->position = 0; if (empty($this->position)) {
$this->position = 0;
}
$now = dol_now(); $now = dol_now();
@ -164,17 +171,15 @@ class Bookmark extends CommonObject
$sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").",";
$sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($now)."',";
$sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',";
$sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', ".(int) $this->position;
$sql .= ", ".$this->db->escape($conf->entity); $sql .= ", ".(int) $conf->entity;
$sql .= ")"; $sql .= ")";
dol_syslog("Bookmark::create", LOG_DEBUG); dol_syslog("Bookmark::create", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark");
if ($id > 0) if ($id > 0) {
{
$this->id = $id; $this->id = $id;
$this->db->commit(); $this->db->commit();
return $id; return $id;
@ -202,7 +207,9 @@ class Bookmark extends CommonObject
// Clean parameters // Clean parameters
$this->url = trim($this->url); $this->url = trim($this->url);
$this->title = trim($this->title); $this->title = trim($this->title);
if (empty($this->position)) $this->position = 0; if (empty($this->position)) {
$this->position = 0;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark";
$sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0");
@ -211,12 +218,11 @@ class Bookmark extends CommonObject
$sql .= " ,target = '".$this->db->escape($this->target)."'"; $sql .= " ,target = '".$this->db->escape($this->target)."'";
$sql .= " ,title = '".$this->db->escape($this->title)."'"; $sql .= " ,title = '".$this->db->escape($this->title)."'";
$sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'";
$sql .= " ,position = '".$this->db->escape($this->position)."'"; $sql .= " ,position = ".(int) $this->position;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog("Bookmark::update", LOG_DEBUG); dol_syslog("Bookmark::update", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql)) {
{
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -237,8 +243,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::remove", LOG_DEBUG); dol_syslog("Bookmark::remove", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
@ -288,7 +293,9 @@ class Bookmark extends CommonObject
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
@ -298,33 +305,40 @@ class Bookmark extends CommonObject
$url = DOL_URL_ROOT.'/bookmarks/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/bookmarks/card.php?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $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 ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowBookmark"); $label = $langs->trans("ShowBookmark");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $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) {
if ($withpicto != 2) $result .= $this->ref; $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; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -332,8 +346,11 @@ class Bookmark extends CommonObject
$hookmanager->initHooks(array('mybookmarkdao')); $hookmanager->initHooks(array('mybookmarkdao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result); $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 $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; if ($reshook > 0) {
else $result .= $hookmanager->resPrint; $result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result; return $result;
} }

View File

@ -62,10 +62,10 @@ class modIntracommreport extends DolibarrModules
$this->config_page_url = array("intracommreport.php@intracommreport"); $this->config_page_url = array("intracommreport.php@intracommreport");
// Dependencies // Dependencies
$this->depends = array("modFacture", "modTax"); // List of modules id that must be enabled if this module is enabled $this->depends = array("modFacture", "modTax", "modCategorie"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array(); // List of modules id this module is in conflict with $this->conflictwith = array(); // List of modules id this module is in conflict with
$this->phpmin = array(5, 5); // Minimum version of PHP required by module $this->phpmin = array(5, 6); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(13, 0, -5); // Minimum version of Dolibarr required by module
$this->langfiles = array("intracommreport"); $this->langfiles = array("intracommreport");

View File

@ -159,9 +159,8 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").'</td>'; print '<td>'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").'</td>';
$arraychoices = array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €');
print '<td>'; print '<td>';
print $formother->select_categories(0, $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'INTRACOMMREPORT_CATEG_FRAISDEPORT'); print $formother->select_categories('product', $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'INTRACOMMREPORT_CATEG_FRAISDEPORT');
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -193,10 +192,8 @@ foreach ($list_DES as $key)
print '</table>'; print '</table>';
print '<div class="tabsAction">'; print '<div class="center">';
print '<div class="inline-block divButAction">'; print '<input type="submit" name="bt_save" class="butAction button-save" value="'.$langs->trans("Update").'" />';
print '<input type="submit" name="bt_save" class="butAction button-save" value="'.$langs->trans("Save").'" />';
print '</div>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';

View File

@ -142,7 +142,7 @@ class IntracommReport extends CommonObject
$date_time->addChild('date', date('Y-m-d')); $date_time->addChild('date', date('Y-m-d'));
$date_time->addChild('time', date('H:i:s')); $date_time->addChild('time', date('H:i:s'));
$party = $enveloppe->addChild('Party'); $party = $enveloppe->addChild('Party');
$party->addAttribute('partType', $conf->global->INTRACOMMREPORT_TYPE_ACTEUR); $party->addAttribute('partyType', $conf->global->INTRACOMMREPORT_TYPE_ACTEUR);
$party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_ROLE_ACTEUR); $party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_ROLE_ACTEUR);
$party->addChild('partyId', $party_id); $party->addChild('partyId', $party_id);
$party->addChild('partyName', $declarant); $party->addChild('partyName', $declarant);
@ -286,13 +286,13 @@ class IntracommReport extends CommonObject
global $mysoc, $conf; global $mysoc, $conf;
if ($type == 'expedition' || $exporttype == 'des') { if ($type == 'expedition' || $exporttype == 'des') {
$sql = 'SELECT f.facnumber, f.total as total_ht'; $sql = 'SELECT f.ref as refinvoice, f.total as total_ht';
$table = 'facture'; $table = 'facture';
$table_extraf = 'facture_extrafields'; $table_extraf = 'facture_extrafields';
$tabledet = 'facturedet'; $tabledet = 'facturedet';
$field_link = 'fk_facture'; $field_link = 'fk_facture';
} else { // Introduction } else { // Introduction
$sql = 'SELECT f.ref_supplier as facnumber, f.total_ht'; $sql = 'SELECT f.ref_supplier as refinvoice, f.total_ht';
$table = 'facture_fourn'; $table = 'facture_fourn';
$table_extraf = 'facture_fourn_extrafields'; $table_extraf = 'facture_fourn_extrafields';
$tabledet = 'facture_fourn_det'; $tabledet = 'facture_fourn_det';
@ -330,7 +330,7 @@ class IntracommReport extends CommonObject
public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '') public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '')
{ {
$item = $declaration->addChild('Item'); $item = $declaration->addChild('Item');
$item->addChild('ItemNumber', $i); $item->addChild('itemNumber', $i);
$cn8 = $item->addChild('CN8'); $cn8 = $item->addChild('CN8');
if (empty($code_douane_spe)) { if (empty($code_douane_spe)) {
$code_douane = $res->customcode; $code_douane = $res->customcode;
@ -338,14 +338,15 @@ class IntracommReport extends CommonObject
$code_douane = $code_douane_spe; $code_douane = $code_douane_spe;
} }
$cn8->addChild('CN8Code', $code_douane); $cn8->addChild('CN8Code', $code_douane);
$item->addChild('MSConsDestCode', $res->code); // code iso pays client
$item->addChild('countryOfOriginCode', substr($res->zip, 0, 2)); // code iso pays d'origine
$item->addChild('netMass', round($res->weight * $res->qty)); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne
$item->addChild('invoicedAmount', round($res->total_ht)); // Montant total ht de la facture (entier attendu)
// $item->addChild('invoicedNumber', $res->refinvoice); // Numéro facture
if (!empty($res->tva_intra)) { if (!empty($res->tva_intra)) {
$item->addChild('partnerId', $res->tva_intra); $item->addChild('partnerId', $res->tva_intra);
} }
$item->addChild('MSConsDestCode', $res->code); // code iso pays client
$item->addChild('netMass', $res->weight * $res->qty); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne
$item->addChild('invoicedAmount', round($res->total_ht)); // Montant total ht de la facture (entier attendu)
$item->addChild('invoicedNumber', $res->facnumber); // Numéro facture
$item->addChild('statisticalProcedureCode', '11'); $item->addChild('statisticalProcedureCode', '11');
$nature_of_transaction = $item->addChild('NatureOfTransaction'); $nature_of_transaction = $item->addChild('NatureOfTransaction');
$nature_of_transaction->addChild('natureOfTransactionACode', 1); $nature_of_transaction->addChild('natureOfTransactionACode', 1);
@ -389,7 +390,7 @@ class IntracommReport extends CommonObject
$table = 'facture'; $table = 'facture';
$tabledet = 'facturedet'; $tabledet = 'facturedet';
$field_link = 'fk_facture'; $field_link = 'fk_facture';
$more_sql = 'f.facnumber'; $more_sql = 'f.ref';
} else { // Introduction } else { // Introduction
$table = 'facture_fourn'; $table = 'facture_fourn';
$tabledet = 'facture_fourn_det'; $tabledet = 'facture_fourn_det';
@ -404,14 +405,14 @@ class IntracommReport extends CommonObject
INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = d.fk_product) INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = d.fk_product)
WHERE d.fk_product IS NOT NULL WHERE d.fk_product IS NOT NULL
AND f.entity = '.$conf->entity.' AND f.entity = '.$conf->entity.'
AND '.$more_sql.' = "'.$res->facnumber.'" AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.total_ht = AND d.total_ht =
( (
SELECT MAX(d.total_ht) SELECT MAX(d.total_ht)
FROM '.MAIN_DB_PREFIX.$tabledet.' d FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.') INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
WHERE d.fk_product IS NOT NULL WHERE d.fk_product IS NOT NULL
AND '.$more_sql.' = "'.$res->facnumber.'" AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.fk_product NOT IN AND d.fk_product NOT IN
( (
SELECT fk_product SELECT fk_product

View File

@ -617,6 +617,9 @@ class Project extends CommonObject
public function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet') public function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet')
{ {
// phpcs:enable // phpcs:enable
global $hookmanager;
$elements = array(); $elements = array();
if ($this->id <= 0) return $elements; if ($this->id <= 0) return $elements;
@ -662,6 +665,20 @@ class Project extends CommonObject
if (empty($datefieldname)) return 'Error this object has no date field defined'; if (empty($datefieldname)) return 'Error this object has no date field defined';
$sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)";
} }
$parameters = array(
'sql'=>$sql,
'type' => $type,
'tablename' => $tablename,
'datefieldname' => $datefieldname,
'dates' => $dates,
'datee' => $datee,
'fk_projet' => $projectkey
);
$reshook = $hookmanager->executeHooks('getElementList', $parameters, $object, $action);
if ($reshook > 0) $sql = $hookmanager->resPrint;
else $sql .= $hookmanager->resPrint;
if (!$sql) return -1; if (!$sql) return -1;
//print $sql; //print $sql;

View File

@ -648,9 +648,28 @@ print '<td class="right" width="100">'.$langs->trans("AmountTTC").'</td>';
print '</tr>'; print '</tr>';
$total_revenue_ht = 0; $total_revenue_ht = 0;
$balance_ht = 0;
$balance_ttc = 0;
foreach ($listofreferent as $key => $value) foreach ($listofreferent as $key => $value)
{ {
$parameters = array(
'total_revenue_ht' =>& $total_revenue_ht,
'balance_ht' =>& $balance_ht,
'balance_ttc' =>& $balance_ttc,
'key' => $key,
'value' =>& $value,
'dates' => $dates,
'datee' => $datee
);
$reshook = $hookmanager->executeHooks('printOverviewProfit', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif ($reshook > 0) {
print $hookmanager->resPrint;
continue;
}
$name = $langs->trans($value['name']); $name = $langs->trans($value['name']);
$title = $value['title']; $title = $value['title'];
$classname = $value['class']; $classname = $value['class'];
@ -659,20 +678,17 @@ foreach ($listofreferent as $key => $value)
$qualified = $value['test']; $qualified = $value['test'];
$margin = $value['margin']; $margin = $value['margin'];
$project_field = $value['project_field']; $project_field = $value['project_field'];
if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add')
{
$element = new $classname($db); $element = new $classname($db);
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet'); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field) ? $project_field : 'fk_projet');
if (is_array($elementarray) && count($elementarray) > 0) if (is_array($elementarray) && count($elementarray) > 0) {
{
$total_ht = 0; $total_ht = 0;
$total_ttc = 0; $total_ttc = 0;
$num = count($elementarray); $num = count($elementarray);
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++) {
{
$tmp = explode('_', $elementarray[$i]); $tmp = explode('_', $elementarray[$i]);
$idofelement = $tmp[0]; $idofelement = $tmp[0];
$idofelementuser = $tmp[1]; $idofelementuser = $tmp[1];
@ -682,13 +698,11 @@ foreach ($listofreferent as $key => $value)
// Define if record must be used for total or not // Define if record must be used for total or not
$qualifiedfortotal = true; $qualifiedfortotal = true;
if ($key == 'invoice') if ($key == 'invoice') {
{
if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total if (!empty($element->close_code) && $element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice, do not include into total
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $element->type == Facture::TYPE_DEPOSIT) $qualifiedfortotal = false; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included
} }
if ($key == 'propal') if ($key == 'propal') {
{
if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedfortotal = false; // Only signed proposal must not be included in total if ($element->status != Propal::STATUS_SIGNED && $element->status != Propal::STATUS_BILLED) $qualifiedfortotal = false; // Only signed proposal must not be included in total
} }
@ -698,10 +712,8 @@ foreach ($listofreferent as $key => $value)
if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ht_by_line = $element->amount;
elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount(); elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount();
elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty); elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty);
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task') {
{ if ($idofelementuser) {
if ($idofelementuser)
{
$tmp = $element->getSumOfAmount($elementuser, $dates, $datee); $tmp = $element->getSumOfAmount($elementuser, $dates, $datee);
$total_ht_by_line = price2num($tmp['amount'], 'MT'); $total_ht_by_line = price2num($tmp['amount'], 'MT');
} else { } else {
@ -737,8 +749,7 @@ foreach ($listofreferent as $key => $value)
if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount; if ($tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary') $total_ttc_by_line = $element->amount;
elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount(); elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount();
elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line = $element->price * abs($element->qty);
elseif ($tablename == 'projet_task') elseif ($tablename == 'projet_task') {
{
$defaultvat = get_default_tva($mysoc, $mysoc); $defaultvat = get_default_tva($mysoc, $mysoc);
$total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT');
} elseif ($key == 'loan') { } elseif ($key == 'loan') {
@ -746,18 +757,15 @@ foreach ($listofreferent as $key => $value)
} else $total_ttc_by_line = $element->total_ttc; } else $total_ttc_by_line = $element->total_ttc;
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases // Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
if ($tablename == 'payment_various') if ($tablename == 'payment_various') {
{ if ($element->sens == 1) {
if ($element->sens == 1)
{
$total_ht_by_line = -$total_ht_by_line; $total_ht_by_line = -$total_ht_by_line;
$total_ttc_by_line = -$total_ttc_by_line; $total_ttc_by_line = -$total_ttc_by_line;
} }
} }
// Add total if we have to // Add total if we have to
if ($qualifiedfortotal) if ($qualifiedfortotal) {
{
$total_ht = $total_ht + $total_ht_by_line; $total_ht = $total_ht + $total_ht_by_line;
$total_ttc = $total_ttc + $total_ttc_by_line; $total_ttc = $total_ttc + $total_ttc_by_line;
} }
@ -770,13 +778,12 @@ foreach ($listofreferent as $key => $value)
//var_dump($key.' '.$qualifiedforfinalprofit); //var_dump($key.' '.$qualifiedforfinalprofit);
// Calculate margin // Calculate margin
if ($qualifiedforfinalprofit) if ($qualifiedforfinalprofit) {
{
if ($margin == 'add') { if ($margin == 'add') {
$total_revenue_ht += $total_ht; $total_revenue_ht += $total_ht;
} }
if ($margin != "add") // Revert sign if ($margin != "add") { // Revert sign
{ {
$total_ht = -$total_ht; $total_ht = -$total_ht;
$total_ttc = -$total_ttc; $total_ttc = -$total_ttc;
@ -838,6 +845,20 @@ print '<br>';
// Detail // Detail
foreach ($listofreferent as $key => $value) foreach ($listofreferent as $key => $value)
{ {
$parameters = array(
'key' => $key,
'value' =>& $value,
'dates' => $dates,
'datee' => $datee
);
$reshook = $hookmanager->executeHooks('printOverviewDetail', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif ($reshook > 0) {
print $hookmanager->resPrint;
continue;
}
$title = $value['title']; $title = $value['title'];
$classname = $value['class']; $classname = $value['class'];
$tablename = $value['table']; $tablename = $value['table'];
@ -852,8 +873,7 @@ foreach ($listofreferent as $key => $value)
$exclude_select_element = array('payment_various'); $exclude_select_element = array('payment_various');
if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element']; if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element'];
if ($qualified) if ($qualified) {
{
// If we want the project task array to have details of users // If we want the project task array to have details of users
//if ($key == 'project_task') $key = 'project_task_time'; //if ($key == 'project_task') $key = 'project_task_time';