Fix: Sending page when subproduct feature is enabled
This commit is contained in:
parent
5e4f9a3734
commit
b104a84992
@ -71,7 +71,7 @@ $eventstolog=array(
|
||||
array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled),
|
||||
array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled),
|
||||
array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled),
|
||||
*/
|
||||
*/
|
||||
);
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ if ($action == "save")
|
||||
$i=0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
foreach ($eventstolog as $key => $arr)
|
||||
{
|
||||
$param='MAIN_LOGEVENTS_'.$arr['id'];
|
||||
@ -91,18 +91,18 @@ if ($action == "save")
|
||||
if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0);
|
||||
else dolibarr_del_const($db,$param);
|
||||
}
|
||||
|
||||
|
||||
$db->commit();
|
||||
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Affichage du formulaire de saisie
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
llxHeader('',$langs->trans("Audit"));
|
||||
|
||||
//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
|
||||
|
||||
@ -48,8 +48,11 @@ if ($_GET["action"] == 'remove')
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
llxHeader('',$langs->trans("DefaultRights"));
|
||||
|
||||
print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
|
||||
|
||||
@ -126,7 +129,7 @@ if ($result)
|
||||
foreach($objMod->rights as $key => $val)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Break found, it's a new module to catch
|
||||
if ($old <> $obj->module)
|
||||
{
|
||||
|
||||
@ -59,7 +59,7 @@ if ($_GET["action"] == 'setgeneraterule')
|
||||
if ($_GET["action"] == 'activate_encrypt')
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
|
||||
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user as u";
|
||||
@ -157,7 +157,7 @@ else if ($_GET["action"] == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK')
|
||||
* Affichage onglet
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
llxHeader('',$langs->trans("Passwords"));
|
||||
|
||||
if ($mesg) print "$mesg\n";
|
||||
|
||||
@ -332,7 +332,7 @@ print '</td>';
|
||||
|
||||
print '<td align="center" width="100">';
|
||||
// TODO Impossibilité de crypter le mot de passe lorsqu'il y a en a un, il affiche qu'il n'y en a pas !!
|
||||
if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass))
|
||||
if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print img_warning($langs->trans("WarningPassIsEmpty"));
|
||||
|
||||
@ -94,7 +94,7 @@ else if ($_GET["action"] == 'disable_avscan')
|
||||
* Affichage onglet
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
llxHeader('',$langs->trans("Miscellanous"));
|
||||
|
||||
print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
|
||||
|
||||
|
||||
@ -472,12 +472,18 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
|
||||
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
|
||||
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product];
|
||||
$reste_a_livrer_total += $reste_a_livrer[$objp->fk_product];
|
||||
print '<td align="center">';
|
||||
print $reste_a_livrer[$objp->fk_product];
|
||||
print '</td>';
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0 && $conf->stock->enabled)
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $product->stock_reel;
|
||||
@ -491,18 +497,25 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
print "</tr>\n";
|
||||
|
||||
// associations sous produits
|
||||
if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $objp->fk_product > 0)
|
||||
// Show subproducts details
|
||||
if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
{
|
||||
$product->get_sousproduits_arbo ();
|
||||
// Set tree of subproducts in product->sousprods
|
||||
$product->get_sousproduits_arbo();
|
||||
//var_dump($product->sousprods);exit;
|
||||
|
||||
// Define a new tree with quantiies recalculated
|
||||
$prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
|
||||
//var_dump($prods_arbo);
|
||||
if(sizeof($prods_arbo) > 0)
|
||||
{
|
||||
foreach($prods_arbo as $key => $value)
|
||||
{
|
||||
print '<tr><td colspan="4">';
|
||||
print $value[0];
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -619,7 +632,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouv<EFBFBD>e */
|
||||
/* Commande non trouvee */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2008-2009 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
|
||||
@ -22,6 +22,7 @@
|
||||
* \brief Library for expedition module
|
||||
* \version $Id$
|
||||
*/
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
|
||||
|
||||
/**
|
||||
@ -33,16 +34,22 @@
|
||||
function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
{
|
||||
global $db, $conf, $langs, $bc;
|
||||
|
||||
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.qty as qty_asked";
|
||||
global $html;
|
||||
|
||||
$product_static=new Product($db);
|
||||
|
||||
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked";
|
||||
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
|
||||
$sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition";
|
||||
if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_livraison")." as date_delivery, ld.qty as qty_received";
|
||||
$sql.= ", e.ref as exp_ref, ".$db->pdate("e.date_expedition")." as date_expedition,";
|
||||
if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_livraison")." as date_delivery, ld.qty as qty_received,";
|
||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$origin."det as obj,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."expedition as e)";
|
||||
if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
|
||||
$sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
|
||||
$sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
|
||||
if ($filter) $sql.=$filter;
|
||||
$sql.= " AND obj.rowid = ed.fk_origin_line";
|
||||
$sql.= " AND ed.fk_expedition = e.rowid";
|
||||
@ -60,8 +67,8 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
if ($somethingshown) print '<br>';
|
||||
|
||||
if ($filter) print_titre($langs->trans("OtherSendingsForSameOrder"));
|
||||
else print_titre($langs->trans("SendingsAndReceivingForSameOrder"));
|
||||
|
||||
else print_titre($langs->trans("SendingsAndReceivingForSameOrder"));
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Description").'</td>';
|
||||
@ -83,30 +90,51 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
$var=!$var;
|
||||
$objp = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Description
|
||||
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.dol_trunc($product->libelle,20);
|
||||
if ($objp->description) print '<br>'.dol_htmlentitiesbr(dol_trunc($objp->description,24));
|
||||
|
||||
// Show product and description
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".dol_htmlentitiesbr(dol_trunc($objp->description,24))."</td>\n";
|
||||
print "<td>";
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' '.nl2br($objp->description);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
//print '<td align="center">'.$objp->qty_asked.'</td>';
|
||||
|
||||
|
||||
// Sending id
|
||||
print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
|
||||
print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a></td>';
|
||||
|
||||
print '<td align="center">'.$objp->qty_shipped.'</td>';
|
||||
|
||||
|
||||
print '<td align="center" nowrap="nowrap">'.dol_print_date($objp->date_expedition,'dayhour').'</td>';
|
||||
if ($conf->livraison_bon->enabled)
|
||||
{
|
||||
|
||||
@ -1826,22 +1826,22 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits
|
||||
* \return void
|
||||
* \brief fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits
|
||||
* \remarks Define value of this->res
|
||||
* \param multiply Because each sublevel must be multiplicated by parent nb
|
||||
* \return void
|
||||
*/
|
||||
function fetch_prod_arbo($prod,$compl_path="",$multiply="")
|
||||
function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->res;
|
||||
$this->pere_encours;
|
||||
foreach($prod as $nom_pere => $desc_pere)
|
||||
{
|
||||
// on est dans une sous-categorie
|
||||
if(is_array($desc_pere))
|
||||
if (is_array($desc_pere)) // If this parent desc is an array, this is an array of childs
|
||||
{
|
||||
if($multiply)
|
||||
{
|
||||
//print "XXX ".$desc_pere[1]." multiply=".$multiply;
|
||||
$img="";
|
||||
$trueValue=$desc_pere[1]*$multiply;
|
||||
$product = new Product($this->db);
|
||||
@ -1851,24 +1851,34 @@ class Product extends CommonObject
|
||||
{
|
||||
$img=img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
$this->res[]= array("<tr><td>
|
||||
$this->res[]= array(
|
||||
"<tr><td> ->
|
||||
<a href=\"".DOL_URL_ROOT."/product/fiche.php?id=".$desc_pere[0]."\">".$compl_path.stripslashes($nom_pere)."
|
||||
</a></td><td align=\"center\"> ".$trueValue."</td><td> </td></td><td> </td>
|
||||
</td><td align=\"center\">".$this->stock_entrepot[1]." ".$img."</td></tr>",
|
||||
$desc_pere[0]);
|
||||
</a> (".$desc_pere[1].")</td><td align=\"center\"> ".$trueValue."</td><td> </td><td> </td>
|
||||
<td align=\"center\">".$this->stock_entrepot[1]." ".$img."</td></tr>",
|
||||
$desc_pere[0],
|
||||
'fullpath' => $compl_path.$nom_pere);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->res[]= array($compl_path.$nom_pere." (".$desc_pere[1].")",$desc_pere[0]);
|
||||
$this->res[]= array($compl_path.$nom_pere." (".$desc_pere[1].")",
|
||||
$desc_pere[0],
|
||||
'fullpath' => $compl_path.$nom_pere);
|
||||
}
|
||||
}
|
||||
else if($nom_pere != "0" && $nom_pere != "1")
|
||||
$this->res[]= array($compl_path.$nom_pere,$desc_pere);
|
||||
if(sizeof($desc_pere) >1)
|
||||
{
|
||||
$this ->fetch_prod_arbo($desc_pere,$nom_pere." -> ");
|
||||
$this->res[]= array($compl_path.$nom_pere,$desc_pere);
|
||||
}
|
||||
|
||||
// Recursive call
|
||||
if (is_array($desc_pere))
|
||||
{
|
||||
$this ->fetch_prod_arbo($desc_pere, $nom_pere." -> ", $desc_pere[1]*$multiply, $level+1);
|
||||
}
|
||||
}
|
||||
|
||||
//if ($level == 1) var_dump($this->res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1891,20 +1901,19 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief reconstruit l'arborescence des categorie sous la forme d'un tableau
|
||||
* \return array $this->res
|
||||
* \brief reconstruit l'arborescence des categorie sous la forme d'un tableau
|
||||
* \return array $this->res
|
||||
*/
|
||||
function get_arbo_each_prod($multiply="")
|
||||
function get_arbo_each_prod($multiply=1)
|
||||
{
|
||||
$this->res = array();
|
||||
if(is_array($this -> sousprods))
|
||||
if (is_array($this -> sousprods))
|
||||
{
|
||||
foreach($this -> sousprods as $nom_pere => $desc_pere)
|
||||
{
|
||||
if(sizeof($desc_pere) >1)
|
||||
$this ->fetch_prod_arbo($desc_pere,"",$multiply);
|
||||
if (is_array($desc_pere)) $this->fetch_prod_arbo($desc_pere,"",$multiply);
|
||||
}
|
||||
sort($this->res);
|
||||
// dol_sort($this->res,);
|
||||
}
|
||||
return $this->res;
|
||||
}
|
||||
@ -1930,8 +1939,8 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne les cat<EFBFBD>gories p<EFBFBD>res
|
||||
* \return array prod
|
||||
* \brief Return all parent products
|
||||
* \return array prod
|
||||
*/
|
||||
function get_pere()
|
||||
{
|
||||
@ -1940,15 +1949,16 @@ class Product extends CommonObject
|
||||
$sql .= MAIN_DB_PREFIX."product_association as pa,";
|
||||
$sql .= MAIN_DB_PREFIX."product as p";
|
||||
$sql .= " where p.rowid=pa.fk_product_pere and p.rowid = '".$this->id."'";
|
||||
|
||||
$res = $this->db->query ($sql);
|
||||
if ($res)
|
||||
{
|
||||
$prods = array ();
|
||||
while ($record = $this->db->fetch_array ($res))
|
||||
{
|
||||
$prods[addslashes($record['label'])] = array(0=>$record['id']);
|
||||
}
|
||||
return $prods;
|
||||
{
|
||||
$prods[addslashes($record['label'])] = array(0=>$record['id']);
|
||||
}
|
||||
return $prods;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1958,26 +1968,26 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne les fils de la cat<EFBFBD>gorie structur<EFBFBD>s pour l'arbo
|
||||
* \return array prod
|
||||
* \brief Return childs
|
||||
* \return array prod
|
||||
*/
|
||||
function get_fils_arbo ($id_pere)
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.label as label,pa.qty as qty,pa.fk_product_fils as id FROM ";
|
||||
$sql .= MAIN_DB_PREFIX."product as p,".MAIN_DB_PREFIX."product_association as pa";
|
||||
$sql .= " WHERE p.rowid = pa.fk_product_fils and pa.fk_product_pere = '".$id_pere."'";
|
||||
$res = $this->db->query ($sql);
|
||||
|
||||
$res = $this->db->query ($sql);
|
||||
if ($res)
|
||||
{
|
||||
$prods = array();
|
||||
while ($rec = $this->db->fetch_array ($res))
|
||||
{
|
||||
$prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
||||
foreach($this -> get_fils_arbo($rec['id']) as $kf=>$vf)
|
||||
$prods[addslashes($rec['label'])][$kf] = $vf;
|
||||
}
|
||||
return $prods;
|
||||
{
|
||||
$prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
||||
foreach($this -> get_fils_arbo($rec['id']) as $kf=>$vf)
|
||||
$prods[addslashes($rec['label'])][$kf] = $vf;
|
||||
}
|
||||
return $prods;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1985,21 +1995,23 @@ class Product extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief compose l'arborescence des sousproduits, id, nom et quantit<69> sous la forme d'un tableau associatif
|
||||
* \return void
|
||||
* \brief Return tree of all subproducts for product. Tree contains id, name and quantity.
|
||||
* \remarks Set this->sousprods
|
||||
* \return void
|
||||
*/
|
||||
function get_sousproduits_arbo ()
|
||||
function get_sousproduits_arbo()
|
||||
{
|
||||
$peres = $this -> get_pere();
|
||||
foreach($peres as $k=>$v)
|
||||
{
|
||||
foreach($this -> get_fils_arbo($v[0]) as $kf=>$vf)
|
||||
{
|
||||
$peres[$k][$kf] = $vf;
|
||||
$peres[$k][$kf] = $vf;
|
||||
}
|
||||
}
|
||||
// on concat<61>ne tout <20>a
|
||||
// concatenation
|
||||
foreach($peres as $k=>$v)
|
||||
{
|
||||
$this -> sousprods[$k]=$v;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user