Works on contact canvas in relation to the thirdparty canvas module

This commit is contained in:
Regis Houssin 2010-11-03 11:39:40 +00:00
parent 23fed3b53f
commit ab53d438ce
12 changed files with 1438 additions and 905 deletions

View File

@ -55,8 +55,8 @@ class ActionsContactCardCommon
*/ */
function assign_values($action='') function assign_values($action='')
{ {
global $conf, $langs, $user, $mysoc, $canvas; global $conf, $langs, $user, $canvas;
global $form, $formadmin, $formcompany; global $form, $formcompany, $objsoc;
foreach($this->object as $key => $value) foreach($this->object as $key => $value)
{ {
@ -65,58 +65,41 @@ class ActionsContactCardCommon
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit')
{ {
// Load object modCodeClient if ($conf->use_javascript_ajax)
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined"));
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
{ {
$module = substr($module, 0, dol_strlen($module)-4); $this->tpl['ajax_selectpays'] = "\n".'<script type="text/javascript" language="javascript">
jQuery(document).ready(function () {
jQuery("#selectpays_id").change(function() {
document.formsoc.action.value="'.$action.'";
document.formsoc.submit();
});
})
</script>'."\n";
} }
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
$modCodeClient = new $module;
$this->tpl['auto_customercode'] = $modCodeClient->code_auto;
// We verified if the tag prefix is used
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
// Load object modCodeFournisseur if (is_object($objsoc) && $objsoc->id > 0)
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
{ {
$module = substr($module, 0, dol_strlen($module)-4); $this->tpl['company'] = $objsoc->getNomUrl(1);
$this->tpl['company_id'] = $objsoc->id;
}
else
{
$this->tpl['company'] = $form->select_company($this->object->socid,'socid','',1);
} }
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
$modCodeFournisseur = new $module;
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
// We verified if the tag prefix is used
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
// TODO create a function // Civility
$this->tpl['select_customertype'] = '<select class="flat" name="client">'; $this->tpl[select_civility] = $formcompany->select_civility($this->object->civilite_id);
$this->tpl['select_customertype'].= '<option value="2"'.($this->object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
$this->tpl['select_customertype'].= '<option value="3"'.($this->object->client==3?' selected="selected"':'').'>'.$langs->trans('ProspectCustomer').'</option>';
$this->tpl['select_customertype'].= '<option value="1"'.($this->object->client==1?' selected="selected"':'').'>'.$langs->trans('Customer').'</option>';
$this->tpl['select_customertype'].= '<option value="0"'.($this->object->client==0?' selected="selected"':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
$this->tpl['select_customertype'].= '</select>';
// Customer // Predefined with third party
$this->tpl['customercode'] = $this->object->code_client; if ($objsoc->typent_code == 'TE_PRIVATE')
if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0); {
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable(); if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address;
$s=$modCodeClient->getToolTip($langs,$this->object,0); if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->cp;
$this->tpl['help_customercode'] = $form->textwithpicto('',$s,1); if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->ville;
if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->tel;
// Supplier if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax;
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1); if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
$this->tpl['suppliercode'] = $this->object->code_fournisseur; }
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
$this->object->LoadSupplierCateg();
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
// Zip // Zip
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->cp,'zipcode',array('town','selectpays_id','departement_id'),6); $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->cp,'zipcode',array('town','selectpays_id','departement_id'),6);
@ -124,124 +107,105 @@ class ActionsContactCardCommon
// Town // Town
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->ville,'town',array('zipcode','selectpays_id','departement_id')); $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->ville,'town',array('zipcode','selectpays_id','departement_id'));
if (dol_strlen(trim($this->object->fk_pays)) == 0) $this->object->fk_pays = $objsoc->pays_id;
// Country // Country
$this->tpl['select_country'] = $form->select_country($this->object->pays_id,'pays_id'); $this->tpl['select_country'] = $form->select_country($this->object->fk_pays,'pays_id');
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
// State // State
if ($this->object->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code); if ($this->object->fk_pays) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code);
else $this->tpl['select_state'] = $countrynotdefined; else $this->tpl['select_state'] = $countrynotdefined;
// Language // Public or private
if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
$this->tpl['select_visibility'] = $form->selectarray('priv',$selectarray,$this->object->priv,0);
// VAT
$this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation
// Select users
$this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id,'commercial_id',1);
// Local Tax
// TODO mettre dans une classe propre au pays
if($mysoc->pays_code=='ES')
{
$this->tpl['localtax'] = '';
if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1")
{
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td>';
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
$this->tpl['localtax'].= '</td><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td>';
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
$this->tpl['localtax'].= '</td></tr>';
}
elseif($mysoc->localtax1_assuj=="1")
{
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax1IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1);
$this->tpl['localtax'].= '</td><tr>';
}
elseif($mysoc->localtax2_assuj=="1")
{
$this->tpl['localtax'].= '<tr><td>'.$langs->trans("LocalTax2IsUsedES").'</td><td colspan="3">';
$this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1);
$this->tpl['localtax'].= '</td><tr>';
}
} }
if ($action == 'view' || $action == 'edit')
{
// Emailing
if ($conf->mailing->enabled)
{
$langs->load("mails");
$this->tpl['nb_emailing'] = $object->getNbOfEMailings();
}
// Linked element
$this->tpl['contact_element'] = array();
$i=0;
$this->object->load_ref_elements();
if ($conf->commande->enabled)
{
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande?$this->object->ref_commande:$langs->trans("NoContactForAnyOrder");
$i++;
}
if ($conf->propal->enabled)
{
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal?$this->object->ref_propal:$langs->trans("NoContactForAnyProposal");
$i++;
}
if ($conf->contrat->enabled)
{
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat?$this->object->ref_contrat:$langs->trans("NoContactForAnyContract");
$i++;
}
if ($conf->facture->enabled)
{
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation?$this->object->ref_facturation:$langs->trans("NoContactForAnyInvoice");
$i++;
}
// Dolibarr user
if ($this->object->user_id)
{
$dolibarr_user=new User($this->db);
$result=$dolibarr_user->fetch($this->object->user_id);
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
}
else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
} }
if ($action == 'view') if ($action == 'view')
{ {
$this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom'); $this->tpl['showrefnav'] = $form->showrefnav($this->object,'id');
if (is_object($objsoc) && $this->object->socid > 0)
{
$objsoc->fetch($this->object->socid);
$this->tpl['company'] = $objsoc->getNomUrl(1);
}
else
{
$this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany");
}
$this->tpl['civility'] = $this->object->getCivilityLabel();
$this->tpl['checkcustomercode'] = $this->object->check_codeclient();
$this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
$this->tpl['address'] = dol_nl2br($this->object->address); $this->tpl['address'] = dol_nl2br($this->object->address);
$this->tpl['zip'] = ($this->object->cp?$this->object->cp.'&nbsp;':'');
$img=picto_from_langcode($this->pays_code); $img=picto_from_langcode($this->pays_code);
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->pays,$langs->trans("CountryIsInEEC"),1,0);
$this->tpl['country'] = ($img?$img.' ':'').$this->pays; $this->tpl['country'] = ($img?$img.' ':'').$this->pays;
$this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL'); $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro,$this->object->pays_code,0,$this->object->id,'AC_TEL');
$this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso,$this->object->pays_code,0,$this->object->id,'AC_TEL');
$this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile,$this->object->pays_code,0,$this->object->id,'AC_TEL');
$this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX'); $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');
$this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL'); $this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL');
$this->tpl['url'] = dol_print_url($this->object->url);
$this->tpl['tva_assuj'] = yn($this->object->tva_assuj); $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv);
// Third party type $this->tpl['note'] = nl2br($this->object->note);
$arr = $formcompany->typent_array(1);
$this->tpl['typent'] = $arr[$this->object->typent_code];
if ($conf->global->MAIN_MULTILANGS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
//$s=picto_from_langcode($this->default_lang);
//print ($s?$s.' ':'');
$langs->load("languages");
$this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):'');
}
$this->tpl['image_edit'] = img_edit();
$this->tpl['display_rib'] = $this->object->display_rib();
// Sales representatives
// TODO move in business class
$sql = "SELECT count(sc.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE sc.fk_soc =".$this->object->id;
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$obj = $this->db->fetch_object($resql);
$this->tpl['sales_representatives'] = $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected");
}
else
{
dol_print_error($this->db);
}
// Linked member
if ($conf->adherent->enabled)
{
$langs->load("members");
$adh=new Adherent($this->db);
$result=$adh->fetch('','',$this->object->id);
if ($result > 0)
{
$adh->ref=$adh->getFullName($langs);
$this->tpl['linked_member'] = $adh->getNomUrl(1);
}
else
{
$this->tpl['linked_member'] = $langs->trans("UserNotLinkedToMember");
}
}
} }
} }
@ -252,47 +216,34 @@ class ActionsContactCardCommon
{ {
global $langs, $mysoc; global $langs, $mysoc;
$this->object->id = $_POST["socid"]; $this->object->old_name = $_POST["old_name"];
$this->object->nom = $_POST["nom"]; $this->object->old_firstname = $_POST["old_firstname"];
$this->object->prefix_comm = $_POST["prefix_comm"];
$this->object->client = $_POST["client"]; $this->object->socid = $_POST["socid"];
$this->object->code_client = $_POST["code_client"]; $this->object->name = $_POST["name"];
$this->object->fournisseur = $_POST["fournisseur"]; $this->object->firstname = $_POST["firstname"];
$this->object->code_fournisseur = $_POST["code_fournisseur"]; $this->object->civilite_id = $_POST["civilite_id"];
$this->object->adresse = $_POST["adresse"]; // TODO obsolete $this->object->poste = $_POST["poste"];
$this->object->address = $_POST["adresse"]; $this->object->address = $_POST["address"];
$this->object->cp = $_POST["cp"]; $this->object->cp = $_POST["cp"];
$this->object->ville = $_POST["ville"]; $this->object->ville = $_POST["ville"];
$this->object->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $this->object->fk_pays = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
$this->object->departement_id = $_POST["departement_id"]; $this->object->fk_departement = $_POST["departement_id"];
$this->object->tel = $_POST["tel"]; $this->object->phone_pro = $_POST["phone_pro"];
$this->object->phone_perso = $_POST["phone_perso"];
$this->object->phone_mobile = $_POST["phone_mobile"];
$this->object->fax = $_POST["fax"]; $this->object->fax = $_POST["fax"];
$this->object->email = $_POST["email"]; $this->object->email = $_POST["email"];
$this->object->url = $_POST["url"]; $this->object->jabberid = $_POST["jabberid"];
$this->object->capital = $_POST["capital"]; $this->object->priv = $_POST["priv"];
$this->object->siren = $_POST["idprof1"]; $this->object->note = $_POST["note"];
$this->object->siret = $_POST["idprof2"];
$this->object->ape = $_POST["idprof3"];
$this->object->idprof4 = $_POST["idprof4"];
$this->object->typent_id = $_POST["typent_id"];
$this->object->effectif_id = $_POST["effectif_id"];
$this->object->gencod = $_POST["gencod"];
$this->object->forme_juridique_code = $_POST["forme_juridique_code"];
$this->object->default_lang = $_POST["default_lang"];
$this->object->commercial_id = $_POST["commercial_id"];
$this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1;
$this->object->tva_intra = $_POST["tva_intra"];
//Local Taxes
$this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
$this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
// We set pays_id, and pays_code label of the chosen country // We set pays_id, and pays_code label of the chosen country
// TODO move in business class // TODO move in business class
if ($this->object->pays_id) if ($this->object->fk_pays)
{ {
$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->pays_id; $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->fk_pays;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -310,11 +261,109 @@ class ActionsContactCardCommon
/** /**
* Load data control * Load data control
*/ */
function doActions($socid) function doActions($id)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
// Creation utilisateur depuis contact
if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes' && $user->rights->user->user->creer)
{
// Recuperation contact actuel
$result = $this->object->fetch($id);
if ($result > 0)
{
// Creation user
$nuser = new User($this->db);
$result=$nuser->create_from_contact($this->object,$_POST["login"]);
if ($result < 0)
{
$msg=$nuser->error;
}
}
else
{
$msg=$object->error;
}
}
// Creation contact
if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
{
$this->assign_post();
if (! $_POST["name"])
{
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
$_GET["action"] = $_POST["action"] = 'create';
}
if ($_POST["name"])
{
$id = $this->object->create($user);
if ($id > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$errors=array($this->object->error);
$_GET["action"] = $_POST["action"] = 'create';
}
}
}
if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
{
$result=$this->object->fetch($id);
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$result = $this->object->delete();
if ($result > 0)
{
Header("Location: index.php");
exit;
}
else
{
$mesg=$this->object->error;
}
}
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
{
if (empty($_POST["name"]))
{
$errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
$error++;
$_GET["action"] = $_POST["action"] = 'edit';
}
if (! sizeof($errors))
{
$this->object->fetch($_POST["contactid"]);
$this->object->oldcopy=dol_clone($this->object);
$this->assign_post();
$result = $this->object->update($_POST["contactid"], $user);
if ($result > 0)
{
$this->object->old_name='';
$this->object->old_firstname='';
}
else
{
$mesg=$this->object->error;
}
}
}
} }
} }

