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.
For users:
- New: Each user can remove/add its own boxes.
- New: Can use personalized fields of products/services.
- New: Can attach files on social contributions.
- New: Show payments terms and conditions onto muscadet template.

View File

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

View File

@ -1,27 +1,25 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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 <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/boxes.php
* \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)
{
$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();
foreach($boxavailable as $box)
@ -54,11 +52,32 @@ function printBoxesArea($user,$areacode)
$arrayboxtoactivatelabel[$box->id]=$box->boxlabel;
}
$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))
{
@ -151,11 +170,10 @@ function printBoxesArea($user,$areacode)
});
'."\n";
print 'function updateOrder() {
var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));
var right_list = cleanSerialize(jQuery("#right").sortable("serialize" ));
var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
var userid = \''.$user->id.'\';
jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&userid=\'+'.$user->id.');
jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.');
}'."\n";
// For closing
print 'jQuery(document).ready(function() {

View File

@ -31,6 +31,12 @@ if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
require('../../main.inc.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
@ -45,14 +51,20 @@ top_httphead();
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
if (GETPOST('boxorder') && GETPOST('userid'))
if ($boxorder && $zone != '' && $userid > 0)
{
// 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);
$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:
* Clean values of a "Sortable.serialize". Used by drag and drop.
* Works for Scriptaculous and jQuery.
* Input: expr
* Author: Regis Houssin
* Licence: GPL
* ==================================================================
*/
function cleanSerialize(expr) {
if (typeof(expr) != 'string') return '';
var reg = new RegExp("(&)", "g");
var reg2 = new RegExp("[^A-Z0-9,]", "g");
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 (! isset($_GET["mainmenu"])) $_GET["mainmenu"]="home";
$action=GETPOST('action');
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');