Qual: Reduce size of form.class

This commit is contained in:
Laurent Destailleur
2012-02-20 12:20:56 +01:00
parent db7ac346e8
commit 475bba2ea7
7 changed files with 75 additions and 1868 deletions

View File

@@ -92,9 +92,9 @@ $hookmanager->callHooks(array('propalcard'));
/******************************************************************************/
/* Actions */
/******************************************************************************/
/*
* Actions
*/
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@@ -1358,11 +1358,11 @@ if ($id > 0 || ! empty($ref))
if ($action == 'editdelivery_address')
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid'),'fk_address','propal',$object->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid'),'fk_address','propal',$object->id);
}
else
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid'),'none','propal',$object->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid'),'none','propal',$object->id);
}
print '</td></tr>';
}

View File

@@ -29,6 +29,7 @@
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formorder.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/modules/commande/modules_commande.php");
@@ -1185,6 +1186,7 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES
$form = new Form($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$formorder = new FormOrder($db);
@@ -1324,9 +1326,8 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery address
if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
{
// Link to edit: $form->form_address($_SERVER['PHP_SELF'].'?action=create','',$soc->id,'adresse_livraison_id','commande','');
print '<tr><td nowrap="nowrap">'.$langs->trans('DeliveryAddress').'</td><td colspan="2">';
$numaddress = $form->select_address($soc->fk_delivery_address, $socid,'fk_address',1);
$numaddress = $formother->select_address($soc->fk_delivery_address, $socid,'fk_address',1);
print ' &nbsp; <a href="../comm/address.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddAddress").'</a>';
print '</td></tr>';
}

View File

@@ -2721,50 +2721,6 @@ class Form
}
}
/**
* Show form to select addresse
*
* @param page Page
* @param selected Id condition pre-selectionne
* @param htmlname Nom du formulaire select
* @param origin Origine de l'appel pour pouvoir creer un retour
* @param originid Id de l'origine
* @return void
* @deprecated
*/
function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='')
{
global $langs,$conf;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setaddress">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_address($selected, $socid, $htmlname, 1);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
$langs->load("companies");
print ' &nbsp; <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
print '</td></tr></table></form>';
}
else
{
if ($selected)
{
require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php");
$address=new Address($this->db);
$result=$address->fetch_address($selected);
print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
}
else
{
print "&nbsp;";
}
}
}
/**
* Retourne la liste des devises, dans la langue de l'utilisateur
*

View File

@@ -542,7 +542,7 @@ class FormOther
function select_month($selected='',$htmlname='monthid',$useempty=0)
{
global $langs;
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
$montharray = monthArray($langs); // Get array
@@ -713,6 +713,52 @@ function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selecte
$level--;
}
}
/**
* Show form to select addresse
*
* @param int $page Page
* @param string $selected Id condition pre-selectionne
* @param string $htmlname Nom du formulaire select
* @param string $origin Origine de l'appel pour pouvoir creer un retour
* @param int $originid Id de l'origine
* @return void
* @deprecated
*/
function form_address($page, $selected='', $socid, $htmlname='address_id', $origin='', $originid='')
{
global $langs,$conf;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setaddress">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_address($selected, $socid, $htmlname, 1);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
$langs->load("companies");
print ' &nbsp; <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
print '</td></tr></table></form>';
}
else
{
if ($selected)
{
require_once(DOL_DOCUMENT_ROOT ."/societe/class/address.class.php");
$address=new Address($this->db);
$result=$address->fetch_address($selected);
print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
}
else
{
print "&nbsp;";
}
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -28,8 +28,9 @@
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/sendings.lib.php");
@@ -482,6 +483,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
llxHeader('',$langs->trans('Sending'),'Expedition');
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
$formproduct = new FormProduct($db);
@@ -580,7 +582,7 @@ if ($action == 'create')
print '<td colspan="3">';
if (!empty($object->fk_delivery_address))
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$_GET['socid'],'none','commande',$object->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$_GET['socid'],'none','commande',$object->id);
}
print '</td></tr>'."\n";
}
@@ -1006,7 +1008,7 @@ else
print '<td colspan="3">';
if (!empty($object->fk_delivery_address))
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->deliveryaddress->socid,'none','shipment',$object->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->deliveryaddress->socid,'none','shipment',$object->id);
}
print '</td></tr>'."\n";
}

View File

@@ -25,8 +25,9 @@
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/class/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/sendings.lib.php");
@@ -117,21 +118,20 @@ if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
}
/*
* View
*/
$form = new Form($db);
$formproduct = new FormProduct($db);
$formfile = new FormFile($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
$formother = new FormOther($db);
$formproduct = new FormProduct($db);
llxHeader('',$langs->trans('OrderCard'),'');
$id = $_GET['id'];
$ref= $_GET['ref'];
$id = GETPSOT('id');
$ref= GETPOST('ref');
if ($id > 0 || ! empty($ref))
{
$commande = new Commande($db);
@@ -287,11 +287,11 @@ if ($id > 0 || ! empty($ref))
if ($_GET['action'] == 'editdelivery_adress')
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'delivery_address_id','commande',$commande->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'delivery_address_id','commande',$commande->id);
}
else
{
$form->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'none','commande',$commande->id);
$formother->form_address($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'none','commande',$commande->id);
}
print '</td></tr>';
}
@@ -440,7 +440,7 @@ if ($id > 0 || ! empty($ref))
{
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
{
$commande->fetch_thirdparty();
$prod = new Product($db, $objp->fk_product);
$outputlangs = $langs;
@@ -452,7 +452,7 @@ if ($id > 0 || ! empty($ref))
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $objp->product_label;
}
else