forked from Wavyzz/dolibarr
Qual: Move script to init data in same directoty
This commit is contained in:
17
dev/initdata/README
Normal file
17
dev/initdata/README
Normal file
@@ -0,0 +1,17 @@
|
||||
README (English)
|
||||
--------------------------------
|
||||
|
||||
*** Demo
|
||||
|
||||
Scripts in this directory can be used to reinit a demo database.
|
||||
WARNING: This will erase current database with data into initdemo.sql.
|
||||
|
||||
Do a chmod 700 initdemo.sh
|
||||
then run ./initdemo.sh to launch Graphic User Interface.
|
||||
|
||||
Install of package "dialog" is required.
|
||||
|
||||
|
||||
*** Other
|
||||
|
||||
Other scripts can be used to load data test.
|
||||
20
dev/initdata/README-FR
Normal file
20
dev/initdata/README-FR
Normal file
@@ -0,0 +1,20 @@
|
||||
README (French)
|
||||
--------------------------------
|
||||
|
||||
*** Demo
|
||||
|
||||
Ce script permet de reinitialiser une base de donnée Dolibarr avec des
|
||||
données de demo.
|
||||
ATTENTION: Ceci efface les données en cours de la base avec les données
|
||||
du fichier initdemo.sql.
|
||||
|
||||
Faite un chmod 700 initdemo.sh
|
||||
puis ./initdemo.sh pour lancer l'interface graphique.
|
||||
|
||||
L'installation du package "dialog" est indispensable.
|
||||
|
||||
|
||||
*** Autre
|
||||
|
||||
Les autres scripts peuvent être utilisé pour charger en base des données de tests
|
||||
générés automatiquement.
|
||||
198
dev/initdata/generate-commande.php
Normal file
198
dev/initdata/generate-commande.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ATTENTION DE PAS EXECUTER CE SCRIPT SUR UNE INSTALLATION DE PRODUCTION
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/dev/generate-commande.php
|
||||
\brief Script de generation de donnees aleatoires pour les commandes
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
$path=preg_replace('/generate-commande.php/i','',$_SERVER["PHP_SELF"]);
|
||||
require ($path."../htdocs/master.inc.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
|
||||
|
||||
|
||||
/*
|
||||
* Parametre
|
||||
*/
|
||||
|
||||
define (GEN_NUMBER_COMMANDE, 10);
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
$societesid[$i] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else { print "err"; }
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
$commandesid[$i] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else { print "err"; }
|
||||
|
||||
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dates = array (mktime(12,0,0,1,3,2003),
|
||||
mktime(12,0,0,1,9,2003),
|
||||
mktime(12,0,0,2,13,2003),
|
||||
mktime(12,0,0,2,23,2003),
|
||||
mktime(12,0,0,3,30,2003),
|
||||
mktime(12,0,0,4,3,2003),
|
||||
mktime(12,0,0,4,3,2003),
|
||||
mktime(12,0,0,5,9,2003),
|
||||
mktime(12,0,0,5,1,2003),
|
||||
mktime(12,0,0,5,13,2003),
|
||||
mktime(12,0,0,5,19,2003),
|
||||
mktime(12,0,0,5,23,2003),
|
||||
mktime(12,0,0,6,3,2003),
|
||||
mktime(12,0,0,6,19,2003),
|
||||
mktime(12,0,0,6,24,2003),
|
||||
mktime(12,0,0,7,3,2003),
|
||||
mktime(12,0,0,7,9,2003),
|
||||
mktime(12,0,0,7,23,2003),
|
||||
mktime(12,0,0,7,30,2003),
|
||||
mktime(12,0,0,8,9,2003),
|
||||
mktime(12,0,0,9,23,2003),
|
||||
mktime(12,0,0,10,3,2003),
|
||||
mktime(12,0,0,11,12,2003),
|
||||
mktime(12,0,0,11,13,2003),
|
||||
mktime(12,0,0,1,3,2002),
|
||||
mktime(12,0,0,1,9,2002),
|
||||
mktime(12,0,0,2,13,2002),
|
||||
mktime(12,0,0,2,23,2002),
|
||||
mktime(12,0,0,3,30,2002),
|
||||
mktime(12,0,0,4,3,2002),
|
||||
mktime(12,0,0,4,3,2002),
|
||||
mktime(12,0,0,5,9,2002),
|
||||
mktime(12,0,0,5,1,2002),
|
||||
mktime(12,0,0,5,13,2002),
|
||||
mktime(12,0,0,5,19,2002),
|
||||
mktime(12,0,0,5,23,2002),
|
||||
mktime(12,0,0,6,3,2002),
|
||||
mktime(12,0,0,6,19,2002),
|
||||
mktime(12,0,0,6,24,2002),
|
||||
mktime(12,0,0,7,3,2002),
|
||||
mktime(12,0,0,7,9,2002),
|
||||
mktime(12,0,0,7,23,2002),
|
||||
mktime(12,0,0,7,30,2002),
|
||||
mktime(12,0,0,8,9,2002),
|
||||
mktime(12,0,0,9,23,2002),
|
||||
mktime(12,0,0,10,3,2002),
|
||||
mktime(12,0,0,11,12,2003),
|
||||
mktime(12,0,0,11,13,2003),
|
||||
mktime(12,0,0,12,12,2003),
|
||||
mktime(12,0,0,12,13,2003),
|
||||
);
|
||||
|
||||
require(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
|
||||
|
||||
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
|
||||
{
|
||||
print "Order ".$s;
|
||||
|
||||
$com = new Commande($db);
|
||||
|
||||
$com->socid = 4;
|
||||
$com->date_commande = $dates[rand(1, sizeof($dates)-1)];
|
||||
$com->note = $_POST["note"];
|
||||
$com->source = 1;
|
||||
$com->projetid = 0;
|
||||
$com->remise_percent = 0;
|
||||
|
||||
$nbp = rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
// \TODO Utiliser addline plutot que add_product
|
||||
$prodid = rand(1, $num_prods);
|
||||
$result=$com->add_product($prodids[$prodid],rand(1,11),rand(1,6),rand(0,20));
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($db,$propal->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
|
||||
$result=$com->create($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$result=$com->valid($user);
|
||||
if ($result) print " OK";
|
||||
else
|
||||
{
|
||||
dol_print_error($db,$com->error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,$com->error);
|
||||
}
|
||||
|
||||
print "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
135
dev/initdata/generate-facture.php
Normal file
135
dev/initdata/generate-facture.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ATTENTION DE PAS EXECUTER CE SCRIPT SUR UNE INSTALLATION DE PRODUCTION
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/dev/generate-facture.php
|
||||
\brief Script de generation de donnees aleatoires pour les factures
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
$path=preg_replace('/generate-facture.php/i','',$_SERVER["PHP_SELF"]);
|
||||
require ($path."../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
|
||||
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
|
||||
define (GEN_NUMBER_FACTURE, 5);
|
||||
|
||||
|
||||
$sql = "SELECT min(rowid) FROM ".MAIN_DB_PREFIX."user";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$user = new User($db, $row[0]);
|
||||
}
|
||||
|
||||
$socids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_socs = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_socs)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$socids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$result=0;
|
||||
while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||
{
|
||||
$i++;
|
||||
$socid = rand(1, $num_socs);
|
||||
|
||||
print "Invoice ".$i." for socid ".$socid;
|
||||
|
||||
$facture = new Facture($db, $socids[$socid]);
|
||||
$facture->date = time();
|
||||
$facture->cond_reglement_id = 3;
|
||||
$facture->mode_reglement_id = 3;
|
||||
|
||||
$result=$facture->create($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$result=$facture->set_valid($user,$socid);
|
||||
if ($result)
|
||||
{
|
||||
$nbp = rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
$prodid = rand(1, $num_prods);
|
||||
$product=new Product($db);
|
||||
$product->fetch($prodids[$prodid]);
|
||||
$result=$facture->addline($facid,$product->description,$product->price, rand(1,5), $product->tva_tx, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
||||
$xnbp++;
|
||||
}
|
||||
|
||||
print " OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,$facture->error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,$facture->error);
|
||||
}
|
||||
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
86
dev/initdata/generate-produit.php
Normal file
86
dev/initdata/generate-produit.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ATTENTION DE PAS EXECUTER CE SCRIPT SUR UNE INSTALLATION DE PRODUCTION
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/dev/generate-produit.php
|
||||
\brief Script de generation de donnees aleatoires pour les produits
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
$path=preg_replace('/generate-produit.php/i','',$_SERVER["PHP_SELF"]);
|
||||
require ($path."../htdocs/master.inc.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
|
||||
|
||||
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
|
||||
define (GEN_NUMBER_PRODUIT, 5);
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||
if ($db->query($sql)) {
|
||||
$num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $productsid[$i] = $row[0]; $i++; } }
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++; } } else { print "err"; }
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $commandesid[$i] = $row[0]; $i++; } } else { print "err"; }
|
||||
|
||||
|
||||
print "Generates ".GEN_NUMBER_PRODUIT." products\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_PRODUIT ; $s++)
|
||||
{
|
||||
print "Product ".$s;
|
||||
$produit = new Product($db);
|
||||
$produit->type = rand(0,1);
|
||||
$produit->status = 1;
|
||||
$produit->ref = 'P'.time().$s;
|
||||
$produit->libelle = 'Label '.time().$s;
|
||||
$produit->description = 'Description '.time().$s;
|
||||
$produit->price = rand(1,1000);
|
||||
$produit->tva_tx = "19.6";
|
||||
$ret=$produit->create($user);
|
||||
if ($ret < 0) print "Error $ret - ".$produit->error;
|
||||
else print " OK";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
164
dev/initdata/generate-propale.php
Normal file
164
dev/initdata/generate-propale.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ATTENTION DE PAS EXECUTER CE SCRIPT SUR UNE INSTALLATION DE PRODUCTION
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/dev/generate-propale.php
|
||||
\brief Script de generation de donnees aleatoires pour les propales
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
$path=preg_replace('/generate-propale.php/i','',$_SERVER["PHP_SELF"]);
|
||||
require ($path."../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
|
||||
/*
|
||||
* Parameters
|
||||
*/
|
||||
|
||||
define (GEN_NUMBER_PROPAL, 5);
|
||||
|
||||
|
||||
$sql = "SELECT min(rowid) FROM ".MAIN_DB_PREFIX."user";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$user = new User($db, $row[0]);
|
||||
}
|
||||
|
||||
$socids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_socs = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_socs)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$socids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$contids = array();
|
||||
$sql = "SELECT rowid, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_conts = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_conts)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
||||
}
|
||||
}
|
||||
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$user->rights->propale->valider=1;
|
||||
|
||||
|
||||
if (defined("PROPALE_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php"))
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php");
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$result=0;
|
||||
while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
{
|
||||
$i++;
|
||||
$socid = rand(1, $num_socs);
|
||||
print "Proposal ".$i." for socid ".$socid;
|
||||
|
||||
$soc = new Societe($db);
|
||||
|
||||
|
||||
$obj = $conf->global->PROPALE_ADDON;
|
||||
$modPropale = new $obj;
|
||||
$numpr = $modPropale->getNextValue($soc);
|
||||
|
||||
$propal = new Propal($db, $socids[$socid]);
|
||||
|
||||
$propal->ref = $numpr;
|
||||
$propal->contactid = $contids[$socids[$socid]][0];
|
||||
$propal->datep = time();
|
||||
$propal->cond_reglement_id = 3;
|
||||
$propal->mode_reglement_id = 3;
|
||||
$propal->author = $user->id;
|
||||
|
||||
$result=$propal->create($user);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$nbp = rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
$prodid = rand(1, $num_prods);
|
||||
$result=$propal->addline($propal->id, 'Description '.$xnbp, '100', rand(1,5), '19.6', $prodids[$prodid], 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($db,$propal->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
print " OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db,$propal->error);
|
||||
}
|
||||
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
112
dev/initdata/generate-societe.php
Normal file
112
dev/initdata/generate-societe.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* ATTENTION DE PAS EXECUTER CE SCRIPT SUR UNE INSTALLATION DE PRODUCTION
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/dev/generate-societe.php
|
||||
\brief Script de generation de donnees aleatoires pour les societes
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
$path=preg_replace('/generate-societe.php/i','',$_SERVER["PHP_SELF"]);
|
||||
require ($path."../htdocs/master.inc.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/societe.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
|
||||
|
||||
$villes = array("Auray","Baden","Vannes","Pirouville","Haguenau","Souffelweiersheim","Illkirch-Graffenstaden","Lauterbourg","Picauville","Sainte-Mère Eglise","Le Bono");
|
||||
$prenoms = array("Joe","Marc","Steve","Laurent","Nico","Isabelle","Dorothee","Saby","Brigitte","Karine","Jose-Anne","Celine","Virginie");
|
||||
|
||||
|
||||
/*
|
||||
* Parametre
|
||||
*/
|
||||
|
||||
define (GEN_NUMBER_SOCIETE, 10);
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||
if ($db->query($sql)) {
|
||||
$num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $productsid[$i] = $row[0]; $i++; } }
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++; } } else { print "err"; }
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||
if ($db->query($sql)) { $num = $db->num_rows(); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($i); $commandesid[$i] = $row[0]; $i++; } } else { print "err"; }
|
||||
|
||||
|
||||
|
||||
print "Generates ".GEN_NUMBER_SOCIETE." companies\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++)
|
||||
{
|
||||
print "Company $s\n";
|
||||
$soc = new Societe($db);
|
||||
$soc->nom = "Company num ".time()."$s";
|
||||
$soc->ville = $villes[rand(0,sizeof($villes)-1)];
|
||||
$soc->client = rand(1,2); // Une societe sur 2 est prospect, l'autre client
|
||||
$soc->fournisseur = rand(0,1); // Une societe sur 2 est fournisseur
|
||||
$soc->tva_assuj=1;
|
||||
$soc->pays_id=1;
|
||||
$soc->pays_code='FR';
|
||||
// Un client sur 10 a une remise de 5%
|
||||
$user_remise=rand(1,10); if ($user_remise==10) $soc->remise_client=5;
|
||||
print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_client."\n";
|
||||
$soc->note='Fictional company created by the script generate-societe.php';
|
||||
$socid = $soc->create();
|
||||
|
||||
if ($socid >= 0)
|
||||
{
|
||||
$rand = rand(1,4);
|
||||
print "> Generates $rand contact\n";
|
||||
for ($c = 0 ; $c < $rand ; $c++)
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->socid = $soc->id;
|
||||
$contact->name = "NomFamille".$c;
|
||||
$contact->firstname = $prenoms[rand(0,sizeof($prenoms)-1)];
|
||||
if ( $contact->create($user) )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error: ".$soc->error."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
132
dev/initdata/initdemo.sh
Normal file
132
dev/initdata/initdemo.sh
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------
|
||||
# Script to purge and init a database with demo values.
|
||||
# Note: "dialog" tool need to be available.
|
||||
#
|
||||
# Regis Houssin - regis@dolibarr.fr
|
||||
# Laurent Destailleur - eldy@users.sourceforge.net
|
||||
#------------------------------------------------------
|
||||
# WARNING: This script erase all data of database
|
||||
# with data into initdemo.sql
|
||||
#------------------------------------------------------
|
||||
|
||||
export mydir=`echo "$_" | sed -e 's/initdemo.sh//'`;
|
||||
export id=`id -u`;
|
||||
|
||||
# ----------------------------- check if root
|
||||
if [ "x$id" != "x0" ]
|
||||
then
|
||||
echo "Script must be ran as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
# ----------------------------- database name
|
||||
DIALOG=${DIALOG=dialog}
|
||||
DIALOG="$DIALOG --ascii-lines"
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--inputbox "Mysql database name :" 16 51 dolibarrdemo 2> $fichtemp
|
||||
valret=$?
|
||||
case $valret in
|
||||
0)
|
||||
base=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- database port
|
||||
DIALOG=${DIALOG=dialog}
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--inputbox "Mysql port (ex: 3306):" 16 51 3306 2> $fichtemp
|
||||
|
||||
valret=$?
|
||||
|
||||
case $valret in
|
||||
0)
|
||||
port=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- compte admin mysql
|
||||
DIALOG=${DIALOG=dialog}
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--inputbox "Mysql root login (ex: root):" 16 51 root 2> $fichtemp
|
||||
|
||||
valret=$?
|
||||
|
||||
case $valret in
|
||||
0)
|
||||
admin=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- mot de passe admin mysql
|
||||
DIALOG=${DIALOG=dialog}
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--inputbox "Password for Mysql root login :" 16 51 2> $fichtemp
|
||||
|
||||
valret=$?
|
||||
|
||||
case $valret in
|
||||
0)
|
||||
passwd=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- chemin d'acces du repertoire documents
|
||||
DIALOG=${DIALOG=dialog}
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--inputbox "Full path to documents directory (ex: /var/www/dolibarr/documents)- no / at end :" 16 51 2> $fichtemp
|
||||
|
||||
valret=$?
|
||||
|
||||
case $valret in
|
||||
0)
|
||||
docs=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- confirmation
|
||||
DIALOG=${DIALOG=dialog}
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||
--yesno "Do you confirm ? \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : '$passwd' \n Documents dir : '$docs'" 15 40
|
||||
|
||||
case $? in
|
||||
0) echo "Ok, start process...";;
|
||||
1) exit;;
|
||||
255) exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- run sql file
|
||||
if [ "x$passwd" != "x" ]
|
||||
then
|
||||
export passwd="-p$passwd"
|
||||
fi
|
||||
echo "mysql -u$admin $passwd $base < $mydir/initdemo.sql"
|
||||
mysql -u$admin $passwd $base < $mydir/initdemo.sql
|
||||
|
||||
echo "Dolibarr data demo has been loaded."
|
||||
echo
|
||||
5401
dev/initdata/initdemo.sql
Normal file
5401
dev/initdata/initdemo.sql
Normal file
File diff suppressed because one or more lines are too long
38
dev/initdata/removedemo.sh
Normal file
38
dev/initdata/removedemo.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------
|
||||
# Script to remove setup of a Dolibarr installation.
|
||||
# Note: "dialog" tool need to be available.
|
||||
#
|
||||
# Regis Houssin - regis@dolibarr.fr
|
||||
# Laurent Destailleur - eldy@users.sourceforge.net
|
||||
#------------------------------------------------------
|
||||
# WARNING: This script erase all data of database
|
||||
#------------------------------------------------------
|
||||
|
||||
export mydir=`echo "$_" | sed -e 's/removedemo.sh//'`;
|
||||
|
||||
DIALOG=${DIALOG=dialog}
|
||||
DIALOG="$DIALOG --ascii-lines"
|
||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||
$DIALOG --title "Remove Dolibarr install" --clear \
|
||||
--yesno "Do you confirm ?" 15 40
|
||||
valret=$?
|
||||
case $valret in
|
||||
0)
|
||||
base=`cat $fichtemp`;;
|
||||
1)
|
||||
exit;;
|
||||
255)
|
||||
exit;;
|
||||
esac
|
||||
|
||||
# ---------------------------- remove conf file
|
||||
echo "Remove file $mydir../../htdocs/conf/conf.php"
|
||||
cp -pf $mydir../../htdocs/conf/conf.php $mydir../../htdocs/conf/conf.sav.php 2>/dev/null
|
||||
rm $mydir../../htdocs/conf/conf.php 2>/dev/null
|
||||
echo "Remove file $mydir../../install.lock"
|
||||
rm $mydir../../install.lock 2>/dev/null
|
||||
|
||||
echo "Dolibarr demo has been removed (need to be installed again)."
|
||||
echo
|
||||
Reference in New Issue
Block a user