54 public $errors = array();
74 if (!empty($id))
$object->fetch($id);
90 global $conf, $langs, $user, $canvas;
91 global $form, $formcompany, $objsoc;
93 if ($action ==
'add' || $action ==
'update') $this->
assign_post();
95 foreach ($this->
object as $key => $value)
97 $this->tpl[$key] = $value;
100 $this->tpl[
'error'] = $this->error;
101 $this->tpl[
'errors'] = $this->errors;
103 if ($action ==
'create' || $action ==
'edit')
105 if ($conf->use_javascript_ajax)
107 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript" language="javascript">
108 jQuery(document).ready(function () {
109 jQuery("#selectcountry_id").change(function() {
110 document.formsoc.action.value="'.$action.
'";
111 document.formsoc.canvas.value="'.$canvas.
'";
112 document.formsoc.submit();
118 if (is_object($objsoc) && $objsoc->id > 0)
120 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
121 $this->tpl[
'company_id'] = $objsoc->id;
123 $this->tpl[
'company'] = $form->select_company($this->object->socid,
'socid',
'', 1);
127 $this->tpl[
'select_civility'] = $formcompany->select_civility($this->object->civility_id);
130 if ((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS))
132 if (
dol_strlen(trim($this->object->address)) == 0) $this->tpl[
'address'] = $objsoc->address;
133 if (
dol_strlen(trim($this->object->zip)) == 0) $this->
object->zip = $objsoc->zip;
134 if (
dol_strlen(trim($this->object->town)) == 0) $this->
object->town = $objsoc->town;
135 if (
dol_strlen(trim($this->object->phone_pro)) == 0) $this->
object->phone_pro = $objsoc->phone;
136 if (
dol_strlen(trim($this->object->fax)) == 0) $this->
object->fax = $objsoc->fax;
137 if (
dol_strlen(trim($this->object->email)) == 0) $this->
object->email = $objsoc->email;
141 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
144 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
146 if (
dol_strlen(trim($this->object->country_id)) == 0) $this->
object->country_id = $objsoc->country_id;
149 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
150 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
152 if ($user->admin) $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
155 if ($this->object->country_id) $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
156 else $this->tpl[
'select_state'] = $countrynotdefined;
159 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
160 $this->tpl[
'select_visibility'] = $form->selectarray(
'priv', $selectarray, $this->object->priv, 0);
163 if ($action ==
'view' || $action ==
'edit' || $action ==
'delete')
166 if (!empty($conf->mailing->enabled))
168 $langs->load(
"mails");
169 $this->tpl[
'nb_emailing'] = $this->
object->getNbOfEMailings();
173 $this->tpl[
'contact_element'] = array();
176 $this->
object->load_ref_elements();
178 if (!empty($conf->commande->enabled))
180 $this->tpl[
'contact_element'][$i][
'linked_element_label'] = $langs->trans(
"ContactForOrders");
181 $this->tpl[
'contact_element'][$i][
'linked_element_value'] = $this->
object->ref_commande ? $this->
object->ref_commande : $langs->trans(
"NoContactForAnyOrder");
184 if (!empty($conf->propal->enabled))
186 $this->tpl[
'contact_element'][$i][
'linked_element_label'] = $langs->trans(
"ContactForProposals");
187 $this->tpl[
'contact_element'][$i][
'linked_element_value'] = $this->
object->ref_propal ? $this->
object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
190 if (!empty($conf->contrat->enabled))
192 $this->tpl[
'contact_element'][$i][
'linked_element_label'] = $langs->trans(
"ContactForContracts");
193 $this->tpl[
'contact_element'][$i][
'linked_element_value'] = $this->
object->ref_contrat ? $this->
object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
196 if (!empty($conf->facture->enabled))
198 $this->tpl[
'contact_element'][$i][
'linked_element_label'] = $langs->trans(
"ContactForInvoices");
199 $this->tpl[
'contact_element'][$i][
'linked_element_value'] = $this->
object->ref_facturation ? $this->
object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
204 if ($this->object->user_id)
206 $dolibarr_user =
new User($this->
db);
207 $result = $dolibarr_user->fetch($this->object->user_id);
208 $this->tpl[
'dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
209 }
else $this->tpl[
'dolibarr_user'] = $langs->trans(
"NoDolibarrAccess");
212 if ($action ==
'view' || $action ==
'delete')
214 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'id');
216 if ($this->object->socid > 0)
220 $objsoc->fetch($this->object->socid);
221 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
223 $this->tpl[
'company'] = $langs->trans(
"ContactNotLinkedToCompany");
226 $this->tpl[
'civility'] = $this->
object->getCivilityLabel();
228 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
230 $this->tpl[
'zip'] = ($this->
object->zip ? $this->
object->zip.
' ' :
'');
233 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
235 $this->tpl[
'phone_pro'] =
dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
236 $this->tpl[
'phone_perso'] =
dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
237 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
238 $this->tpl[
'fax'] =
dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id,
'AC_FAX');
239 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
241 $this->tpl[
'visibility'] = $this->
object->LibPubPriv($this->object->priv);
243 $this->tpl[
'note'] = nl2br($this->object->note);
246 if ($action ==
'create_user')
249 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
250 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
251 $login =
dol_buildlogin($this->object->lastname, $this->object->firstname);
254 $password = $generated_password;
257 $formquestion = array(
258 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
259 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password));
261 $this->tpl[
'action_create_user'] = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$this->object->id, $langs->trans(
"CreateDolibarrLogin"), $langs->trans(
"ConfirmCreateContact"),
"confirm_create_user", $formquestion,
'no');
274 global $langs, $mysoc;
276 $this->
object->old_name = $_POST[
"old_name"];
277 $this->
object->old_firstname = $_POST[
"old_firstname"];
279 $this->
object->socid = $_POST[
"socid"];
280 $this->
object->lastname = $_POST[
"name"];
281 $this->
object->firstname = $_POST[
"firstname"];
282 $this->
object->civility_id = $_POST[
"civility_id"];
283 $this->
object->poste = $_POST[
"poste"];
284 $this->
object->address = $_POST[
"address"];
285 $this->
object->zip = $_POST[
"zipcode"];
286 $this->
object->town = $_POST[
"town"];
287 $this->
object->country_id = $_POST[
"country_id"] ? $_POST[
"country_id"] : $mysoc->country_id;
288 $this->
object->state_id = $_POST[
"state_id"];
289 $this->
object->phone_pro = $_POST[
"phone_pro"];
290 $this->
object->phone_perso = $_POST[
"phone_perso"];
291 $this->
object->phone_mobile = $_POST[
"phone_mobile"];
292 $this->
object->fax = $_POST[
"fax"];
293 $this->
object->email = $_POST[
"email"];
294 $this->
object->jabberid = $_POST[
"jabberid"];
295 $this->
object->priv = $_POST[
"priv"];
296 $this->
object->note = $_POST[
"note"];
297 $this->
object->canvas = $_POST[
"canvas"];
300 if ($this->object->country_id)
302 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_country WHERE rowid = ".$this->
object->country_id;
306 $obj = $this->
db->fetch_object(
$resql);
310 $this->
object->country_id = $langs->trans(
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : $obj->label;
311 $this->
object->country_code = $obj->code;
312 $this->
object->country = $langs->trans(
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : $obj->label;
Class to manage Dolibarr users.
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ=" ", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
$conf db
API class for accounts.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
print $_SERVER["PHP_SELF"]
Edit parameters.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.