102 global
$conf, $langs, $user, $canvas;
103 global $form, $formcompany, $objsoc;
105 if ($action ==
'add' || $action ==
'update') {
109 foreach ($this->
object as $key => $value) {
110 $this->tpl[$key] = $value;
113 $this->tpl[
'error'] = $this->error;
114 $this->tpl[
'errors'] = $this->errors;
116 if ($action ==
'create' || $action ==
'edit') {
117 if (
$conf->use_javascript_ajax) {
118 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript">
119 jQuery(document).ready(function () {
120 jQuery("#selectcountry_id").change(function() {
121 document.formsoc.action.value="'.$action.
'";
122 document.formsoc.canvas.value="'.$canvas.
'";
123 document.formsoc.submit();
129 if (is_object($objsoc) && $objsoc->id > 0) {
130 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
131 $this->tpl[
'company_id'] = $objsoc->id;
133 $this->tpl[
'company'] = $form->select_company($this->object->socid,
'socid',
'', 1);
137 $this->tpl[
'select_civility'] = $formcompany->select_civility($this->object->civility_id);
140 if ((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE')) {
141 if (
dol_strlen(trim($this->object->address)) == 0) {
142 $this->tpl[
'address'] = $objsoc->address;
144 if (
dol_strlen(trim($this->object->zip)) == 0) {
145 $this->
object->zip = $objsoc->zip;
147 if (
dol_strlen(trim($this->object->town)) == 0) {
148 $this->
object->town = $objsoc->town;
150 if (
dol_strlen(trim($this->object->phone_perso)) == 0) {
151 $this->
object->phone_perso = $objsoc->phone;
153 if (
dol_strlen(trim($this->object->phone_mobile)) == 0) {
154 $this->
object->phone_mobile = $objsoc->phone_mobile;
156 if (
dol_strlen(trim($this->object->email)) == 0) {
157 $this->
object->email = $objsoc->email;
162 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
165 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
167 if ($this->object->country_id == 0) {
168 $this->
object->country_id = $objsoc->country_id;
172 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
173 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
176 $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
180 if ($this->object->country_id) {
181 $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
183 $this->tpl[
'select_state'] = $countrynotdefined;
187 $selectarray = array(
'0' => $langs->trans(
"Physical"),
'1' => $langs->trans(
"Moral"));
188 $this->tpl[
'select_morphy'] = $form->selectarray(
'morphy', $selectarray, $this->object->morphy, 0);
191 if ($action ==
'view' || $action ==
'edit' || $action ==
'delete') {
193 if (isModEnabled(
'mailing')) {
194 $langs->load(
"mails");
195 $this->tpl[
'nb_emailing'] = $this->
object->getNbOfEMailings();
199 if ($this->object->user_id) {
200 $dolibarr_user =
new User($this->db);
201 $result = $dolibarr_user->fetch($this->object->user_id);
202 $this->tpl[
'dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
204 $this->tpl[
'dolibarr_user'] = $langs->trans(
"NoDolibarrAccess");
208 if ($action ==
'view' || $action ==
'delete') {
209 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'id');
211 if ($this->object->socid > 0) {
212 $objsoc =
new Societe($this->db);
214 $objsoc->fetch($this->object->socid);
215 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
217 $this->tpl[
'company'] = $langs->trans(
"AdherentNotLinkedToThirdParty");
220 $this->tpl[
'civility'] = $this->
object->getCivilityLabel();
222 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
224 $this->tpl[
'zip'] = ($this->
object->zip ? $this->
object->zip.
' ' :
'');
227 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
229 $this->tpl[
'phone_perso'] =
dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
230 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
231 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
233 $this->tpl[
'visibility'] = $this->
object->getmorphylib($this->object->morphy);
235 $this->tpl[
'note'] = $this->
object->note_private;
238 if ($action ==
'create_user') {
240 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
241 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
242 $login =
dol_buildlogin($this->object->lastname, $this->object->firstname);
245 $password = $generated_password;
248 $formquestion = array(
249 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
250 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password));
252 $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');