dourong4031 2017-10-30 15:17
浏览 56

Dolibarr软件找不到我的文件

I'm looking to create Forms in Dolibarr software but apparently he doesn't find the file card.php.

The software is installed in /var/www/html/dolibarr

I have a left menu which looks like this :

$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++;

And my card.php looks like this (it's a simple form because I'm learning about php and Dolibarr modules) :

<?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">'."
";
   print '<input type="hidden" name="action" value="create" />'."
";

   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 '&nbsp; &nbsp; ';
        print '<input type="button" value="'.$langs->trans("Cancel").'" class="button" onclick="history.go(-1)">';
        print '</div>';

        print '</from>'."
";
    }
}

dol_print_error($db);

llxFooter();
$db->close();

This file has all rights but when I click on my submenu Formulaire Dolibarr, I'm getting a blank page.

enter image description here

The url becomes : http://172.30.10.180/moduletest/card.php?action=create&idmenu=202&mainmenu=moduletest&leftmenu=

Do you have any idea if my PHP script gets any issue ?

I tried with an other file which just contains echo ... and it works, but not with card.php

  • 写回答

2条回答 默认 最新

  • dongyangben6144 2018-09-04 15:42
    关注

    Import the file that content your class Moduletest

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题