86 global $conf, $langs, $user, $canvas;
87 global $form, $formcompany, $objsoc;
89 if ($action ==
'add' || $action ==
'update') {
93 foreach ($this->
object as $key => $value) {
94 $this->tpl[$key] = $value;
97 $this->tpl[
'error'] = $this->error;
98 $this->tpl[
'errors'] = $this->errors;
100 if ($action ==
'create' || $action ==
'edit') {
101 if ($conf->use_javascript_ajax) {
102 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
103 jQuery(document).ready(function () {
104 jQuery("#selectcountry_id").change(function() {
105 document.formsoc.action.value="'.$action.
'";
106 document.formsoc.canvas.value="'.$canvas.
'";
107 document.formsoc.submit();
113 if (is_object($objsoc) && $objsoc->id > 0) {
114 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
115 $this->tpl[
'company_id'] = $objsoc->id;
117 $this->tpl[
'company'] = $form->select_company($this->object->socid,
'socid',
'', 1);
121 $this->tpl[
'select_civility'] = $formcompany->select_civility($this->object->civility_id);
124 if ((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE')) {
125 if (
dol_strlen(trim($this->object->address)) == 0) {
126 $this->tpl[
'address'] = $objsoc->address;
128 if (
dol_strlen(trim($this->object->zip)) == 0) {
129 $this->
object->zip = $objsoc->zip;
131 if (
dol_strlen(trim($this->object->town)) == 0) {
132 $this->
object->town = $objsoc->town;
134 if (
dol_strlen(trim($this->object->phone_perso)) == 0) {
135 $this->
object->phone_perso = $objsoc->phone;
137 if (
dol_strlen(trim($this->object->phone_mobile)) == 0) {
138 $this->
object->phone_mobile = $objsoc->phone_mobile;
140 if (
dol_strlen(trim($this->object->email)) == 0) {
141 $this->
object->email = $objsoc->email;
146 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
149 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
151 if ($this->object->country_id == 0) {
152 $this->
object->country_id = $objsoc->country_id;
156 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
157 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
160 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
164 if ($this->object->country_id) {
165 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
167 $this->tpl[
'select_state'] = $countrynotdefined;
171 $selectarray = array(
'0' => $langs->trans(
"Physical"),
'1' => $langs->trans(
"Moral"));
172 $this->tpl[
'select_morphy'] = $form->selectarray(
'morphy', $selectarray, $this->object->morphy, 0);
175 if ($action ==
'view' || $action ==
'edit' || $action ==
'delete') {
177 if (isModEnabled(
'mailing')) {
178 $langs->load(
"mails");
179 $this->tpl[
'nb_emailing'] = $this->
object->getNbOfEMailings();
183 if ($this->object->user_id) {
184 $dolibarr_user =
new User($this->db);
185 $result = $dolibarr_user->fetch($this->object->user_id);
186 $this->tpl[
'dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
188 $this->tpl[
'dolibarr_user'] = $langs->trans(
"NoDolibarrAccess");
192 if ($action ==
'view' || $action ==
'delete') {
193 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'id');
195 if ($this->object->socid > 0) {
196 $objsoc =
new Societe($this->db);
198 $objsoc->fetch($this->object->socid);
199 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
201 $this->tpl[
'company'] = $langs->trans(
"AdherentNotLinkedToThirdParty");
204 $this->tpl[
'civility'] = $this->
object->getCivilityLabel();
206 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
208 $this->tpl[
'zip'] = ($this->
object->zip ? $this->
object->zip.
' ' :
'');
211 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
213 $this->tpl[
'phone_perso'] =
dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
214 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
215 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
217 $this->tpl[
'visibility'] = $this->
object->getmorphylib($this->object->morphy);
219 $this->tpl[
'note'] = $this->
object->note_private;
222 if ($action ==
'create_user') {
224 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
225 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
226 $login =
dol_buildlogin($this->object->lastname, $this->object->firstname);
229 $password = $generated_password;
232 $formquestion = array(
233 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
234 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password));
236 $this->tpl[
'action_create_user'] = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$this->object->id, $langs->trans(
"CreateDolibarrLogin"), $langs->trans(
"ConfirmCreateAdherent"),
"confirm_create_user", $formquestion,
'no');