Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Jun 26, 2014
2 parents 8de6748 + f25bb79 commit d5e0bcf
Show file tree
Hide file tree
Showing 10 changed files with 618 additions and 74 deletions.
140 changes: 140 additions & 0 deletions htdocs/admin/dons.php
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* 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
Expand Down Expand Up @@ -109,6 +110,63 @@
}
}

// Option
if ($action == 'set_DONATION_MESSAGE')
{
$freemessage = GETPOST('DONATION_MESSAGE'); // No alpha here, we want exact string

$res = dolibarr_set_const($db, "DONATION_MESSAGE",$freemessage,'chaine',0,'',$conf->entity);

if (! $res > 0) $error++;

if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}

// Activate an article
else if ($action == 'setart200') {
$setart200 = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "DONATION_ART200", $setart200, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;

if (! $error) {
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
} else {
setEventMessage($langs->trans("Error"), 'mesgs');
}
}
else if ($action == 'setart238') {
$setart238 = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "DONATION_ART238", $setart238, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;

if (! $error) {
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
} else {
setEventMessage($langs->trans("Error"), 'mesgs');
}
}
else if ($action == 'setart885') {
$setart885 = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "DONATION_ART885", $setart885, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;

if (! $error) {
setEventMessage($langs->trans("SetupSaved"), 'mesgs');
} else {
setEventMessage($langs->trans("Error"), 'mesgs');
}
}

/*
* View
*/
Expand All @@ -121,6 +179,88 @@
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup');

/*
* Params
*/
print_titre($langs->trans("Options"));

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=true;

$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_DONATION_MESSAGE" />';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("FreeTextOnDonations").'<br>';
print '<textarea name="DONATION_MESSAGE" class="flat" cols="120">'.$conf->global->DONATION_MESSAGE.'</textarea>';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
print "</td></tr>\n";
print "</table>\n";
print '</form>';

/*
* French params
*/
if ($conf->global->MAIN_LANG_DEFAULT == "fr_FR")
{
print '<br>';
print_titre($langs->trans("FrenchOptions"));

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('Parameters') . '</td>';
print "</tr>\n";

$var=!$var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("DONATION_ART200") . '</td>';
if (! empty($conf->global->DONATION_ART200)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart200&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart200&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';

$var=!$var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("DONATION_ART238") . '</td>';
if (! empty($conf->global->DONATION_ART238)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart238&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart238&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';

$var=!$var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("DONATION_ART885") . '</td>';
if (! empty($conf->global->DONATION_ART885)) {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart885&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
} else {
print '<td align="center" colspan="2"><a href="' . $_SERVER['PHP_SELF'] . '?action=setart885&value=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>';
}
print '</tr>';
print "</table>\n";
}

// Document templates
print '<br>';
print_titre($langs->trans("DonationsModels"));
Expand Down
3 changes: 1 addition & 2 deletions htdocs/core/boxes/box_factures.php
Expand Up @@ -24,7 +24,6 @@
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';


/**
* Class to manage the box to show last invoices
*/
Expand Down Expand Up @@ -159,4 +158,4 @@ function showBox($head = null, $contents = null)
}

}

?>
156 changes: 156 additions & 0 deletions htdocs/core/boxes/box_project.php
@@ -0,0 +1,156 @@
<?php
/* Copyright (C) 2012-2014 Charles-François BENKE <charles.fr@benke.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 3 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/core/boxes/box_activite.php
* \ingroup projet
* \brief Module to show Projet activity of the current Year
*/
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");

/**
* Class to manage the box to show last projet
*/
class box_project extends ModeleBoxes
{
var $boxcode="project";
var $boximg="object_projectpub";
var $boxlabel;
//var $depends = array("projet");
var $db;
var $param;

var $info_box_head = array();
var $info_box_contents = array();

/**
* \brief Constructeur de la classe
*/
function box_project()
{
global $langs;
$langs->load("boxes");
$langs->load("projects");

$this->boxlabel="Projet";
}

/**
* Load data for box to show them later
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max=5)
{
global $conf, $user, $langs, $db;

$this->max=$max;

$totalMnt = 0;
$totalnb = 0;
$totalnbTask=0;
include_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
$projectstatic=new Project($db);



$textHead = $langs->trans("Projet");
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));

// list the summary of the orders
if ($user->rights->projet->lire)
{

$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut ";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."projet as p";
$sql.= ")";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts
$sql.= " ORDER BY p.datec DESC";
$sql.= $db->plimit($max, 0);

$result = $db->query($sql);

if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_projectpub');

$objp = $db->fetch_object($result);
$projectstatic->fetch($objp->rowid);

$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' =>$projectstatic->getNomUrl(1)
);

$this->info_box_contents[$i][2] = array('td' => 'align="left"',
'text' => $objp->title
);

$sql ="SELECT count(*) as nb, sum(progress) as totprogress";
$sql.=" FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p";
$sql.=" WHERE pt.fk_projet = p.rowid";
$sql.=" AND p.entity = ".$conf->entity;
$resultTask = $db->query($sql);
if ($resultTask)
{
$objTask = $db->fetch_object($resultTask);
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format($objTask->nb, 0, ',', ' ')."&nbsp;".$langs->trans("Tasks"));
if ($objTask->nb > 0 )
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => number_format(($objTask->totprogress/$objTask->nb), 0, ',', ' ')." %&nbsp;".$langs->trans("Progress"));
else
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A&nbsp;");
$totalnbTask += $objTask->nb;
}
else
{
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format(0, 0, ',', ' '));
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A&nbsp;");
}

$i++;
}
}
}


// Add the sum à the bottom of the boxes
$this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'colspan=2 align="left" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$i][1] = array('td' => 'align="right" ', 'text' => number_format($num, 0, ',', ' ')."&nbsp;".$langs->trans("Projects"));
$this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnbTask, 0, ',', ' ')."&nbsp;".$langs->trans("Tasks"));
$this->info_box_contents[$i][4] = array('td' => 'colspan=2', 'text' => "");

}

/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}
?>

0 comments on commit d5e0bcf

Please sign in to comment.