我希望在Dolibarr软件中创建Forms,但显然他找不到文件card.php
。
该软件安装在/var/www/html/dolibarr
我有一个左侧菜单,如下所示:
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=moduletest,fk_leftmenu=PremierMenu', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftm$
'type'=>'left', // This is a Left menu entry
'titre'=>'Formulaire Dolibarr',
'mainmenu'=>'moduletest',
'leftmenu'=>'PremierMenu',
'url'=>'moduletest/card.php?action=create',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>102,
'enabled'=> 1,
'perms'=>'1',
'target'=>'',
'user'=>2);
$r++;
我的card.php看起来像这样(这是一个简单的表格,因为我正在学习php和Dolibarr模块):
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2015 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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/moduletest/card.php
* \brief Tab of user card
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
$langs->load("mymodule@mymodule");
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
$confirm = GETPOST('confirm','alpha');
$subaction = GETPOST('subaction','alpha');
$group = GETPOST("group","int",3);
$cancel = GETPOST('cancel');
/*
* Actions
*/
// If create a request
if ($action == 'create')
{
$object = new Moduletest($db);
$db->begin();
$nom = GETPOST('nom');
$prenom = GETPOST('prenom');
$datenaissance = dol_mktime(0, 0, 0, GETPOST('datenaissance_month'), GETPOST('datenaissance_day'), GETPOST('datenaissance_year'));
$adresse=GETPOST('adresse');
$codepostal=GETPOST('codepostal');
$pays=GETPOST('pays');
$valideur = GETPOST('valideur');
// If no name
if (empty($nom))
{
setEventMessages($langs->trans("Pas de nom"), null, 'errors');
$error++;
$action='create';
}
// If no firstname
if (empty($prenom))
{
setEventMessages($langs->trans("Pas de prénom"), null, 'errors');
$error++;
$action='create';
}
// If no birthday
if (empty($datenaissance))
{
setEventMessages($langs->trans("Pas de date de naissance"), null, 'errors');
$error++;
$action='create';
}
// If no address
if (empty($adresse))
{
setEventMessages($langs->trans("Pas d'adresse"), null, 'errors');
$error++;
$action='create';
}
// If no code postal
if (empty($codepostal))
{
setEventMessages($langs->trans("Pas de code postal"), null, 'errors');
$error++;
$action='create';
}
// If no validator designated
if ($valideur < 1)
{
setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
$error++;
}
$result = 0;
if (! $error)
{
$object->nom = $nom;
$object->prenom = $prenom;
$object->datenaissance = $datenaissance;
$object->adresse = $adresse;
$object->codepostal = $codepostal;
$object->pays = $pays;
$result = $object->create($user);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
// If no SQL error we redirect to the request card
if (! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
{
$db->rollback();
}
}
}
/*
* View
*/
$form = new Form($db);
$object = new Moduletest($db);
llxHeader('', $langs->trans('Formulaire de test'));
if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create')
{
// Formulaire de demande de congés payés
print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png');
// Formulaire de demande
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
print '<input type="hidden" name="action" value="create" />'."\n";
dol_fiche_head();
print '<table class="border" width="100%">';
print '<tbody>';
// Nom
print '<tr>';
print '<td class="titlefield fieldrequired">'.$langs->trans("Nom").'</td>';
print '<td>';
print '<input type="hidden" name="nom" value="'.$object->nom.'">';
print '</td></tr>';
// Prenom
print '<tr>';
print '<td class="titlefield fieldrequired">'.$langs->trans("Nom").'</td>';
print '<td>';
print '<input type="hidden" name="prenom" value="'.$object->prenom.'">';
print '</td></tr>';
// Date Naissance
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Nom").'</td>';
print '</td>';
print '<td>';
if (! GETPOST('datenaissance')) {
$form->select_date(-1, 'datenaissance', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOST('datenaissance_month'), GETPOST('datenaissance_day'), GETPOST('datenaissance_year'));
$form->select_date($tmpdate, 'datenaissance', 0, 0, 0, '', 1, 1);
}
print '</td>';
print '</tr>';
// Adresse
print '<tr>';
print '<td class="titlefield fieldrequired">'.$langs->trans("Adresse").'</td>';
print '<td>';
print '<input type="hidden" name="adresse" value="'.$object->adresse.'">';
print '</td></tr>';
// Code Postal
print '<tr>';
print '<td class="titlefield fieldrequired">'.$langs->trans("Code Postal").'</td>';
print '<td>';
print '<input type="hidden" name="codepostal" value="'.$object->codepostal.'">';
print '</td></tr>';
// Country
print '<tr><td>'.fieldLabel('Pays','selectcountry_id').'</td><td class="maxwidthonsmartphone">';
print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->pays));
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
print '</tbody>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" value="'.$langs->trans("SendRequestCP").'" name="bouton" class="button">';
print ' ';
print '<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)">';
print '</div>';
print '</from>'."\n";
}
}
dol_print_error($db);
llxFooter();
$db->close();
此文件具有所有权利,但当我点击我的子菜单Formulaire Dolibarr
时,我收到一个空白页。
网址变为:http://172.30.10.180/moduletest/card.php?action=create&idmenu=202&mainmenu=moduletest&leftmenu=
你知道我的PHP脚本是否有任何问题吗?
我尝试使用其他文件,该文件只包含echo ...
并且有效,但不适用于card.php
答案 0 :(得分:1)
您需要更改:
'url'=>'moduletest/card.php?action=create'
收件人:
'url'=>'/moduletest/card.php?action=create'
modxxx.class.php
中的Dolibarr搜索在菜单中的链接之前需要“ /”。
答案 1 :(得分:0)
导入满足您的类Moduletest的文件