View File

@ -53,9 +53,8 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$out=''; $out='';
if ($action == 'view') $out.= $langs->trans("ThirdParty"); if ($action == 'view' || $action == 'edit') $out.= $langs->trans("Contact");
if ($action == 'edit') $out.= $langs->trans("EditCompany"); if ($action == 'create') $out.= $langs->trans("AddContact");
if ($action == 'create') $out.= $langs->trans("NewCompany");
return $out; return $out;
} }
@ -72,9 +71,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
* Execute actions * Execute actions
* @param Id of object (may be empty for creation) * @param Id of object (may be empty for creation)
*/ */
function doActions($socid) function doActions($id)
{ {
$return = parent::doActions($socid); $return = parent::doActions($id);
return $return; return $return;
} }

View File

@ -21,6 +21,101 @@
<!-- BEGIN PHP TEMPLATE --> <!-- BEGIN PHP TEMPLATE -->
<?php echo $this->tpl['ajax_selectpays']; ?>
<br>
<form method="post" name="formsoc" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="add">
<?php if ($this->control->tpl['company_id']) { ?>
<input type="hidden" name="socid" value="<?php echo $this->control->tpl['company_id']; ?>">
<?php } ?>
<table class="border" width="100%">
<tr>
<td width="15%" class="fieldrequired"><?php echo $langs->trans("Lastname").' / '.$langs->trans("Label"); ?></td>
<td><input name="name" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td width="20%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['firstname']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Company"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['company']; ?></td>
</tr>
<tr>
<td width="15%"><?php echo $langs->trans("UserTitle"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_civility']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PostOrFunction"); ?></td>
<td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['poste']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Address"); ?></td>
<td colspan="3"><textarea class="flat" name="address" cols="70"><?php echo $this->control->tpl['address']; ?></textarea></td>
</tr>
<tr>
<td><?php echo $langs->trans("Zip").' / '.$langs->trans("Town"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_zip'].'&nbsp;'.$this->control->tpl['select_town']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Country"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_country'].$this->control->tpl['info_admin']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_state']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhonePro"); ?></td>
<td><input name="phone_pro" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_pro']; ?>"></td>
<td><?php echo $langs->trans("PhonePerso"); ?></td>
<td><input name="phone_perso" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_perso']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhoneMobile"); ?></td>
<td><input name="phone_mobile" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_mobile']; ?>"></td>
<td><?php echo $langs->trans("Fax"); ?></td>
<td><input name="fax" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['fax']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Email"); ?></td>
<td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['email']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Jabberid"); ?></td>
<td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['jabberid']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("ContactVisibility"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_civility']; ?></td>
</tr>
<tr>
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
<td colspan="3" valign="top"><textarea name="note" cols="70" rows="<?php echo ROWS_3; ?>"><?php echo $this->control->tpl['note']; ?></textarea></td>
</tr>
<tr>
<td align="center" colspan="4"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></td>
</tr>
</table><br>
</form>
<!-- END PHP TEMPLATE --> <!-- END PHP TEMPLATE -->

View File

@ -21,6 +21,131 @@
<!-- BEGIN PHP TEMPLATE --> <!-- BEGIN PHP TEMPLATE -->
<?php echo $this->tpl['ajax_selectpays']; ?>
<br>
<form method="post" name="formsoc" action="<?php echo $_SERVER["PHP_SELF"].'?id='.GETPOST("id"); ?>">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="id" value="<?php echo GETPOST("id"); ?>">
<input type="hidden" name="action" value="update">
<input type="hidden" name="contactid" value="<?php echo $object->id; ?>">
<input type="hidden" name="old_name" value="<?php echo $object->name; ?>">
<input type="hidden" name="old_firstname" value="<?php echo $object->firstname; ?>">
<?php if ($this->control->tpl['company_id']) { ?>
<input type="hidden" name="socid" value="<?php echo $this->control->tpl['company_id']; ?>">
<?php } ?>
<table class="border" width="100%">
<tr>
<td><?php echo $langs->trans("Ref"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['ref']; ?></td>
</tr>
<tr>
<td width="15%" class="fieldrequired"><?php echo $langs->trans("Lastname").' / '.$langs->trans("Label"); ?></td>
<td><input name="name" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['name']; ?>"></td>
<td width="20%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="<?php echo $this->control->tpl['firstname']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Company"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['company']; ?></td>
</tr>
<tr>
<td width="15%"><?php echo $langs->trans("UserTitle"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_civility']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PostOrFunction"); ?></td>
<td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['poste']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Address"); ?></td>
<td colspan="3"><textarea class="flat" name="address" cols="70"><?php echo $this->control->tpl['address']; ?></textarea></td>
</tr>
<tr>
<td><?php echo $langs->trans("Zip").' / '.$langs->trans("Town"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_zip'].'&nbsp;'.$this->control->tpl['select_town']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Country"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_country'].$this->control->tpl['info_admin']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_state']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhonePro"); ?></td>
<td><input name="phone_pro" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_pro']; ?>"></td>
<td><?php echo $langs->trans("PhonePerso"); ?></td>
<td><input name="phone_perso" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_perso']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhoneMobile"); ?></td>
<td><input name="phone_mobile" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['phone_mobile']; ?>"></td>
<td><?php echo $langs->trans("Fax"); ?></td>
<td><input name="fax" type="text" size="18" maxlength="80" value="<?php echo $this->control->tpl['fax']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("Email"); ?></td>
<td><input name="email" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['email']; ?>"></td>
<?php if ($this->control->tpl['nb_emailing']) { ?>
<td nowrap><?php echo $langs->trans("NbOfEMailingsReceived"); ?></td>
<td><?php echo $this->control->tpl['nb_emailing']; ?></td>
<?php } else { ?>
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
<tr>
<td><?php echo $langs->trans("Jabberid"); ?></td>
<td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="<?php echo $this->control->tpl['jabberid']; ?>"></td>
</tr>
<tr>
<td><?php echo $langs->trans("ContactVisibility"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['select_visibility']; ?></td>
</tr>
<tr>
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
<td colspan="3" valign="top"><textarea name="note" cols="70" rows="<?php echo ROWS_3; ?>"><?php echo $this->control->tpl['note']; ?></textarea></td>
</tr>
<?php foreach ($this->control->tpl['contact_element'] as $element) { ?>
<tr>
<td><?php echo $element['linked_element_label']; ?></td>
<td colspan="3"><?php echo $element['linked_element_value']; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo $langs->trans("DolibarrLogin"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['dolibarr_user']; ?></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" class="button" name="save" value="<?php echo $langs->trans("Save"); ?>">&nbsp;
<input type="submit" class="button" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
</td>
</tr>
</table><br>
</form>
<!-- END PHP TEMPLATE --> <!-- END PHP TEMPLATE -->

View File

@ -21,6 +21,109 @@
<!-- BEGIN PHP TEMPLATE --> <!-- BEGIN PHP TEMPLATE -->
<table class="border" width="100%">
<tr>
<td width="20%"><?php echo $langs->trans("Ref"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['showrefnav']; ?></td>
</tr>
<tr>
<td width="20%"><?php echo $langs->trans("Lastname"); ?></td>
<td width="30%"><?php echo $this->control->tpl['name']; ?></td>
<td width="25%"><?php echo $langs->trans("Firstname"); ?></td>
<td width="25%"><?php echo $this->control->tpl['firstname']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Company"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['company']; ?></td>
</tr>
<tr>
<td width="15%"><?php echo $langs->trans("UserTitle"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['civility']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PostOrFunction" ); ?></td>
<td colspan="3"><?php echo $this->control->tpl['poste']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Address"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['address']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Zip").' / '.$langs->trans("Town"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['zip'].$this->control->tpl['ville']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("Country"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['country']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans('State'); ?></td>
<td colspan="3"><?php echo $this->control->tpl['departement']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhonePro"); ?></td>
<td><?php echo $this->control->tpl['phone_pro']; ?></td>
<td><?php echo $langs->trans("PhonePerso"); ?></td>
<td><?php echo $this->control->tpl['phone_perso']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("PhoneMobile"); ?></td>
<td><?php echo $this->control->tpl['phone_mobile']; ?></td>
<td><?php echo $langs->trans("Fax"); ?></td>
<td><?php echo $this->control->tpl['fax']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("EMail"); ?></td>
<td><?php echo $this->control->tpl['email']; ?></td>
<?php if ($this->control->tpl['nb_emailing']) { ?>
<td nowrap><?php echo $langs->trans("NbOfEMailingsReceived"); ?></td>
<td><a href="<?php echo DOL_URL_ROOT.'/comm/mailing/liste.php?filteremail='.urlencode($this->control->tpl['email']); ?>"><?php echo $this->control->tpl['nb_emailing']; ?></a></td>
<?php } else { ?>
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
<tr>
<td><?php echo $langs->trans("Jabberid"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['jabberid']; ?></td>
</tr>
<tr>
<td><?php echo $langs->trans("ContactVisibility"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['visibility']; ?></td>
</tr>
<tr>
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['note']; ?></td>
</tr>
<?php foreach ($this->control->tpl['contact_element'] as $element) { ?>
<tr>
<td><?php echo $element['linked_element_label']; ?></td>
<td colspan="3"><?php echo $element['linked_element_value']; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo $langs->trans("DolibarrLogin"); ?></td>
<td colspan="3"><?php echo $this->control->tpl['dolibarr_user']; ?></td>
</tr>
</table>
</div>
<!-- END PHP TEMPLATE --> <!-- END PHP TEMPLATE -->

View File

@ -38,31 +38,63 @@ $langs->load("companies");
$langs->load("users"); $langs->load("users");
$errors = array(); $errors = array();
$socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"]; $socid = GETPOST("socid");
// Security check // Security check
$contactid = isset($_GET["id"])?$_GET["id"]:''; $id = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $contactid, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission $object = new Contact($db);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
if (!empty($id)) $object->getCanvas($id);
$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
if (! empty($canvas))
{
require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
$objcanvas = new Canvas($db);
$objcanvas->getCanvas('thirdparty','contactcard',$canvas);
// Security check
$result = $objcanvas->restrictedArea($user, 'contact', $id, 'socpeople');
}
else
{
// Security check
$result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission
}
/* /*
* Actions * Actions
*/ */
// If canvas is defined, because on url, or because contact was created with canvas feature on,
// we use the canvas feature.
// If canvas is not defined, we use standard feature.
if (! empty($canvas))
{
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
// Load data control
$objcanvas->doActions($id);
}
else
{
// Creation utilisateur depuis contact // Creation utilisateur depuis contact
if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
{ {
// Recuperation contact actuel // Recuperation contact actuel
$contact = new Contact($db); $result = $object->fetch($_GET["id"]);
$result = $contact->fetch($_GET["id"]);
if ($result > 0) if ($result > 0)
{ {
// Creation user // Creation user
$nuser = new User($db); $nuser = new User($db);
$result=$nuser->create_from_contact($contact,$_POST["login"]); $result=$nuser->create_from_contact($object,$_POST["login"]);
if ($result < 0) if ($result < 0)
{ {
@ -71,47 +103,42 @@ if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $
} }
else else
{ {
$msg=$contact->error; $msg=$object->error;
} }
} }
// Creation contact // Creation contact
if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer) if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
{ {
$contact = new Contact($db); $object->socid = $_POST["socid"];
$contact->socid = $_POST["socid"]; $object->name = $_POST["name"];
$object->firstname = $_POST["firstname"];
$contact->name = $_POST["name"]; $object->civilite_id = $_POST["civilite_id"];
$contact->firstname = $_POST["firstname"]; $object->poste = $_POST["poste"];
$contact->civilite_id = $_POST["civilite_id"]; $object->address = $_POST["address"];
$contact->poste = $_POST["poste"]; $object->cp = $_POST["cp"];
$contact->address = $_POST["address"]; $object->ville = $_POST["ville"];
$contact->cp = $_POST["cp"]; $object->fk_pays = $_POST["pays_id"];
$contact->ville = $_POST["ville"]; $object->fk_departement = $_POST["departement_id"];
$contact->fk_pays = $_POST["pays_id"]; $object->email = $_POST["email"];
$contact->fk_departement = $_POST["departement_id"]; $object->phone_pro = $_POST["phone_pro"];
$contact->email = $_POST["email"]; $object->phone_perso = $_POST["phone_perso"];
$contact->phone_pro = $_POST["phone_pro"]; $object->phone_mobile = $_POST["phone_mobile"];
$contact->phone_perso = $_POST["phone_perso"]; $object->fax = $_POST["fax"];
$contact->phone_mobile = $_POST["phone_mobile"]; $object->jabberid = $_POST["jabberid"];
$contact->fax = $_POST["fax"]; $object->priv = $_POST["priv"];
$contact->jabberid = $_POST["jabberid"]; $object->note = $_POST["note"];
$contact->priv = $_POST["priv"];
$contact->note = $_POST["note"];
if (! $_POST["name"]) if (! $_POST["name"])
{ {
array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"))); array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
$_GET["action"] = 'create'; $_GET["action"] = $_POST["action"] = 'create';
$_POST["action"] = 'create';
$_REQUEST["action"] = 'create';
} }
if ($_POST["name"]) if ($_POST["name"])
{ {
$id = $contact->create($user); $id = $object->create($user);
if ($id > 0) if ($id > 0)
{ {
Header("Location: fiche.php?id=".$id); Header("Location: fiche.php?id=".$id);
@ -119,23 +146,20 @@ if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer)
} }
else else
{ {
$errors=array($contact->error); $errors=array($object->error);
$_GET["action"] = 'create'; $_GET["action"] = $_POST["action"] = 'create';
$_POST["action"] = 'create';
$_REQUEST["action"] = 'create';
} }
} }
} }
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->contact->supprimer) if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
{ {
$contact = new Contact($db); $result=$object->fetch($_GET["id"]);
$result=$contact->fetch($_GET["id"]);
$contact->old_name = $_POST["old_name"]; $object->old_name = $_POST["old_name"];
$contact->old_firstname = $_POST["old_firstname"]; $object->old_firstname = $_POST["old_firstname"];
$result = $contact->delete(); $result = $object->delete();
if ($result > 0) if ($result > 0)
{ {
Header("Location: index.php"); Header("Location: index.php");
@ -143,7 +167,7 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
} }
else else
{ {
$mesg=$contact->error; $mesg=$object->error;
} }
} }
@ -153,53 +177,50 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe
{ {
$errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
$error++; $error++;
$_GET["action"] = 'edit'; $_GET["action"] = $_POST["action"] = 'edit';
$_POST["action"] = 'edit';
$_REQUEST["action"] = 'edit';
} }
if (! sizeof($errors)) if (! sizeof($errors))
{ {
$contact = new Contact($db); $object->fetch($_POST["contactid"]);
$contact->fetch($_POST["contactid"]);
$contact->oldcopy=dol_clone($contact); $object->oldcopy=dol_clone($object);
$contact->old_name = $_POST["old_name"]; $object->old_name = $_POST["old_name"];
$contact->old_firstname = $_POST["old_firstname"]; $object->old_firstname = $_POST["old_firstname"];
$contact->socid = $_POST["socid"]; $object->socid = $_POST["socid"];
$contact->name = $_POST["name"]; $object->name = $_POST["name"];
$contact->firstname = $_POST["firstname"]; $object->firstname = $_POST["firstname"];
$contact->civilite_id = $_POST["civilite_id"]; $object->civilite_id = $_POST["civilite_id"];
$contact->poste = $_POST["poste"]; $object->poste = $_POST["poste"];
$contact->address = $_POST["address"]; $object->address = $_POST["address"];
$contact->cp = $_POST["cp"]; $object->cp = $_POST["cp"];
$contact->ville = $_POST["ville"]; $object->ville = $_POST["ville"];
$contact->fk_departement= $_POST["departement_id"]; $object->fk_departement= $_POST["departement_id"];
$contact->fk_pays = $_POST["pays_id"]; $object->fk_pays = $_POST["pays_id"];
$contact->email = $_POST["email"]; $object->email = $_POST["email"];
$contact->phone_pro = $_POST["phone_pro"]; $object->phone_pro = $_POST["phone_pro"];
$contact->phone_perso = $_POST["phone_perso"]; $object->phone_perso = $_POST["phone_perso"];
$contact->phone_mobile = $_POST["phone_mobile"]; $object->phone_mobile = $_POST["phone_mobile"];
$contact->fax = $_POST["fax"]; $object->fax = $_POST["fax"];
$contact->jabberid = $_POST["jabberid"]; $object->jabberid = $_POST["jabberid"];
$contact->priv = $_POST["priv"]; $object->priv = $_POST["priv"];
$object->note = $_POST["note"];
$contact->note = $_POST["note"]; $result = $object->update($_POST["contactid"], $user);
$result = $contact->update($_POST["contactid"], $user);
if ($result > 0) if ($result > 0)
{ {
$contact->old_name=''; $object->old_name='';
$contact->old_firstname=''; $object->old_firstname='';
} }
else else
{ {
$mesg=$contact->error; $mesg=$object->error;
}
} }
} }
} }
@ -222,6 +243,143 @@ if ($socid > 0)
$objsoc->fetch($socid); $objsoc->fetch($socid);
} }
if (! empty($canvas))
{
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
if ($user->rights->societe->contact->creer)
{
if (GETPOST("action") == 'create')
{
// Set action type
$objcanvas->setAction(GETPOST("action"));
// Card header
$title = $objcanvas->getTitle();
print_fiche_titre($title);
// Assign _POST data
$objcanvas->assign_post();
// Assign template values
$objcanvas->assign_values();
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
// Display canvas
$objcanvas->display_canvas();
}
else if (GETPOST("id") && GETPOST("action") == 'edit')
{
/*
* Mode edition
*/
// Set action type
$objcanvas->setAction(GETPOST("action"));
// Fetch object
$result=$objcanvas->fetch($id);
if ($result > 0)
{
// Card header
$head = contact_prepare_head($objcanvas->control->object);
$title = $objcanvas->getTitle();
dol_fiche_head($head, 'general', $title, 0, 'contact');
if ($_POST["name"])
{
// Assign _POST data
$objcanvas->assign_post();
}
// Assign values
$objcanvas->assign_values();
// Display canvas
$objcanvas->display_canvas();
}
else
{
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
}
}
}
if (GETPOST("id") && GETPOST("action") != 'edit')
{
// Set action type
$objcanvas->setAction('view');
// Fetch object
$result=$objcanvas->fetch($id);
if ($result > 0)
{
// Card header
$head = contact_prepare_head($objcanvas->control->object);
$title = $objcanvas->getTitle();
dol_fiche_head($head, 'general', $title, 0, 'contact');
// Assign values
$objcanvas->assign_values();
// Display canvas
$objcanvas->display_canvas();
// Barre d'actions
if (! $user->societe_id)
{
print '<div class="tabsAction">';
if ($user->rights->societe->contact->creer)
{
print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
}
if (! $object->user_id && $user->rights->user->user->creer)
{
print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
}
if ($user->rights->societe->contact->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
print "</div><br>";
}
print show_actions_todo($conf,$langs,$db,$objsoc,$object);
print show_actions_done($conf,$langs,$db,$objsoc,$object);
}
else
{
dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
}
}
}
else
{
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
/*
* Confirmation de la suppression du contact
*/
if ($user->rights->societe->contact->supprimer)
{
if ($_GET["action"] == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1);
if ($ret == 'html') print '<br>';
}
}
/* /*
* Onglets * Onglets
@ -245,35 +403,22 @@ if ($_GET["id"] > 0)
dol_fiche_head($head, 'general', $langs->trans("Contact"), 0, 'contact'); dol_fiche_head($head, 'general', $langs->trans("Contact"), 0, 'contact');
} }
/*
* Confirmation de la suppression du contact
*/
if ($user->rights->societe->contact->supprimer)
{
if ($_GET["action"] == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1);
if ($ret == 'html') print '<br>';
}
}
if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->creer)
{ {
if ($_GET["action"] == 'create' || $_POST["action"] == 'create') if (GETPOST("action") == 'create')
{ {
/* /*
* Fiche en mode creation * Fiche en mode creation
*/ */
$contact->fk_departement = $_POST["departement_id"]; $object->fk_departement = $_POST["departement_id"];
// We set pays_id, pays_code and label for the selected country // We set pays_id, pays_code and label for the selected country
$contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $object->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
if ($contact->fk_pays) if ($object->fk_pays)
{ {
$sql = "SELECT code, libelle"; $sql = "SELECT code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; $sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE rowid = ".$contact->fk_pays; $sql.= " WHERE rowid = ".$object->fk_pays;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -283,8 +428,8 @@ if ($user->rights->societe->contact->creer)
{ {
dol_print_error($db); dol_print_error($db);
} }
$contact->pays_code=$obj->code; $object->pays_code=$obj->code;
$contact->pays=$obj->libelle; $object->pays=$obj->libelle;
} }
print_fiche_titre($langs->trans("AddContact")); print_fiche_titre($langs->trans("AddContact"));
@ -311,8 +456,8 @@ if ($user->rights->societe->contact->creer)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Name // Name
print '<tr><td width="15%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="30" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$contact->name).'"></td>'; print '<tr><td width="15%" class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="30" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$contact->firstname).'"></td></tr>'; print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="30" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
// Company // Company
if ($socid > 0) if ($socid > 0)
@ -334,33 +479,33 @@ if ($user->rights->societe->contact->creer)
// Civility // Civility
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$contact->civilite_id); print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$contact->poste).'"></td>'; print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$object->poste).'"></td>';
// Address // Address
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->address)) == 0) $contact->address = $objsoc->address; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.(isset($_POST["address"])?$_POST["address"]:$contact->address).'</textarea></td>'; print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.(isset($_POST["address"])?$_POST["address"]:$object->address).'</textarea></td>';
// Zip / Town // Zip / Town
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->cp)) == 0) $contact->cp = $objsoc->cp; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->cp)) == 0) $object->cp = $objsoc->cp; // Predefined with third party
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->ville)) == 0) $contact->ville = $objsoc->ville; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->ville)) == 0) $object->ville = $objsoc->ville; // Predefined with third party
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.(isset($_POST["cp"])?$_POST["cp"]:$contact->cp).'">&nbsp;'; print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.(isset($_POST["cp"])?$_POST["cp"]:$object->cp).'">&nbsp;';
print '<input name="ville" type="text" size="20" value="'.(isset($_POST["ville"])?$_POST["ville"]:$contact->ville).'" maxlength="80"></td></tr>'; print '<input name="ville" type="text" size="20" value="'.(isset($_POST["ville"])?$_POST["ville"]:$object->ville).'" maxlength="80"></td></tr>';
// Country // Country
if (dol_strlen(trim($contact->fk_pays)) == 0) $contact->fk_pays = $objsoc->pays_id; // Predefined with third party if (dol_strlen(trim($object->fk_pays)) == 0) $object->fk_pays = $objsoc->pays_id; // Predefined with third party
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$form->select_pays((isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays),'pays_id'); $form->select_pays((isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays),'pays_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>'; print '</td></tr>';
// State // State
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($contact->fk_pays) if ($object->fk_pays)
{ {
$formcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$contact->fk_departement,$contact->pays_code); $formcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$object->fk_departement,$object->pays_code);
} }
else else
{ {
@ -369,45 +514,45 @@ if ($user->rights->societe->contact->creer)
print '</td></tr>'; print '</td></tr>';
// Phone / Fax // Phone / Fax
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->phone_pro)) == 0) $contact->phone_pro = $objsoc->tel; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->tel; // Predefined with third party
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_pro"])?$_POST["phone_pro"]:$contact->phone_pro).'"></td>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_pro"])?$_POST["phone_pro"]:$object->phone_pro).'"></td>';
print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$contact->phone_perso).'"></td></tr>'; print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>';
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->fax)) == 0) $contact->fax = $objsoc->fax; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$contact->phone_mobile).'"></td>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></td>';
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.(isset($_POST["fax"])?$_POST["fax"]:$contact->fax).'"></td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.(isset($_POST["fax"])?$_POST["fax"]:$object->fax).'"></td></tr>';
// EMail // EMail
if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->email)) == 0) $contact->email = $objsoc->email; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party
print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.(isset($_POST["email"])?$_POST["email"]:$contact->email).'"></td></tr>'; print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>';
// Jabberid // Jabberid
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.(isset($_POST["jabberid"])?$_POST["jabberid"]:$contact->jabberid).'"></td></tr>'; print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.(isset($_POST["jabberid"])?$_POST["jabberid"]:$object->jabberid).'"></td></tr>';
// Visibility // Visibility
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">';
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
print $form->selectarray('priv',$selectarray,(isset($_POST["priv"])?$_POST["priv"]:$contact->priv),0); print $form->selectarray('priv',$selectarray,(isset($_POST["priv"])?$_POST["priv"]:$object->priv),0);
print '</td></tr>'; print '</td></tr>';
// Note // Note
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="note"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.(isset($_POST["note"])?$_POST["note"]:$contact->note).'</textarea></td></tr>'; print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="top"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.(isset($_POST["note"])?$_POST["note"]:$object->note).'</textarea></td></tr>';
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>'; print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print "</table><br>"; print "</table><br>";
print "</form>"; print "</form>";
} }
elseif ($_REQUEST["action"] == 'edit' && $_REQUEST["id"]) elseif (GETPOST("action") == 'edit' && GETPOST("id"))
{ {
/* /*
* Fiche en mode edition * Fiche en mode edition
*/ */
// We set pays_id, and pays_code label of the chosen country // We set pays_id, and pays_code label of the chosen country
if (isset($_POST["pays_id"]) || $contact->fk_pays) if (isset($_POST["pays_id"]) || $object->fk_pays)
{ {
$sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays); $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -417,8 +562,8 @@ if ($user->rights->societe->contact->creer)
{ {
dol_print_error($db); dol_print_error($db);
} }
$contact->pays_code=$obj->code; $object->pays_code=$obj->code;
$contact->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; $object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
} }
// Affiche les erreurs // Affiche les erreurs
@ -436,70 +581,70 @@ if ($user->rights->societe->contact->creer)
print '</script>'."\n"; print '</script>'."\n";
} }
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$_REQUEST["id"].'" name="formsoc">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.GETPOST("id").'" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'; print '<input type="hidden" name="id" value="'.GETPOST("id").'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="contactid" value="'.$contact->id.'">'; print '<input type="hidden" name="contactid" value="'.$object->id.'">';
print '<input type="hidden" name="old_name" value="'.$contact->name.'">'; print '<input type="hidden" name="old_name" value="'.$object->name.'">';
print '<input type="hidden" name="old_firstname" value="'.$contact->firstname.'">'; print '<input type="hidden" name="old_firstname" value="'.$object->firstname.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
print $contact->ref; print $object->ref;
print '</td></tr>'; print '</td></tr>';
// Name // Name
print '<tr><td class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$contact->name).'"></td>'; print '<tr><td class="fieldrequired">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.(isset($_POST["name"])?$_POST["name"]:$object->name).'"></td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$contact->firstname).'"></td></tr>'; print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td></tr>';
// Company // Company
print '<tr><td width="20%">'.$langs->trans("Company").'</td>'; print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($contact->socid?$contact->socid:-1),'socid','',1); print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($object->socid?$object->socid:-1),'socid','',1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$contact->civilite_id); print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$contact->poste).'"></td></tr>'; print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.(isset($_POST["poste"])?$_POST["poste"]:$object->poste).'"></td></tr>';
// Address // Address
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.(isset($_POST["address"])?$_POST["address"]:$contact->address).'</textarea></td>'; print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><textarea class="flat" name="address" cols="70">'.(isset($_POST["address"])?$_POST["address"]:$object->address).'</textarea></td>';
// Zip / Town // Zip / Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.(isset($_POST["cp"])?$_POST["cp"]:$contact->cp).'">&nbsp;'; print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.(isset($_POST["cp"])?$_POST["cp"]:$object->cp).'">&nbsp;';
print '<input name="ville" type="text" size="20" value="'.(isset($_POST["ville"])?$_POST["ville"]:$contact->ville).'" maxlength="80"></td></tr>'; print '<input name="ville" type="text" size="20" value="'.(isset($_POST["ville"])?$_POST["ville"]:$object->ville).'" maxlength="80"></td></tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$form->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays,'pays_id'); $form->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays,'pays_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>'; print '</td></tr>';
// Department // Department
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
$formcompany->select_departement($contact->fk_departement,$contact->pays_code); $formcompany->select_departement($object->fk_departement,$object->pays_code);
print '</td></tr>'; print '</td></tr>';
// Phone // Phone
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_pro"])?$_POST["phone_pro"]:$contact->phone_pro).'"></td>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input name="phone_pro" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_pro"])?$_POST["phone_pro"]:$object->phone_pro).'"></td>';
print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$contact->phone_perso).'"></td></tr>'; print '<td>'.$langs->trans("PhonePerso").'</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>';
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$contact->phone_mobile).'"></td>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></td>';
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.(isset($_POST["fax"])?$_POST["fax"]:$contact->fax).'"></td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.(isset($_POST["fax"])?$_POST["fax"]:$object->fax).'"></td></tr>';
// EMail // EMail
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.(isset($_POST["email"])?$_POST["email"]:$contact->email).'"></td>'; print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td>';
if ($conf->mailing->enabled) if ($conf->mailing->enabled)
{ {
$langs->load("mails"); $langs->load("mails");
print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>'; print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
print '<td>'.$contact->getNbOfEMailings().'</td>'; print '<td>'.$object->getNbOfEMailings().'</td>';
} }
else else
{ {
@ -508,55 +653,55 @@ if ($user->rights->societe->contact->creer)
print '</tr>'; print '</tr>';
// Jabberid // Jabberid
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="40" maxlength="80" value="'.(isset($_POST["jabberid"])?$_POST["jabberid"]:$contact->jabberid).'"></td></tr>'; print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="40" maxlength="80" value="'.(isset($_POST["jabberid"])?$_POST["jabberid"]:$object->jabberid).'"></td></tr>';
// Visibility // Visibility
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">';
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
print $form->selectarray('priv',$selectarray,$contact->priv,0); print $form->selectarray('priv',$selectarray,$object->priv,0);
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">';
print '<textarea name="note" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note" cols="70" rows="'.ROWS_3.'">';
print isset($_POST["note"])?$_POST["note"]:$contact->note; print isset($_POST["note"])?$_POST["note"]:$object->note;
print '</textarea></td></tr>'; print '</textarea></td></tr>';
$contact->load_ref_elements(); $object->load_ref_elements();
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForOrders").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForOrders").'</td><td colspan="3">';
print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForProposals").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForProposals").'</td><td colspan="3">';
print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice");
print '</td></tr>'; print '</td></tr>';
} }
// Login Dolibarr // Login Dolibarr
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
if ($contact->user_id) if ($object->user_id)
{ {
$dolibarr_user=new User($db); $dolibarr_user=new User($db);
$result=$dolibarr_user->fetch($contact->user_id); $result=$dolibarr_user->fetch($object->user_id);
print $dolibarr_user->getLoginUrl(1); print $dolibarr_user->getLoginUrl(1);
} }
else print $langs->trans("NoDolibarrAccess"); else print $langs->trans("NoDolibarrAccess");
@ -573,13 +718,12 @@ if ($user->rights->societe->contact->creer)
} }
} }
if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit') if (GETPOST("id") && GETPOST("action") != 'edit')
{ {
$objsoc = new Societe($db); $objsoc = new Societe($db);
/* /*
* Fiche en mode visualisation * Fiche en mode visualisation
*
*/ */
if ($msg) if ($msg)
{ {
@ -589,13 +733,12 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
if ($_GET["action"] == 'create_user') if ($_GET["action"] == 'create_user')
{ {
$login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4)); $login=strtolower(substr($object->prenom, 0, 4)) . strtolower(substr($object->nom, 0, 4));
// Create a form array // Create a form array
$formquestion=array( $formquestion=array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));
$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$contact->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion); $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -603,18 +746,18 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
// Ref // Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($contact,'id'); print $form->showrefnav($object,'id');
print '</td></tr>'; print '</td></tr>';
// Name // Name
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$contact->name.'</td>'; print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td width="30%">'.$object->name.'</td>';
print '<td width="25%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>'; print '<td width="25%">'.$langs->trans("Firstname").'</td><td width="25%">'.$object->firstname.'</td></tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($contact->socid > 0) if ($object->socid > 0)
{ {
$objsoc->fetch($contact->socid); $objsoc->fetch($object->socid);
print $objsoc->getNomUrl(1); print $objsoc->getNomUrl(1);
} }
else else
@ -625,44 +768,44 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
// Civility // Civility
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $contact->getCivilityLabel(); print $object->getCivilityLabel();
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3">'.$contact->poste.'</td>'; print '<tr><td>'.$langs->trans("PostOrFunction" ).'</td><td colspan="3">'.$object->poste.'</td>';
// Address // Address
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($contact->address).'</td></tr>'; print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">'.nl2br($object->address).'</td></tr>';
// Zip Town // Zip Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">';
print $contact->cp; print $object->cp;
if ($contact->cp) print '&nbsp;'; if ($object->cp) print '&nbsp;';
print $contact->ville.'</td></tr>'; print $object->ville.'</td></tr>';
// Country // Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($contact->pays_code); $img=picto_from_langcode($object->pays_code);
if ($img) print $img.' '; if ($img) print $img.' ';
print $contact->pays; print $object->pays;
print '</td></tr>'; print '</td></tr>';
// Department // Department
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$contact->departement.'</td>'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$object->departement.'</td>';
// Phone // Phone
print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($contact->phone_pro,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($object->phone_pro,$object->pays_code,$object->id,$object->socid,'AC_TEL').'</td>';
print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($contact->phone_perso,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td></tr>'; print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($object->phone_perso,$object->pays_code,$object->id,$object->socid,'AC_TEL').'</td></tr>';
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($contact->phone_mobile,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'</td>'; print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($object->phone_mobile,$object->pays_code,$object->id,$object->socid,'AC_TEL').'</td>';
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($contact->fax,$contact->pays_code,$contact->id,$contact->socid,'AC_FAX').'</td></tr>'; print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($object->fax,$object->pays_code,$object->id,$object->socid,'AC_FAX').'</td></tr>';
// Email // Email
print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($contact->email,$contact->id,$contact->socid,'AC_EMAIL').'</td>'; print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email,$object->id,$object->socid,'AC_EMAIL').'</td>';
if ($conf->mailing->enabled) if ($conf->mailing->enabled)
{ {
$langs->load("mails"); $langs->load("mails");
print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>'; print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/liste.php?filteremail='.urlencode($contact->email).'">'.$contact->getNbOfEMailings().'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/liste.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td>';
} }
else else
{ {
@ -671,51 +814,51 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
print '</tr>'; print '</tr>';
// Jabberid // Jabberid
print '<tr><td>Jabberid</td><td colspan="3">'.$contact->jabberid.'</td></tr>'; print '<tr><td>Jabberid</td><td colspan="3">'.$object->jabberid.'</td></tr>';
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">';
print $contact->LibPubPriv($contact->priv); print $object->LibPubPriv($object->priv);
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">';
print nl2br($contact->note); print nl2br($object->note);
print '</td></tr>'; print '</td></tr>';
$contact->load_ref_elements(); $object->load_ref_elements();
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForOrders").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForOrders").'</td><td colspan="3">';
print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForProposals").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForProposals").'</td><td colspan="3">';
print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->contrat->enabled) if ($conf->contrat->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract");
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice");
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
if ($contact->user_id) if ($object->user_id)
{ {
$dolibarr_user=new User($db); $dolibarr_user=new User($db);
$result=$dolibarr_user->fetch($contact->user_id); $result=$dolibarr_user->fetch($object->user_id);
print $dolibarr_user->getLoginUrl(1); print $dolibarr_user->getLoginUrl(1);
} }
else print $langs->trans("NoDolibarrAccess"); else print $langs->trans("NoDolibarrAccess");
@ -725,7 +868,6 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
print "</div>"; print "</div>";
// Barre d'actions // Barre d'actions
if (! $user->societe_id) if (! $user->societe_id)
{ {
@ -733,26 +875,26 @@ if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit')
if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->creer)
{ {
print '<a class="butAction" href="fiche.php?id='.$contact->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=edit">'.$langs->trans('Modify').'</a>';
} }
if (! $contact->user_id && $user->rights->user->user->creer) if (! $object->user_id && $user->rights->user->user->creer)
{ {
print '<a class="butAction" href="fiche.php?id='.$contact->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>'; print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
} }
if ($user->rights->societe->contact->supprimer) if ($user->rights->societe->contact->supprimer)
{ {
print '<a class="butActionDelete" href="fiche.php?id='.$contact->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="fiche.php?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
} }
print "</div><br>"; print "</div><br>";
} }
print show_actions_todo($conf,$langs,$db,$objsoc,$object);
print show_actions_todo($conf,$langs,$db,$objsoc,$contact); print show_actions_done($conf,$langs,$db,$objsoc,$object);
}
print show_actions_done($conf,$langs,$db,$objsoc,$contact);
} }
$db->close(); $db->close();

