Start to clean html.form class.
This commit is contained in:
parent
fad44a068d
commit
f42065146a
@ -353,7 +353,7 @@ if ($id && (empty($action) || $action == 'view'))
|
|||||||
|
|
||||||
// Example 2 : Adding links to objects
|
// Example 2 : Adding links to objects
|
||||||
// The class must extends CommonObject class to have this method available
|
// The class must extends CommonObject class to have this method available
|
||||||
//$somethingshown=$object->showLinkedObjectBlock();
|
//$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ print "</tr>\n";
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
|
print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print $form->select_thirdparty($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',0,array(),1);
|
print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',1,0,1,array(),0);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
if (! empty($conf->banque->enabled))
|
if (! empty($conf->banque->enabled))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1712,7 +1712,7 @@ if ($action == 'create')
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown = $object->showLinkedObjectBlock();
|
$somethingshown = $form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
|||||||
@ -2310,7 +2310,7 @@ if ($action == 'create')
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown = $object->showLinkedObjectBlock();
|
$somethingshown = $form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
// print '</td><td valign="top" width="50%">';
|
// print '</td><td valign="top" width="50%">';
|
||||||
|
|||||||
@ -2308,7 +2308,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown = $object->showLinkedObjectBlock();
|
$somethingshown = $form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
// print '</td><td valign="top" width="50%">';
|
// print '</td><td valign="top" width="50%">';
|
||||||
|
|||||||
@ -3776,7 +3776,7 @@ if ($action == 'create')
|
|||||||
$somethingshown = $formfile->numoffiles;
|
$somethingshown = $formfile->numoffiles;
|
||||||
|
|
||||||
// Linked object block
|
// Linked object block
|
||||||
$somethingshown = $object->showLinkedObjectBlock();
|
$somethingshown = $form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
$linktoelem='';
|
$linktoelem='';
|
||||||
|
|
||||||
|
|||||||
@ -1874,7 +1874,7 @@ else
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown=$object->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
|||||||
@ -2580,87 +2580,18 @@ abstract class CommonObject
|
|||||||
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
|
// TODO: All functions here must be redesigned and moved as they are not business functions but output functions
|
||||||
// --------------------
|
// --------------------
|
||||||
|
|
||||||
/* This is to show linked object block */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show linked object block
|
* Show linked object block.
|
||||||
* TODO Move this into html.class.php
|
|
||||||
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
|
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int <0 if KO, >0 if OK
|
||||||
|
* @deprecated Use instead $form->shoLinkedObjectBlock($object)
|
||||||
*/
|
*/
|
||||||
function showLinkedObjectBlock()
|
function showLinkedObjectBlock()
|
||||||
{
|
{
|
||||||
global $conf,$langs,$hookmanager;
|
global $form;
|
||||||
global $bc;
|
return $form->showLinkedObjectBlock($this);
|
||||||
|
|
||||||
$this->fetchObjectLinked();
|
|
||||||
|
|
||||||
// Bypass the default method
|
|
||||||
$hookmanager->initHooks(array('commonobject'));
|
|
||||||
$parameters=array();
|
|
||||||
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook
|
|
||||||
|
|
||||||
if (empty($reshook))
|
|
||||||
{
|
|
||||||
$num = count($this->linkedObjects);
|
|
||||||
|
|
||||||
foreach($this->linkedObjects as $objecttype => $objects)
|
|
||||||
{
|
|
||||||
$tplpath = $element = $subelement = $objecttype;
|
|
||||||
|
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
|
||||||
{
|
|
||||||
$element = $regs[1];
|
|
||||||
$subelement = $regs[2];
|
|
||||||
$tplpath = $element.'/'.$subelement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// To work with non standard path
|
|
||||||
if ($objecttype == 'facture') {
|
|
||||||
$tplpath = 'compta/'.$element;
|
|
||||||
if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'propal') {
|
|
||||||
$tplpath = 'comm/'.$element;
|
|
||||||
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'askpricesupplier') {
|
|
||||||
$tplpath = 'comm/'.$element;
|
|
||||||
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
|
|
||||||
$tplpath = 'expedition';
|
|
||||||
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'delivery') {
|
|
||||||
$tplpath = 'livraison';
|
|
||||||
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'invoice_supplier') {
|
|
||||||
$tplpath = 'fourn/facture';
|
|
||||||
}
|
|
||||||
else if ($objecttype == 'order_supplier') {
|
|
||||||
$tplpath = 'fourn/commande';
|
|
||||||
}
|
|
||||||
|
|
||||||
global $linkedObjectBlock;
|
|
||||||
$linkedObjectBlock = $objects;
|
|
||||||
|
|
||||||
// Output template part (modules that overwrite templates must declare this into descriptor)
|
|
||||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
|
|
||||||
foreach($dirtpls as $reldir)
|
|
||||||
{
|
|
||||||
$res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php');
|
|
||||||
if ($res) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This is to show add lines */
|
/* This is to show add lines */
|
||||||
|
|
||||||
|
|||||||
@ -803,11 +803,28 @@ class Form
|
|||||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||||
* @param int $forcecombo Force to use combo box
|
* @param int $forcecombo Force to use combo box
|
||||||
* @return string Return select box for thirdparty.
|
* @return string Return select box for thirdparty.
|
||||||
|
* @deprecated Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0)
|
||||||
*/
|
*/
|
||||||
function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
|
function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output html form to select a third party
|
||||||
|
*
|
||||||
|
* @param string $selected Preselected type
|
||||||
|
* @param string $htmlname Name of field in form
|
||||||
|
* @param string $filter optional filters criteras (example: 's.rowid <> x')
|
||||||
|
* @param int $showempty Add an empty field
|
||||||
|
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
|
||||||
|
* @param int $forcecombo Force to use combo box
|
||||||
|
* @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||||
|
* @param int $limit Maximum number of elements
|
||||||
|
* @return string HTML string with select box for thirdparty.
|
||||||
|
*/
|
||||||
|
function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0)
|
||||||
|
{
|
||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
/* TODO Use ajax_autocompleter like for products (not finished)
|
/* TODO Use ajax_autocompleter like for products (not finished)
|
||||||
@ -840,32 +857,12 @@ class Form
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{*/
|
{*/
|
||||||
$out.=$this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0,$limit);
|
$out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Output html form to select a third party
|
|
||||||
*
|
|
||||||
* @param string $selected Preselected type
|
|
||||||
* @param string $htmlname Name of field in form
|
|
||||||
* @param string $filter optional filters criteras (example: 's.rowid <> x')
|
|
||||||
* @param int $showempty Add an empty field
|
|
||||||
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
|
|
||||||
* @param int $forcecombo Force to use combo box
|
|
||||||
* @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
|
||||||
* @param int $limit Maximum number of elements
|
|
||||||
* @return string HTML string with
|
|
||||||
* @deprecated Use select_thirdparty instead
|
|
||||||
* @see select_thirdparty()
|
|
||||||
*/
|
|
||||||
function select_company($selected='', $htmlname='socid', $filter='', $showempty=0, $showtype=0, $forcecombo=0, $events=array(), $limit=0)
|
|
||||||
{
|
|
||||||
return $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output html form to select a third party
|
* Output html form to select a third party
|
||||||
*
|
*
|
||||||
@ -4620,6 +4617,84 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show linked object block.
|
||||||
|
*
|
||||||
|
* @param CommonObject $object Object we want to show links to
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function showLinkedObjectBlock($object)
|
||||||
|
{
|
||||||
|
global $conf,$langs,$hookmanager;
|
||||||
|
global $bc;
|
||||||
|
|
||||||
|
$object->fetchObjectLinked();
|
||||||
|
|
||||||
|
// Bypass the default method
|
||||||
|
$hookmanager->initHooks(array('commonobject'));
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
$num = count($object->linkedObjects);
|
||||||
|
|
||||||
|
foreach($object->linkedObjects as $objecttype => $objects)
|
||||||
|
{
|
||||||
|
$tplpath = $element = $subelement = $objecttype;
|
||||||
|
|
||||||
|
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||||
|
{
|
||||||
|
$element = $regs[1];
|
||||||
|
$subelement = $regs[2];
|
||||||
|
$tplpath = $element.'/'.$subelement;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To work with non standard path
|
||||||
|
if ($objecttype == 'facture') {
|
||||||
|
$tplpath = 'compta/'.$element;
|
||||||
|
if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'propal') {
|
||||||
|
$tplpath = 'comm/'.$element;
|
||||||
|
if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'askpricesupplier') {
|
||||||
|
$tplpath = 'comm/'.$element;
|
||||||
|
if (empty($conf->askpricesupplier->enabled)) continue; // Do not show if module disabled
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
|
||||||
|
$tplpath = 'expedition';
|
||||||
|
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'delivery') {
|
||||||
|
$tplpath = 'livraison';
|
||||||
|
if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'invoice_supplier') {
|
||||||
|
$tplpath = 'fourn/facture';
|
||||||
|
}
|
||||||
|
else if ($objecttype == 'order_supplier') {
|
||||||
|
$tplpath = 'fourn/commande';
|
||||||
|
}
|
||||||
|
|
||||||
|
global $linkedObjectBlock;
|
||||||
|
$linkedObjectBlock = $objects;
|
||||||
|
|
||||||
|
// Output template part (modules that overwrite templates must declare this into descriptor)
|
||||||
|
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/'.$tplpath.'/tpl'));
|
||||||
|
foreach($dirtpls as $reldir)
|
||||||
|
{
|
||||||
|
$res=@include dol_buildpath($reldir.'/linkedobjectblock.tpl.php');
|
||||||
|
if ($res) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an html string with a select combo box to choose yes or no
|
* Return an html string with a select combo box to choose yes or no
|
||||||
*
|
*
|
||||||
|
|||||||
@ -103,7 +103,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
|||||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||||
print $langs->trans("ThirdParty").' ';
|
print $langs->trans("ThirdParty").' ';
|
||||||
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
|
print '</td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px;">';
|
||||||
print $form->select_thirdparty($socid, 'socid');
|
print $form->select_company($socid, 'socid');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1505,7 +1505,7 @@ else if ($id || $ref)
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown=$object->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||||
|
|
||||||
|
|||||||
@ -1722,7 +1722,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown=$object->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
//print '</td><td valign="top" width="50%">';
|
//print '</td><td valign="top" width="50%">';
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|||||||
@ -2766,7 +2766,7 @@ elseif (! empty($object->id))
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown=$object->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|
||||||
|
|||||||
@ -2415,7 +2415,7 @@ else
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$somethingshown=$object->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($object);
|
||||||
|
|
||||||
$linktoelem='';
|
$linktoelem='';
|
||||||
|
|
||||||
|
|||||||
@ -788,7 +788,7 @@ else
|
|||||||
$shipment = new Expedition($db);
|
$shipment = new Expedition($db);
|
||||||
$shipment->fetch($object->origin_id);
|
$shipment->fetch($object->origin_id);
|
||||||
|
|
||||||
$somethingshown=$shipment->showLinkedObjectBlock();
|
$somethingshown=$form->showLinkedObjectBlock($shipment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||||
|
|||||||
@ -75,7 +75,7 @@ print '<br><br>'."\n";
|
|||||||
|
|
||||||
// Test4d: form->select_thirdparty
|
// Test4d: form->select_thirdparty
|
||||||
print "Test 4d: Select thirdparty<br>\n";
|
print "Test 4d: Select thirdparty<br>\n";
|
||||||
print $form->select_thirdparty(0,'thirdpartytest');
|
print $form->select_company(0,'thirdpartytest');
|
||||||
|
|
||||||
print '<br><br>'."\n";
|
print '<br><br>'."\n";
|
||||||
|
|
||||||
|
|||||||
@ -1849,7 +1849,7 @@ else
|
|||||||
'name' => 'soc_origin',
|
'name' => 'soc_origin',
|
||||||
'label' => $langs->trans('MergeOriginThirdparty'),
|
'label' => $langs->trans('MergeOriginThirdparty'),
|
||||||
'type' => 'other',
|
'type' => 'other',
|
||||||
'value' => $form->select_thirdparty('', 'soc_origin', 's.rowid != '.$object->id)
|
'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user