53 public $errors = array();
73 if (!empty($id))
$object->fetch($id);
89 global $conf, $langs, $user, $canvas;
90 global $form, $formcompany, $objsoc;
92 if ($action ==
'add' || $action ==
'update') $this->
assign_post();
94 foreach ($this->
object as $key => $value) {
95 $this->tpl[$key] = $value;
98 $this->tpl[
'error'] = $this->error;
99 $this->tpl[
'errors'] = $this->errors;
101 if ($action ==
'create' || $action ==
'edit') {
102 if ($conf->use_javascript_ajax) {
103 $this->tpl[
'ajax_selectcountry'] =
"\n".
'<script type="text/javascript" language="javascript">
104 jQuery(document).ready(function () {
105 jQuery("#selectcountry_id").change(function() {
106 document.formsoc.action.value="'.$action.
'";
107 document.formsoc.canvas.value="'.$canvas.
'";
108 document.formsoc.submit();
114 if (is_object($objsoc) && $objsoc->id > 0) {
115 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
116 $this->tpl[
'company_id'] = $objsoc->id;
118 $this->tpl[
'company'] = $form->select_company($this->object->socid,
'socid',
'', 1);
122 $this->tpl[
'select_civility'] = $formcompany->select_civility($this->object->civility_id);
125 if ((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE')) {
126 if (
dol_strlen(trim($this->object->address)) == 0) $this->tpl[
'address'] = $objsoc->address;
127 if (
dol_strlen(trim($this->object->zip)) == 0) $this->
object->zip = $objsoc->zip;
128 if (
dol_strlen(trim($this->object->town)) == 0) $this->
object->town = $objsoc->town;
129 if (
dol_strlen(trim($this->object->phone_perso)) == 0) $this->
object->phone_perso = $objsoc->phone;
130 if (
dol_strlen(trim($this->object->phone_mobile)) == 0) $this->
object->phone_mobile = $objsoc->phone_mobile;
131 if (
dol_strlen(trim($this->object->email)) == 0) $this->
object->email = $objsoc->email;
135 $this->tpl[
'select_zip'] = $formcompany->select_ziptown($this->object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6);
138 $this->tpl[
'select_town'] = $formcompany->select_ziptown($this->object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
140 if (
dol_strlen(trim($this->object->country_id)) == 0) $this->
object->country_id = $objsoc->country_id;
143 $this->tpl[
'select_country'] = $form->select_country($this->object->country_id,
'country_id');
144 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
146 if ($user->admin) $this->tpl[
'info_admin'] =
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
149 if ($this->object->country_id) $this->tpl[
'select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
150 else $this->tpl[
'select_state'] = $countrynotdefined;
153 $selectarray = array(
'0'=>$langs->trans(
"Physical"),
'1'=>$langs->trans(
"Moral"));
154 $this->tpl[
'select_morphy'] = $form->selectarray(
'morphy', $selectarray, $this->object->morphy, 0);
157 if ($action ==
'view' || $action ==
'edit' || $action ==
'delete') {
159 if (!empty($conf->mailing->enabled)) {
160 $langs->load(
"mails");
161 $this->tpl[
'nb_emailing'] = $this->
object->getNbOfEMailings();
165 if ($this->object->user_id) {
166 $dolibarr_user =
new User($this->
db);
167 $result = $dolibarr_user->fetch($this->object->user_id);
168 $this->tpl[
'dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
169 }
else $this->tpl[
'dolibarr_user'] = $langs->trans(
"NoDolibarrAccess");
172 if ($action ==
'view' || $action ==
'delete') {
173 $this->tpl[
'showrefnav'] = $form->showrefnav($this->
object,
'id');
175 if ($this->object->socid > 0) {
178 $objsoc->fetch($this->object->socid);
179 $this->tpl[
'company'] = $objsoc->getNomUrl(1);
181 $this->tpl[
'company'] = $langs->trans(
"AdherentNotLinkedToThirdParty");
184 $this->tpl[
'civility'] = $this->
object->getCivilityLabel();
186 $this->tpl[
'address'] =
dol_nl2br($this->object->address);
188 $this->tpl[
'zip'] = ($this->
object->zip ? $this->
object->zip.
' ' :
'');
191 $this->tpl[
'country'] = ($img ? $img.
' ' :
'').$this->object->country;
193 $this->tpl[
'phone_perso'] =
dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
194 $this->tpl[
'phone_mobile'] =
dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id,
'AC_TEL');
195 $this->tpl[
'email'] =
dol_print_email($this->object->email, 0, $this->object->id,
'AC_EMAIL');
197 $this->tpl[
'visibility'] = $this->
object->getmorphylib($this->object->morphy);
199 $this->tpl[
'note'] = nl2br($this->object->note);
202 if ($action ==
'create_user') {
204 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
205 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
206 $login =
dol_buildlogin($this->object->lastname, $this->object->firstname);
209 $password = $generated_password;
212 $formquestion = array(
213 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
214 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password));
216 $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');
229 global $langs, $mysoc;
231 $this->
object->old_name = $_POST[
"old_name"];
232 $this->
object->old_firstname = $_POST[
"old_firstname"];
234 $this->
object->fk_soc = $_POST[
"fk_soc"];
235 $this->
object->lastname = $_POST[
"lastname"];
236 $this->
object->firstname = $_POST[
"firstname"];
237 $this->
object->civility_id = $_POST[
"civility_id"];
238 $this->
object->address = $_POST[
"address"];
239 $this->
object->zip = $_POST[
"zipcode"];
240 $this->
object->town = $_POST[
"town"];
241 $this->
object->country_id = $_POST[
"country_id"] ? $_POST[
"country_id"] : $mysoc->country_id;
242 $this->
object->state_id = $_POST[
"state_id"];
243 $this->
object->phone_perso = $_POST[
"phone_perso"];
244 $this->
object->phone_mobile = $_POST[
"phone_mobile"];
245 $this->
object->email = $_POST[
"email"];
246 $this->
object->note = $_POST[
"note"];
247 $this->
object->canvas = $_POST[
"canvas"];
250 if ($this->object->country_id) {
251 $sql =
"SELECT code, label FROM ".MAIN_DB_PREFIX.
"c_country WHERE rowid = ".$this->
object->country_id;
254 $obj = $this->
db->fetch_object(
$resql);
256 $this->
object->country_code = $obj->code;
257 $this->
object->country = $langs->trans(
"Country".$obj->code) ? $langs->trans(
"Country".$obj->code) : $obj->libelle;
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.
assign_post()
Assign POST values into object.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
$conf db
API class for accounts.
assign_values(&$action, $id)
Set content of ->tpl array, to use into template.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
Class to manage members of a foundation.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
Class to manage members using default canvas.
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.
getObject($id)
Get object.
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.