104 global $conf, $langs, $user, $canvas;
105 global $form, $formcompany, $objsoc;
107 if ($action ==
'add' || $action ==
'update') {
111 foreach ($this->
object as $key => $value) {
112 $this->tpl[$key] = $value;
115 $this->tpl[
'error'] = $this->error;
116 $this->tpl[
'errors'] = $this->errors;
118 if ($action ==
'create' || $action ==
'edit') {
119 if ($conf->use_javascript_ajax) {
120 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
121 jQuery(document).ready(function () {
122 jQuery("#selectcountry_id").change(function() {
123 document.formsoc.action.value="'.$action.
'";
124 document.formsoc.canvas.value="'.$canvas.
'";
125 document.formsoc.submit();
131 if (is_object($objsoc) && $objsoc->id > 0) {
132 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
133 $this->tpl[
'company_id'] = $objsoc->id;
135 $this->tpl[
'company'] = $form->select_company($this->object->socid,
'socid',
'', 1);
139 $this->tpl[
'select_civility'] = $formcompany->select_civility($this->object->civility_id);
142 if ((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE')) {
143 if (
dol_strlen(trim($this->object->address)) == 0) {
144 $this->tpl[
'address'] = $objsoc->address;
146 if (
dol_strlen(trim($this->object->zip)) == 0) {
147 $this->
object->zip = $objsoc->zip;
149 if (
dol_strlen(trim($this->object->town)) == 0) {
150 $this->
object->town = $objsoc->town;
152 if (
dol_strlen(trim($this->object->phone_perso)) == 0) {
153 $this->
object->phone_perso = $objsoc->phone;
155 if (
dol_strlen(trim($this->object->phone_mobile)) == 0) {
156 $this->
object->phone_mobile = $objsoc->phone_mobile;
158 if (
dol_strlen(trim($this->object->email)) == 0) {
159 $this->
object->email = $objsoc->email;
164 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
167 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
169 if ($this->object->country_id == 0) {
170 $this->
object->country_id = $objsoc->country_id;
174 $this->tpl[
'select_country'] = $form->select_country((
string) $this->object->country_id,
'country_id');
175 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
178 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
182 if ($this->object->country_id) {
183 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
185 $this->tpl[
'select_state'] = $countrynotdefined;
189 $selectarray = array(
'0' => $langs->trans(
"Physical"),
'1' => $langs->trans(
"Moral"));
190 $this->tpl[
'select_morphy'] = $form->selectarray(
'morphy', $selectarray, $this->object->morphy, 0);
193 if ($action ==
'view' || $action ==
'edit' || $action ==
'delete') {
196 $langs->load(
"mails");
197 $this->tpl[
'nb_emailing'] = $this->
object->getNbOfEMailings();
201 if ($this->object->user_id) {
202 $dolibarr_user =
new User($this->db);
203 $result = $dolibarr_user->fetch($this->object->user_id);
204 $this->tpl[
'dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
206 $this->tpl[
'dolibarr_user'] = $langs->trans(
"NoDolibarrAccess");
210 if ($action ==
'view' || $action ==
'delete') {
211 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'id');
213 if ($this->object->socid > 0) {
214 $objsoc =
new Societe($this->db);
216 $objsoc->fetch($this->object->socid);
217 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
219 $this->tpl[
'company'] = $langs->trans(
"AdherentNotLinkedToThirdParty");
222 $this->tpl[
'civility'] = $this->
object->getCivilityLabel();
224 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
226 $this->tpl[
'zip'] = ($this->
object->zip ? $this->
object->zip.
' ' :
'');
229 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
231 $this->tpl[
'phone_perso'] =
dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
232 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
233 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
235 $this->tpl[
'visibility'] = $this->
object->getmorphylib($this->object->morphy);
237 $this->tpl[
'note'] = $this->
object->note_private;
240 if ($action ==
'create_user') {
242 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
243 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
244 $login =
dol_buildlogin($this->object->lastname, $this->object->firstname);
247 $password = $generated_password;
250 $formquestion = array(
251 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
252 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password));
254 $this->tpl[
'action_create_user'] = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$this->object->id, $langs->trans(
"CreateDolibarrLogin"), $langs->trans(
"ConfirmCreateMember"),
"confirm_create_user", $formquestion,
'no');