More fix for canvas features

This commit is contained in:
Laurent Destailleur 2012-05-30 03:46:06 +02:00
parent cd1c5f6aaf
commit 3c98daaf09
6 changed files with 28 additions and 54 deletions

View File

@ -1,42 +0,0 @@
<?php
/* Copyright (C) 2010 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/contact/canvas/default/dao_contact_default.class.php
* \ingroup thirdparty
* \brief Fichier de la classe des contacts par defaut
*/
/**
* \class DaoContactDefault
* \brief Classe permettant la gestion des contacts par defaut, cette classe surcharge la classe contact
*/
class DaoContactDefault extends Contact
{
/**
* Constructor
*
* @param DoliDB $DB Handler acces base de donnees
*/
function DaoContactDefault($DB)
{
$this->db = $DB;
}
}
?>

View File

@ -22,6 +22,10 @@
<?php
print_fiche_titre($this->control->tpl['title']);
dol_htmloutput_errors((is_numeric($object->error)?'':$object->error),$object->errors);
dol_htmloutput_errors((is_numeric($GLOBALS['error'])?'':$GLOBALS['error']),$GLOBALS['errors']);
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
echo $this->control->tpl['ajax_selectcountry']; ?>
@ -40,7 +44,7 @@ echo $this->control->tpl['ajax_selectcountry']; ?>
<tr>
<td width="15%" class="fieldrequired"><?php echo $langs->trans("Lastname").' / '.$langs->trans("Label"); ?></td>
<td><input name="name" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td><input name="lastname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td width="20%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['firstname']; ?>"></td>
</tr>

View File

@ -53,7 +53,7 @@ echo $this->control->tpl['ajax_selectcountry'];
<tr>
<td width="15%" class="fieldrequired"><?php echo $langs->trans("Lastname").' / '.$langs->trans("Label"); ?></td>
<td><input name="name" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td><input name="lastname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td width="20%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['firstname']; ?>"></td>
</tr>

View File

@ -53,12 +53,25 @@ class Canvas
{
$this->db = $db;
$this->actiontype = $actiontype;
if ($this->actiontype == 'add') $this->actiontype='create';
if ($this->actiontype == 'update') $this->actiontype='edit';
if (empty($this->actiontype) || $this->actiontype == 'delete' || $this->actiontype == 'create_user') $this->actiontype='view';
$this->actiontype = $this->_cleanaction($actiontype);
}
/**
* Return action code cleaned
*
* @param string $action Action type ('create', 'view', 'edit', 'list', 'add', 'update')
* @return string Cleaned action type ('create', 'view', 'edit', 'list')
*/
private function _cleanaction($action)
{
$newaction = $action;
if ($newaction == 'add') $newaction='create';
if ($newaction == 'update') $newaction='edit';
if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user') $newaction='view';
return $newaction;
}
/**
* Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir
*
@ -126,13 +139,13 @@ class Canvas
* Return the template to display canvas (if it exists)
*
* @param string $action Action code
* @return int 0=Canvas template file does not exist, 1=Canvas template file exists
* @return int 0=Canvas template file does not exist, 1=Canvas template file exists
*/
function displayCanvasExists($action)
{
if (empty($this->template_dir)) return 0;
if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php')) return 1;
if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1;
else return 0;
}
@ -148,7 +161,7 @@ class Canvas
global $db, $conf, $langs, $user, $canvas;
global $form, $formfile;
include($this->template_dir.($this->card?$this->card.'_':'').$this->actiontype.'.tpl.php'); // Include native PHP template
include($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'); // Include native PHP template
}

View File

@ -24,7 +24,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
<?php print_fiche_titre($langs->trans("Product")); ?>
<?php dol_htmloutput_errors($object->error,$object->errors); ?>
<?php dol_htmloutput_errors((is_numeric($object->error)?'':$object->error),$object->errors); ?>
<?php dol_htmloutput_errors($GLOBALS['mesg'],$GLOBALS['mesgs']); ?>

View File

@ -286,8 +286,7 @@ if (empty($reshook))
{
if ($object->update($object->id, $user) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
exit;
$action = 'view';
}
else
{