Som fixes on generator of samples
This commit is contained in:
parent
abb3c810de
commit
1a3b9fada5
@ -41,8 +41,59 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
|||||||
* Parameters
|
* Parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define(GEN_NUMBER_FACTURE, 5);
|
define(GEN_NUMBER_FACTURE, 1);
|
||||||
|
$year = 2016;
|
||||||
|
$dates = array (mktime(12,0,0,1,3,$year),
|
||||||
|
mktime(12,0,0,1,9,$year),
|
||||||
|
mktime(12,0,0,2,13,$year),
|
||||||
|
mktime(12,0,0,2,23,$year),
|
||||||
|
mktime(12,0,0,3,30,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,5,9,$year),
|
||||||
|
mktime(12,0,0,5,1,$year),
|
||||||
|
mktime(12,0,0,5,13,$year),
|
||||||
|
mktime(12,0,0,5,19,$year),
|
||||||
|
mktime(12,0,0,5,23,$year),
|
||||||
|
mktime(12,0,0,6,3,$year),
|
||||||
|
mktime(12,0,0,6,19,$year),
|
||||||
|
mktime(12,0,0,6,24,$year),
|
||||||
|
mktime(12,0,0,7,3,$year),
|
||||||
|
mktime(12,0,0,7,9,$year),
|
||||||
|
mktime(12,0,0,7,23,$year),
|
||||||
|
mktime(12,0,0,7,30,$year),
|
||||||
|
mktime(12,0,0,8,9,$year),
|
||||||
|
mktime(12,0,0,9,23,$year),
|
||||||
|
mktime(12,0,0,10,3,$year),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,1,3,($year - 1)),
|
||||||
|
mktime(12,0,0,1,9,($year - 1)),
|
||||||
|
mktime(12,0,0,2,13,($year - 1)),
|
||||||
|
mktime(12,0,0,2,23,($year - 1)),
|
||||||
|
mktime(12,0,0,3,30,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,5,9,($year - 1)),
|
||||||
|
mktime(12,0,0,5,1,($year - 1)),
|
||||||
|
mktime(12,0,0,5,13,($year - 1)),
|
||||||
|
mktime(12,0,0,5,19,($year - 1)),
|
||||||
|
mktime(12,0,0,5,23,($year - 1)),
|
||||||
|
mktime(12,0,0,6,3,($year - 1)),
|
||||||
|
mktime(12,0,0,6,19,($year - 1)),
|
||||||
|
mktime(12,0,0,6,24,($year - 1)),
|
||||||
|
mktime(12,0,0,7,3,($year - 1)),
|
||||||
|
mktime(12,0,0,7,9,($year - 1)),
|
||||||
|
mktime(12,0,0,7,23,($year - 1)),
|
||||||
|
mktime(12,0,0,7,30,($year - 1)),
|
||||||
|
mktime(12,0,0,8,9,($year - 1)),
|
||||||
|
mktime(12,0,0,9,23,($year - 1)),
|
||||||
|
mktime(12,0,0,10,3,($year - 1)),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,12,12,$year),
|
||||||
|
mktime(12,0,0,12,13,$year),
|
||||||
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('','admin');
|
$ret=$user->fetch('','admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0)
|
||||||
@ -54,16 +105,15 @@ $user->getrights();
|
|||||||
|
|
||||||
|
|
||||||
$socids = array();
|
$socids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1, 3)";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num_socs = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_socs)
|
while ($i < $num_thirdparties)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$socids[$i] = $row[0];
|
$socids[$i] = $row[0];
|
||||||
}
|
}
|
||||||
@ -79,7 +129,6 @@ if ($resql)
|
|||||||
while ($i < $num_prods)
|
while ($i < $num_prods)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$prodids[$i] = $row[0];
|
$prodids[$i] = $row[0];
|
||||||
}
|
}
|
||||||
@ -90,46 +139,51 @@ $result=0;
|
|||||||
while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
$socid = mt_rand(1, $num_socs);
|
$socid = mt_rand(1, $num_thirdparties);
|
||||||
|
|
||||||
print "Invoice ".$i." for socid ".$socid;
|
print "Invoice ".$i." for socid ".$socid;
|
||||||
|
|
||||||
$facture = new Facture($db);
|
$object = new Facture($db);
|
||||||
$facture->date = time();
|
$object->socid = $socids[$socid];
|
||||||
$facture->cond_reglement_id = 3;
|
$object->date = $dates[mt_rand(1, count($dates)-1)];
|
||||||
$facture->mode_reglement_id = 3;
|
$object->cond_reglement_id = 3;
|
||||||
|
$object->mode_reglement_id = 3;
|
||||||
|
|
||||||
$result=$facture->create($user);
|
$fuser = new User($db);
|
||||||
|
$fuser->fetch(mt_rand(1,2));
|
||||||
|
$fuser->getRights();
|
||||||
|
|
||||||
|
$result=$object->create($fuser);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result=$facture->validate($user);
|
$nbp = mt_rand(2, 5);
|
||||||
|
$xnbp = 0;
|
||||||
|
while ($xnbp < $nbp)
|
||||||
|
{
|
||||||
|
$prodid = mt_rand(1, $num_prods);
|
||||||
|
$product=new Product($db);
|
||||||
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
|
$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
dol_print_error($db,$propal->error);
|
||||||
|
}
|
||||||
|
$xnbp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result=$object->validate($fuser);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$nbp = mt_rand(2, 5);
|
print " OK with ref ".$object->ref."\n";;
|
||||||
$xnbp = 0;
|
|
||||||
while ($xnbp < $nbp)
|
|
||||||
{
|
|
||||||
$prodid = mt_rand(1, $num_prods);
|
|
||||||
$product=new Product($db);
|
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
|
||||||
$result=$facture->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
dol_print_error($db,$propal->error);
|
|
||||||
}
|
|
||||||
$xnbp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
print " OK with ref ".$facture->ref."\n";;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db,$facture->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db,$facture->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -47,7 +48,58 @@ include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
define(GEN_NUMBER_COMMANDE, 10);
|
define(GEN_NUMBER_COMMANDE, 10);
|
||||||
|
$year = 2016;
|
||||||
|
$dates = array (mktime(12,0,0,1,3,$year),
|
||||||
|
mktime(12,0,0,1,9,$year),
|
||||||
|
mktime(12,0,0,2,13,$year),
|
||||||
|
mktime(12,0,0,2,23,$year),
|
||||||
|
mktime(12,0,0,3,30,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,5,9,$year),
|
||||||
|
mktime(12,0,0,5,1,$year),
|
||||||
|
mktime(12,0,0,5,13,$year),
|
||||||
|
mktime(12,0,0,5,19,$year),
|
||||||
|
mktime(12,0,0,5,23,$year),
|
||||||
|
mktime(12,0,0,6,3,$year),
|
||||||
|
mktime(12,0,0,6,19,$year),
|
||||||
|
mktime(12,0,0,6,24,$year),
|
||||||
|
mktime(12,0,0,7,3,$year),
|
||||||
|
mktime(12,0,0,7,9,$year),
|
||||||
|
mktime(12,0,0,7,23,$year),
|
||||||
|
mktime(12,0,0,7,30,$year),
|
||||||
|
mktime(12,0,0,8,9,$year),
|
||||||
|
mktime(12,0,0,9,23,$year),
|
||||||
|
mktime(12,0,0,10,3,$year),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,1,3,($year - 1)),
|
||||||
|
mktime(12,0,0,1,9,($year - 1)),
|
||||||
|
mktime(12,0,0,2,13,($year - 1)),
|
||||||
|
mktime(12,0,0,2,23,($year - 1)),
|
||||||
|
mktime(12,0,0,3,30,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,5,9,($year - 1)),
|
||||||
|
mktime(12,0,0,5,1,($year - 1)),
|
||||||
|
mktime(12,0,0,5,13,($year - 1)),
|
||||||
|
mktime(12,0,0,5,19,($year - 1)),
|
||||||
|
mktime(12,0,0,5,23,($year - 1)),
|
||||||
|
mktime(12,0,0,6,3,($year - 1)),
|
||||||
|
mktime(12,0,0,6,19,($year - 1)),
|
||||||
|
mktime(12,0,0,6,24,($year - 1)),
|
||||||
|
mktime(12,0,0,7,3,($year - 1)),
|
||||||
|
mktime(12,0,0,7,9,($year - 1)),
|
||||||
|
mktime(12,0,0,7,23,($year - 1)),
|
||||||
|
mktime(12,0,0,7,30,($year - 1)),
|
||||||
|
mktime(12,0,0,8,9,($year - 1)),
|
||||||
|
mktime(12,0,0,9,23,($year - 1)),
|
||||||
|
mktime(12,0,0,10,3,($year - 1)),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,12,12,$year),
|
||||||
|
mktime(12,0,0,12,13,$year),
|
||||||
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('','admin');
|
$ret=$user->fetch('','admin');
|
||||||
if ($ret <= 0)
|
if ($ret <= 0)
|
||||||
@ -57,34 +109,34 @@ if ($ret <= 0)
|
|||||||
}
|
}
|
||||||
$user->getrights();
|
$user->getrights();
|
||||||
|
|
||||||
|
$societesid = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num_thirdparties) {
|
||||||
$row = $db->fetch_row($resql);
|
$i++;
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
$societesid[$i] = $row[0];
|
$societesid[$i] = $row[0];
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { print "err"; }
|
else { print "err"; }
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
$commandesid = array();
|
||||||
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$row = $db->fetch_row($resql);
|
|
||||||
$commandesid[$i] = $row[0];
|
|
||||||
$i++;
|
$i++;
|
||||||
|
$row = $db->fetch_row($resql);
|
||||||
|
$commandesid[$i] = $row[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { print "err"; }
|
else { print "err"; }
|
||||||
|
|
||||||
|
|
||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -102,59 +154,6 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$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/class/commande.class.php");
|
|
||||||
|
|
||||||
|
|
||||||
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
||||||
@ -162,53 +161,63 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
|
|||||||
{
|
{
|
||||||
print "Process order ".$s."\n";
|
print "Process order ".$s."\n";
|
||||||
|
|
||||||
$com = new Commande($db);
|
$object = new Commande($db);
|
||||||
|
|
||||||
$com->socid = 4;
|
|
||||||
$com->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
|
||||||
$com->note = 'A comment';
|
|
||||||
$com->source = 1;
|
|
||||||
$com->fk_project = 0;
|
|
||||||
$com->remise_percent = 0;
|
|
||||||
|
|
||||||
|
$object->socid = $societesid[mt_rand(1, $num_thirdparties)];
|
||||||
|
$object->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
||||||
|
$object->note = 'My small comment about this order. Hum. Nothing.';
|
||||||
|
$object->source = 1;
|
||||||
|
$object->fk_project = 0;
|
||||||
|
$object->remise_percent = 0;
|
||||||
|
$object->shipping_method_id = mt_rand(1, 2);
|
||||||
|
$object->cond_reglement_id = mt_rand(0, 2);
|
||||||
|
$object->more_reglement_id = mt_rand(0, 7);
|
||||||
|
$object->availability_id = mt_rand(0, 1);
|
||||||
|
|
||||||
|
$listofuserid=array(12,13,16);
|
||||||
|
|
||||||
|
$fuser = new User($db);
|
||||||
|
$fuser->fetch($listofuserid[mt_rand(0,2)]);
|
||||||
|
$fuser->getRights();
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$result=$com->create($user);
|
$result=$object->create($fuser);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result=$com->valid($user);
|
$nbp = mt_rand(2, 5);
|
||||||
|
$xnbp = 0;
|
||||||
|
while ($xnbp < $nbp)
|
||||||
|
{
|
||||||
|
$prodid = mt_rand(1, $num_prods);
|
||||||
|
$product=new Product($db);
|
||||||
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
|
$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
dol_print_error($db,$object->error);
|
||||||
|
}
|
||||||
|
$xnbp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result=$object->valid($fuser);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$nbp = mt_rand(2, 5);
|
|
||||||
$xnbp = 0;
|
|
||||||
while ($xnbp < $nbp)
|
|
||||||
{
|
|
||||||
$prodid = mt_rand(1, $num_prods);
|
|
||||||
$product=new Product($db);
|
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
|
||||||
$result=$com->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
|
||||||
if ($result < 0)
|
|
||||||
{
|
|
||||||
dol_print_error($db,$propal->error);
|
|
||||||
}
|
|
||||||
$xnbp++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
print " OK with ref ".$com->ref."\n";
|
print " OK with ref ".$object->ref."\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print " KO\n";
|
print " KO\n";
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
dol_print_error($db,$com->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print " KO\n";
|
print " KO\n";
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
dol_print_error($db,$com->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,8 +43,59 @@ require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
|||||||
* Parameters
|
* Parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define(GEN_NUMBER_PROPAL, 5);
|
define(GEN_NUMBER_PROPAL, 10);
|
||||||
|
$year = 2016;
|
||||||
|
$dates = array (mktime(12,0,0,1,3,$year),
|
||||||
|
mktime(12,0,0,1,9,$year),
|
||||||
|
mktime(12,0,0,2,13,$year),
|
||||||
|
mktime(12,0,0,2,23,$year),
|
||||||
|
mktime(12,0,0,3,30,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,4,3,$year),
|
||||||
|
mktime(12,0,0,5,9,$year),
|
||||||
|
mktime(12,0,0,5,1,$year),
|
||||||
|
mktime(12,0,0,5,13,$year),
|
||||||
|
mktime(12,0,0,5,19,$year),
|
||||||
|
mktime(12,0,0,5,23,$year),
|
||||||
|
mktime(12,0,0,6,3,$year),
|
||||||
|
mktime(12,0,0,6,19,$year),
|
||||||
|
mktime(12,0,0,6,24,$year),
|
||||||
|
mktime(12,0,0,7,3,$year),
|
||||||
|
mktime(12,0,0,7,9,$year),
|
||||||
|
mktime(12,0,0,7,23,$year),
|
||||||
|
mktime(12,0,0,7,30,$year),
|
||||||
|
mktime(12,0,0,8,9,$year),
|
||||||
|
mktime(12,0,0,9,23,$year),
|
||||||
|
mktime(12,0,0,10,3,$year),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,1,3,($year - 1)),
|
||||||
|
mktime(12,0,0,1,9,($year - 1)),
|
||||||
|
mktime(12,0,0,2,13,($year - 1)),
|
||||||
|
mktime(12,0,0,2,23,($year - 1)),
|
||||||
|
mktime(12,0,0,3,30,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,4,3,($year - 1)),
|
||||||
|
mktime(12,0,0,5,9,($year - 1)),
|
||||||
|
mktime(12,0,0,5,1,($year - 1)),
|
||||||
|
mktime(12,0,0,5,13,($year - 1)),
|
||||||
|
mktime(12,0,0,5,19,($year - 1)),
|
||||||
|
mktime(12,0,0,5,23,($year - 1)),
|
||||||
|
mktime(12,0,0,6,3,($year - 1)),
|
||||||
|
mktime(12,0,0,6,19,($year - 1)),
|
||||||
|
mktime(12,0,0,6,24,($year - 1)),
|
||||||
|
mktime(12,0,0,7,3,($year - 1)),
|
||||||
|
mktime(12,0,0,7,9,($year - 1)),
|
||||||
|
mktime(12,0,0,7,23,($year - 1)),
|
||||||
|
mktime(12,0,0,7,30,($year - 1)),
|
||||||
|
mktime(12,0,0,8,9,($year - 1)),
|
||||||
|
mktime(12,0,0,9,23,($year - 1)),
|
||||||
|
mktime(12,0,0,10,3,($year - 1)),
|
||||||
|
mktime(12,0,0,11,12,$year),
|
||||||
|
mktime(12,0,0,11,13,$year),
|
||||||
|
mktime(12,0,0,12,12,$year),
|
||||||
|
mktime(12,0,0,12,13,$year),
|
||||||
|
);
|
||||||
|
|
||||||
$ret=$user->fetch('','admin');
|
$ret=$user->fetch('','admin');
|
||||||
if (! $ret > 0)
|
if (! $ret > 0)
|
||||||
@ -56,16 +107,15 @@ $user->getrights();
|
|||||||
|
|
||||||
|
|
||||||
$socids = array();
|
$socids = array();
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1,3)";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num_socs = $db->num_rows($resql);
|
$num_thirdparties = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_socs)
|
while ($i < $num_thirdparties)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$socids[$i] = $row[0];
|
$socids[$i] = $row[0];
|
||||||
}
|
}
|
||||||
@ -81,7 +131,6 @@ if ($resql)
|
|||||||
while ($i < $num_conts)
|
while ($i < $num_conts)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
||||||
}
|
}
|
||||||
@ -97,7 +146,6 @@ if ($resql)
|
|||||||
while ($i < $num_prods)
|
while ($i < $num_prods)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $db->fetch_row($resql);
|
$row = $db->fetch_row($resql);
|
||||||
$prodids[$i] = $row[0];
|
$prodids[$i] = $row[0];
|
||||||
}
|
}
|
||||||
@ -117,27 +165,25 @@ $result=0;
|
|||||||
while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
$socid = mt_rand(1, $num_socs);
|
$socid = mt_rand(1, $num_thirdparties);
|
||||||
print "Proposal ".$i." for socid ".$socid;
|
print "Proposal ".$i." for socid ".$socid;
|
||||||
|
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
|
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$object = new Propal($db);
|
||||||
|
|
||||||
$obj = $conf->global->PROPALE_ADDON;
|
$fuser = new User($db);
|
||||||
$modPropale = new $obj;
|
$fuser->fetch(mt_rand(1,2));
|
||||||
$numpr = $modPropale->getNextValue($soc,$propal);
|
$fuser->getRights();
|
||||||
|
|
||||||
|
$object->contactid = $contids[$socids[$socid]][0];
|
||||||
|
$object->socid = $socids[$socid];
|
||||||
|
$object->datep = $dates[mt_rand(1, count($dates)-1)];
|
||||||
|
$object->cond_reglement_id = 3;
|
||||||
|
$object->mode_reglement_id = 3;
|
||||||
|
|
||||||
$propal->ref = $numpr;
|
$result=$object->create($fuser);
|
||||||
$propal->contactid = $contids[$socids[$socid]][0];
|
|
||||||
$propal->socid = $socids[$socid];
|
|
||||||
$propal->datep = time();
|
|
||||||
$propal->cond_reglement_id = 3;
|
|
||||||
$propal->mode_reglement_id = 3;
|
|
||||||
$propal->author = $user->id;
|
|
||||||
|
|
||||||
$result=$propal->create($user);
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$nbp = mt_rand(2, 5);
|
$nbp = mt_rand(2, 5);
|
||||||
@ -147,18 +193,30 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
|||||||
$prodid = mt_rand(1, $num_prods);
|
$prodid = mt_rand(1, $num_prods);
|
||||||
$product=new Product($db);
|
$product=new Product($db);
|
||||||
$result=$product->fetch($prodids[$prodid]);
|
$result=$product->fetch($prodids[$prodid]);
|
||||||
$result=$propal->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
|
$result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$propal->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
$xnbp++;
|
$xnbp++;
|
||||||
}
|
}
|
||||||
print " OK with ref ".$propal->ref."\n";
|
|
||||||
|
$result=$object->valid($fuser);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
print " OK with ref ".$object->ref."\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print " KO\n";
|
||||||
|
$db->rollback();
|
||||||
|
dol_print_error($db,$object->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($db,$propal->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,7 @@ if (! empty($conf->projet->enabled)) {
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||||
|
|
||||||
$langs->load('orders');
|
$langs->load('orders');
|
||||||
@ -61,6 +62,7 @@ $langs->load('sendings');
|
|||||||
$langs->load('products');
|
$langs->load('products');
|
||||||
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
|
if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
|
||||||
if (! empty($conf->margin->enabled)) $langs->load('margins');
|
if (! empty($conf->margin->enabled)) $langs->load('margins');
|
||||||
|
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
|
||||||
|
|
||||||
$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
|
$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
|
||||||
$ref = GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user