dolibarr/htdocs/admin/system/gendata.php

269 lines
7.6 KiB
PHP
Raw Normal View History

<?php
2003-09-14 13:56:32 +02:00
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2003-09-14 13:56:32 +02:00
*
* 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.
*
* $Id$
* $Source$
*/
/*! \file htdocs/admin/system/gendata.php
\brief Page de g<EFBFBD>n<EFBFBD>ration de donn<EFBFBD>es al<EFBFBD>atoires pour les commandes et expedition
\version $Revision$
*/
2003-09-14 13:56:32 +02:00
require("./pre.inc.php");
$langs->load("admin");
2003-11-16 17:41:29 +01:00
$user->getrights('commande');
$user->getrights('expedition');
if (!$user->admin)
accessforbidden();
2003-09-14 13:56:32 +02:00
llxHeader();
2003-09-14 13:56:32 +02:00
?>
2003-11-16 17:41:29 +01:00
<h2>Attention : Ceci est un g<EFBFBD>n<EFBFBD>rateur de donn<EFBFBD>es al<EFBFBD>atoires, ne
2003-09-14 18:58:20 +02:00
pas utiliser sur une base de donn<EFBFBD>es en production, les op<EFBFBD>rations ne sont pas r<EFBFBD>versibles</h2>
2003-11-16 17:41:29 +01:00
<a href="gendata.php">Home</a><br>
2003-09-14 13:56:32 +02:00
<br>
<?php
2003-09-14 13:56:32 +02:00
include_once "../../societe.class.php";
include_once "../../contact.class.php";
include_once "../../facture.class.php";
2003-09-14 18:58:20 +02:00
include_once "../../product.class.php";
2003-09-14 14:25:10 +02:00
include_once "../../paiement.class.php";
2003-09-14 13:56:32 +02:00
include_once "../../contrat/contrat.class.php";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
2003-09-14 13:56:32 +02:00
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 idp FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
2003-09-14 13:56:32 +02:00
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();
2003-11-16 17:41:29 +01:00
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 '<table class="border"><tr>';
2003-11-16 17:41:29 +01:00
print '<td><a href="gendata.php?action=societe">Soci<63>t<EFBFBD>s</a></td>';
print '<td><a href="gendata.php?action=product">Produits</a></td>';
print '<td><a href="gendata.php?action=facture">Factures</a></td>';
print '<td><a href="gendata.php?action=commande">Commandes</a></td>';
print '</tr><tr>';
print "<td>". sizeof($societesid) ."</td>";
print "<td>". sizeof($productsid) ."</td>";
print '<td>';
print "<td>". sizeof($commandesid) ."</td>";
2003-09-14 13:56:32 +02:00
2003-11-16 17:41:29 +01:00
print '</table>';
2003-09-14 13:56:32 +02:00
print "<p>";
2003-09-14 18:58:20 +02:00
if ($action == 'product')
{
$randf = rand(1,200);
print "G<EFBFBD>n<EFBFBD>re $randf produits<br>";
for ($f = 0 ; $f < $randf ; $f++)
{
$produit = new Product($db);
$produit->type = 1;
$produit->envente = 1;
$produit->ref = time() . "$f";
$produit->libelle = $langs->trans("Label");
$produit->description = $langs->trans("Description");
2003-09-14 18:58:20 +02:00
$produit->price = rand(1,10000);
$produit->tva_tx = "19.6";
$produit->create($user);
}
}
2003-09-14 13:56:32 +02:00
if ($action == 'facture')
{
2003-09-17 18:19:58 +02:00
$randf = rand(1,2);
2003-09-14 13:56:32 +02:00
print "G<EFBFBD>n<EFBFBD>re $randf factures<br>";
for ($f = 0 ; $f < $randf ; $f++)
{
$facture = new Facture($db, $societesid[rand(1, sizeof($societesid)-1)]);
$facture->number = time() . $f;
2003-09-14 14:25:10 +02:00
$datef = time()*2;
while($datef > time())
$datef = mktime(12,0,0,rand(1,12),rand(1,31),rand(2002,2003));
$facture->date = $datef;
2003-09-14 13:56:32 +02:00
$facture->note = '';
$facture->cond_reglement = 1;
$facture->remise_percent = rand(0,50);
2003-09-14 14:05:09 +02:00
2003-09-17 18:19:58 +02:00
$prand = rand(1,200);
2003-09-14 14:05:09 +02:00
for ($p = 0 ; $p < $prand ; $p++)
{
$pidrand = rand(1, sizeof($productsid)-1);
$facture->add_product($productsid[rand(1, sizeof($productsid)-1)],rand(1,11));
2003-09-14 18:58:20 +02:00
print "(AP ".$productsid[$pidrand].") ";
2003-09-14 14:05:09 +02:00
}
2003-09-14 13:56:32 +02:00
$id = $facture->create($user);
if ($id)
{
2003-09-14 14:25:10 +02:00
print " - <b>facture $id ok";
2003-09-14 13:56:32 +02:00
$test = rand(0,1);
2003-09-14 13:57:09 +02:00
$test = 1;
2003-09-14 13:56:32 +02:00
if ($test > 0)
{
$facture->set_valid($id, $user);
print " - valid<69>e";
}
2003-09-14 14:25:10 +02:00
if($datef < (time() - (24*3600*30)))
{
$paiement = new Paiement($db);
$paiement->facid = $id;
$paiement->amount = $facture->total_ttc;
$paiement->paiementid = 1;
$paiement->datepaye = "now()";
$paiement->create($user);
$facture->set_payed($id);
print " - pay<61>e";
}
print "</b><br>";
2003-09-14 13:56:32 +02:00
}
}
}
2003-09-14 18:58:20 +02:00
2003-11-16 17:41:29 +01:00
if ($_GET["action"] == 'societe')
2003-09-14 13:56:32 +02:00
{
2003-09-14 18:58:20 +02:00
$rands = rand(1,400);
2003-09-14 13:56:32 +02:00
print "G<EFBFBD>n<EFBFBD>re $rands soci<63>t<EFBFBD><br>";
for ($s = 0 ; $s < $rands ; $s++)
{
print "- soci<63>t<EFBFBD> $s<br>";
$soc = new Societe($db);
2003-09-14 14:38:33 +02:00
$soc->nom = "Soci<EFBFBD>t<EFBFBD> al<61>atoire num ".time()."$s";
2003-09-14 14:02:17 +02:00
$villes = array("Auray","Baden","Vannes","Pirouville","Haguenau","Souffelweiersheim","Illkirch-Graffenstaden","Lauterbourg","Picauville","Sainte-M<>re Eglise","Le Bono");
$soc->ville = $villes[rand(0,sizeof($villes)-1)];
2003-09-14 13:56:32 +02:00
$soc->client = 1;
$socid = $soc->create();
if ($socid)
{
2003-09-14 14:32:54 +02:00
$rand = rand(1,4);
2003-09-14 13:56:32 +02:00
print "-- g<>n<EFBFBD>re $rand contact<br>";
for ($c = 0 ; $c < $rand ; $c++)
{
$contact = new Contact($db);
$contact->socid = $socid;
2003-09-14 14:35:44 +02:00
$contact->nom = "Nom al<61>a ".time()."-$c";
2003-09-14 13:56:32 +02:00
if ( $contact->create($user) )
{
2003-09-14 14:05:09 +02:00
2003-09-14 13:56:32 +02:00
}
}
}
}
}
2003-11-16 17:41:29 +01:00
if ($_GET["action"] == 'commande')
{
$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";
$com = new Commande($db);
$com->soc_id = 4;
$com->date_commande = $dates[rand(1, sizeof($dates)-1)];
$com->note = $_POST["note"];
2003-11-16 17:41:29 +01:00
$com->source = 1;
$com->projetid = 0;
$com->remise_percent = 0;
$pidrand = rand(1, sizeof($productsid)-1);
$com->add_product($productsid[rand(1, sizeof($productsid)-1)],rand(1,11),rand(1,6),rand(0,20));
$id = $com->create($user);
print " " . strftime("%d %B %Y",$com->date_commande);
$com->fetch($id);
print " " . $com->valid($user);
}
2003-09-14 13:56:32 +02:00
llxFooter();
?>