Fix: optimize code

Fix: better function name
This commit is contained in:
Regis Houssin 2011-04-11 07:11:10 +00:00
parent 8ec6346bf3
commit 64986dd12f
4 changed files with 28 additions and 55 deletions

View File

@ -1425,12 +1425,9 @@ if ($id > 0 || ! empty($ref))
} }
print '<table id="tablelines" class="noborder" width="100%">'; print '<table id="tablelines" class="noborder" width="100%">';
if (!empty($object->lines)) // Show object lines
{ if (! empty($object->lines)) $object->printObjectLines(0,$mysoc,$soc);
$object->print_title_list();
$object->printLinesList(0,$mysoc,$soc);
}
/* /*
* Form to add new line * Form to add new line
@ -1442,13 +1439,13 @@ if ($id > 0 || ! empty($ref))
$var=true; $var=true;
// Add free products/services // Add free products/services
$object->showAddFreeProductForm(0,$mysoc,$soc); $object->formAddFreeProduct(0,$mysoc,$soc);
// Add predefined products/services // Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$var=!$var; $var=!$var;
$object->showAddPredefinedProductForm(0,$mysoc,$soc); $object->formAddPredefinedProduct(0,$mysoc,$soc);
} }
// Hook of thirdparty module // Hook of thirdparty module

View File

@ -1377,8 +1377,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print_titre($title); print_titre($title);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$objectsrc->printOriginTitleList();
$objectsrc->printOriginLinesList($object); $objectsrc->printOriginLinesList($object);
print '</table>'; print '</table>';
@ -1783,13 +1782,8 @@ else
print '<table id="tablelines" class="noborder" width="100%">'; print '<table id="tablelines" class="noborder" width="100%">';
if (!empty($object->lines)) // Show object lines
{ if (! empty($object->lines)) $object->printObjectLines(0,$mysoc,$soc);
$object->print_title_list();
$object->printLinesList(1,$mysoc,$soc);
}
$numlines=sizeof($object->lines);
/* /*
* Form to add new line * Form to add new line
@ -1800,13 +1794,13 @@ else
{ {
$var=true; $var=true;
$object->showAddFreeProductForm(1,$mysoc,$soc); $object->formAddFreeProduct(1,$mysoc,$soc);
// Add predefined products/services // Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$var=!$var; $var=!$var;
$object->showAddPredefinedProductForm(1,$mysoc,$soc); $object->formAddPredefinedProduct(1,$mysoc,$soc);
} }
// Hook of thirdparty module // Hook of thirdparty module

View File

@ -1816,7 +1816,6 @@ if ($_GET['action'] == 'create')
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$objectsrc->printOriginTitleList();
$objectsrc->printOriginLinesList($object); $objectsrc->printOriginLinesList($object);
print '</table>'; print '</table>';
@ -2534,11 +2533,8 @@ else
print '<table id="tablelines" class="noborder" width="100%">'; print '<table id="tablelines" class="noborder" width="100%">';
if (!empty($object->lines)) // Show object lines
{ if (! empty($object->lines)) $object->printObjectLines(0,$mysoc,$soc);
$object->print_title_list();
$object->printLinesList(1,$mysoc,$soc);
}
/* /*
* Form to add new line * Form to add new line
@ -2547,13 +2543,13 @@ else
{ {
$var=true; $var=true;
$object->showAddFreeProductForm(1,$mysoc,$soc); $object->formAddFreeProduct(1,$mysoc,$soc);
// Add predefined products/services // Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled) if ($conf->product->enabled || $conf->service->enabled)
{ {
$var=!$var; $var=!$var;
$object->showAddPredefinedProductForm(1,$mysoc,$soc); $object->formAddPredefinedProduct(1,$mysoc,$soc);
} }
// Hook of thirdparty module // Hook of thirdparty module

View File

@ -1328,7 +1328,7 @@ class CommonObject
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* @param $dateSelector 1=Show also date range input fields * @param $dateSelector 1=Show also date range input fields
*/ */
function showAddPredefinedProductForm($dateSelector,$seller,$buyer) function formAddPredefinedProduct($dateSelector,$seller,$buyer)
{ {
global $conf,$langs,$object; global $conf,$langs,$object;
global $html,$bcnd,$var; global $html,$bcnd,$var;
@ -1343,7 +1343,7 @@ class CommonObject
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* @param $dateSelector 1=Show also date range input fields * @param $dateSelector 1=Show also date range input fields
*/ */
function showAddFreeProductForm($dateSelector,$seller,$buyer) function formAddFreeProduct($dateSelector,$seller,$buyer)
{ {
global $conf,$langs,$object; global $conf,$langs,$object;
global $html,$bcnd,$var; global $html,$bcnd,$var;
@ -1403,14 +1403,17 @@ class CommonObject
} }
/** /**
* Return HTML table with title list * Return HTML with object lines list.
* Array $this->lines must be defined.
* @param $dateSelector Show date input fields (if service)
* @param $seller Object of seller third party
* @param uyer Object of buyer third party
* TODO Move this into page (into a lib.php file if mutualized. No code for output must be present into a business class). * TODO Move this into page (into a lib.php file if mutualized. No code for output must be present into a business class).
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
*/ */
function print_title_list() function printObjectLines($dateSelector=0,$seller,$buyer)
{ {
global $conf,$langs; global $conf,$langs;
print '<tr class="liste_titre nodrag nodrop">'; print '<tr class="liste_titre nodrag nodrop">';
print '<td>'.$langs->trans('Description').'</td>'; print '<td>'.$langs->trans('Description').'</td>';
if ($conf->global->PRODUIT_USE_MARKUP) print '<td align="right" width="80">'.$langs->trans('Markup').'</td>'; if ($conf->global->PRODUIT_USE_MARKUP) print '<td align="right" width="80">'.$langs->trans('Markup').'</td>';
@ -1423,18 +1426,7 @@ class CommonObject
print '<td width="10">&nbsp;</td>'; print '<td width="10">&nbsp;</td>';
print '<td nowrap="nowrap">&nbsp;</td>'; // No width to allow autodim print '<td nowrap="nowrap">&nbsp;</td>'; // No width to allow autodim
print "</tr>\n"; print "</tr>\n";
}
/**
* Return HTML with object lines list.
* Array $this->lines must be defined.
* @param $dateSelector Show date input fields (if service)
* @param $seller Object of seller third party
* @param uyer Object of buyer third party
* TODO Move this into page (into a lib.php file if mutualized. No code for output must be present into a business class).
*/
function printLinesList($dateSelector=0,$seller,$buyer)
{
$num = count($this->lines); $num = count($this->lines);
$var = true; $var = true;
$i = 0; $i = 0;
@ -1527,12 +1519,12 @@ class CommonObject
} }
/** /**
* Return HTML table with origin title list * Return HTML with list of origin lines
*/ */
function printOriginTitleList() function printOriginLinesList($object)
{ {
global $langs; global $langs;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>'; print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('Description').'</td>'; print '<td>'.$langs->trans('Description').'</td>';
@ -1540,13 +1532,7 @@ class CommonObject
print '<td align="right">'.$langs->trans('PriceUHT').'</td>'; print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right">'.$langs->trans('Qty').'</td>'; print '<td align="right">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>'; print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
}
/**
* Return HTML with list of origin lines
*/
function printOriginLinesList($object)
{
$num = count($this->lines); $num = count($this->lines);
$var = true; $var = true;
$i = 0; $i = 0;