New: Each user can remove/add its own boxes.

This commit is contained in:
Laurent Destailleur 2012-03-19 14:06:21 +01:00
parent 39332c56b7
commit 0b71aceb90
6 changed files with 61 additions and 30 deletions

View File

@ -8,6 +8,7 @@ WARNING: Because of a major datastructure change onto supplier prices tabkes, be
to make a backup of your database before making upgrade. to make a backup of your database before making upgrade.
For users: For users:
- New: Each user can remove/add its own boxes.
- New: Can use personalized fields of products/services. - New: Can use personalized fields of products/services.
- New: Can attach files on social contributions. - New: Can attach files on social contributions.
- New: Show payments terms and conditions onto muscadet template. - New: Show payments terms and conditions onto muscadet template.

View File

@ -110,7 +110,6 @@ jQuery(document).ready(function() {
jQuery("#myid").removeAttr(\'disabled\'); jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\'); jQuery("#myid").attr(\'disabled\',\'disabled\');
} }
}
init_myfunc(); init_myfunc();
jQuery("#mybutton").click(function() { jQuery("#mybutton").click(function() {
init_needroot(); init_needroot();

View File

@ -1,27 +1,25 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/boxes.php * \file htdocs/boxes.php
* \brief File of class to manage widget boxes * \brief File of class to manage widget boxes
* \author Rodolphe Qiedeville
* \author Laurent Destailleur
*/ */
@ -46,7 +44,7 @@ function printBoxesArea($user,$areacode)
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
$emptyuser=new User($db); $emptyuser=new User($db);
$boxavailable=$infobox->listboxes('available',$areacode,$emptyuser,$arrayboxactivatedid); $boxavailable=$infobox->listboxes('activated',$areacode,$emptyuser,$arrayboxactivatedid); // Available here is activated for empty user
$arrayboxtoactivatelabel=array(); $arrayboxtoactivatelabel=array();
foreach($boxavailable as $box) foreach($boxavailable as $box)
@ -54,11 +52,32 @@ function printBoxesArea($user,$areacode)
$arrayboxtoactivatelabel[$box->id]=$box->boxlabel; $arrayboxtoactivatelabel[$box->id]=$box->boxlabel;
} }
$form=new Form($db); $form=new Form($db);
// TODO enable
//$selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel); $selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1);
} }
print load_fiche_titre($langs->trans("OtherInformationsBoxes"),$selectboxlist,'','','otherboxes'); print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery("#boxcombo").change(function() {
var boxid=jQuery("#boxcombo").val();
if (boxid > 0) {
var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
jQuery.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\',
async: false
});
//jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\');
window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid;
//window.location.href=\''.$_SERVER["PHP_SELF"].'\';
}
});';
if (! count($arrayboxtoactivatelabel)) print 'jQuery("#boxcombo").hide();';
print '
});
</script>';
print load_fiche_titre((count($boxactivated)?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
if (count($boxactivated)) if (count($boxactivated))
{ {
@ -151,11 +170,10 @@ function printBoxesArea($user,$areacode)
}); });
'."\n"; '."\n";
print 'function updateOrder() { print 'function updateOrder() {
var left_list = cleanSerialize(jQuery("#left").sortable("serialize" )); var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
var right_list = cleanSerialize(jQuery("#right").sortable("serialize" )); var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
var boxorder = \'A:\' + left_list + \'-B:\' + right_list; var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
var userid = \''.$user->id.'\'; jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.');
jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');
}'."\n"; }'."\n";
// For closing // For closing
print 'jQuery(document).ready(function() { print 'jQuery(document).ready(function() {

View File

@ -31,6 +31,12 @@ if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require('../../main.inc.php'); require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/boxes.php"); require_once(DOL_DOCUMENT_ROOT."/boxes.php");
$boxid=GETPOST('boxid','int');
$boxorder=GETPOST('boxorder');
$userid=GETPOST('userid');
$zone=GETPOST('zone','int');
$userid=GETPOST('userid','int');
/* /*
* View * View
@ -45,14 +51,20 @@ top_httphead();
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Add a box
if ($boxid > 0 && $zone !='' && $userid > 0)
{
$boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list
}
// Registering the location of boxes after a move // Registering the location of boxes after a move
if (GETPOST('boxorder') && GETPOST('userid')) if ($boxorder && $zone != '' && $userid > 0)
{ {
// boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B"
dol_syslog("AjaxBox boxorder=".GETPOST('boxorder')." userid=".GETPOST('userid'), LOG_DEBUG); dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG);
$infobox=new InfoBox($db); $infobox=new InfoBox($db);
$result=$infobox->saveboxorder("0",GETPOST('boxorder'),GETPOST('userid')); $result=$infobox->saveboxorder($zone,$boxorder,$userid);
} }
?> ?>

View File

@ -578,13 +578,13 @@ function newpopup(url,title) {
* ================================================================= * =================================================================
* Purpose: * Purpose:
* Clean values of a "Sortable.serialize". Used by drag and drop. * Clean values of a "Sortable.serialize". Used by drag and drop.
* Works for Scriptaculous and jQuery.
* Input: expr * Input: expr
* Author: Regis Houssin * Author: Regis Houssin
* Licence: GPL * Licence: GPL
* ================================================================== * ==================================================================
*/ */
function cleanSerialize(expr) { function cleanSerialize(expr) {
if (typeof(expr) != 'string') return '';
var reg = new RegExp("(&)", "g"); var reg = new RegExp("(&)", "g");
var reg2 = new RegExp("[^A-Z0-9,]", "g"); var reg2 = new RegExp("[^A-Z0-9,]", "g");
var liste1 = expr.replace(reg, ","); var liste1 = expr.replace(reg, ",");

View File

@ -31,6 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/boxes.php");
// If not defined, we select menu "home" // If not defined, we select menu "home"
if (! isset($_GET["mainmenu"])) $_GET["mainmenu"]="home"; if (! isset($_GET["mainmenu"])) $_GET["mainmenu"]="home";
$action=GETPOST('action');
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');