Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2015-05-30 00:26:47 +02:00
commit 6701b399ae
24 changed files with 186 additions and 151 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2015 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
@ -205,36 +205,42 @@ if ($action == 'create') {
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr class="pair">'; print '<tr>';
print '<td>' . $langs->trans("NumMvts") . '</td>'; print '<td>' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $next_num_mvt . '</td>'; print '<td>' . $next_num_mvt . '</td>';
print '</tr>'; print '</tr>';
print '<tr class="impair">'; print '<tr>';
print '<td>' . $langs->trans("Docdate") . '</td>'; print '<td>' . $langs->trans("Docdate") . '</td>';
print '<td>'; print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="pair">'; print '<tr>';
print '<td>' . $langs->trans("Codejournal") . '</td>'; print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>'; print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
print '</tr>'; print '</tr>';
print '<tr class="impair">'; print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>'; print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>'; print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
print '</tr>'; print '</tr>';
print '<tr class="pair">'; print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" size="20" name="doc_type" value=""/></td>'; print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '<br>';
print '<input type="submit" class="butAction" value="' . $langs->trans("Save") . '">'; dol_fiche_end();
print '<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)" />';
print '</div>';
print '</form>'; print '</form>';
} }
else else

View File

@ -1,7 +1,7 @@
<?PHP <?PHP
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2015 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
@ -44,7 +44,6 @@ if ($user->societe_id > 0)
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
if (! GETPOST('cancel', 'alpha')) if (! GETPOST('cancel', 'alpha'))
{ {
@ -63,6 +62,10 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
} }
} }
/*
* View
*/
llxHeader("", "", "FicheVentilation"); llxHeader("", "", "FicheVentilation");
if ($cancel == $langs->trans("Cancel")) { if ($cancel == $langs->trans("Cancel")) {
@ -108,6 +111,8 @@ if (! empty($id)) {
$linkback='<a href="'.DOL_URL_ROOT.'/accountancy/customer/lines.php">'.$langs->trans("Back").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/accountancy/customer/lines.php">'.$langs->trans("Back").'</a>';
print_fiche_titre($langs->trans('CustomersVentilation'),$linkback,'title_setup'); print_fiche_titre($langs->trans('CustomersVentilation'),$linkback,'title_setup');
dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref facture // Ref facture
@ -120,13 +125,13 @@ if (! empty($id)) {
print '<tr><td width="20%">' . $langs->trans("Line") . '</td>'; print '<tr><td width="20%">' . $langs->trans("Line") . '</td>';
print '<td>' . nl2br($objp->description) . '</td></tr>'; print '<td>' . nl2br($objp->description) . '</td></tr>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>'; print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end();
print '<br><div class="center">'; print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">'; print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">'; print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
@ -144,4 +149,4 @@ if (! empty($id)) {
} }
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,9 +1,9 @@
<?php <?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
@ -172,8 +172,8 @@ if ($resql) {
while ( $i < $num ) { while ( $i < $num ) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$var=!$var;
print '<tr><td>' . length_accountg($row[0]) . '</td>'; print '<tr '.$bc[$var].'><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>'; print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>'; print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>'; print '<td align="right">' . price($row[3]) . '</td>';

View File

@ -43,7 +43,7 @@ $search_facture = GETPOST('search_facture','alpha');
$search_label = GETPOST('search_label','alpha'); $search_label = GETPOST('search_label','alpha');
$search_desc = GETPOST('search_desc','alpha'); $search_desc = GETPOST('search_desc','alpha');
$search_amount = GETPOST('search_amount','alpha'); $search_amount = GETPOST('search_amount','alpha');
$search_acount = GETPOST('search_account','alpha'); $search_account = GETPOST('search_account','alpha');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)

View File

@ -555,9 +555,9 @@ else
$h=0; $h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal; $head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal;
$head[$h][1] = $langs->trans("Report"); $head[$h][1] = $langs->trans("Report");
$head[$h][2] = 'report'; $head[$h][2] = 'card';
dol_fiche_head($head, $hselected); dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal.'">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';

View File

@ -1,11 +1,11 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
@ -34,31 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
// Langs // Langs
$langs->load("compta");
$langs->load("bills"); $langs->load("bills");
$langs->load("other");
$langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$action = GETPOST('action'); $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int');
$codeventil = GETPOST('codeventil'); $codeventil = GETPOST('codeventil');
$id = GETPOST('id');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) {
{ if (! GETPOST('cancel', 'alpha'))
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; {
$sql .= " SET fk_code_ventilation = " . $codeventil; $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " WHERE rowid = " . $id; $sql .= " SET fk_code_ventilation = " . $codeventil;
$sql .= " WHERE rowid = " . $id;
dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql);
dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) { if (! $resql) {
setEventMessage($db->lasterror(), 'errors'); setEventMessage($db->lasterror(), 'errors');
}
} else {
header("Location: ./lines.php");
exit();
} }
} }
@ -78,7 +79,7 @@ $form = new Form($db);
$facturefournisseur_static = new FactureFournisseur($db); $facturefournisseur_static = new FactureFournisseur($db);
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
if ($_GET["id"]) { if (! empty($id)) {
$sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, ";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label";
$sql .= ", aa.account_number, aa.label"; $sql .= ", aa.account_number, aa.label";
@ -87,11 +88,14 @@ if ($_GET["id"]) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
if (! empty($conf->multicompany->enabled)) { if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")";
} }
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num_lines = $db->num_rows($result); $num_lines = $db->num_rows($result);
$i = 0; $i = 0;
@ -103,7 +107,10 @@ if ($_GET["id"]) {
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
print_fiche_titre($langs->trans("SuppliersVentilation")); $linkback='<a href="'.DOL_URL_ROOT.'/accountancy/supplier/lines.php">'.$langs->trans("Back").'</a>';
print_fiche_titre($langs->trans('SuppliersVentilation'),$linkback,'title_setup');
dol_fiche_head();
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">'; print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
@ -119,19 +126,24 @@ if ($_GET["id"]) {
print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>'; print '<tr><td width="20%">' . $langs->trans("ProductLabel") . '</td>';
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>'; print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>'; print '<tr><td width="20%">' . $langs->trans("Account") . '</td><td>';
print $objp->account_number . '-' . $objp->label;
print '<tr><td width="20%">' . $langs->trans("NewAccount") . '</td><td>';
print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" class="button" value="' . $langs->trans("Update") . '"></td></tr>';
print '</table>'; print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';
print '</form>'; print '</form>';
} else { } else {
print "Error 1"; print "Error";
} }
} else { } else {
print "Error 2"; print "Error";
} }
} else { } else {
print "Error ID incorrect"; print "Error ID incorrect";

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -158,8 +158,8 @@ if ($resql) {
while ( $i < $num ) { while ( $i < $num ) {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$var=!$var;
print '<tr><td>' . length_accountg($row[0]) . '</td>'; print '<tr '.$bc[$var].'><td>' . length_accountg($row[0]) . '</td>';
print '<td align="left">' . $row[1] . '</td>'; print '<td align="left">' . $row[1] . '</td>';
print '<td align="right">' . price($row[2]) . '</td>'; print '<td align="right">' . price($row[2]) . '</td>';
print '<td align="right">' . price($row[3]) . '</td>'; print '<td align="right">' . price($row[3]) . '</td>';

View File

@ -44,7 +44,7 @@ $search_facture = GETPOST('search_facture','alpha');
$search_label = GETPOST('search_label','alpha'); $search_label = GETPOST('search_label','alpha');
$search_desc = GETPOST('search_desc','alpha'); $search_desc = GETPOST('search_desc','alpha');
$search_amount = GETPOST('search_amount','alpha'); $search_amount = GETPOST('search_amount','alpha');
$search_acount = GETPOST('search_account','alpha'); $search_account = GETPOST('search_account','alpha');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)

View File

@ -121,7 +121,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
$pathtodelete=$listofpaths[$keytodelete]; $pathtodelete=$listofpaths[$keytodelete];
$filetodelete=$listofnames[$keytodelete]; $filetodelete=$listofnames[$keytodelete];
$result = dol_delete_file($pathtodelete,1); $result = dol_delete_file($pathtodelete,1);
if ($result >= 0) if ($result)
{ {
setEventMessage($langs->trans("FileWasRemoved"), $filetodelete); setEventMessage($langs->trans("FileWasRemoved"), $filetodelete);

View File

@ -89,7 +89,7 @@ if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allf
// If (file that is not logfile) or (if logfile with option logfile) // If (file that is not logfile) or (if logfile with option logfile)
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile') if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
{ {
$count+=dol_delete_file($filesarray[$key]['fullname']); $count+=(dol_delete_file($filesarray[$key]['fullname'])?1:0);
} }
} }
} }

View File

@ -1759,10 +1759,8 @@ if (empty($reshook))
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$action = ''; $action = '';
} }
} }

