diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 50d13c91c17..bfe6dd11ddd 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -53,18 +53,18 @@ if (!empty($id)) $object->getCanvas($id);
$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas"));
if (! empty($canvas))
{
- require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
- $objcanvas = new Canvas($db);
+ require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
+ $objcanvas = new Canvas($db);
- $objcanvas->getCanvas('contact','contactcard',$canvas);
+ $objcanvas->getCanvas('contact','contactcard',$canvas);
- // Security check
- $result = $objcanvas->restrictedArea($user, 'contact', $id, 'socpeople');
+ // Security check
+ $result = $objcanvas->restrictedArea($user, 'contact', $id, 'socpeople');
}
else
{
- // Security check
- $result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission
+ // Security check
+ $result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission
}
@@ -77,195 +77,195 @@ else
// If canvas is not defined, we use standard feature.
if (! empty($canvas))
{
- // -----------------------------------------
- // When used with CANVAS
- // -----------------------------------------
+ // -----------------------------------------
+ // When used with CANVAS
+ // -----------------------------------------
- // Load data control
- $objcanvas->doActions($id);
+ // Load data control
+ $objcanvas->doActions($id);
}
else
{
- // Creation utilisateur depuis contact
- if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
- {
- // Recuperation contact actuel
- $result = $object->fetch($_GET["id"]);
+ // Creation utilisateur depuis contact
+ if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
+ {
+ // Recuperation contact actuel
+ $result = $object->fetch($_GET["id"]);
- if ($result > 0)
- {
- $db->begin();
+ if ($result > 0)
+ {
+ $db->begin();
- // Creation user
- $nuser = new User($db);
- $result=$nuser->create_from_contact($object,$_POST["login"]);
+ // Creation user
+ $nuser = new User($db);
+ $result=$nuser->create_from_contact($object,$_POST["login"]);
- if ($result > 0)
- {
- $result2=$nuser->setPassword($user,$_POST["password"],0,1,1);
+ if ($result > 0)
+ {
+ $result2=$nuser->setPassword($user,$_POST["password"],0,1,1);
if ($result2)
{
- $db->commit();
+ $db->commit();
}
else
{
$db->rollback();
}
- }
- else
- {
- $msg=$nuser->error;
+ }
+ else
+ {
+ $msg=$nuser->error;
$db->rollback();
- }
- }
- else
- {
- $msg=$object->error;
- }
- }
+ }
+ }
+ else
+ {
+ $msg=$object->error;
+ }
+ }
- // Cancel
- if (GETPOST("cancel") && GETPOST('backtopage'))
- {
- header("Location: ".GETPOST('backtopage'));
- exit;
- }
-
- // Add contact
- if (GETPOST("action") == 'add' && $user->rights->societe->contact->creer)
- {
- $error=0;
+ // Cancel
+ if (GETPOST("cancel") && GETPOST('backtopage'))
+ {
+ header("Location: ".GETPOST('backtopage'));
+ exit;
+ }
- $db->begin();
+ // Add contact
+ if (GETPOST("action") == 'add' && $user->rights->societe->contact->creer)
+ {
+ $error=0;
- $object->socid = $_POST["socid"];
+ $db->begin();
- $object->name = $_POST["name"];
- $object->firstname = $_POST["firstname"];
- $object->civilite_id = $_POST["civilite_id"];
- $object->poste = $_POST["poste"];
- $object->address = $_POST["address"];
- $object->zip = $_POST["zipcode"];
- $object->town = $_POST["town"];
- $object->fk_pays = $_POST["pays_id"];
- $object->fk_departement = $_POST["departement_id"];
- $object->email = $_POST["email"];
- $object->phone_pro = $_POST["phone_pro"];
- $object->phone_perso = $_POST["phone_perso"];
- $object->phone_mobile = $_POST["phone_mobile"];
- $object->fax = $_POST["fax"];
- $object->jabberid = $_POST["jabberid"];
- $object->priv = $_POST["priv"];
- $object->note = $_POST["note"];
+ $object->socid = $_POST["socid"];
+
+ $object->name = $_POST["name"];
+ $object->firstname = $_POST["firstname"];
+ $object->civilite_id = $_POST["civilite_id"];
+ $object->poste = $_POST["poste"];
+ $object->address = $_POST["address"];
+ $object->zip = $_POST["zipcode"];
+ $object->town = $_POST["town"];
+ $object->fk_pays = $_POST["pays_id"];
+ $object->fk_departement = $_POST["departement_id"];
+ $object->email = $_POST["email"];
+ $object->phone_pro = $_POST["phone_pro"];
+ $object->phone_perso = $_POST["phone_perso"];
+ $object->phone_mobile = $_POST["phone_mobile"];
+ $object->fax = $_POST["fax"];
+ $object->jabberid = $_POST["jabberid"];
+ $object->priv = $_POST["priv"];
+ $object->note = $_POST["note"];
// Note: Correct date should be completed with location to have exact GM time of birth.
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
$object->birthday_alert = $_POST["birthday_alert"];
- if (! $_POST["name"])
- {
- $error++;
- array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
- $_GET["action"] = $_POST["action"] = 'create';
- }
+ if (! $_POST["name"])
+ {
+ $error++;
+ array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label")));
+ $_GET["action"] = $_POST["action"] = 'create';
+ }
- if ($_POST["name"])
- {
- $id = $object->create($user);
- if ($id <= 0)
- {
+ if ($_POST["name"])
+ {
+ $id = $object->create($user);
+ if ($id <= 0)
+ {
$error++;
- $errors=($object->error?array($object->error):$object->errors);
- $_GET["action"] = $_POST["action"] = 'create';
- }
- }
+ $errors=($object->error?array($object->error):$object->errors);
+ $_GET["action"] = $_POST["action"] = 'create';
+ }
+ }
- if (! $error && $id > 0)
- {
- $db->commit();
- if (GETPOST('backtopage')) $url=GETPOST('backtopage');
- else $url='fiche.php?id='.$id;
- Header("Location: ".$url);
- exit;
- }
- else
- {
- $db->rollback();
- }
- }
+ if (! $error && $id > 0)
+ {
+ $db->commit();
+ if (GETPOST('backtopage')) $url=GETPOST('backtopage');
+ else $url='fiche.php?id='.$id;
+ Header("Location: ".$url);
+ exit;
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
- if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
- {
- $result=$object->fetch($_GET["id"]);
+ if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer)
+ {
+ $result=$object->fetch($_GET["id"]);
- $object->old_name = $_POST["old_name"];
- $object->old_firstname = $_POST["old_firstname"];
+ $object->old_name = $_POST["old_name"];
+ $object->old_firstname = $_POST["old_firstname"];
- $result = $object->delete();
- if ($result > 0)
- {
- Header("Location: index.php");
- exit;
- }
- else
- {
- $mesg=$object->error;
- }
- }
+ $result = $object->delete();
+ if ($result > 0)
+ {
+ Header("Location: index.php");
+ exit;
+ }
+ else
+ {
+ $mesg=$object->error;
+ }
+ }
- if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
- {
- if (empty($_POST["name"]))
- {
- $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
- $error++;
- $_GET["action"] = $_POST["action"] = 'edit';
- }
+ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
+ {
+ if (empty($_POST["name"]))
+ {
+ $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label")));
+ $error++;
+ $_GET["action"] = $_POST["action"] = 'edit';
+ }
- if (! sizeof($errors))
- {
- $object->fetch($_POST["contactid"]);
+ if (! sizeof($errors))
+ {
+ $object->fetch($_POST["contactid"]);
- $object->oldcopy=dol_clone($object);
+ $object->oldcopy=dol_clone($object);
- $object->old_name = $_POST["old_name"];
- $object->old_firstname = $_POST["old_firstname"];
+ $object->old_name = $_POST["old_name"];
+ $object->old_firstname = $_POST["old_firstname"];
- $object->socid = $_POST["socid"];
- $object->name = $_POST["name"];
- $object->firstname = $_POST["firstname"];
- $object->civilite_id = $_POST["civilite_id"];
- $object->poste = $_POST["poste"];
+ $object->socid = $_POST["socid"];
+ $object->name = $_POST["name"];
+ $object->firstname = $_POST["firstname"];
+ $object->civilite_id = $_POST["civilite_id"];
+ $object->poste = $_POST["poste"];
- $object->address = $_POST["address"];
- $object->zip = $_POST["zipcode"];
- $object->town = $_POST["town"];
- $object->fk_departement = $_POST["departement_id"];
- $object->fk_pays = $_POST["pays_id"];
+ $object->address = $_POST["address"];
+ $object->zip = $_POST["zipcode"];
+ $object->town = $_POST["town"];
+ $object->fk_departement = $_POST["departement_id"];
+ $object->fk_pays = $_POST["pays_id"];
- $object->email = $_POST["email"];
- $object->phone_pro = $_POST["phone_pro"];
- $object->phone_perso = $_POST["phone_perso"];
- $object->phone_mobile = $_POST["phone_mobile"];
- $object->fax = $_POST["fax"];
- $object->jabberid = $_POST["jabberid"];
- $object->priv = $_POST["priv"];
- $object->note = $_POST["note"];
+ $object->email = $_POST["email"];
+ $object->phone_pro = $_POST["phone_pro"];
+ $object->phone_perso = $_POST["phone_perso"];
+ $object->phone_mobile = $_POST["phone_mobile"];
+ $object->fax = $_POST["fax"];
+ $object->jabberid = $_POST["jabberid"];
+ $object->priv = $_POST["priv"];
+ $object->note = $_POST["note"];
- $result = $object->update($_POST["contactid"], $user);
+ $result = $object->update($_POST["contactid"], $user);
- if ($result > 0)
- {
- $object->old_name='';
- $object->old_firstname='';
- }
- else
- {
- $mesg=$object->error;
- }
- }
- }
+ if ($result > 0)
+ {
+ $object->old_name='';
+ $object->old_firstname='';
+ }
+ else
+ {
+ $mesg=$object->error;
+ }
+ }
+ }
}
@@ -288,282 +288,285 @@ if ($socid > 0)
if (! empty($canvas))
{
- // -----------------------------------------
- // When used with CANVAS
- // -----------------------------------------
+ // -----------------------------------------
+ // When used with CANVAS
+ // -----------------------------------------
- if (GETPOST("action") == 'create')
- {
- // Set action type to objcanvas->action
- $objcanvas->setAction(GETPOST("action"));
+ if (GETPOST("action") == 'create')
+ {
+ // Set action type to objcanvas->action
+ $objcanvas->setAction(GETPOST("action"));
- // Assign _POST data to objcanvas->object->xxx
- $objcanvas->assign_post();
+ // Assign _POST data to objcanvas->object->xxx
+ $objcanvas->assign_post();
- // Assign template values into objcanvas->control->tpl
- $objcanvas->assign_values();
+ // Assign template values into objcanvas->control->tpl
+ $objcanvas->assign_values();
- // Card header TODO This should be done into canvas_display
- $title = $objcanvas->getTitle();
- print_fiche_titre($title);
+ // Card header TODO This should be done into canvas_display
+ $title = $objcanvas->getTitle();
+ print_fiche_titre($title);
- // Show errors TODO This should be done into assign_values()
- // that should get string of dol_htmloutput_errors and
- // assigne it into objcanvas->control->tpl like other strings to show
- // by templates, then output of string should be done into display_canvas
- dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
+ // Show errors TODO This should be done into assign_values()
+ // that should get string of dol_htmloutput_errors and
+ // assigne it into objcanvas->control->tpl like other strings to show
+ // by templates, then output of string should be done into display_canvas
+ dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
- // Display canvas
- $objcanvas->display_canvas();
- }
- else if (GETPOST("id") && GETPOST("action") == 'edit')
- {
- /*
- * Mode edition
- */
+ // Display canvas
+ $objcanvas->display_canvas();
+ }
+ else if (GETPOST("id") && GETPOST("action") == 'edit')
+ {
+ /*
+ * Mode edition
+ */
- // Set action type
- $objcanvas->setAction(GETPOST("action"));
+ // Set action type
+ $objcanvas->setAction(GETPOST("action"));
- // Fetch object
- $result=$objcanvas->fetch($id);
- if ($result > 0)
- {
- // Card header
- $objcanvas->showHead();
+ // Fetch object
+ $result=$objcanvas->fetch($id);
+ if ($result > 0)
+ {
+ // Card header
+ $objcanvas->showHead();
- if ($_POST["name"])
- {
- // Assign _POST data
- $objcanvas->assign_post();
- }
+ if ($_POST["name"])
+ {
+ // Assign _POST data
+ $objcanvas->assign_post();
+ }
- // Assign values
- $objcanvas->assign_values();
+ // Assign values
+ $objcanvas->assign_values();
- // Display canvas
- $objcanvas->display_canvas();
- }
- else
- {
- dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
- }
- }
+ // Display canvas
+ $objcanvas->display_canvas();
+ }
+ else
+ {
+ dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
+ }
+ }
- if (GETPOST("id") && GETPOST("action") != 'edit')
- {
- // Set action type
- $objcanvas->setAction('view');
+ if (GETPOST("id") && GETPOST("action") != 'edit')
+ {
+ // Set action type
+ $objcanvas->setAction('view');
- // Fetch object
- $result=$objcanvas->fetch($id);
- if ($result > 0)
- {
- // Assign values
- $objcanvas->assign_values();
+ // Fetch object
+ $result=$objcanvas->fetch($id);
+ if ($result > 0)
+ {
+ // Assign values
+ $objcanvas->assign_values();
- // FIXME div of tab is shown by showHead but /div is closed by
- // display_canvas. All output should be processed by template so
- // showHead and dol_htmloutput_errors should be moved into
- // display_canvas.
+ // FIXME div of tab is shown by showHead but /div is closed by
+ // display_canvas. All output should be processed by template so
+ // showHead and dol_htmloutput_errors should be moved into
+ // display_canvas.
- // Card header
- $objcanvas->showHead();
+ // Card header
+ $objcanvas->showHead();
- // Show errors TODO This output string should be set by
- // assign_values and output by template into display_canvas
- dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
+ // Show errors TODO This output string should be set by
+ // assign_values and output by template into display_canvas
+ dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
- // Display canvas
- $objcanvas->display_canvas();
+ // Display canvas
+ $objcanvas->display_canvas();
- print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
+ print show_actions_todo($conf,$langs,$db,$objsoc,$objcanvas->control->object);
- print show_actions_done($conf,$langs,$db,$objsoc,$objcanvas->control->object);
- }
- else
- {
- dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
- }
- }
+ print show_actions_done($conf,$langs,$db,$objsoc,$objcanvas->control->object);
+ }
+ else
+ {
+ dol_htmloutput_errors($objcanvas->error,$objcanvas->errors);
+ }
+ }
}
else
{
- // -----------------------------------------
- // When used in standard mode
- // -----------------------------------------
+ // -----------------------------------------
+ // When used in standard mode
+ // -----------------------------------------
- // Confirm deleting contact
- if ($user->rights->societe->contact->supprimer)
- {
- if ($_GET["action"] == 'delete')
- {
- $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1);
- if ($ret == 'html') print '
';
- }
- }
+ // Confirm deleting contact
+ if ($user->rights->societe->contact->supprimer)
+ {
+ if ($_GET["action"] == 'delete')
+ {
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1);
+ if ($ret == 'html') print '
';
+ }
+ }
- /*
- * Onglets
- */
- if (GETPOST("id") > 0)
- {
- // Si edition contact deja existant
- $object = new Contact($db);
- $return=$object->fetch(GETPOST("id"), $user);
- if ($return <= 0)
- {
- dol_print_error('',$object->error);
- $_GET["id"]=0;
- }
+ /*
+ * Onglets
+ */
+ if (GETPOST("id") > 0)
+ {
+ // Si edition contact deja existant
+ $object = new Contact($db);
+ $return=$object->fetch(GETPOST("id"), $user);
+ if ($return <= 0)
+ {
+ dol_print_error('',$object->error);
+ $_GET["id"]=0;
+ }
- // Show tabs
- $head = contact_prepare_head($object);
+ // Show tabs
+ $head = contact_prepare_head($object);
- dol_fiche_head($head, 'card', $langs->trans("ContactsAddresses"), 0, 'contact');
- }
+ dol_fiche_head($head, 'card', $langs->trans("ContactsAddresses"), 0, 'contact');
+ }
- if ($user->rights->societe->contact->creer)
- {
- if (GETPOST("action") == 'create')
- {
- /*
- * Fiche en mode creation
- */
- $object->fk_departement = $_POST["departement_id"];
+ if ($user->rights->societe->contact->creer)
+ {
+ if (GETPOST("action") == 'create')
+ {
+ /*
+ * Fiche en mode creation
+ */
+ $object->fk_departement = $_POST["departement_id"];
- // We set pays_id, pays_code and label for the selected country
- $object->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
- if ($object->fk_pays)
- {
- $sql = "SELECT code, libelle";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
- $sql.= " WHERE rowid = ".$object->fk_pays;
- $resql=$db->query($sql);
- if ($resql)
- {
- $obj = $db->fetch_object($resql);
- }
- else
- {
- dol_print_error($db);
- }
- $object->pays_code=$obj->code;
- $object->pays=$obj->libelle;
- }
+ // We set pays_id, pays_code and label for the selected country
+ $object->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
+ if ($object->fk_pays)
+ {
+ $sql = "SELECT code, libelle";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
+ $sql.= " WHERE rowid = ".$object->fk_pays;
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ $object->pays_code=$obj->code;
+ $object->pays=$obj->libelle;
+ }
- print_fiche_titre($langs->trans("AddContact"));
+ print_fiche_titre($langs->trans("AddContact"));
- // Affiche les erreurs
- dol_htmloutput_errors($mesg,$errors);
+ // Affiche les erreurs
+ dol_htmloutput_errors($mesg,$errors);
- if ($conf->use_javascript_ajax)
- {
- print "\n".''."\n";
- }
-
- print '
';
- print '