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
$langs->load("admin");
if (!$user->admin)
accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
if ($action == 'setvalue')
{
if ($action == 'setvalue') {
$showmenu = GETPOST('BOOKMARKS_SHOW_IN_MENU', 'alpha');
$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();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {

View File

@ -38,20 +38,23 @@ function printDropdownBookmarksList()
$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"]) : '');
} else {
global $sortfield, $sortorder;
$tmpurl = '';
// No urlencode, all param $url will be urlencoded later
if ($sortfield) $tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield;
if ($sortorder) $tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder;
if (is_array($_POST))
{
foreach ($_POST as $key => $val)
{
if (preg_match('/^search_/', $key) && $val != '') $tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val;
if ($sortfield) {
$tmpurl .= ($tmpurl ? '&' : '').'sortfield='.$sortfield;
}
if ($sortorder) {
$tmpurl .= ($tmpurl ? '&' : '').'sortorder='.$sortorder;
}
if (is_array($_POST)) {
foreach ($_POST as $key => $val) {
if (preg_match('/^search_/', $key) && $val != '') {
$tmpurl .= ($tmpurl ? '&' : '').$key.'='.$val;
}
}
}
$url .= ($tmpurl ? '?'.$tmpurl : '');
@ -68,8 +71,7 @@ function printDropdownBookmarksList()
// Url to go on create new bookmark page
$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;url='.urlencode($url);
$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 .= " AND entity IN (".getEntity('bookmarks').")";
$sql .= " ORDER BY position";
if ($resql = $db->query($sql))
{
if ($resql = $db->query($sql)) {
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$bookmarkList = '<div id="dropdown-bookmarks-list" >';
$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 .= dol_escape_htmltag($obj->title);
$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 .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
// 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);
$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>';
}
$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 .= dol_escape_htmltag($obj->title);
$searchForm .= '</option>';
@ -132,74 +130,74 @@ function printDropdownBookmarksList()
$html .= '<!-- script to open selected choice -->
<script>
$(document).ready(function () {
jQuery("#boxbookmark").change(function() {
var urlselected = jQuery("#boxbookmark option:selected").attr("rel");
$(document).ready(function () {
jQuery("#boxbookmark").change(function() {
var urlselected = jQuery("#boxbookmark option:selected").attr("rel");
if (! urlselected) console.log("Error, failed to get the URL to jump to from the rel attribute");
var urltarget = jQuery("#boxbookmark option:selected").attr("target");
if (! urltarget) { urltarget=""; }
jQuery("form#top-menu-action-bookmark").attr("target",urltarget);
jQuery("form#top-menu-action-bookmark").attr("action",urlselected);
var urltarget = jQuery("#boxbookmark option:selected").attr("target");
if (! urltarget) { urltarget=""; }
jQuery("form#top-menu-action-bookmark").attr("target",urltarget);
jQuery("form#top-menu-action-bookmark").attr("action",urlselected);
console.log("We change select bookmark. We choose urlselected="+urlselected+" with target="+urltarget);
console.log("We change select bookmark. We choose urlselected="+urlselected+" with target="+urltarget);
// Method is POST for internal link, GET for external
if (urlselected.startsWith(\'http\'))
{
var newmethod=\'GET\';
jQuery("form#top-menu-action-bookmark").attr("method", newmethod);
console.log("We change method to newmethod="+newmethod);
jQuery("form#top-menu-action-bookmark").submit();
console.log("We restore method to POST");
// Method is POST for internal link, GET for external
if (urlselected.startsWith(\'http\'))
{
var newmethod=\'GET\';
jQuery("form#top-menu-action-bookmark").attr("method", newmethod);
console.log("We change method to newmethod="+newmethod);
jQuery("form#top-menu-action-bookmark").submit();
console.log("We restore method to POST");
jQuery("form#top-menu-action-bookmark").attr("method", \'POST\');
}
else
{
jQuery("form#top-menu-action-bookmark").submit();
jQuery("form#top-menu-action-bookmark").submit();
}
});
})
});
})
</script>';
} else {
$html = '
<!-- search input -->
<div class="dropdown-header bookmark-header">
' . $searchForm.'
</div>
';
<!-- search input -->
<div class="dropdown-header bookmark-header">
' . $searchForm.'
</div>
';
$html .= '
<!-- Menu Body -->
<div class="bookmark-body dropdown-body">
'.$bookmarkList.'
</div>
';
<!-- Menu Body -->
<div class="bookmark-body dropdown-body">
'.$bookmarkList.'
</div>
';
$html .= '
<!-- Menu Footer-->
<div class="bookmark-footer">
'.$newbtn.$listbtn.'
<div style="clear:both;"></div>
</div>
';
<!-- Menu Footer-->
<div class="bookmark-footer">
'.$newbtn.$listbtn.'
<div style="clear:both;"></div>
</div>
';
$html .= '<!-- script to open/close the popup -->
<script>
$( document ).on("keyup", "#top-bookmark-search-input", function () {
$( document ).on("keyup", "#top-bookmark-search-input", function () {
var filter = $(this).val(), count = 0;
$("#dropdown-bookmarks-list .bookmark-item").each(function () {
var filter = $(this).val(), count = 0;
$("#dropdown-bookmarks-list .bookmark-item").each(function () {
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).addClass("hidden-search-result");
} else {
$(this).removeClass("hidden-search-result");
count++;
}
});
$("#top-bookmark-search-filter-count").text(count);
});
</script>';
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).addClass("hidden-search-result");
} else {
$(this).removeClass("hidden-search-result");
count++;
}
});
$("#top-bookmark-search-filter-count").text(count);
});
</script>';
}
return $html;

View File

@ -83,8 +83,14 @@ class Bookmark extends CommonObject
*/
public $title;
/**
* @var int position of bookmark
*/
public $position;
/**
* @var string favicon
*/
public $favicon;
@ -116,8 +122,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -151,7 +156,9 @@ class Bookmark extends CommonObject
// Clean parameters
$this->url = trim($this->url);
$this->title = trim($this->title);
if (empty($this->position)) $this->position = 0;
if (empty($this->position)) {
$this->position = 0;
}
$now = dol_now();
@ -164,17 +171,15 @@ class Bookmark extends CommonObject
$sql .= ($this->fk_user > 0 ? $this->fk_user : "0").",";
$sql .= " '".$this->db->idate($now)."',";
$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($conf->entity);
$sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', ".(int) $this->position;
$sql .= ", ".(int) $conf->entity;
$sql .= ")";
dol_syslog("Bookmark::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark");
if ($id > 0)
{
if ($id > 0) {
$this->id = $id;
$this->db->commit();
return $id;
@ -202,7 +207,9 @@ class Bookmark extends CommonObject
// Clean parameters
$this->url = trim($this->url);
$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 .= " 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 .= " ,title = '".$this->db->escape($this->title)."'";
$sql .= " ,favicon = '".$this->db->escape($this->favicon)."'";
$sql .= " ,position = '".$this->db->escape($this->position)."'";
$sql .= " ,position = ".(int) $this->position;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Bookmark::update", LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -237,8 +243,7 @@ class Bookmark extends CommonObject
dol_syslog("Bookmark::remove", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
return 1;
} else {
$this->error = $this->db->lasterror();
@ -288,7 +293,9 @@ class Bookmark extends CommonObject
{
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 = '';
@ -298,33 +305,40 @@ class Bookmark extends CommonObject
$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_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 ($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';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowBookmark");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$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;
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)) : '');
@ -332,8 +346,11 @@ class Bookmark extends CommonObject
$hookmanager->initHooks(array('mybookmarkdao'));
$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;
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}
return $result;
}

View File

@ -62,10 +62,10 @@ class modIntracommreport extends DolibarrModules
$this->config_page_url = array("intracommreport.php@intracommreport");
// 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->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->langfiles = array("intracommreport");

View File

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

View File

@ -142,7 +142,7 @@ class IntracommReport extends CommonObject
$date_time->addChild('date', date('Y-m-d'));
$date_time->addChild('time', date('H:i:s'));
$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->addChild('partyId', $party_id);
$party->addChild('partyName', $declarant);
@ -286,13 +286,13 @@ class IntracommReport extends CommonObject
global $mysoc, $conf;
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_extraf = 'facture_extrafields';
$tabledet = 'facturedet';
$field_link = 'fk_facture';
} 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_extraf = 'facture_fourn_extrafields';
$tabledet = 'facture_fourn_det';
@ -330,7 +330,7 @@ class IntracommReport extends CommonObject
public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '')
{
$item = $declaration->addChild('Item');
$item->addChild('ItemNumber', $i);
$item->addChild('itemNumber', $i);
$cn8 = $item->addChild('CN8');
if (empty($code_douane_spe)) {
$code_douane = $res->customcode;
@ -338,14 +338,15 @@ class IntracommReport extends CommonObject
$code_douane = $code_douane_spe;
}
$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)) {
$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');
$nature_of_transaction = $item->addChild('NatureOfTransaction');
$nature_of_transaction->addChild('natureOfTransactionACode', 1);
@ -389,7 +390,7 @@ class IntracommReport extends CommonObject
$table = 'facture';
$tabledet = 'facturedet';
$field_link = 'fk_facture';
$more_sql = 'f.facnumber';
$more_sql = 'f.ref';
} else { // Introduction
$table = 'facture_fourn';
$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)
WHERE d.fk_product IS NOT NULL
AND f.entity = '.$conf->entity.'
AND '.$more_sql.' = "'.$res->facnumber.'"
AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.total_ht =
(
SELECT MAX(d.total_ht)
FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
WHERE d.fk_product IS NOT NULL
AND '.$more_sql.' = "'.$res->facnumber.'"
AND '.$more_sql.' = "'.$res->refinvoice.'"
AND d.fk_product NOT IN
(
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')
{
// phpcs:enable
global $hookmanager;
$elements = array();
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';
$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;
//print $sql;

View File

@ -648,9 +648,28 @@ print '<td class="right" width="100">'.$langs->trans("AmountTTC").'</td>';
print '</tr>';
$total_revenue_ht = 0;
$balance_ht = 0;
$balance_ttc = 0;
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']);
$title = $value['title'];
$classname = $value['class'];
@ -659,20 +678,17 @@ foreach ($listofreferent as $key => $value)
$qualified = $value['test'];
$margin = $value['margin'];
$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);
$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_ttc = 0;
$num = count($elementarray);
for ($i = 0; $i < $num; $i++)
{
for ($i = 0; $i < $num; $i++) {
$tmp = explode('_', $elementarray[$i]);
$idofelement = $tmp[0];
$idofelementuser = $tmp[1];
@ -682,13 +698,11 @@ foreach ($listofreferent as $key => $value)
// Define if record must be used for total or not
$qualifiedfortotal = true;
if ($key == 'invoice')
{
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 ($key == 'invoice') {
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 ($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
}
@ -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;
elseif ($tablename == 'fichinter') $total_ht_by_line = $element->getAmount();
elseif ($tablename == 'stock_mouvement') $total_ht_by_line = $element->price * abs($element->qty);
elseif ($tablename == 'projet_task')
{
if ($idofelementuser)
{
elseif ($tablename == 'projet_task') {
if ($idofelementuser) {
$tmp = $element->getSumOfAmount($elementuser, $dates, $datee);
$total_ht_by_line = price2num($tmp['amount'], 'MT');
} 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;
elseif ($tablename == 'fichinter') $total_ttc_by_line = $element->getAmount();
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);
$total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT');
} elseif ($key == 'loan') {
@ -746,18 +757,15 @@ foreach ($listofreferent as $key => $value)
} else $total_ttc_by_line = $element->total_ttc;
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
if ($tablename == 'payment_various')
{
if ($element->sens == 1)
{
if ($tablename == 'payment_various') {
if ($element->sens == 1) {
$total_ht_by_line = -$total_ht_by_line;
$total_ttc_by_line = -$total_ttc_by_line;
}
}
// Add total if we have to
if ($qualifiedfortotal)
{
if ($qualifiedfortotal) {
$total_ht = $total_ht + $total_ht_by_line;
$total_ttc = $total_ttc + $total_ttc_by_line;
}
@ -770,13 +778,12 @@ foreach ($listofreferent as $key => $value)
//var_dump($key.' '.$qualifiedforfinalprofit);
// Calculate margin
if ($qualifiedforfinalprofit)
{
if ($qualifiedforfinalprofit) {
if ($margin == 'add') {
$total_revenue_ht += $total_ht;
}
if ($margin != "add") // Revert sign
if ($margin != "add") { // Revert sign
{
$total_ht = -$total_ht;
$total_ttc = -$total_ttc;
@ -838,6 +845,20 @@ print '<br>';
// Detail
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'];
$classname = $value['class'];
$tablename = $value['table'];
@ -852,8 +873,7 @@ foreach ($listofreferent as $key => $value)
$exclude_select_element = array('payment_various');
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 ($key == 'project_task') $key = 'project_task_time';