mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Error management in categories creation
This commit is contained in:
parent
0b12c2de44
commit
8371684535
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 53 KiB |
|
|
@ -700,26 +700,21 @@ class Categorie
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if no category with same label already exists
|
||||
* \brief Check if no category with same label already exists
|
||||
* \return boolean 1 if already exist, 0 otherwise, -1 if error
|
||||
*/
|
||||
function already_exists()
|
||||
{
|
||||
$sql = "SELECT count(c.rowid)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_association as ca";
|
||||
$sql.= " WHERE c.label = '".addslashes($this -> label)."' AND type=".$this->type;
|
||||
/*if($this -> id_mere != "")
|
||||
{
|
||||
$sql.= " AND c.rowid = ca.fk_categorie_fille";
|
||||
$sql.= " AND ca.fk_categorie_mere = '".$this -> id_mere."'";
|
||||
}
|
||||
*/
|
||||
dol_syslog("Categorie::already_exists sql=".$sql);
|
||||
$res = $this->db->query($sql);
|
||||
if ($res)
|
||||
{
|
||||
$obj = $this->db->fetch_array($res);
|
||||
if($obj[0] > 0) return true;
|
||||
else return false;
|
||||
if($obj[0] > 0) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@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
|
||||
|
|
@ -20,11 +20,11 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/categories/fiche.php
|
||||
\ingroup category
|
||||
\brief Page creation nouvelle categorie
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/categories/fiche.php
|
||||
* \ingroup category
|
||||
* \brief Page to create a new category
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require "./pre.inc.php";
|
||||
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
|
||||
|
|
@ -128,7 +128,8 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
|
|||
$_GET["action"] = 'create';
|
||||
}
|
||||
|
||||
if ($categorie->error =="")
|
||||
// Create category in database
|
||||
if (! $categorie->error)
|
||||
{
|
||||
$result = $categorie->create();
|
||||
if ($result > 0)
|
||||
|
|
@ -171,6 +172,9 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader("","",$langs->trans("Categories"));
|
||||
$html = new Form($db);
|
||||
|
|
@ -182,12 +186,6 @@ if ($user->rights->categorie->creer)
|
|||
*/
|
||||
if ($_GET["action"] == 'create' || $_POST["addcat"] == 'addcat')
|
||||
{
|
||||
if($categorie->error != "")
|
||||
{
|
||||
print '<div class="error">';
|
||||
print $categorie->error;
|
||||
print '</div>';
|
||||
}
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?type='.$_GET['type'].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
|
@ -207,6 +205,13 @@ if ($user->rights->categorie->creer)
|
|||
|
||||
print_fiche_titre($langs->trans("CreateCat"));
|
||||
|
||||
if ($categorie->error)
|
||||
{
|
||||
print '<div class="error">';
|
||||
print $categorie->error;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
print '<tr>';
|
||||
print '<td width="25%">'.$langs->trans("Ref").'</td><td><input name="nom" size="25" value="'.$categorie->label.'">';
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ SupplierHasNoCategory=This supplier is not in any categories
|
|||
CompanyHasNoCategory=This company is not in any categories
|
||||
ClassifyInCategory=Classify in category
|
||||
NoneCategory=None
|
||||
CategoryExistsAtSameLevel=This category already exists at same place
|
||||
CategoryExistsAtSameLevel=This category already exists with this ref
|
||||
ReturnInProduct=Back to product/service card
|
||||
ReturnInSupplier=Back to supplier card
|
||||
ReturnInCompany=Back to customer/prospect card
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ SupplierHasNoCategory=Ce fournisseur n'est dans aucune catégorie en particulier
|
|||
CompanyHasNoCategory=Cette societé n'est dans aucune catégorie en particulier
|
||||
ClassifyInCategory=Classer dans la catégorie
|
||||
NoneCategory=Aucune
|
||||
CategoryExistsAtSameLevel=Cette catégorie existe déjà au même endroit
|
||||
CategoryExistsAtSameLevel=Cette catégorie existe déjà pour cette référence
|
||||
ReturnInProduct=Retour sur la fiche produit/service
|
||||
ReturnInSupplier=Retour sur la fiche fournisseur
|
||||
ReturnInCompany=Retour sur la fiche client/prospect
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user