Merge remote-tracking branch 'origin/3.5' into develop

This commit is contained in:
Laurent Destailleur 2013-11-24 13:19:41 +01:00
commit 73408479ba
15 changed files with 466 additions and 315 deletions

26
dev/fixnotabfiles.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
#------------------------------------------------------
# Script to find files that are not Unix encoded
#
# Laurent Destailleur - eldy@users.sourceforge.net
#------------------------------------------------------
# Usage: fixnotabfiles.sh [list|fix]
#------------------------------------------------------
# Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then
echo "Usage: fixnotabfiles.sh [list|fix]"
fi
# To detec
if [ "x$1" = "xlist" ]
then
find build \( -iname "*.sh" -o -iname "*.spec" \) -exec grep -l -P '\t' {} \;
fi
# To convert
if [ "x$1" = "xfix" ]
then
echo Feature not implemented. Please fix files manually.
fi

View File

@ -321,6 +321,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$result=$object->update($user,0,$nosyncuser,$nosyncuserpass); $result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
if ($result >= 0 && ! count($object->errors)) if ($result >= 0 && ! count($object->errors))
{ {
// Logo/Photo save
$dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos';
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -361,6 +362,19 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$errmsgs[] = "ErrorBadImageFormat"; $errmsgs[] = "ErrorBadImageFormat";
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
$rowid=$object->id; $rowid=$object->id;
$action=''; $action='';

View File

@ -887,7 +887,7 @@ class ActionComm extends CommonObject
$sql.= " AND a.entity = ".$conf->entity; $sql.= " AND a.entity = ".$conf->entity;
foreach ($filters as $key => $value) foreach ($filters as $key => $value)
{ {
if ($key == 'notolderthan') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'"; if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'";
if ($key == 'year') $sql.=" AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value,1))."' AND '".$this->db->idate(dol_get_last_day($value,12))."'"; if ($key == 'year') $sql.=" AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value,1))."' AND '".$this->db->idate(dol_get_last_day($value,12))."'";
if ($key == 'id') $sql.=" AND a.id=".(is_numeric($value)?$value:0); if ($key == 'id') $sql.=" AND a.id=".(is_numeric($value)?$value:0);
if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0); if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0);

View File

@ -2358,7 +2358,7 @@ function dol_print_error_email($prefixcode)
* @param string $field Field to use for new sorting * @param string $field Field to use for new sorting
* @param string $begin ("" by defaut) * @param string $begin ("" by defaut)
* @param string $moreparam Add more parameters on sort url links ("" by default) * @param string $moreparam Add more parameters on sort url links ("" by default)
* @param string $td Options of attribute td ("" by defaut) * @param string $td Options of attribute td ("" by defaut, example: 'align="center"')
* @param string $sortfield Current field used to sort * @param string $sortfield Current field used to sort
* @param string $sortorder Current sort order * @param string $sortorder Current sort order
* @return void * @return void

View File

@ -484,7 +484,7 @@ function quotedPrintEncode($str,$forcal=0)
{ {
$newpara = ''; $newpara = '';
$strlength=dol_strlen($line); $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes
for ($j = 0; $j <= ($strlength - 1); $j++) for ($j = 0; $j <= ($strlength - 1); $j++)
{ {
$char = substr($line, $j, 1); $char = substr($line, $j, 1);
@ -493,7 +493,7 @@ function quotedPrintEncode($str,$forcal=0)
if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
$char = '=' . strtoupper(sprintf("%02X", $ascii)); $char = '=' . strtoupper(sprintf("%02X", $ascii));
if ((dol_strlen($newpara) + dol_strlen($char)) >= 76 ) if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes
{ {
$out .= $newpara . '=' . "\r\n"; // CRLF $out .= $newpara . '=' . "\r\n"; // CRLF
if ($forcal) $out .= " "; // + Space for cal if ($forcal) $out .= " "; // + Space for cal

View File

@ -154,3 +154,5 @@ DefaultRIB=Default BAN
AllRIB=All BAN AllRIB=All BAN
LabelRIB=BAN Label LabelRIB=BAN Label
NoBANRecord=No BAN record NoBANRecord=No BAN record
DeleteARib=Delete BAN record
ConfirmDeleteRib=Are you sure you want to delete this BAN record ?

View File

@ -154,3 +154,5 @@ DefaultRIB=RIB par défaut
AllRIB=Tous les RIB AllRIB=Tous les RIB
LabelRIB=Nom du RIB LabelRIB=Nom du RIB
NoBANRecord=Aucun RIB enregistré NoBANRecord=Aucun RIB enregistré
DeleteARib=Supprimé RIB enregistré
ConfirmDeleteRib=Etes vous sur de vouloir supprimé ce RIB ?

View File

@ -77,13 +77,23 @@ class CompanyBankAccount extends Account
{ {
$now=dol_now(); $now=dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, '".$this->db->idate($now)."')"; // Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1";
$result = $this->db->query($sql);
if ($result)
{
$numrows=$this->db->num_rows($result);
if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)";
$sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->affected_rows($resql)) if ($this->db->affected_rows($resql))
{ {
$this->default_rib = 1;
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
return 1; return 1;
} }
@ -204,6 +214,30 @@ class CompanyBankAccount extends Account
} }
} }
/**
* Delete a rib from database
*
* @param User $user User deleting
* @return int <0 if KO, >0 if OK
*/
function delete($user)
{
global $conf;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql);
if ($result) {
return 1;
}
else {
dol_print_error($this->db);
return -1;
}
}
/** /**
* Return RIB * Return RIB
* *

View File

@ -31,11 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
$langs->load("companies"); $langs->load("companies");
$langs->load("commercial");
$langs->load("banks"); $langs->load("banks");
$langs->load("bills"); $langs->load("bills");
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = GETPOST("socid");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe','',''); $result = restrictedArea($user, 'societe','','');
@ -43,17 +44,21 @@ $soc = new Societe($db);
$soc->id = $_GET["socid"]; $soc->id = $_GET["socid"];
$soc->fetch($_GET["socid"]); $soc->fetch($_GET["socid"]);
$id=GETPOST("id","int");
$ribid=GETPOST("ribid","int");
$action=GETPOST("action");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'update' && ! $_POST["cancel"]) if ($action == 'update' && ! $_POST["cancel"])
{ {
// Modification // Modification
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
$account->fetch($_POST["id"]); $account->fetch($id);
$account->socid = $soc->id; $account->socid = $soc->id;
@ -85,7 +90,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
} }
} }
if ($_POST["action"] == 'add' && ! $_POST["cancel"]) if ($action == 'add' && ! $_POST["cancel"])
{ {
// Ajout // Ajout
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
@ -106,7 +111,7 @@ if ($_POST["action"] == 'add' && ! $_POST["cancel"])
$account->proprio = $_POST["proprio"]; $account->proprio = $_POST["proprio"];
$account->owner_address = $_POST["owner_address"]; $account->owner_address = $_POST["owner_address"];
$result = $account->update($user); $result = $account->update($user); // TODO Use create and include update into create method
if (! $result) if (! $result)
{ {
$message=$account->error; $message=$account->error;
@ -120,10 +125,10 @@ if ($_POST["action"] == 'add' && ! $_POST["cancel"])
} }
} }
if ($_GET['action'] == 'setasdefault') if ($action == 'setasdefault')
{ {
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
$res = $account->setAsDefault($_GET['ribid']); $res = $account->setAsDefault(GETPOST('ribid','int'));
if ($res) { if ($res) {
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id; $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id;
header('Location: '.$url); header('Location: '.$url);
@ -133,10 +138,35 @@ if ($_GET['action'] == 'setasdefault')
} }
} }
if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
{
$account = new CompanyBankAccount($db);
if ($account->fetch($ribid?$ribid:$id))
{
$result = $account->delete($user);
if ($result > 0)
{
$url = $_SERVER['PHP_SELF']."?socid=".$soc->id;
header('Location: '.$url);
exit;
}
else
{
$message = $account->error;
}
}
else
{
$message = $account->error;
}
}
/* /*
* View * View
*/ */
$form = new Form($db);
llxHeader(); llxHeader();
$head=societe_prepare_head2($soc); $head=societe_prepare_head2($soc);
@ -144,10 +174,10 @@ $head=societe_prepare_head2($soc);
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
$account = new CompanyBankAccount($db); $account = new CompanyBankAccount($db);
if (!$_GET['id']) if (! $id)
$account->fetch(0,$soc->id); $account->fetch(0,$soc->id);
else else
$account->fetch($_GET['id']); $account->fetch($id);
if (empty($account->socid)) $account->socid=$soc->id; if (empty($account->socid)) $account->socid=$soc->id;
@ -158,9 +188,16 @@ if (empty($account->socid)) $account->socid=$soc->id;
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create") if ($socid && $action != 'edit' && $action != "create")
{ {
// Confirm delete third party
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$soc->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1);
}
print_titre($langs->trans("DefaultRIB")); print_titre($langs->trans("DefaultRIB"));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("LabelRIB").'</td>'; print '<tr><td>'.$langs->trans("LabelRIB").'</td>';
@ -236,11 +273,12 @@ if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create")
print_liste_field_titre($langs->trans("LabelRIB")); print_liste_field_titre($langs->trans("LabelRIB"));
print_liste_field_titre($langs->trans("Bank")); print_liste_field_titre($langs->trans("Bank"));
print_liste_field_titre($langs->trans("RIB")); print_liste_field_titre($langs->trans("RIB"));
print_liste_field_titre($langs->trans("DefaultRIB")); print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"');
print '<td width="40"></td>'; print '<td width="40"></td>';
print '</tr>'; print '</tr>';
foreach ($rib_list as $rib) { foreach ($rib_list as $rib)
{
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.$rib->label.'</td>'; print '<td>'.$rib->label.'</td>';
print '<td>'.$rib->bank.'</td>'; print '<td>'.$rib->bank.'</td>';
@ -248,16 +286,26 @@ if ($_GET["socid"] && $_GET["action"] != 'edit' && $_GET["action"] != "create")
print '<td align="center" width="70">'; print '<td align="center" width="70">';
if (!$rib->default_rib) { if (!$rib->default_rib) {
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&ribid='.$rib->id.'&action=setasdefault">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&ribid='.$rib->id.'&action=setasdefault">';
print img_picto($langs->trans("Disabled"),'switch_off'); print img_picto($langs->trans("Disabled"),'off');
print '</a>'; print '</a>';
} else { } else {
print img_picto($langs->trans("Enabled"),'switch_on'); print img_picto($langs->trans("Enabled"),'on');
} }
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
if ($user->rights->societe->creer)
{
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&id='.$rib->id.'&action=edit">'; print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&id='.$rib->id.'&action=edit">';
print img_picto($langs->trans("Modify"),'edit'); print img_picto($langs->trans("Modify"),'edit');
print '</a>'; print '</a>';
print '&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'&id='.$rib->id.'&action=delete">';
print img_picto($langs->trans("Delete"),'delete');
print '</a>';
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$var = !$var; $var = !$var;

View File

@ -8,7 +8,6 @@
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2011-2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* *
*
* 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 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
@ -280,7 +279,7 @@ if (empty($reshook))
} }
} }
// Gestion du logo de la société // Logo/Photo save
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -311,6 +310,19 @@ if (empty($reshook))
} }
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
// Gestion du logo de la société // Gestion du logo de la société
} }
else else
@ -354,7 +366,7 @@ if (empty($reshook))
$error = $object->error; $errors = $object->errors; $error = $object->error; $errors = $object->errors;
} }
// Gestion du logo de la société // Logo/Photo save
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK) if ($file_OK)
@ -397,6 +409,19 @@ if (empty($reshook))
$errors[] = "ErrorBadImageFormat"; $errors[] = "ErrorBadImageFormat";
} }
} }
else
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors[] = "ErrorFileSizeTooLarge";
break;
case 3: //uploaded file was only partially uploaded
$errors[] = "ErrorFilePartiallyUploaded";
break;
}
}
// Gestion du logo de la société // Gestion du logo de la société

View File

@ -1976,14 +1976,14 @@ div.ok {
} }
div.warning { div.warning {
color: #504020; color: #302020;
padding: 0.3em 0.3em 0.3em 0.3em; padding: 0.3em 0.3em 0.3em 0.3em;
margin: 0.5em 0em 0.5em 0em; margin: 0.5em 0em 0.5em 0em;
border: 1px solid #e0d0b0; border: 1px solid #e0d0b0;
-moz-border-radius:6px; -moz-border-radius:6px;
-webkit-border-radius: 6px; -webkit-border-radius: 6px;
border-radius: 6px; border-radius: 6px;
background: #FFEF9A; background: #EFDF9A;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
} }