Fix: compatibility with element and subelement

This commit is contained in:
Regis Houssin 2011-02-22 16:01:17 +00:00
parent 41f73f57a3
commit 424eabd13c
4 changed files with 55 additions and 32 deletions

View File

@ -45,12 +45,11 @@ $langs->load('bills');
$langs->load('orders');
$langs->load('products');
$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"];
if (isset($_GET["msg"])) { $mesg=$_GET["mesg"]; }
$year=isset($_GET["year"])?$_GET["year"]:"";
$month=isset($_GET["month"])?$_GET["month"]:"";
$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid'];
$mesg=isset($_GET['mesg'])?$_GET['mesg']:'';
$sall=GETPOST("sall");
$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
$year=GETPOST("year");
$month=GETPOST("month");
$socid=GETPOST('socid');
// Security check
$module='propale';
@ -370,11 +369,11 @@ if ($_GET["action"] == 'classifybilled')
/*
* Cloture de la propale
*/
if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer)
if (GETPOST('action') == 'setstatut' && $user->rights->propale->cloturer)
{
if (! $_POST['cancel'])
{
if (empty($_REQUEST['statut']))
if (! GETPOST('statut'))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>';
$_REQUEST['action']='statut';
@ -964,8 +963,8 @@ $companystatic=new Societe($db);
$now=dol_now();
$id = $_REQUEST['id']?$_REQUEST['id']:$_REQUEST['id'];
$ref= $_REQUEST['ref'];
$id = GETPOST('id');
$ref= GETPOST('ref');
if ($id > 0 || ! empty($ref))
{
@ -973,7 +972,7 @@ if ($id > 0 || ! empty($ref))
* Show object in view mode
*/
if ($mesg)
if ($mesg)
{
if (! preg_match('/div class=/',$mesg)) print '<div class="ok">'.$mesg.'</div><br>';
else print $mesg."<br>";
@ -1559,7 +1558,13 @@ if ($id > 0 || ! empty($ref))
foreach($object->linked_object as $linked_object => $linked_objectid)
{
if($conf->$linked_object->enabled && $linked_object != $object->element)
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}

View File

@ -1860,7 +1860,13 @@ else
foreach($object->linked_object as $linked_object => $linked_objectid)
{
if($conf->$linked_object->enabled && $linked_object != $object->element)
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}

View File

@ -1314,20 +1314,20 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
/*
* Generate document
*/
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
if (GETPOST('action') == 'builddoc') // En get ou en post
{
$object->fetch($facid);
$object->fetch_thirdparty();
if ($_REQUEST['model'])
if (GETPOST('model'))
{
$object->setDocModel($user, $_REQUEST['model']);
$object->setDocModel($user, GETPOST('model'));
}
// Define output language
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{
@ -2780,7 +2780,13 @@ else
foreach($object->linked_object as $linked_object => $linked_objectid)
{
if($conf->$linked_object->enabled && $linked_object != $object->element)
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}

View File

@ -1358,22 +1358,28 @@ class CommonObject
global $langs,$bc;
//print 'objecttype='.$objecttype.'<br>';
$this->objectid = $objectid;
$num = sizeof($this->objectid);
if ($num)
{
$classpath = $objecttype.'/class';
$tplpath = $objecttype;
if ($objecttype == 'facture') { $tplpath = 'compta/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($objecttype == 'propal') { $tplpath = 'comm/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path
$element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
$classpath = $element.'/class';
$tplpath = $element;
if ($element == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($element == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($element == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path
if ($element == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path
$classfile = strtolower($objecttype); $classname = ucfirst($objecttype);
if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; }
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
if ($subelement == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
if ($subelement == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; }
//print $classfile." - ".$classpath." - ".$tplpath;
if(!class_exists($classname))
{
@ -1381,7 +1387,7 @@ class CommonObject
}
$this->linkedObjectBlock = new $classname($this->db);
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php');
return $num;
}
}
@ -1525,7 +1531,7 @@ class CommonObject
print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
}
/**
* Return HTML with list of origin lines
*/
@ -1560,7 +1566,7 @@ class CommonObject
function printOriginLine($line,$var)
{
global $langs,$bc;
//var_dump($line);
$date_start=$line->date_debut_prevue;
@ -1627,7 +1633,7 @@ class CommonObject
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;';
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? $line->remise_percent.'%' : '&nbsp;';
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
}
}