diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php
index 468c2181349..1b60e197126 100644
--- a/htdocs/comm/addpropal.php
+++ b/htdocs/comm/addpropal.php
@@ -201,19 +201,6 @@ if ($action == 'create')
}
print '';
- // Delivery address
- if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
- {
- print '
'.$langs->trans('DeliveryAddress').' ';
- print '';
- $numaddress = $form->select_address($soc->fk_delivery_address, $_GET['socid'],'fk_address',1);
- if ($numaddress==0)
- {
- print ' id.'&action=create>'.$langs->trans("AddAddress").' ';
- }
- print ' ';
- }
-
// Model
print '';
print ''.$langs->trans("DefaultModel").' ';
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 7ac7cec3de5..0a33c822392 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -246,13 +246,6 @@ else if ($action == 'setdate_livraison')
if ($result < 0) dol_print_error($db,$object->error);
}
-else if ($action == 'setaddress' && $user->rights->propale->creer)
-{
- $object->fetch($id);
- $result=$object->set_adresse_livraison($user,$_POST['fk_address']);
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
// Positionne ref client
else if ($action == 'set_ref_client' && $user->rights->propale->creer)
{
@@ -1340,29 +1333,6 @@ if ($id > 0 || ! empty($ref))
print '';
print ' ';
- // Delivery address (deprecated)
- if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
- {
- print '';
- print '';
- print ' ';
-
- if ($action == 'editdelivery_address')
- {
- $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','propal',$object->id);
- }
- else
- {
- $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','propal',$object->id);
- }
- print ' ';
- }
-
// Delivery delay
print '';
print '';
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 809a5e3a76a..57493f436a9 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -27,6 +27,7 @@ require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("facture");
@@ -43,6 +44,8 @@ $action=GETPOST('action', 'alpha');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal');
+$object = new Propal($db);
+
/*
* Ajout d'un nouveau contact
@@ -50,42 +53,38 @@ $result = restrictedArea($user, 'propale', $id, 'propal');
if ($action == 'addcontact' && $user->rights->propale->creer)
{
-
- $result = 0;
- $propal = new Propal($db);
- $result = $propal->fetch($id);
+ $result = $object->fetch($id);
if ($result > 0 && $id > 0)
{
- $result = $propal->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
+ $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
- if ($propal->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
}
else
{
- $mesg = ''.$propal->error.'
';
+ $mesg = ''.$object->error.'
';
}
}
}
// Bascule du statut d'un contact
-if ($action == 'swapstatut' && $user->rights->propale->creer)
+else if ($action == 'swapstatut' && $user->rights->propale->creer)
{
- $propal = new Propal($db);
- if ($propal->fetch($id) > 0)
+ if ($object->fetch($id) > 0)
{
- $result=$propal->swapContactStatus(GETPOST('ligne'));
+ $result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@@ -94,15 +93,14 @@ if ($action == 'swapstatut' && $user->rights->propale->creer)
}
// Efface un contact
-if ($action == 'deleteline' && $user->rights->propale->creer)
+else if ($action == 'deleteline' && $user->rights->propale->creer)
{
- $propal = new Propal($db);
- $propal->fetch($id);
- $result = $propal->delete_contact($lineid);
+ $object->fetch($id);
+ $result = $object->delete_contact($lineid);
if ($result >= 0)
{
- Header("Location: ".$_SERVER['PHP_SELF']."?id=".$propal->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
@@ -111,6 +109,13 @@ if ($action == 'deleteline' && $user->rights->propale->creer)
}
}
+else if ($action == 'setaddress' && $user->rights->propale->creer)
+{
+ $object->fetch($id);
+ $result=$object->set_adresse_livraison($user,$_POST['fk_address']);
+ if ($result < 0) dol_print_error($db,$object->error);
+}
+
/*
* View
@@ -120,6 +125,7 @@ llxHeader('', $langs->trans("Proposal"), "Propal");
$form = new Form($db);
$formcompany= new FormCompany($db);
+$formother = new FormOther($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
@@ -133,13 +139,12 @@ dol_htmloutput_mesg($mesg);
if ($id > 0 || ! empty($ref))
{
- $propal = New Propal($db);
- if ($propal->fetch($id,$ref) > 0)
+ if ($object->fetch($id,$ref) > 0)
{
$soc = new Societe($db);
- $soc->fetch($propal->socid);
+ $soc->fetch($object->socid);
- $head = propal_prepare_head($propal);
+ $head = propal_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
/*
@@ -151,7 +156,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print ' '.$langs->trans('Ref').' ';
- print $form->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
+ print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print ' ';
// Ref client
@@ -161,15 +166,37 @@ if ($id > 0 || ! empty($ref))
print '';
print '
';
print ' ';
- print $propal->ref_client;
+ print $object->ref_client;
print ' ';
print ' ';
// Customer
- if ( is_null($propal->client) )
- $propal->fetch_thirdparty();
+ if (is_null($object->client)) $object->fetch_thirdparty();
print "".$langs->trans("Company")." ";
- print ''.$propal->client->getNomUrl(1).' ';
+ print ''.$object->client->getNomUrl(1).' ';
+
+ // Delivery address
+ if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
+ {
+ print '';
+ print '';
+ print ' ';
+
+ if ($action == 'editdelivery_address')
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','propal',$object->id);
+ }
+ else
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','propal',$object->id);
+ }
+ print ' ';
+ }
print "";
@@ -215,11 +242,11 @@ if ($id > 0 || ! empty($ref))
print '';
// On recupere les id des users deja selectionnes
- //$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type
+ //$userAlreadySelected = $object->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type
$form->select_users($user->id,'contactid',0,$userAlreadySelected);
print ' ';
print '';
- $formcompany->selectTypeContact($propal, '', 'type','internal');
+ $formcompany->selectTypeContact($object, '', 'type','internal');
print ' ';
print ' ';
print '';
@@ -241,8 +268,8 @@ if ($id > 0 || ! empty($ref))
print '';
print '';
- $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id;
- $selectedCompany = $formcompany->selectCompaniesForNewContact($propal, 'id', $selectedCompany, 'newcompany');
+ $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->client->id;
+ $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany');
print ' ';
print '';
@@ -250,7 +277,7 @@ if ($id > 0 || ! empty($ref))
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print ' ';
print '';
- $formcompany->selectTypeContact($propal, '', 'type','external');
+ $formcompany->selectTypeContact($object, '', 'type','external');
print ' ';
print ' 0 || ! empty($ref))
foreach(array('internal','external') as $source)
{
- $tab = $propal->liste_contact(-1,$source);
+ $tab = $object->liste_contact(-1,$source);
$num=count($tab);
$i = 0;
@@ -335,9 +362,9 @@ if ($id > 0 || ! empty($ref))
// Statut
print '';
// Activation desativation du contact
- if ($propal->statut >= 0) print '';
+ if ($object->statut >= 0) print ' ';
print $contactstatic->LibStatut($tab[$i]['status'],3);
- if ($propal->statut >= 0) print ' ';
+ if ($object->statut >= 0) print '';
print ' ';
// Icon update et delete
@@ -345,7 +372,7 @@ if ($id > 0 || ! empty($ref))
if ($user->rights->propale->creer)
{
print ' ';
- print 'id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
+ print ' id.'&action=deleteline&lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print ' ';
}
@@ -364,8 +391,6 @@ if ($id > 0 || ! empty($ref))
}
}
-llxFooter();
-
$db->close();
-
+llxFooter();
?>
\ No newline at end of file
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 828dc7c0a26..fae3c3c1261 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -1,7 +1,7 @@
* Copyright (C) 2005-2011 Laurent Destailleur
- * Copyright (C) 2005-2011 Regis Houssin
+ * Copyright (C) 2005-2012 Regis Houssin
*
* 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
@@ -27,61 +27,61 @@ require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
$langs->load("orders");
$langs->load("sendings");
$langs->load("companies");
-$comid = isset($_GET["id"])?$_GET["id"]:'';
+$id=GETPOST('id','int');
+$ref=GETPOST('ref','alpha');
+$action=GETPOST('action','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'commande', $comid,'');
+$result = restrictedArea($user, 'commande', $id,'');
+$object = new Commande($db);
/*
* Ajout d'un nouveau contact
*/
-if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer)
+if ($action == 'addcontact' && $user->rights->commande->creer)
{
+ $result = $object->fetch($id);
- $result = 0;
- $commande = new Commande($db);
- $result = $commande->fetch($_GET["id"]);
-
- if ($result > 0 && $_GET["id"] > 0)
+ if ($result > 0 && $id > 0)
{
- $result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
+ $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
- Header("Location: contact.php?id=".$commande->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else
{
- if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
}
else
{
- $mesg = ''.$commande->error.'
';
+ $mesg = ''.$object->error.'
';
}
}
}
// bascule du statut d'un contact
-if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
+else if ($action == 'swapstatut' && $user->rights->commande->creer)
{
- $commande = new Commande($db);
- if ($commande->fetch(GETPOST('id','int')))
+ if ($object->fetch($id))
{
- $result=$commande->swapContactStatus(GETPOST('ligne'));
+ $result=$object->swapContactStatus(GETPOST('ligne'));
}
else
{
@@ -90,15 +90,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
}
// Efface un contact
-if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
+else if ($action == 'deleteline' && $user->rights->commande->creer)
{
- $commande = new Commande($db);
- $commande->fetch($_GET["id"]);
- $result = $commande->delete_contact($_GET["lineid"]);
+ $object->fetch($id);
+ $result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
- Header("Location: contact.php?id=".$commande->id);
+ Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
else {
@@ -106,6 +105,11 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
}
}
+else if ($action == 'setaddress' && $user->rights->commande->creer)
+{
+ $object->fetch($id);
+ $object->set_adresse_livraison($user,$_POST['fk_address']);
+}
/*
* View
@@ -115,6 +119,7 @@ llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES
$form = new Form($db);
$formcompany = new FormCompany($db);
+$formother = new FormOther($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
@@ -126,19 +131,17 @@ $userstatic=new User($db);
/* *************************************************************************** */
dol_htmloutput_mesg($mesg);
-$id = $_GET['id'];
-$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{
$langs->trans("OrderCard");
- $commande = new Commande($db);
- if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
+
+ if ($object->fetch($id, $ref) > 0)
{
$soc = new Societe($db);
- $soc->fetch($commande->socid);
+ $soc->fetch($object->socid);
- $head = commande_prepare_head($commande);
+ $head = commande_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), 0, 'order');
@@ -149,7 +152,7 @@ if ($id > 0 || ! empty($ref))
// Ref
print ''.$langs->trans("Ref").' ';
- print $form->showrefnav($commande,'ref','',1,'ref','ref');
+ print $form->showrefnav($object,'ref','',1,'ref','ref');
print " ";
// Ref commande client
@@ -159,16 +162,39 @@ if ($id > 0 || ! empty($ref))
print '';
print '';
print '';
- print $commande->ref_client;
+ print $object->ref_client;
print ' ';
print '';
// Customer
- if ( is_null($commande->client) )
- $commande->fetch_thirdparty();
+ if (is_null($object->client)) $object->fetch_thirdparty();
print "".$langs->trans("Company")." ";
- print ''.$commande->client->getNomUrl(1).' ';
+ print ''.$object->client->getNomUrl(1).' ';
+
+ // Delivery address
+ if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
+ {
+ print '';
+ print '';
+ print ' ';
+
+ if ($action == 'editdelivery_address')
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'fk_address','commande',$object->id);
+ }
+ else
+ {
+ $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,GETPOST('socid','int'),'none','commande',$object->id);
+ }
+ print ' ';
+ }
+
print "";
print '';
@@ -182,7 +208,7 @@ if ($id > 0 || ! empty($ref))
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
- if ($_GET["action"] != 'editline' && $user->rights->commande->creer)
+ if ($action != 'editline' && $user->rights->commande->creer)
{
print '';
print ''.$langs->trans("Source").' ';
@@ -195,7 +221,7 @@ if ($id > 0 || ! empty($ref))
$var = false;
- print ' ';
print '';
- print '