View File

@ -84,9 +84,9 @@ class Canvas
* Execute actions * Execute actions
* @param Id of object (may be empty for creation) * @param Id of object (may be empty for creation)
*/ */
function doActions($socid) function doActions($id)
{ {
return $this->control->doActions($socid); return $this->control->doActions($id);
} }
/** /**
@ -118,13 +118,19 @@ class Canvas
{ {
$childmodule = $this->aliasmodule = $this->module = $regs[2]; $childmodule = $this->aliasmodule = $this->module = $regs[2];
$this->canvas = $regs[1]; $this->canvas = $regs[1];
}
// For compatibility // For compatibility
if ($childmodule == 'thirdparty') $childmodule = $this->aliasmodule = 'societe'; if ($childmodule == 'thirdparty') $childmodule = $this->aliasmodule = 'societe';
if ($targetmodule == 'thirdparty') $targetmodule = 'societe'; if ($targetmodule == 'thirdparty') $targetmodule = 'societe';
if ($childmodule == 'contact')
{
$childmodule = 'societe';
$this->targetmodule = 'contact';
} }
//print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>'; //print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
//print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
//print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>'; //print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';
if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden(); if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden();
@ -159,6 +165,7 @@ class Canvas
} }
else else
{ {
//print 'access ko';
accessforbidden(); accessforbidden();
} }

View File

@ -487,18 +487,34 @@ class Form
} }
/** /**
* \brief Output html form to select a third party * Output html form to select a third party
* \param selected Preselected type * @param selected Preselected type
* \param htmlname Name of field in form * @param htmlname Name of field in form
* \param filter Optionnal filters criteras * @param filter Optionnal filters criteras
* \param showempty Add an empty field * @param showempty Add an empty field
* \param showtype Show third party type in combolist (customer, prospect or supplier) * @param showtype Show third party type in combolist (customer, prospect or supplier)
* \param forcecombo Force to use combo box * @param forcecombo Force to use combo box
*/ */
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
{
print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo);
}
/**
* Output html form to select a third party
* @param selected Preselected type
* @param htmlname Name of field in form
* @param filter Optionnal filters criteras
* @param showempty Add an empty field
* @param showtype Show third party type in combolist (customer, prospect or supplier)
* @param forcecombo Force to use combo box
*/
function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$out='';
// On recherche les societes // On recherche les societes
$sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
@ -524,26 +540,26 @@ class Form
$socid = $obj->rowid?$obj->rowid:''; $socid = $obj->rowid?$obj->rowid:'';
} }
print "\n".'<!-- Input text for third party with Ajax.Autocompleter (select_societes) -->'."\n"; $out.= "\n".'<!-- Input text for third party with Ajax.Autocompleter (select_societes) -->'."\n";
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; $out.= '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding">'; $out.= '<td class="nobordernopadding">';
if ($socid == 0) if ($socid == 0)
{ {
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="" />'; $out.= '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="" />';
} }
else else
{ {
print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" />'; $out.= '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->nom.'" />';
} }
print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '', $minLength); $out.= ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '', $minLength);
print '</td>'; $out.= '</td>';
print '</tr>'; $out.= '</tr>';
print '</table>'; $out.= '</table>';
} }
else else
{ {
print '<select id="select'.$htmlname.'" class="flat" name="'.$htmlname.'">'; $out.= '<select id="select'.$htmlname.'" class="flat" name="'.$htmlname.'">';
if ($showempty) print '<option value="-1">&nbsp;</option>'; if ($showempty) $out.=$out.= '<option value="-1">&nbsp;</option>';
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
if ($num) if ($num)
@ -562,22 +578,24 @@ class Form
} }
if ($selected > 0 && $selected == $obj->rowid) if ($selected > 0 && $selected == $obj->rowid)
{ {
print '<option value="'.$obj->rowid.'" selected="selected">'.$label.'</option>'; $out.= '<option value="'.$obj->rowid.'" selected="selected">'.$label.'</option>';
} }
else else
{ {
print '<option value="'.$obj->rowid.'">'.$label.'</option>'; $out.= '<option value="'.$obj->rowid.'">'.$label.'</option>';
} }
$i++; $i++;
} }
} }
print '</select>'; $out.= '</select>';
} }
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
return $out;
} }

