mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Show counter of access of website in website list
This commit is contained in:
parent
dac735dc4b
commit
5bbfdbb775
|
|
@ -84,7 +84,7 @@ $tablib[1] = "Websites";
|
|||
|
||||
// Requests to extract data
|
||||
$tabsql = array();
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
|
||||
$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation, f.lastaccess, f.pageviews_previous_month, f.pageviews_total FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')';
|
||||
|
||||
// Criteria to sort dictionaries
|
||||
$tabsqlsort = array();
|
||||
|
|
@ -92,7 +92,7 @@ $tabsqlsort[1] = "ref ASC";
|
|||
|
||||
// Nom des champs en resultat de select pour affichage du dictionnaire
|
||||
$tabfield = array();
|
||||
$tabfield[1] = "ref,description,virtualhost,position,date_creation";
|
||||
$tabfield[1] = "ref,description,virtualhost,position,date_creation,lastaccess,pageviews_previous_month,pageviews_total";
|
||||
|
||||
// Nom des champs d'edition pour modification d'un enregistrement
|
||||
$tabfieldvalue = array();
|
||||
|
|
@ -186,7 +186,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
|
|||
$sql .= $tabrowid[$id].",";
|
||||
}
|
||||
$sql .= $tabfieldinsert[$id];
|
||||
$sql .= ",status)";
|
||||
$sql .= ", status, date_creation)";
|
||||
$sql .= " VALUES(";
|
||||
|
||||
// List of values
|
||||
|
|
@ -211,7 +211,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
|
|||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ",1)";
|
||||
$sql .= ", 1, '".$db->idate(dol_now())."')";
|
||||
|
||||
dol_syslog("actionadd", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
|
|
@ -441,12 +441,10 @@ if ($id) {
|
|||
|
||||
// Form to add a new line
|
||||
if ($tabname[$id]) {
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
if ($fieldlist[$field] == 'date_creation') {
|
||||
if (in_array($fieldlist[$field], array('date_creation', 'lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -522,6 +520,7 @@ if ($id) {
|
|||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Title of lines
|
||||
|
|
@ -533,6 +532,10 @@ if ($id) {
|
|||
$align = "left";
|
||||
$sortable = 1;
|
||||
$valuetoshow = '';
|
||||
if (in_array($fieldlist[$field], array('pageviews_total', 'pageviews_previous_month'))) {
|
||||
$align = 'right';
|
||||
}
|
||||
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
|
|
@ -554,14 +557,24 @@ if ($id) {
|
|||
if ($fieldlist[$field] == 'date_creation') {
|
||||
$valuetoshow = $langs->trans("DateCreation");
|
||||
}
|
||||
if ($fieldlist[$field] == 'lastaccess') {
|
||||
$valuetoshow = $langs->trans("LastAccess");
|
||||
}
|
||||
if ($fieldlist[$field] == 'pageviews_previous_month') {
|
||||
$valuetoshow = $langs->trans("PagesViewedPreviousMonth");
|
||||
}
|
||||
if ($fieldlist[$field] == 'pageviews_total') {
|
||||
$valuetoshow = $langs->trans("PagesViewedTotal");
|
||||
}
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield) {
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder);
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, $align.' ');
|
||||
}
|
||||
}
|
||||
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder);
|
||||
// Status
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, 'center ');
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
|
@ -581,8 +594,9 @@ if ($id) {
|
|||
fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
}
|
||||
|
||||
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"> </a><input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print ' <input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
print '<td colspan="7" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"> </a>';
|
||||
print '<input type="submit" class="button button-edit small" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print ' <input type="submit" class="button button-cancel small" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
} else {
|
||||
$tmpaction = 'view';
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
|
|
@ -593,13 +607,16 @@ if ($id) {
|
|||
if (empty($reshook)) {
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
$showfield = 1;
|
||||
$align = "left";
|
||||
$fieldname = $fieldlist[$field];
|
||||
$align = "left";
|
||||
if (in_array($fieldname, array('pageviews_total', 'pageviews_previous_month'))) {
|
||||
$align = 'right';
|
||||
}
|
||||
$valuetoshow = $obj->$fieldname;
|
||||
|
||||
// Show value for field
|
||||
if ($showfield) {
|
||||
print '<td align="'.$align.'">'.$valuetoshow.'</td>';
|
||||
print '<td class="'.$align.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -612,6 +629,7 @@ if ($id) {
|
|||
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&';
|
||||
|
||||
|
||||
// Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
print '<a class="reposition" href="'.$url.'action='.$acts[($obj->status ? 1 : 0)].'">'.$actl[($obj->status ? 1 : 0)].'</a>';
|
||||
|
|
@ -633,6 +651,7 @@ if ($id) {
|
|||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
|
@ -668,6 +687,10 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '')
|
|||
$formadmin = new FormAdmin($db);
|
||||
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
if (in_array($fieldlist[$field], array('lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fieldname = $fieldlist[$field];
|
||||
|
||||
if ($fieldlist[$field] == 'lang') {
|
||||
|
|
|
|||
|
|
@ -438,7 +438,14 @@ function dolWebsiteIncrementCounter($websiteid, $websitepagetype, $websitepageid
|
|||
if (in_array($websitepagetype, array('blogpost', 'page'))) {
|
||||
global $db;
|
||||
|
||||
$sql = "UPDATE ".$db->prefix()."website SET pageviews_total = pageviews_total + 1, lastaccess = '".$db->idate(dol_now())."'";
|
||||
$tmpnow = dol_getdate(dol_now('gmt'), true, 'gmt');
|
||||
|
||||
$sql = "UPDATE ".$db->prefix()."website SET ";
|
||||
$sql .= " pageviews_total = pageviews_total + 1,";
|
||||
$sql .= " pageviews_month = pageviews_month + 1,";
|
||||
// if last access was done during previous month, we save pageview_month into pageviews_previous_month
|
||||
$sql .= " pageviews_previous_month = ".$db->ifsql("lastaccess < '".$db->idate(dol_mktime(0, 0, 0, $tmpnow['month'], 1, $tmpnow['year'], 'gmt', 0), 'gmt')."'", 'pageviews_month', 'pageviews_previous_month').",";
|
||||
$sql .= " lastaccess = '".$db->idate(dol_now('gmt'), 'gmt')."'";
|
||||
$sql .= " WHERE rowid = ".((int) $websiteid);
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) {
|
||||
|
|
|
|||
|
|
@ -59,3 +59,5 @@ INSERT INTO llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2
|
|||
|
||||
ALTER TABLE llx_user ADD COLUMN flagdelsessionsbefore datetime DEFAULT NULL;
|
||||
|
||||
ALTER TABLE llx_website ADD COLUMN pageviews_previous_month BIGINT UNSIGNED DEFAULT 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ CREATE TABLE llx_website
|
|||
fk_user_modif integer,
|
||||
date_creation datetime,
|
||||
position integer DEFAULT 0,
|
||||
lastaccess datetime NULL,
|
||||
pageviews_month BIGINT UNSIGNED DEFAULT 0,
|
||||
pageviews_total BIGINT UNSIGNED DEFAULT 0,
|
||||
lastaccess datetime NULL, -- updated at each page access
|
||||
pageviews_previous_month BIGINT UNSIGNED DEFAULT 0,
|
||||
pageviews_month BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, saved into pageviews_previous_month when on different month than lastaccess
|
||||
pageviews_total BIGINT UNSIGNED DEFAULT 0, -- increased by 1 at each page access, no reset
|
||||
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
|
|
|
|||
|
|
@ -1216,3 +1216,4 @@ NoSpecificContactAddress=No specific contact or address
|
|||
NoSpecificContactAddressBis=This tab is dedicated to force specific contacts or addresses for the current object. Use it only if you want to define one or several specific contacts or addresses for the object when the information on the thirdparty is not enough or not accurate.
|
||||
HideOnVCard=Hide %s
|
||||
AddToContacts=Add address to my contacts
|
||||
LastAccess=Last access
|
||||
|
|
@ -155,3 +155,5 @@ WebpageMustBeDisabled=The web page must have the status "%s"
|
|||
SetWebsiteOnlineBefore=When website is offline, all pages are offline. Change status of website first.
|
||||
Booking=Booking
|
||||
Reservation=Reservation
|
||||
PagesViewedPreviousMonth=Pages viewed (previous month)
|
||||
PagesViewedTotal=Pages viewed (total)
|
||||
Loading…
Reference in New Issue
Block a user