View File

@ -823,10 +823,8 @@ else if ($action == 'remove_file' && $user->rights->contrat->creer) {
$upload_dir = $conf->contrat->dir_output; $upload_dir = $conf->contrat->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
} }
} }

View File

@ -525,9 +525,9 @@ abstract class CommonObject
* Return array with list of possible values for type of contacts * Return array with list of possible values for type of contacts
* *
* @param string $source 'internal', 'external' or 'all' * @param string $source 'internal', 'external' or 'all'
* @param string $order Sort order by : 'code' or 'rowid' * @param string $order Sort order by 'code' or 'rowid'
* @param string $option 0=Return array id->label, 1=Return array code->label * @param int $option 0=Return array id->label, 1=Return array code->label
* @param string $activeonly 0=all status of contact, 1=only the active * @param int $activeonly 0=all status of contact, 1=only the active
* @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE')
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1) * @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/ */
@ -541,7 +541,7 @@ abstract class CommonObject
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle"; $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE tc.element='".$this->element."'"; $sql.= " WHERE tc.element='".$this->element."'";
if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types
if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'"; if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'";
if (! empty($code)) $sql.= " AND tc.code='".$code."'"; if (! empty($code)) $sql.= " AND tc.code='".$code."'";
$sql.= " ORDER by tc.".$order; $sql.= " ORDER by tc.".$order;
@ -626,12 +626,12 @@ abstract class CommonObject
} }
/** /**
* Charge le contact d'id $id dans this->contact * Load object contact with id=$this->contactid into $this->contact
* *
* @param int $contactid Id du contact. Use this->contactid if empty. * @param int $contactid Id du contact. Use this->contactid if empty.
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_contact($contactid='') function fetch_contact($contactid=null)
{ {
if (empty($contactid)) $contactid=$this->contactid; if (empty($contactid)) $contactid=$this->contactid;
@ -858,14 +858,14 @@ abstract class CommonObject
/** /**
* Update a specific field into database * Update a specific field into database
* *
* @param string $field Field to update * @param string $field Field to update
* @param mixed $value New value * @param mixed $value New value
* @param string $table To force other table element or element line (should not be used) * @param string $table To force other table element or element line (should not be used)
* @param int $id To force other object id (should not be used) * @param int $id To force other object id (should not be used)
* @param string $format Data format ('text', 'date'). 'text' is used if not defined * @param string $format Data format ('text', 'date'). 'text' is used if not defined
* @param string $id_field To force rowid field name. 'rowid' is used it not defined * @param string $id_field To force rowid field name. 'rowid' is used it not defined
* @param string $user Update last update fields also if user object provided * @param User|string $user Update last update fields also if user object provided
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='') function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='')
{ {
@ -1655,10 +1655,10 @@ abstract class CommonObject
* @param int $exclspec >0 = Exclude special product (product_type=9) * @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object. * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
* @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object. * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='') function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
{ {
global $conf; global $conf;
@ -2684,9 +2684,9 @@ abstract class CommonObject
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* *
* @param string $action Action code * @param string $action Action code
* @param string $seller Object of seller third party * @param Societe $seller Object of seller third party
* @param string $buyer Object of buyer third party * @param Societe $buyer Object of buyer third party
* @param string $selected Object line selected * @param int $selected Object line selected
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @return void * @return void
*/ */
@ -2799,16 +2799,16 @@ abstract class CommonObject
* Return HTML content of a detail line * Return HTML content of a detail line
* TODO Move this into an output class file (htmlline.class.php) * TODO Move this into an output class file (htmlline.class.php)
* *
* @param string $action GET/POST action * @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output * @param CommonObjectLine $line Selected object line to output
* @param string $var Is it a an odd line (true) * @param string $var Is it a an odd line (true)
* @param int $num Number of line (0) * @param int $num Number of line (0)
* @param int $i I * @param int $i I
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param string $seller Object of seller third party * @param Societe $seller Object of seller third party
* @param string $buyer Object of buyer third party * @param Societe $buyer Object of buyer third party
* @param string $selected Object line selected * @param int $selected Object line selected
* @param object $extrafieldsline Object of extrafield line attribute * @param object $extrafieldsline Object of extrafield line attribute
* @return void * @return void
*/ */
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
@ -3086,7 +3086,7 @@ abstract class CommonObject
/** /**
* get Margin info * get Margin info
* *
* @param string $force_price True of not * @param boolean $force_price True of not
* @return mixed Array with info * @return mixed Array with info
*/ */
function getMarginInfos($force_price=false) function getMarginInfos($force_price=false)
@ -3212,7 +3212,7 @@ abstract class CommonObject
/** /**
* Show the array with all margin infos * Show the array with all margin infos
* *
* @param string $force_price Force price * @param boolean $force_price Force price
* @return void * @return void
*/ */
function displayMarginInfos($force_price=false) function displayMarginInfos($force_price=false)
@ -3304,7 +3304,7 @@ abstract class CommonObject
/** /**
* Add resources to the current object : add entry into llx_element_resources * Add resources to the current object : add entry into llx_element_resources
*Need $this->element & $this->id * Need $this->element & $this->id
* *
* @param int $resource_id Resource id * @param int $resource_id Resource id
* @param string $resource_element Resource element * @param string $resource_element Resource element
@ -3726,7 +3726,7 @@ abstract class CommonObject
{ {
$attributeKey = substr($key,8); // Remove 'options_' prefix $attributeKey = substr($key,8); // Remove 'options_' prefix
$attributeType = $extrafields->attribute_type[$attributeKey]; $attributeType = $extrafields->attribute_type[$attributeKey];
$attributeSize = $extrafields->attribute_size[$attributeKey]; //$attributeSize = $extrafields->attribute_size[$attributeKey]; Not required to insert an extrafield value. Only used for definition.
$attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey];
$attributeParam = $extrafields->attribute_param[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey];
switch ($attributeType) switch ($attributeType)
@ -3751,19 +3751,19 @@ abstract class CommonObject
case 'datetime': case 'datetime':
$this->array_options[$key]=$this->db->idate($this->array_options[$key]); $this->array_options[$key]=$this->db->idate($this->array_options[$key]);
break; break;
case 'link': case 'link':
$param_list=array_keys($attributeParam ['options']); $param_list=array_keys($attributeParam ['options']);
// 0 : ObjectName // 0 : ObjectName
// 1 : classPath // 1 : classPath
$InfoFieldList = explode(":", $param_list[0]); $InfoFieldList = explode(":", $param_list[0]);
dol_include_once($InfoFieldList[1]); dol_include_once($InfoFieldList[1]);
$object = new $InfoFieldList[0]($this->db); $object = new $InfoFieldList[0]($this->db);
if ($value) if ($value)
{ {
$object->fetch(0,$value); $object->fetch(0,$value);
$this->array_options[$key]=$object->id; $this->array_options[$key]=$object->id;
} }
break; break;
} }
} }
$this->db->begin(); $this->db->begin();
@ -3771,6 +3771,7 @@ abstract class CommonObject
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id;
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
$this->db->query($sql_del); $this->db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
foreach($this->array_options as $key => $value) foreach($this->array_options as $key => $value)
{ {
@ -3825,7 +3826,7 @@ abstract class CommonObject
* *
* @return string * @return string
*/ */
function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='')
{ {
global $_POST, $conf; global $_POST, $conf;

View File

@ -39,7 +39,7 @@ class ExtraFields
var $attribute_type; var $attribute_type;
// Tableau contenant le nom des champs en clef et le label de ces champs en value // Tableau contenant le nom des champs en clef et le label de ces champs en value
var $attribute_label; var $attribute_label;
// Tableau contenant le nom des champs en clef et la taille de ces champs en value // Tableau contenant le nom des champs en clef et la taille/longueur max de ces champs en value
var $attribute_size; var $attribute_size;
// Tableau contenant le nom des choix en clef et la valeur de ces choix en value // Tableau contenant le nom des choix en clef et la valeur de ces choix en value
var $attribute_choice; var $attribute_choice;
@ -124,6 +124,7 @@ class ExtraFields
if (empty($label)) return -1; if (empty($label)) return -1;
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
// Create field into database except for separator type which is not stored in database // Create field into database except for separator type which is not stored in database
if ($type != 'separate') if ($type != 'separate')
@ -169,6 +170,7 @@ class ExtraFields
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0) private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0)
{ {
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields'; $table=$elementtype.'_extrafields';
@ -248,6 +250,7 @@ class ExtraFields
global $conf; global $conf;
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
// Clean parameters // Clean parameters
if (empty($pos)) $pos=0; if (empty($pos)) $pos=0;
@ -308,6 +311,7 @@ class ExtraFields
function delete($attrname, $elementtype='member') function delete($attrname, $elementtype='member')
{ {
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields'; $table=$elementtype.'_extrafields';
@ -342,6 +346,7 @@ class ExtraFields
global $conf; global $conf;
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{ {
@ -389,6 +394,7 @@ class ExtraFields
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='') function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='')
{ {
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$table=$elementtype.'_extrafields'; $table=$elementtype.'_extrafields';
@ -486,6 +492,8 @@ class ExtraFields
// Clean parameters // Clean parameters
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if (empty($list)) $list=0; if (empty($list)) $list=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
@ -570,6 +578,7 @@ class ExtraFields
if ( empty($elementtype) ) return array(); if ( empty($elementtype) ) return array();
if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
$array_name_label=array(); $array_name_label=array();

View File

@ -116,9 +116,9 @@ class HookManager
* @param array $parameters Array of parameters * @param array $parameters Array of parameters
* @param Object $object Object to use hooks on * @param Object $object Object to use hooks on
* @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 means KO. * @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO.
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint.
* Can also return some values into an array ->results. * All types can also return some values into an array ->results.
* $this->error or this->errors are also defined by class called by this function if error. * $this->error or this->errors are also defined by class called by this function if error.
*/ */
function executeHooks($method, $parameters=false, &$object='', &$action='') function executeHooks($method, $parameters=false, &$object='', &$action='')
@ -135,7 +135,8 @@ class HookManager
array( array(
'addMoreActionsButtons', 'addMoreActionsButtons',
'addStatisticLine', 'addStatisticLine',
'doActions', 'deleteFile',
'doActions',
'formCreateThirdpartyOptions', 'formCreateThirdpartyOptions',
'formObjectOptions', 'formObjectOptions',
'formattachOptions', 'formattachOptions',
@ -147,7 +148,7 @@ class HookManager
'formatEvent' 'formatEvent'
) )
)) $hooktype='addreplace'; )) $hooktype='addreplace';
// Deprecated hook types // Deprecated hook types ('returnvalue')
if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks. if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks.
if ($method == 'insertExtraFields') if ($method == 'insertExtraFields')
{ {
@ -195,7 +196,7 @@ class HookManager
if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);
if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints;
} }
// Generic hooks that return a string or array (printSearchForm, printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
else else
{ {
// TODO. this should be done into the method of hook by returning nothing // TODO. this should be done into the method of hook by returning nothing

View File

@ -2825,7 +2825,7 @@ class Form
/** /**
* Creates HTML units selector (code => label) * Creates HTML units selector (code => label)
* *
* @param string $selected Preselected code ('km', 'm', 'l', 'p', ...) * @param string $selected Preselected Unit ID
* @param string $htmlname Select name * @param string $htmlname Select name
* @param int $showempty Add a nempty line * @param int $showempty Add a nempty line
* @return string HTML select * @return string HTML select
@ -2846,13 +2846,13 @@ class Form
while($res = $this->db->fetch_object($resql)) while($res = $this->db->fetch_object($resql))
{ {
if ($selected == $res[0]) if ($selected == $res->rowid)
{ {
$return.='<option value="'.$res->code.'" selected>'.$langs->trans($res->label).'</option>'; $return.='<option value="'.$res->rowid.'" selected>'.$langs->trans($res->label).'</option>';
} }
else else
{ {
$return.='<option value="'.$res->code.'">'.$langs->trans($res->label).'</option>'; $return.='<option value="'.$res->rowid.'">'.$langs->trans($res->label).'</option>';
} }
} }
$return.='</select>'; $return.='</select>';

View File

@ -793,12 +793,12 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
/** /**
* Remove a file or several files with a mask * Remove a file or several files with a mask
* *
* @param string $file File to delete or mask of file to delete * @param string $file File to delete or mask of files to delete
* @param int $disableglob Disable usage of glob like * * @param int $disableglob Disable usage of glob like * so function is an exact delete function that will return error if no file found
* @param int $nophperrors Disable all PHP output errors * @param int $nophperrors Disable all PHP output errors
* @param int $nohook Disable all hooks * @param int $nohook Disable all hooks
* @param object $object Current object in use * @param object $object Current object in use
* @return boolean True if file is deleted (or if glob is used and there's nothing to delete), False if error * @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
*/ */
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null) function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null)
{ {
@ -823,19 +823,20 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
$reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object); $reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object);
} }
if (empty($nohook) && isset($reshook) && $reshook != '') // 0:not deleted, 1:deleted, null or '' for bypass if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko
{ {
return $reshook; if ($reshook < 0) return false;
return true;
} }
else else
{ {
$error=0; $error=0;
//print "x".$file." ".$disableglob;exit; //print "x".$file." ".$disableglob;exit;
$ok=true;
$file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset
if (empty($disableglob) && ! empty($file_osencoded)) if (empty($disableglob) && ! empty($file_osencoded))
{ {
$ok=true;
$globencoded=str_replace('[','\[',$file_osencoded); $globencoded=str_replace('[','\[',$file_osencoded);
$globencoded=str_replace(']','\]',$globencoded); $globencoded=str_replace(']','\]',$globencoded);
$listofdir=glob($globencoded); $listofdir=glob($globencoded);
@ -853,6 +854,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
} }
else else
{ {
$ok=false;
if ($nophperrors) $ok=@unlink($file_osencoded); if ($nophperrors) $ok=@unlink($file_osencoded);
else $ok=unlink($file_osencoded); else $ok=unlink($file_osencoded);
if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
@ -958,9 +960,9 @@ function dol_delete_preview($object)
if (file_exists($file) && is_writable($file)) if (file_exists($file) && is_writable($file))
{ {
if ( ! dol_delete_file($file,1) ) if (! dol_delete_file($file,1))
{ {
$object->error=$langs->trans("ErrorFailedToOpenFile",$file); $object->error=$langs->trans("ErrorFailedToDeleteFile",$file);
return 0; return 0;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2014 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2007-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -58,6 +58,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
$sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'"; $sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'";
if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'"; if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
$sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; $sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")";
$sql.=' AND statut = 1';
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -127,10 +127,10 @@ class mod_facture_mars extends ModeleNumRefFactures
*/ */
function getNextValue($objsoc,$facture,$mode='next') function getNextValue($objsoc,$facture,$mode='next')
{ {
global $db,$conf; global $db;
$prefix=$this->prefixinvoice; $prefix=$this->prefixinvoice;
if ($facture->type == 1) $prefix=$this->prefixreplacement; if ($facture->type == 1) $prefix=$this->prefixreplacement;
else if ($facture->type == 2) $prefix=$this->prefixcreditnote; else if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit; else if ($facture->type == 3) $prefix=$this->prefixdeposit;
@ -141,7 +141,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity IN (".getEntity('facture', 1).")";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -165,7 +165,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity IN (".getEntity('facture', 1).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.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
@ -111,7 +111,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$this->error=$langs->trans('ErrorNumRefModel',$max); $this->error=$langs->trans('ErrorNumRefModel',$max);
return false; return false;
} }
// Check deposit num // Check deposit num
$fayymm=''; $fayymm='';
@ -146,7 +146,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/ */
function getNextValue($objsoc,$facture,$mode='next') function getNextValue($objsoc,$facture,$mode='next')
{ {
global $db,$conf; global $db;
if ($facture->type == 2) $prefix=$this->prefixcreditnote; if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit; else if ($facture->type == 3) $prefix=$this->prefixdeposit;
@ -157,7 +157,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity IN (".getEntity('facture', 1).")";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -181,7 +181,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity IN (".getEntity('facture', 1).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);

View File

@ -59,11 +59,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
if ($urlfile) if ($urlfile)
{ {
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) { if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile));
setEventMessage($langs->trans("FileWasRemoved", $urlfile)); else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
} else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
}
} }
elseif ($linkid) elseif ($linkid)
{ {

View File

@ -3680,7 +3680,7 @@ function migrate_delete_old_files($db,$langs,$conf)
print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'</div>'; print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'</div>';
} }
else else
{ {
//print $langs->trans("FileWasRemoved",$filetodelete); //print $langs->trans("FileWasRemoved",$filetodelete);
} }
} }

View File

@ -698,7 +698,7 @@ else
if ($action == 'edit' && $userWrite > 0) if ($action == 'edit' && $userWrite > 0)
{ {
print '<div align="center">'; print '<div align="center">';
print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; &nbsp; '; print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
} }

View File

@ -339,10 +339,15 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertTrue($result,'delete file'); $this->assertTrue($result,'delete file');
// Again to test no error when deleteing a non existing file // Again to test there is error when deleting a non existing file with option disableglob
$result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv',1,1);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertTrue($result,'delete file that does not exists'); $this->assertFalse($result,'delete file that does not exists with disableglo must return ko');
// Again to test there is no error when deleting a non existing file without option disableglob
$result=dol_delete_file($conf->admin->dir_temp.'/file2.csv',0,1);
print __METHOD__." result=".$result."\n";
$this->assertTrue($result,'delete file that does not exists without disabling glob must return ok');
// Test copy with special char / delete with blob // Test copy with special char / delete with blob
$result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1); $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1);