View File

@ -95,3 +95,5 @@ create table llx_c_ziptown
ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county); ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county);
ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county FOREIGN KEY (fk_county) REFERENCES llx_c_departements (rowid); ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county FOREIGN KEY (fk_county) REFERENCES llx_c_departements (rowid);
ALTER TABLE llx_socpeople ADD COLUMN canvas varchar(32) DEFAULT 'default@contact' after default_lang;

View File

@ -77,6 +77,6 @@ create table llx_societe
gencod varchar(255), -- barcode gencod varchar(255), -- barcode
price_level integer NULL, -- level of price for multiprices price_level integer NULL, -- level of price for multiprices
default_lang varchar(6), -- default language default_lang varchar(6), -- default language
canvas varchar(32) DEFAULT 'default', -- type of canvas canvas varchar(32) DEFAULT 'default@thirdparty', -- type of canvas
import_key varchar(14) -- import key import_key varchar(14) -- import key
)type=innodb; )type=innodb;

View File

@ -1,7 +1,7 @@
-- ============================================================================ -- ============================================================================
-- Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net> -- Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> -- Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@ -48,13 +48,6 @@ create table llx_socpeople
fk_user_modif integer, fk_user_modif integer,
note text, note text,
default_lang varchar(6), default_lang varchar(6),
canvas varchar(32) DEFAULT 'default@contact', -- type of canvas
import_key varchar(14) import_key varchar(14)
)type=innodb; )type=innodb;
--
-- List of codes for the field entity
--
-- 1 : first company contact
-- 2 : second company contact
-- 3 : etc...
--

View File

@ -187,9 +187,9 @@ class ActionsCardCommon
$this->tpl['checksuppliercode'] = $this->object->check_codefournisseur(); $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
$this->tpl['address'] = dol_nl2br($this->object->address); $this->tpl['address'] = dol_nl2br($this->object->address);
$img=picto_from_langcode($this->pays_code); $img=picto_from_langcode($this->object->pays_code);
if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->pays,$langs->trans("CountryIsInEEC"),1,0); if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->country,$langs->trans("CountryIsInEEC"),1,0);
$this->tpl['country'] = ($img?$img.' ':'').$this->pays; $this->tpl['country'] = ($img?$img.' ':'').$this->object->country;
$this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL'); $this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL');
$this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX'); $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');